render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
404507
From 0d4d7811a11bcd2bf12446425e5e05014faecf52 Mon Sep 17 00:00:00 2001
404507
Message-Id: <0d4d7811a11bcd2bf12446425e5e05014faecf52@dist-git>
404507
From: Michal Privoznik <mprivozn@redhat.com>
404507
Date: Mon, 20 Nov 2017 11:08:53 +0100
404507
Subject: [PATCH] qemuBuildDriveDevStr: Prefer default alias for SATA bus
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1434451
404507
404507
Just like in 9324f67a572f9b32 we need to put default sata alias
404507
(which is hardcoded to "ide", obvious, right?) onto the command
404507
line instead of the one provided by user.
404507
404507
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
404507
(cherry picked from commit f66e5896ad6013c2f31eef1c909999b33ba8847e)
404507
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/qemu/qemu_command.c                            | 15 ++++++++--
404507
 .../qemuxml2argv-user-aliases2.args                |  1 +
404507
 .../qemuxml2argv-user-aliases2.xml                 | 34 ++++++++++++++++++++++
404507
 tests/qemuxml2argvtest.c                           |  1 +
404507
 4 files changed, 48 insertions(+), 3 deletions(-)
404507
 create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args
404507
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml
404507
404507
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
404507
index 272ef610a3..7dc7387a15 100644
404507
--- a/src/qemu/qemu_command.c
404507
+++ b/src/qemu/qemu_command.c
404507
@@ -2076,9 +2076,18 @@ qemuBuildDriveDevStr(const virDomainDef *def,
404507
             virBufferAddLit(&opt, "ide-drive");
404507
         }
404507
 
404507
-        if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_SATA,
404507
-                                                      disk->info.addr.drive.controller)))
404507
-           goto error;
404507
+        /* When domain has builtin SATA controller we don't put it onto cmd
404507
+         * line. Therefore we can't set its alias. In that case, use the
404507
+         * default one. */
404507
+        if (qemuDomainIsQ35(def) &&
404507
+            disk->info.addr.drive.controller == 0) {
404507
+            contAlias = "ide";
404507
+        } else {
404507
+            if (!(contAlias = virDomainControllerAliasFind(def,
404507
+                                                           VIR_DOMAIN_CONTROLLER_TYPE_SATA,
404507
+                                                           disk->info.addr.drive.controller)))
404507
+                goto error;
404507
+        }
404507
         virBufferAsprintf(&opt, ",bus=%s.%d",
404507
                           contAlias,
404507
                           disk->info.addr.drive.unit);
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args
404507
new file mode 120000
404507
index 0000000000..e029bc0ec8
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.args
404507
@@ -0,0 +1 @@
404507
+qemuxml2argv-boot-floppy-q35.args
404507
\ No newline at end of file
404507
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml
404507
new file mode 100644
404507
index 0000000000..a288b86117
404507
--- /dev/null
404507
+++ b/tests/qemuxml2argvdata/qemuxml2argv-user-aliases2.xml
404507
@@ -0,0 +1,34 @@
404507
+<domain type='qemu'>
404507
+  <name>QEMUGuest1</name>
404507
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
404507
+  <memory unit='KiB'>219100</memory>
404507
+  <currentMemory unit='KiB'>219100</currentMemory>
404507
+  <vcpu placement='static'>1</vcpu>
404507
+  <os>
404507
+    <type arch='x86_64' machine='pc-q35-2.4'>hvm</type>
404507
+    <boot dev='fd'/>
404507
+  </os>
404507
+  <clock offset='utc'/>
404507
+  <on_poweroff>destroy</on_poweroff>
404507
+  <on_reboot>restart</on_reboot>
404507
+  <on_crash>destroy</on_crash>
404507
+  <devices>
404507
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
404507
+    <disk type='file' device='floppy'>
404507
+      <driver name='qemu' type='raw'/>
404507
+      <source file='/tmp/firmware.img'/>
404507
+      <target dev='fda' bus='fdc'/>
404507
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
404507
+    </disk>
404507
+    <controller type='sata' index='0'>
404507
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
404507
+    </controller>
404507
+    <controller type='pci' index='0' model='pcie-root'>
404507
+      <alias name='ua-MySataController'/>
404507
+    </controller>
404507
+    <controller type='fdc' index='0'/>
404507
+    <input type='mouse' bus='ps2'/>
404507
+    <input type='keyboard' bus='ps2'/>
404507
+    <memballoon model='none'/>
404507
+  </devices>
404507
+</domain>
404507
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
404507
index ecc86d045c..ff9c8608aa 100644
404507
--- a/tests/qemuxml2argvtest.c
404507
+++ b/tests/qemuxml2argvtest.c
404507
@@ -2827,6 +2827,7 @@ mymain(void)
404507
             QEMU_CAPS_OBJECT_MEMORY_FILE, QEMU_CAPS_PIIX_DISABLE_S3,
404507
             QEMU_CAPS_PIIX_DISABLE_S4, QEMU_CAPS_VNC,
404507
             QEMU_CAPS_HDA_DUPLEX);
404507
+    DO_TEST("user-aliases2", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI);
404507
 
404507
     if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
404507
         virFileDeleteTree(fakerootdir);
404507
-- 
404507
2.15.0
404507