mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
qemuxml2argvtest: Update qemuCaps after parsing domain XML
Some parts of qemuCaps depend on guest architecture, machine type, and possibly other things that we know only once the domain XML has been parsed. Let's move all these updates into a dedicated function. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
30de7164ef
commit
4df4b8dea3
@ -272,6 +272,7 @@ struct testInfo {
|
|||||||
int migrateFd;
|
int migrateFd;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
unsigned int parseFlags;
|
unsigned int parseFlags;
|
||||||
|
bool skipLegacyCPUs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -305,17 +306,15 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testPrepareExtraFlags(struct testInfo *info,
|
testInitQEMUCaps(struct testInfo *info,
|
||||||
bool skipLegacyCPUs,
|
int gic)
|
||||||
int gic)
|
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(info->qemuCaps = virQEMUCapsNew()))
|
if (!(info->qemuCaps = virQEMUCapsNew()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (testAddCPUModels(info->qemuCaps, skipLegacyCPUs) < 0)
|
virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_NO_ACPI);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0)
|
if (testQemuCapsSetGIC(info->qemuCaps, gic) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -327,6 +326,27 @@ testPrepareExtraFlags(struct testInfo *info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
testUpdateQEMUCaps(const struct testInfo *info,
|
||||||
|
virDomainObjPtr vm)
|
||||||
|
{
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (testAddCPUModels(info->qemuCaps, info->skipLegacyCPUs) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);
|
||||||
|
|
||||||
|
if (ARCH_IS_X86(vm->def->os.arch))
|
||||||
|
virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testCompareXMLToArgv(const void *data)
|
testCompareXMLToArgv(const void *data)
|
||||||
{
|
{
|
||||||
@ -400,10 +420,6 @@ testCompareXMLToArgv(const void *data)
|
|||||||
if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
|
if (qemuProcessPrepareMonitorChr(&monitor_chr, priv->libDir) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virQEMUCapsSetList(info->qemuCaps,
|
|
||||||
QEMU_CAPS_NO_ACPI,
|
|
||||||
QEMU_CAPS_LAST);
|
|
||||||
|
|
||||||
if (STREQ(vm->def->os.machine, "pc") &&
|
if (STREQ(vm->def->os.machine, "pc") &&
|
||||||
STREQ(vm->def->emulator, "/usr/bin/qemu-system-x86_64")) {
|
STREQ(vm->def->emulator, "/usr/bin/qemu-system-x86_64")) {
|
||||||
VIR_FREE(vm->def->os.machine);
|
VIR_FREE(vm->def->os.machine);
|
||||||
@ -411,17 +427,13 @@ testCompareXMLToArgv(const void *data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
virQEMUCapsFilterByMachineType(info->qemuCaps, vm->def->os.machine);
|
if (testUpdateQEMUCaps(info, vm) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
log = virTestLogContentAndReset();
|
log = virTestLogContentAndReset();
|
||||||
VIR_FREE(log);
|
VIR_FREE(log);
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
|
|
||||||
if (vm->def->os.arch == VIR_ARCH_X86_64 ||
|
|
||||||
vm->def->os.arch == VIR_ARCH_I686) {
|
|
||||||
virQEMUCapsSet(info->qemuCaps, QEMU_CAPS_PCI_MULTIBUS);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < vm->def->nhostdevs; i++) {
|
for (i = 0; i < vm->def->nhostdevs; i++) {
|
||||||
virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
|
virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
|
||||||
|
|
||||||
@ -536,9 +548,11 @@ mymain(void)
|
|||||||
parseFlags, gic, ...) \
|
parseFlags, gic, ...) \
|
||||||
do { \
|
do { \
|
||||||
static struct testInfo info = { \
|
static struct testInfo info = { \
|
||||||
name, NULL, migrateFrom, migrateFd, (flags), parseFlags \
|
name, NULL, migrateFrom, migrateFd, (flags), parseFlags, \
|
||||||
|
false \
|
||||||
}; \
|
}; \
|
||||||
if (testPrepareExtraFlags(&info, skipLegacyCPUs, gic) < 0) \
|
info.skipLegacyCPUs = skipLegacyCPUs; \
|
||||||
|
if (testInitQEMUCaps(&info, gic) < 0) \
|
||||||
return EXIT_FAILURE; \
|
return EXIT_FAILURE; \
|
||||||
virQEMUCapsSetList(info.qemuCaps, __VA_ARGS__, QEMU_CAPS_LAST); \
|
virQEMUCapsSetList(info.qemuCaps, __VA_ARGS__, QEMU_CAPS_LAST); \
|
||||||
if (virTestRun("QEMU XML-2-ARGV " name, \
|
if (virTestRun("QEMU XML-2-ARGV " name, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user