render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From 9c3b9ce8260ffc476f7539cc683e7efe59eba979 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <9c3b9ce8260ffc476f7539cc683e7efe59eba979.1380112457.git.jdenemar@redhat.com>
43fe83
From: Laine Stump <laine@laine.org>
43fe83
Date: Fri, 20 Sep 2013 05:16:21 -0600
43fe83
Subject: [PATCH] qemu: use "ide" as device name for implicit SATA controller
43fe83
 on Q35
43fe83
43fe83
This resolves https://bugzilla.redhat.com/show_bug.cgi?id=1008903
43fe83
43fe83
The Q35 machinetype has an implicit SATA controller at 00:1F.2 which
43fe83
isn't given the "expected" id of ahci0 by qemu when it's created. The
43fe83
original suggested solution to this problem was to not specify any
43fe83
controller for the disks that use the default controller and just
43fe83
specify "unit=n" instead; qemu should then use the first IDE or SATA
43fe83
controller for the disk.
43fe83
43fe83
Unfortunately, this "solution" is ignorant of the fact that in the
43fe83
case of SATA disks, the "unit" attribute in the disk XML is actually
43fe83
*not* being used for the unit, but is instead used to specify the
43fe83
"bus" number; each SATA controller has 6 buses, and each bus only
43fe83
allows a single unit. This makes it nonsensical to specify unit='n'
43fe83
where n is anything other than 0. It also means that the only way to
43fe83
connect more than a single device to the implicit SATA controller is
43fe83
to explicitly give the bus names, which happen to be "ide.$n", where
43fe83
$n can be replaced by the disk's "unit" number.
43fe83
43fe83
(cherry picked from commit 30bb4c4b54ed3a23adc90c52540dd96b0cbcfbcc)
43fe83
43fe83
Conflicts:
43fe83
43fe83
tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args - this upstream
43fe83
file didn't yet exist in the libvirt release used as the base for the
43fe83
RHEL7 build.
43fe83
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/qemu/qemu_command.c                      | 15 ++++++---------
43fe83
 tests/qemuxml2argvdata/qemuxml2argv-q35.args |  2 +-
43fe83
 2 files changed, 7 insertions(+), 10 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
43fe83
index 6e9657f..6a6b3cd 100644
43fe83
--- a/src/qemu/qemu_command.c
43fe83
+++ b/src/qemu/qemu_command.c
43fe83
@@ -4280,18 +4280,15 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
43fe83
         if (qemuDomainMachineIsQ35(def) &&
43fe83
             disk->info.addr.drive.controller == 0) {
43fe83
             /* Q35 machines have an implicit ahci (sata) controller at
43fe83
-             * 00:1F.2 which has no "id" associated with it. For this
43fe83
-             * reason, we can't refer to it as "ahci0". Instead, we
43fe83
-             * don't give an id, which qemu interprets as "use the
43fe83
-             * first ahci controller". We then need to specify the
43fe83
-             * unit with "unit=%d" rather than adding it onto the bus
43fe83
-             * arg.
43fe83
+             * 00:1F.2 which for some reason is hardcoded with the id
43fe83
+             * "ide" instead of the seemingly more reasonable "ahci0"
43fe83
+             * or "sata0".
43fe83
              */
43fe83
-            virBufferAsprintf(&opt, ",unit=%d", disk->info.addr.drive.unit);
43fe83
+            virBufferAsprintf(&opt, ",bus=ide.%d", disk->info.addr.drive.unit);
43fe83
         } else {
43fe83
             /* All other ahci controllers have been created by
43fe83
-             * libvirt, so they *do* have an id, and we can identify
43fe83
-             * them that way.
43fe83
+             * libvirt, and we gave them the id "ahci${n}" where ${n}
43fe83
+             * is the controller number. So we identify them that way.
43fe83
              */
43fe83
             virBufferAsprintf(&opt, ",bus=ahci%d.%d",
43fe83
                               disk->info.addr.drive.controller,
43fe83
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35.args b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
43fe83
index 9e67be5..151863e 100644
43fe83
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35.args
43fe83
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
43fe83
@@ -4,5 +4,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
43fe83
 -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x2 \
43fe83
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
43fe83
 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
43fe83
--device ide-drive,unit=0,drive=drive-sata0-0-0,id=sata0-0-0 \
43fe83
+-device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
43fe83
 -vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368
43fe83
-- 
43fe83
1.8.3.2
43fe83