提交 877bc089 编写于 作者: J Ján Tomko

qemu: don't always reserve PCI addresses for implicit controllers

In the past we automatically added a USB controller and assigned
it a PCI address (0:0:1.2) even on machines without a PCI bus.
This didn't break machines with no PCI bus  because the command
line for it is just '-usb', with no mention of the PCI bus.

The implicit IDE controller (reserved address 0:0:1.1) has
no command line at all.

Commit b33eb0dc removed the ability to reserve PCI addresses
on machines without a PCI bus. This made them stop working,
since there would always be the implicit USB controller.

Skip the reservation of addresses for these controllers when
there is no PCI bus, instead of failing.
上级 19635f7d
......@@ -1407,6 +1407,25 @@ static int qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
return 0;
}
/* Ignore implicit controllers on slot 0:0:1.0:
* implicit IDE controller on 0:0:1.1 (no qemu command line)
* implicit USB controller on 0:0:1.2 (-usb)
*
* If the machine does have a PCI bus, they will get reserved
* in qemuAssignDevicePCISlots().
*/
if (device->type == VIR_DOMAIN_DEVICE_CONTROLLER && addr->domain == 0 &&
addr->bus == 0 && addr->slot == 1) {
virDomainControllerDefPtr cont = device->data.controller;
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE && cont->idx == 0 &&
addr->function == 1)
return 0;
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && cont->idx == 0 &&
(cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI ||
cont->model == -1) && addr->function == 2)
return 0;
}
if (addrs->dryRun && qemuDomainPCIAddressSetGrow(addrs, addr) < 0)
return -1;
......@@ -1822,12 +1841,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
qemuDomainPCIAddressSetPtr addrs)
{
size_t i, j;
bool reservedIDE = false;
bool reservedUSB = false;
bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
virDevicePCIAddress tmp_addr;
virDevicePCIAddressPtr addrptr;
unsigned int *func = &tmp_addr.function;
/* Verify that first IDE and USB controllers (if any) is on the PIIX3, fn 1 */
for (i = 0; i < def->ncontrollers ; i++) {
......@@ -1843,9 +1859,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
_("Primary IDE controller must have PCI address 0:0:1.1"));
goto error;
}
/* If TYPE==PCI, then qemuCollectPCIAddress() function
* has already reserved the address, so we must skip */
reservedIDE = true;
} else {
def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
def->controllers[i]->info.addr.pci.domain = 0;
......@@ -1866,7 +1879,6 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
_("PIIX3 USB controller must have PCI address 0:0:1.2"));
goto error;
}
reservedUSB = true;
} else {
def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
def->controllers[i]->info.addr.pci.domain = 0;
......@@ -1883,15 +1895,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
if (addrs->nbuses) {
memset(&tmp_addr, 0, sizeof(tmp_addr));
tmp_addr.slot = 1;
for (*func = 0; *func < QEMU_PCI_ADDRESS_FUNCTION_LAST; (*func)++) {
if ((*func == 1 && reservedIDE) ||
(*func == 2 && reservedUSB))
/* we have reserved this pci address */
continue;
if (qemuDomainPCIAddressReserveAddr(addrs, &tmp_addr) < 0)
goto error;
}
if (qemuDomainPCIAddressReserveSlot(addrs, &tmp_addr) < 0)
goto error;
}
if (def->nvideos > 0) {
......
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
/usr/bin/qemu-system-s390x -S -M s390-virtio -m 214 -smp 1 -nographic \
-nodefconfig -nodefaults \
-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi \
-device virtio-serial-s390,id=virtio-serial0 -usb -drive \
file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 \
-device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-chardev pty,id=charconsole0 \
-device virtconsole,chardev=charconsole0,id=console0 \
-object rng-random,id=rng0,filename=/dev/hwrng -device virtio-rng-s390,rng=rng0
<domain type='qemu'>
<name>test</name>
<memory>219100</memory>
<currentMemory>219100</currentMemory>
<os>
<type arch='s390x' machine='s390-virtio'>hvm</type>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-s390x</emulator>
<disk type='block' device='disk'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='virtio'/>
<boot order='1'/>
</disk>
<console type='pty'>
<target type='virtio'/>
</console>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<memballoon model='virtio'>
</memballoon>
<rng model='virtio'>
<backend model='random'>/dev/hwrng</backend>
</rng>
</devices>
</domain>
......@@ -960,6 +960,11 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
DO_TEST("s390-piix-controllers",
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
DO_TEST("ppc-dtb", QEMU_CAPS_KVM, QEMU_CAPS_DTB);
DO_TEST("tpm-passthrough", QEMU_CAPS_DEVICE,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册