[PATCH 1/2] QEMUD_CMD_FLAG_PCI_MULTIBUS should be set in the function qemuCapsExtractVersionInfo()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The flag QEMUD_CMD_FLAG_PCI_MULTIBUS is used in the function
qemuBuildDeviceAddressStr(). All callers get qemuCmdFlags
by the function qemuCapsExtractVersionInfo() except that
testCompareXMLToArgvFiles() in qemuxml2argvtest.c.

So we should set QEMUD_CMD_FLAG_PCI_MULTIBUS in the function
qemuCapsExtractVersionInfo() instead of qemuBuildCommandLine()
because the function qemuBuildCommandLine() does not be called
when we attach a pci device.

Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx>

---
 src/qemu/qemu_capabilities.c |   12 +++++++++---
 src/qemu/qemu_capabilities.h |    2 +-
 src/qemu/qemu_command.c      |    6 ------
 src/qemu/qemu_driver.c       |   20 +++++++++++---------
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2787ffb..808ead0 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -547,7 +547,7 @@ qemuCapsInitGuest(virCapsPtr caps,
         !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
         goto error;
 
-    if (qemuCapsExtractVersionInfo(binary, NULL, &qemuCmdFlags) < 0 ||
+    if (qemuCapsExtractVersionInfo(binary, info->arch, NULL, &qemuCmdFlags) < 0 ||
         ((qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX) &&
          !virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0)))
         goto error;
@@ -1108,7 +1108,7 @@ qemuCapsParseDeviceStr(const char *str, unsigned long long *flags)
     return 0;
 }
 
-int qemuCapsExtractVersionInfo(const char *qemu,
+int qemuCapsExtractVersionInfo(const char *qemu, const char *arch,
                                unsigned int *retversion,
                                unsigned long long *retflags)
 {
@@ -1144,6 +1144,12 @@ int qemuCapsExtractVersionInfo(const char *qemu,
                              &version, &is_kvm, &kvm_version) == -1)
         goto cleanup;
 
+    /* Currently only x86_64 and i686 support PCI-multibus. */
+    if (STREQLEN(arch, "x86_64", 6) ||
+        STREQLEN(arch, "i686", 4)) {
+        flags |= QEMUD_CMD_FLAG_PCI_MULTIBUS;
+    }
+
     /* qemuCapsExtractDeviceStr will only set additional flags if qemu
      * understands the 0.13.0+ notion of "-device driver,".  */
     if ((flags & QEMUD_CMD_FLAG_DEVICE) &&
@@ -1205,7 +1211,7 @@ int qemuCapsExtractVersion(virCapsPtr caps,
         return -1;
     }
 
-    if (qemuCapsExtractVersionInfo(binary, version, NULL) < 0) {
+    if (qemuCapsExtractVersionInfo(binary, ut.machine, version, NULL) < 0) {
         return -1;
     }
 
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index dd39b3b..a130a4f 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -108,7 +108,7 @@ int qemuCapsProbeCPUModels(const char *qemu,
 
 int qemuCapsExtractVersion(virCapsPtr caps,
                            unsigned int *version);
-int qemuCapsExtractVersionInfo(const char *qemu,
+int qemuCapsExtractVersionInfo(const char *qemu, const char *arch,
                                unsigned int *version,
                                unsigned long long *qemuCmdFlags);
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f78ce71..3ba0950 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2685,12 +2685,6 @@ qemuBuildCommandLine(virConnectPtr conn,
         break;
     }
 
-    /* Currently only x86_64 and i686 support PCI-multibus. */
-    if (STREQLEN(def->os.arch, "x86_64", 6) ||
-        STREQLEN(def->os.arch, "i686", 4)) {
-        qemuCmdFlags |= QEMUD_CMD_FLAG_PCI_MULTIBUS;
-    }
-
     cmd = virCommandNewArgList(emulator, "-S", NULL);
 
     virCommandAddEnvPassCommon(cmd);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b936735..ff396ff 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -943,7 +943,7 @@ qemuReconnectDomain(void *payload, const char *name ATTRIBUTE_UNUSED, void *opaq
     /* XXX we should be persisting the original flags in the XML
      * not re-detecting them, since the binary may have changed
      * since launch time */
-    if (qemuCapsExtractVersionInfo(obj->def->emulator,
+    if (qemuCapsExtractVersionInfo(obj->def->emulator, obj->def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) >= 0 &&
         (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
@@ -2516,7 +2516,7 @@ qemuAssignPCIAddresses(virDomainDefPtr def)
     unsigned long long qemuCmdFlags = 0;
     qemuDomainPCIAddressSetPtr addrs = NULL;
 
-    if (qemuCapsExtractVersionInfo(def->emulator,
+    if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) < 0)
         goto cleanup;
@@ -2749,7 +2749,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
         goto cleanup;
 
     DEBUG0("Determining emulator version");
-    if (qemuCapsExtractVersionInfo(vm->def->emulator,
+    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) < 0)
         goto cleanup;
@@ -6136,7 +6136,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
             def->graphics[i]->data.vnc.port = QEMU_VNC_PORT_MIN;
     }
 
-    if (qemuCapsExtractVersionInfo(def->emulator,
+    if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) < 0)
         goto cleanup;
@@ -6518,7 +6518,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
     if (dev == NULL)
         goto endjob;
 
-    if (qemuCapsExtractVersionInfo(vm->def->emulator,
+    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) < 0)
         goto endjob;
@@ -6688,7 +6688,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
     if (dev == NULL)
         goto endjob;
 
-    if (qemuCapsExtractVersionInfo(vm->def->emulator,
+    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) < 0)
         goto endjob;
@@ -6794,7 +6794,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
     if (dev == NULL)
         goto endjob;
 
-    if (qemuCapsExtractVersionInfo(vm->def->emulator,
+    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
                                    NULL,
                                    &qemuCmdFlags) < 0)
         goto endjob;
@@ -8062,7 +8062,8 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn,
     unlink(unixfile);
 
     /* check that this qemu version supports the interactive exec */
-    if (qemuCapsExtractVersionInfo(vm->def->emulator, NULL, &qemuCmdFlags) < 0) {
+    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
+                                   NULL, &qemuCmdFlags) < 0) {
         qemuReportError(VIR_ERR_INTERNAL_ERROR,
                         _("Cannot determine QEMU argv syntax %s"),
                         vm->def->emulator);
@@ -8573,7 +8574,8 @@ static int doTunnelMigrate(virDomainPtr dom,
     }
 
     /* check that this qemu version supports the unix migration */
-    if (qemuCapsExtractVersionInfo(vm->def->emulator, NULL, &qemuCmdFlags) < 0) {
+    if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
+                                   NULL, &qemuCmdFlags) < 0) {
         qemuReportError(VIR_ERR_INTERNAL_ERROR,
                         _("Cannot extract Qemu version from '%s'"),
                         vm->def->emulator);
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]