mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: fix attach-interface regression
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>
This commit is contained in:
parent
100f4a63a2
commit
6bf4788e86
@ -556,7 +556,7 @@ qemuCapsInitGuest(virCapsPtr caps,
|
|||||||
!virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
|
!virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(binary, NULL, &qemuCmdFlags) < 0 ||
|
if (qemuCapsExtractVersionInfo(binary, info->arch, NULL, &qemuCmdFlags) < 0 ||
|
||||||
((qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX) &&
|
((qemuCmdFlags & QEMUD_CMD_FLAG_BOOTINDEX) &&
|
||||||
!virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0)))
|
!virCapabilitiesAddGuestFeature(guest, "deviceboot", 1, 0)))
|
||||||
goto error;
|
goto error;
|
||||||
@ -1117,7 +1117,7 @@ qemuCapsParseDeviceStr(const char *str, unsigned long long *flags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemuCapsExtractVersionInfo(const char *qemu,
|
int qemuCapsExtractVersionInfo(const char *qemu, const char *arch,
|
||||||
unsigned int *retversion,
|
unsigned int *retversion,
|
||||||
unsigned long long *retflags)
|
unsigned long long *retflags)
|
||||||
{
|
{
|
||||||
@ -1153,6 +1153,12 @@ int qemuCapsExtractVersionInfo(const char *qemu,
|
|||||||
&version, &is_kvm, &kvm_version) == -1)
|
&version, &is_kvm, &kvm_version) == -1)
|
||||||
goto cleanup;
|
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
|
/* qemuCapsExtractDeviceStr will only set additional flags if qemu
|
||||||
* understands the 0.13.0+ notion of "-device driver,". */
|
* understands the 0.13.0+ notion of "-device driver,". */
|
||||||
if ((flags & QEMUD_CMD_FLAG_DEVICE) &&
|
if ((flags & QEMUD_CMD_FLAG_DEVICE) &&
|
||||||
@ -1214,7 +1220,7 @@ int qemuCapsExtractVersion(virCapsPtr caps,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(binary, version, NULL) < 0) {
|
if (qemuCapsExtractVersionInfo(binary, ut.machine, version, NULL) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ int qemuCapsProbeCPUModels(const char *qemu,
|
|||||||
|
|
||||||
int qemuCapsExtractVersion(virCapsPtr caps,
|
int qemuCapsExtractVersion(virCapsPtr caps,
|
||||||
unsigned int *version);
|
unsigned int *version);
|
||||||
int qemuCapsExtractVersionInfo(const char *qemu,
|
int qemuCapsExtractVersionInfo(const char *qemu, const char *arch,
|
||||||
unsigned int *version,
|
unsigned int *version,
|
||||||
unsigned long long *qemuCmdFlags);
|
unsigned long long *qemuCmdFlags);
|
||||||
|
|
||||||
|
@ -2685,12 +2685,6 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
break;
|
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);
|
cmd = virCommandNewArgList(emulator, "-S", NULL);
|
||||||
|
|
||||||
virCommandAddEnvPassCommon(cmd);
|
virCommandAddEnvPassCommon(cmd);
|
||||||
|
@ -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
|
/* XXX we should be persisting the original flags in the XML
|
||||||
* not re-detecting them, since the binary may have changed
|
* not re-detecting them, since the binary may have changed
|
||||||
* since launch time */
|
* since launch time */
|
||||||
if (qemuCapsExtractVersionInfo(obj->def->emulator,
|
if (qemuCapsExtractVersionInfo(obj->def->emulator, obj->def->os.arch,
|
||||||
NULL,
|
NULL,
|
||||||
&qemuCmdFlags) >= 0 &&
|
&qemuCmdFlags) >= 0 &&
|
||||||
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
|
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
|
||||||
@ -2516,7 +2516,7 @@ qemuAssignPCIAddresses(virDomainDefPtr def)
|
|||||||
unsigned long long qemuCmdFlags = 0;
|
unsigned long long qemuCmdFlags = 0;
|
||||||
qemuDomainPCIAddressSetPtr addrs = NULL;
|
qemuDomainPCIAddressSetPtr addrs = NULL;
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(def->emulator,
|
if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
|
||||||
NULL,
|
NULL,
|
||||||
&qemuCmdFlags) < 0)
|
&qemuCmdFlags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2749,7 +2749,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
DEBUG0("Determining emulator version");
|
DEBUG0("Determining emulator version");
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator,
|
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
||||||
NULL,
|
NULL,
|
||||||
&qemuCmdFlags) < 0)
|
&qemuCmdFlags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -6152,7 +6152,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
|
|||||||
def->graphics[i]->data.vnc.port = QEMU_VNC_PORT_MIN;
|
def->graphics[i]->data.vnc.port = QEMU_VNC_PORT_MIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(def->emulator,
|
if (qemuCapsExtractVersionInfo(def->emulator, def->os.arch,
|
||||||
NULL,
|
NULL,
|
||||||
&qemuCmdFlags) < 0)
|
&qemuCmdFlags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -6534,7 +6534,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
|
|||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator,
|
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
||||||
NULL,
|
NULL,
|
||||||
&qemuCmdFlags) < 0)
|
&qemuCmdFlags) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -6704,7 +6704,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator,
|
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
||||||
NULL,
|
NULL,
|
||||||
&qemuCmdFlags) < 0)
|
&qemuCmdFlags) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -6810,7 +6810,7 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
|
|||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (qemuCapsExtractVersionInfo(vm->def->emulator,
|
if (qemuCapsExtractVersionInfo(vm->def->emulator, vm->def->os.arch,
|
||||||
NULL,
|
NULL,
|
||||||
&qemuCmdFlags) < 0)
|
&qemuCmdFlags) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -8078,7 +8078,8 @@ qemudDomainMigratePrepareTunnel(virConnectPtr dconn,
|
|||||||
unlink(unixfile);
|
unlink(unixfile);
|
||||||
|
|
||||||
/* check that this qemu version supports the interactive exec */
|
/* 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,
|
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Cannot determine QEMU argv syntax %s"),
|
_("Cannot determine QEMU argv syntax %s"),
|
||||||
vm->def->emulator);
|
vm->def->emulator);
|
||||||
@ -8589,7 +8590,8 @@ static int doTunnelMigrate(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* check that this qemu version supports the unix migration */
|
/* 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,
|
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Cannot extract Qemu version from '%s'"),
|
_("Cannot extract Qemu version from '%s'"),
|
||||||
vm->def->emulator);
|
vm->def->emulator);
|
||||||
|
@ -111,6 +111,15 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
free(virtTestLogContentAndReset());
|
free(virtTestLogContentAndReset());
|
||||||
virResetLastError();
|
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,
|
if (!(cmd = qemuBuildCommandLine(conn, &driver,
|
||||||
vmdef, &monitor_chr, false, flags,
|
vmdef, &monitor_chr, false, flags,
|
||||||
migrateFrom, migrateFd, NULL,
|
migrateFrom, migrateFd, NULL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user