}
+static char *
+qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ virBufferAddLit(&buf, "pci-assign");
+ virBufferVSprintf(&buf, ",host=%.2x:%.2x.%.1x",
+ dev->source.subsys.u.pci.bus,
+ dev->source.subsys.u.pci.slot,
+ dev->source.subsys.u.pci.function);
+ virBufferVSprintf(&buf, ",id=%s", dev->info.alias);
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info) < 0)
+ goto error;
+
+ if (virBufferError(&buf)) {
+ virReportOOMError(NULL);
+ goto error;
+ }
+
+ return virBufferContentAndReset(&buf);
+
+error:
+ virBufferFreeAndReset(&buf);
+ return NULL;
+}
+
/* This function outputs a -chardev command line option which describes only the
* host side of the character device */
static void qemudBuildCommandLineChrDevChardevStr(virDomainChrDefPtr dev,
/* PCI */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
- if (!(qemuCmdFlags & QEMUD_CMD_FLAG_PCIDEVICE)) {
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ ADD_ARG_LIT("-device");
+ if (!(pcidev = qemuBuildPCIHostdevDevStr(hostdev)))
+ goto error;
+ } else if (qemuCmdFlags & QEMUD_CMD_FLAG_PCIDEVICE) {
+ ADD_ARG_LIT("-pcidevice");
+ if (virAsprintf(&pcidev, "host=%.2x:%.2x.%.1x",
+ hostdev->source.subsys.u.pci.bus,
+ hostdev->source.subsys.u.pci.slot,
+ hostdev->source.subsys.u.pci.function) < 0)
+ goto no_memory;
+ } else {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s",
_("PCI device assignment is not supported by this version of qemu"));
goto error;
}
- ret = virAsprintf(&pcidev, "host=%.2x:%.2x.%.1x",
- hostdev->source.subsys.u.pci.bus,
- hostdev->source.subsys.u.pci.slot,
- hostdev->source.subsys.u.pci.function);
- if (ret < 0) {
- pcidev = NULL;
- goto no_memory;
- }
- ADD_ARG_LIT("-pcidevice");
- ADD_ARG_LIT(pcidev);
- VIR_FREE(pcidev);
+ ADD_ARG(pcidev);
}
}
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <hostdev mode='subsystem' type='pci' managed='yes'>
+ <source>
+ <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+ </source>
+ </hostdev>
+ </devices>
+</domain>
DO_TEST("hostdev-usb-address", 0);
DO_TEST("hostdev-usb-address-device", QEMUD_CMD_FLAG_DEVICE);
DO_TEST("hostdev-pci-address", QEMUD_CMD_FLAG_PCIDEVICE);
+ DO_TEST("hostdev-pci-address-device", QEMUD_CMD_FLAG_PCIDEVICE|QEMUD_CMD_FLAG_DEVICE);
DO_TEST_FULL("restore-v1", QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO, "stdio");
DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "stdio");