qemu: use "ide" as device name for implicit SATA controller on Q35

This resolves https://bugzilla.redhat.com/show_bug.cgi?id=1008903

The Q35 machinetype has an implicit SATA controller at 00:1F.2 which
isn't given the "expected" id of ahci0 by qemu when it's created. The
original suggested solution to this problem was to not specify any
controller for the disks that use the default controller and just
specify "unit=n" instead; qemu should then use the first IDE or SATA
controller for the disk.

Unfortunately, this "solution" is ignorant of the fact that in the
case of SATA disks, the "unit" attribute in the disk XML is actually
*not* being used for the unit, but is instead used to specify the
"bus" number; each SATA controller has 6 buses, and each bus only
allows a single unit. This makes it nonsensical to specify unit='n'
where n is anything other than 0. It also means that the only way to
connect more than a single device to the implicit SATA controller is
to explicitly give the bus names, which happen to be "ide.$n", where
$n can be replaced by the disk's "unit" number.
This commit is contained in:
Laine Stump 2013-09-20 06:00:48 -04:00
parent 604ae65744
commit 30bb4c4b54
3 changed files with 8 additions and 11 deletions

View File

@ -4383,18 +4383,15 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
if (qemuDomainMachineIsQ35(def) && if (qemuDomainMachineIsQ35(def) &&
disk->info.addr.drive.controller == 0) { disk->info.addr.drive.controller == 0) {
/* Q35 machines have an implicit ahci (sata) controller at /* Q35 machines have an implicit ahci (sata) controller at
* 00:1F.2 which has no "id" associated with it. For this * 00:1F.2 which for some reason is hardcoded with the id
* reason, we can't refer to it as "ahci0". Instead, we * "ide" instead of the seemingly more reasonable "ahci0"
* don't give an id, which qemu interprets as "use the * or "sata0".
* first ahci controller". We then need to specify the
* unit with "unit=%d" rather than adding it onto the bus
* arg.
*/ */
virBufferAsprintf(&opt, ",unit=%d", disk->info.addr.drive.unit); virBufferAsprintf(&opt, ",bus=ide.%d", disk->info.addr.drive.unit);
} else { } else {
/* All other ahci controllers have been created by /* All other ahci controllers have been created by
* libvirt, so they *do* have an id, and we can identify * libvirt, and we gave them the id "ahci${n}" where ${n}
* them that way. * is the controller number. So we identify them that way.
*/ */
virBufferAsprintf(&opt, ",bus=ahci%d.%d", virBufferAsprintf(&opt, ",bus=ahci%d.%d",
disk->info.addr.drive.controller, disk->info.addr.drive.controller,

View File

@ -5,5 +5,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x2 \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x2 \
-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \ -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
-device ide-drive,unit=0,drive=drive-sata0-0-0,id=sata0-0-0 \ -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
-vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368 -vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368

View File

@ -4,5 +4,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x2 \ -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x2 \
-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \ -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \ -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
-device ide-drive,unit=0,drive=drive-sata0-0-0,id=sata0-0-0 \ -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
-vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368 -vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368