]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: fix attach-interface regression
authorWen Congyang <wency@cn.fujitsu.com>
Thu, 10 Feb 2011 02:19:38 +0000 (10:19 +0800)
committerEric Blake <eblake@redhat.com>
Thu, 10 Feb 2011 22:07:21 +0000 (15:07 -0700)
QEMUD_CMD_FLAG_PCI_MULTIBUS should be set in the function
qemuCapsExtractVersionInfo()

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.

tests: set QEMUD_CMD_FLAG_PCI_MULTIBUS in testCompareXMLToArgvFiles()

set QEMUD_CMD_FLAG_PCI_MULTIBUS before calling qemuBuildCommandLine()
as the flags is not set by qemuCapsExtractVersionInfo().

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
src/qemu/qemu_capabilities.c
src/qemu/qemu_capabilities.h
src/qemu/qemu_command.c
src/qemu/qemu_driver.c
tests/qemuxml2argvtest.c

index 4504b7e9f1959bbaf5d44ccf25f26c91a20da3fc..ca7d8420c5a0cdc1d7bbd4a694200c52798b194b 100644 (file)
@@ -556,7 +556,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;
@@ -1117,7 +1117,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)
 {
@@ -1153,6 +1153,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) &&
@@ -1214,7 +1220,7 @@ int qemuCapsExtractVersion(virCapsPtr caps,
         return -1;
     }
 
-    if (qemuCapsExtractVersionInfo(binary, version, NULL) < 0) {
+    if (qemuCapsExtractVersionInfo(binary, ut.machine, version, NULL) < 0) {
         return -1;
     }
 
index dd39b3bd3de56bbc0b259d09a749b01a674cb1fc..a130a4f993dbf9f78793ddb81f181cbff1f31a08 100644 (file)
@@ -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);
 
index f78ce71cddc1b1feca2e9e41323023acfc883bd1..3ba095049d95082245298b2576e36528a137fe34 100644 (file)
@@ -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);
index 20a4157ab6cc1249bb5bef90ab5f14bb17c018f9..21d777961bafcc6619dea53f38b7683a263d993a 100644 (file)
@@ -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;
@@ -6152,7 +6152,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;
@@ -6534,7 +6534,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;
@@ -6704,7 +6704,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;
@@ -6810,7 +6810,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;
@@ -8078,7 +8078,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);
@@ -8589,7 +8590,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);
index 52808b51aeb93066e055998f0768480bb3ab756e..96260c0d81614c286744e9dea19c86ed2ac3c476 100644 (file)
@@ -111,6 +111,15 @@ static int testCompareXMLToArgvFiles(const char *xml,
     free(virtTestLogContentAndReset());
     virResetLastError();
 
+    /* We do not call qemuCapsExtractVersionInfo() before calling
+     * qemuBuildCommandLine(), so we should set QEMUD_CMD_FLAG_PCI_MULTIBUS for
+     * x86_64 and i686 architectures here.
+     */
+    if (STREQLEN(vmdef->os.arch, "x86_64", 6) ||
+        STREQLEN(vmdef->os.arch, "i686", 4)) {
+        flags |= QEMUD_CMD_FLAG_PCI_MULTIBUS;
+    }
+
     if (!(cmd = qemuBuildCommandLine(conn, &driver,
                                      vmdef, &monitor_chr, false, flags,
                                      migrateFrom, migrateFd, NULL,