[libvirt] [PATCH 09/10] Convert PCI device assignment over to -device

Daniel P. Berrange berrange at redhat.com
Tue Dec 15 15:14:49 UTC 2009


The old syntax is

  -pcidevice host=BUS:SLOT:FUNCTION

The new syntax is

  -device pci-assign,host=BUS:SLOT:FUNCTION
---
 src/qemu/qemu_conf.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index ac322a7..f8c6ae6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2852,22 +2852,26 @@ int qemudBuildCommandLine(virConnectPtr conn,
         /* 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");
+                ret = virAsprintf(&pcidev, "pci-assign,host=%.2x:%.2x.%.1x",
+                                  hostdev->source.subsys.u.pci.bus,
+                                  hostdev->source.subsys.u.pci.slot,
+                                  hostdev->source.subsys.u.pci.function);
+            } else if (qemuCmdFlags & QEMUD_CMD_FLAG_PCIDEVICE) {
+                ADD_ARG_LIT("-pcidevice");
+                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);
+            } 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;
+            if (ret < 0)
                 goto no_memory;
-            }
-            ADD_ARG_LIT("-pcidevice");
-            ADD_ARG_LIT(pcidev);
-            VIR_FREE(pcidev);
+            ADD_ARG(pcidev);
         }
     }
 
-- 
1.6.5.2




More information about the libvir-list mailing list