[libvirt] [PATCH 0/4] Automatically choose usable GIC version

Currently, if no GIC version has been provided by the user, libvirt will default to GIC v2. This is a problem when trying to create new guests on hardware that only supports GIC v3 guests: QEMU will refuse to start a GIC v2 guest, and guest installation will abort immediately. This series implements a way for libvirt to figure out a suitable GIC version itself, without relying on tools such as virt-install to parse the domain capabilities before attempting installation. Andrea Bolognani (4): qemu: Automatically choose usable GIC version qemu: Add virQEMUCapsSetGICCapabilities() tests: Prepare to have different usable GIC versions tests: Try different usable GIC versions src/conf/domain_capabilities.c | 25 +++ src/conf/domain_capabilities.h | 8 + src/libvirt_private.syms | 1 + src/qemu/qemu_capabilities.c | 29 +++- src/qemu/qemu_capabilities.h | 5 + src/qemu/qemu_domain.c | 66 ++++++-- .../qemuxml2argv-aarch64-gic-none-both.args | 1 + .../qemuxml2argv-aarch64-gic-none-both.xml | 1 + .../qemuxml2argv-aarch64-gic-none-v2.args | 1 + .../qemuxml2argv-aarch64-gic-none-v2.xml | 1 + .../qemuxml2argv-aarch64-gic-none-v3.args | 1 + .../qemuxml2argv-aarch64-gic-none-v3.xml | 1 + tests/qemuxml2argvtest.c | 153 +++++++++++++---- .../qemuxml2xmlout-aarch64-gic-none-both.xml | 1 + .../qemuxml2xmlout-aarch64-gic-none-v2.xml | 1 + .../qemuxml2xmlout-aarch64-gic-none-v3.xml | 1 + tests/qemuxml2xmltest.c | 184 +++++++++++++-------- 17 files changed, 368 insertions(+), 112 deletions(-) create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.args create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.args create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.args create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-both.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v2.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v3.xml -- 2.5.5

When the <gic/> element in not present in the domain XML, use the domain capabilities to figure out what GIC version is usable and choose that one automatically. This allows guests to be created on hardware that only supports GIC v3 without having to update virt-manager and similar tools. Keep using the default GIC version if the <gic/> element has been added to the domain XML but no version has been specified, as not to break existing guests. --- src/conf/domain_capabilities.c | 25 ++++++++++++++++ src/conf/domain_capabilities.h | 8 +++++ src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 66 ++++++++++++++++++++++++++++++++++-------- 4 files changed, 88 insertions(+), 12 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 1676f0e..f9adeb9 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -130,6 +130,31 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum, } +bool +virDomainCapsEnumIsSet(const virDomainCapsEnum *capsEnum, + const char *capsEnumName, + unsigned int value) +{ + unsigned int val = 1 << value; + bool ret = false; + + + if (!val) { + /* Integer overflow */ + virReportError(VIR_ERR_INTERNAL_ERROR, + _("integer overflow on %s. Please contact the " + "libvirt development team at libvir-list@redhat.com"), + capsEnumName); + goto cleanup; + } + + ret = (capsEnum->values & val); + + cleanup: + return ret; +} + + void virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum) { diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 492a9cf..8ed4111 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -137,10 +137,18 @@ virDomainCapsPtr virDomainCapsNew(const char *path, __nvalues, __values); \ } while (0) +# define VIR_DOMAIN_CAPS_ENUM_IS_SET(capsEnum, value) \ + virDomainCapsEnumIsSet(&(capsEnum), #capsEnum, value) \ + int virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum, const char *capsEnumName, size_t nvalues, unsigned int *values); + +bool virDomainCapsEnumIsSet(const virDomainCapsEnum *capsEnum, + const char *capsEnumName, + unsigned int value); + void virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum); char * virDomainCapsFormat(virDomainCapsPtr const caps); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fff8c30..183e84a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -141,6 +141,7 @@ virDomainAuditVcpu; # conf/domain_capabilities.h virDomainCapsEnumClear; +virDomainCapsEnumIsSet; virDomainCapsEnumSet; virDomainCapsFormat; virDomainCapsNew; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 93f0a01..d34450f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1921,26 +1921,67 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, * Make sure that features that should be enabled by default are actually * enabled and configure default values related to those features. */ -static void -qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def) +static int +qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) { - switch (def->os.arch) { - case VIR_ARCH_ARMV7L: - case VIR_ARCH_AARCH64: - if (qemuDomainMachineIsVirt(def)) { - /* GIC is always available to ARM virt machines */ - def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON; + virDomainCapsPtr caps = NULL; + virDomainCapsFeatureGICPtr gic = NULL; + int ret = -1; + + /* The virt machine type always uses GIC: if the relevant element + * was not included in the domain XML, we need to choose a suitable + * GIC version ourselves */ + if ((def->os.arch == VIR_ARCH_ARMV7L || + def->os.arch == VIR_ARCH_AARCH64) && + qemuDomainMachineIsVirt(def) && + def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT) { + + if (!(caps = virDomainCapsNew(def->emulator, + def->os.machine, + def->os.arch, + def->virtType))) + goto cleanup; + + if (virQEMUCapsFillDomainCaps(caps, qemuCaps, NULL, 0) < 0) + goto cleanup; + + gic = &(caps->gic); + + /* Pick the best GIC version from those available */ + if (gic->supported) { + virGICVersion version; + + VIR_DEBUG("Looking for usable GIC version in domain capabilities"); + for (version = VIR_GIC_VERSION_LAST - 1; + version > VIR_GIC_VERSION_NONE; + version--) { + if (VIR_DOMAIN_CAPS_ENUM_IS_SET(gic->version, version)) { + + VIR_DEBUG("Using GIC version %s", + virGICVersionTypeToString(version)); + def->gic_version = version; + break; + } + } } - break; - default: - break; + /* Even if we haven't found a usable GIC version in the domain + * capabilities, we still want to enable this */ + def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON; } /* Use the default GIC version if no version was specified */ if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON && def->gic_version == VIR_GIC_VERSION_NONE) def->gic_version = VIR_GIC_VERSION_DEFAULT; + + ret = 0; + + cleanup: + virObjectUnref(caps); + + return ret; } @@ -2033,7 +2074,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuCanonicalizeMachine(def, qemuCaps) < 0) goto cleanup; - qemuDomainDefEnableDefaultFeatures(def); + if (qemuDomainDefEnableDefaultFeatures(def, qemuCaps) < 0) + goto cleanup; qemuDomainRecheckInternalPaths(def, cfg, parseFlags); -- 2.5.5

On 05/10/2016 08:46 AM, Andrea Bolognani wrote:
When the <gic/> element in not present in the domain XML, use the domain capabilities to figure out what GIC version is usable and choose that one automatically.
This allows guests to be created on hardware that only supports GIC v3 without having to update virt-manager and similar tools.
Keep using the default GIC version if the <gic/> element has been added to the domain XML but no version has been specified, as not to break existing guests. --- src/conf/domain_capabilities.c | 25 ++++++++++++++++ src/conf/domain_capabilities.h | 8 +++++ src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 66 ++++++++++++++++++++++++++++++++++-------- 4 files changed, 88 insertions(+), 12 deletions(-)
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 1676f0e..f9adeb9 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -130,6 +130,31 @@ virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum, }
+bool +virDomainCapsEnumIsSet(const virDomainCapsEnum *capsEnum, + const char *capsEnumName, + unsigned int value) +{ + unsigned int val = 1 << value; + bool ret = false; + +
Extra newline
+ if (!val) { + /* Integer overflow */ + virReportError(VIR_ERR_INTERNAL_ERROR, + _("integer overflow on %s. Please contact the " + "libvirt development team at libvir-list@redhat.com"), + capsEnumName); + goto cleanup; + } +
Heh that's new to me, but I see you're just following the template of virDomainCapsEnumSet, so okay
+ ret = (capsEnum->values & val); + + cleanup: + return ret; +} + + void virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum) { diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 492a9cf..8ed4111 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -137,10 +137,18 @@ virDomainCapsPtr virDomainCapsNew(const char *path, __nvalues, __values); \ } while (0)
+# define VIR_DOMAIN_CAPS_ENUM_IS_SET(capsEnum, value) \ + virDomainCapsEnumIsSet(&(capsEnum), #capsEnum, value) \ + int virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum, const char *capsEnumName, size_t nvalues, unsigned int *values); + +bool virDomainCapsEnumIsSet(const virDomainCapsEnum *capsEnum, + const char *capsEnumName, + unsigned int value); + void virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum);
char * virDomainCapsFormat(virDomainCapsPtr const caps); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fff8c30..183e84a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -141,6 +141,7 @@ virDomainAuditVcpu;
# conf/domain_capabilities.h virDomainCapsEnumClear; +virDomainCapsEnumIsSet; virDomainCapsEnumSet; virDomainCapsFormat; virDomainCapsNew; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 93f0a01..d34450f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1921,26 +1921,67 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, * Make sure that features that should be enabled by default are actually * enabled and configure default values related to those features. */ -static void -qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def) +static int +qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) { - switch (def->os.arch) { - case VIR_ARCH_ARMV7L: - case VIR_ARCH_AARCH64: - if (qemuDomainMachineIsVirt(def)) { - /* GIC is always available to ARM virt machines */ - def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON; + virDomainCapsPtr caps = NULL; + virDomainCapsFeatureGICPtr gic = NULL; + int ret = -1; + + /* The virt machine type always uses GIC: if the relevant element + * was not included in the domain XML, we need to choose a suitable + * GIC version ourselves */ + if ((def->os.arch == VIR_ARCH_ARMV7L || + def->os.arch == VIR_ARCH_AARCH64) && + qemuDomainMachineIsVirt(def) && + def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT) { + + if (!(caps = virDomainCapsNew(def->emulator, + def->os.machine, + def->os.arch, + def->virtType))) + goto cleanup; +
Call this domCaps ? 'caps' name is usually used for virCapabilities
+ if (virQEMUCapsFillDomainCaps(caps, qemuCaps, NULL, 0) < 0) + goto cleanup; + + gic = &(caps->gic); + + /* Pick the best GIC version from those available */ + if (gic->supported) { + virGICVersion version; + + VIR_DEBUG("Looking for usable GIC version in domain capabilities"); + for (version = VIR_GIC_VERSION_LAST - 1; + version > VIR_GIC_VERSION_NONE; + version--) { + if (VIR_DOMAIN_CAPS_ENUM_IS_SET(gic->version, version)) { + + VIR_DEBUG("Using GIC version %s", + virGICVersionTypeToString(version)); + def->gic_version = version; + break; + } + } }
Hmm that's a bit of a new pattern... it seems the only thing you really need from domcaps is the bit of logic we encode via virQEMUCapsFillDomainFeatureGICCaps. Maybe break that logic out into a public function and call it here, rather than spinning up domcaps for a small bit of info? Or is there more to it? - Cole
- break;
- default: - break; + /* Even if we haven't found a usable GIC version in the domain + * capabilities, we still want to enable this */ + def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON; }
/* Use the default GIC version if no version was specified */ if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON && def->gic_version == VIR_GIC_VERSION_NONE) def->gic_version = VIR_GIC_VERSION_DEFAULT; + + ret = 0; + + cleanup: + virObjectUnref(caps); + + return ret; }
@@ -2033,7 +2074,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuCanonicalizeMachine(def, qemuCaps) < 0) goto cleanup;
- qemuDomainDefEnableDefaultFeatures(def); + if (qemuDomainDefEnableDefaultFeatures(def, qemuCaps) < 0) + goto cleanup;
qemuDomainRecheckInternalPaths(def, cfg, parseFlags);

On 11.05.2016 00:42, Cole Robinson wrote:
On 05/10/2016 08:46 AM, Andrea Bolognani wrote:
When the <gic/> element in not present in the domain XML, use the domain capabilities to figure out what GIC version is usable and choose that one automatically.
This allows guests to be created on hardware that only supports GIC v3 without having to update virt-manager and similar tools.
Keep using the default GIC version if the <gic/> element has been added to the domain XML but no version has been specified, as not to break existing guests. --- src/conf/domain_capabilities.c | 25 ++++++++++++++++ src/conf/domain_capabilities.h | 8 +++++ src/libvirt_private.syms | 1 + src/qemu/qemu_domain.c | 66 ++++++++++++++++++++++++++++++++++-------- 4 files changed, 88 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 93f0a01..d34450f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1921,26 +1921,67 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, * Make sure that features that should be enabled by default are actually * enabled and configure default values related to those features. */ -static void -qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def) +static int +qemuDomainDefEnableDefaultFeatures(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) { - switch (def->os.arch) { - case VIR_ARCH_ARMV7L: - case VIR_ARCH_AARCH64: - if (qemuDomainMachineIsVirt(def)) { - /* GIC is always available to ARM virt machines */ - def->features[VIR_DOMAIN_FEATURE_GIC] = VIR_TRISTATE_SWITCH_ON; + virDomainCapsPtr caps = NULL; + virDomainCapsFeatureGICPtr gic = NULL; + int ret = -1; + + /* The virt machine type always uses GIC: if the relevant element + * was not included in the domain XML, we need to choose a suitable + * GIC version ourselves */ + if ((def->os.arch == VIR_ARCH_ARMV7L || + def->os.arch == VIR_ARCH_AARCH64) && + qemuDomainMachineIsVirt(def) && + def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ABSENT) { + + if (!(caps = virDomainCapsNew(def->emulator, + def->os.machine, + def->os.arch, + def->virtType))) + goto cleanup; +
Call this domCaps ? 'caps' name is usually used for virCapabilities
+ if (virQEMUCapsFillDomainCaps(caps, qemuCaps, NULL, 0) < 0) + goto cleanup; + + gic = &(caps->gic); + + /* Pick the best GIC version from those available */ + if (gic->supported) { + virGICVersion version; + + VIR_DEBUG("Looking for usable GIC version in domain capabilities"); + for (version = VIR_GIC_VERSION_LAST - 1; + version > VIR_GIC_VERSION_NONE; + version--) { + if (VIR_DOMAIN_CAPS_ENUM_IS_SET(gic->version, version)) { + + VIR_DEBUG("Using GIC version %s", + virGICVersionTypeToString(version)); + def->gic_version = version; + break; + } + } }
Hmm that's a bit of a new pattern... it seems the only thing you really need from domcaps is the bit of logic we encode via virQEMUCapsFillDomainFeatureGICCaps. Maybe break that logic out into a public function and call it here, rather than spinning up domcaps for a small bit of info? Or is there more to it?
Agreed. This looks like too heavy hammer for nail this small. Michal

On Tue, 2016-05-10 at 18:42 -0400, Cole Robinson wrote:
+ if (virQEMUCapsFillDomainCaps(caps, qemuCaps, NULL, 0) < 0) + goto cleanup; + + gic = &(caps->gic); + + /* Pick the best GIC version from those available */ + if (gic->supported) { + virGICVersion version; + + VIR_DEBUG("Looking for usable GIC version in domain capabilities"); + for (version = VIR_GIC_VERSION_LAST - 1; + version > VIR_GIC_VERSION_NONE; + version--) { + if (VIR_DOMAIN_CAPS_ENUM_IS_SET(gic->version, version)) { + + VIR_DEBUG("Using GIC version %s", + virGICVersionTypeToString(version)); + def->gic_version = version; + break; + } + } } Hmm that's a bit of a new pattern... it seems the only thing you really need from domcaps is the bit of logic we encode via virQEMUCapsFillDomainFeatureGICCaps. Maybe break that logic out into a public function and call it here, rather than spinning up domcaps for a small bit of info? Or is there more to it?
Nothing more to it :) Do you mean I should make virQEMUCapsFillDomainFeatureGICCaps() public and use it here to fill only the part of the domain capabilities I'm actually going to use, or create a new function altogether? Because right now I'm not seeing a way to do the latter without introducing some code duplication or making things quite a bit uglier... Maybe I'm just tired :) -- Andrea Bolognani Software Engineer - Virtualization Team

On 05/12/2016 11:53 AM, Andrea Bolognani wrote:
On Tue, 2016-05-10 at 18:42 -0400, Cole Robinson wrote:
+ if (virQEMUCapsFillDomainCaps(caps, qemuCaps, NULL, 0) < 0) + goto cleanup; + + gic = &(caps->gic); + + /* Pick the best GIC version from those available */ + if (gic->supported) { + virGICVersion version; + + VIR_DEBUG("Looking for usable GIC version in domain capabilities"); + for (version = VIR_GIC_VERSION_LAST - 1; + version > VIR_GIC_VERSION_NONE; + version--) { + if (VIR_DOMAIN_CAPS_ENUM_IS_SET(gic->version, version)) { + + VIR_DEBUG("Using GIC version %s", + virGICVersionTypeToString(version)); + def->gic_version = version; + break; + } + } }
Hmm that's a bit of a new pattern... it seems the only thing you really need from domcaps is the bit of logic we encode via virQEMUCapsFillDomainFeatureGICCaps. Maybe break that logic out into a public function and call it here, rather than spinning up domcaps for a small bit of info? Or is there more to it?
Nothing more to it :)
Do you mean I should make virQEMUCapsFillDomainFeatureGICCaps() public and use it here to fill only the part of the domain capabilities I'm actually going to use, or create a new function altogether?
Because right now I'm not seeing a way to do the latter without introducing some code duplication or making things quite a bit uglier... Maybe I'm just tired :)
Can you break apart the logic like the attached patch, then call the new function from the above code? I didn't try plugging it into your patches but it looks to me like it should work - Cole

For use in the test suite. --- src/qemu/qemu_capabilities.c | 29 +++++++++++++++++++++++++---- src/qemu/qemu_capabilities.h | 5 +++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 1bddf43..f0f641d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2387,6 +2387,30 @@ int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps, } +/** + * virQEMUCapsSetGICCapabilities: + * @qemuCaps: QEMU capabilities + * @capabilities: GIC capabilities + * @ncapabilities: number of GIC capabilities + * + * Set the GIC capabilities for @qemuCaps. + * + * The ownership of @capabilities is taken away from the caller, ie. this + * function will not make a copy of @capabilities, so releasing that memory + * after it's been called is a bug. + */ +void +virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps, + virGICCapability *capabilities, + size_t ncapabilities) +{ + VIR_FREE(qemuCaps->gicCapabilities); + + qemuCaps->gicCapabilities = capabilities; + qemuCaps->ngicCapabilities = ncapabilities; +} + + static int virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon) @@ -2738,10 +2762,7 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qemuCaps, if ((ncaps = qemuMonitorGetGICCapabilities(mon, &caps)) < 0) return -1; - VIR_FREE(qemuCaps->gicCapabilities); - - qemuCaps->gicCapabilities = caps; - qemuCaps->ngicCapabilities = ncaps; + virQEMUCapsSetGICCapabilities(qemuCaps, caps, ncaps); return 0; } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e7d0a60..3562c44 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -426,6 +426,11 @@ bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps); void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps, const char *machineType); +/* Only for use by test suite */ +void virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps, + virGICCapability *capabilities, + size_t ncapabilities); + virQEMUCapsCachePtr virQEMUCapsCacheNew(const char *libDir, const char *cacheDir, uid_t uid, gid_t gid); -- 2.5.5

Now that we choose the GIC version based on hardware features when no <gic/> element has been provided, we need a way to fake the GIC capabilities of the host. Update the qemuxml2argv and qemuxml2xml tests to allow this. --- tests/qemuxml2argvtest.c | 77 ++++++++++++++++++----- tests/qemuxml2xmltest.c | 159 ++++++++++++++++++++++++++++------------------- 2 files changed, 159 insertions(+), 77 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e41444d..b081634 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -34,6 +34,13 @@ static const char *abs_top_srcdir; static virQEMUDriver driver; +enum { + GIC_NONE = 0, + GIC_V2, + GIC_V3, + GIC_BOTH, +}; + static unsigned char * fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED, size_t *value_size, @@ -452,6 +459,49 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy) static int +testPrepareExtraFlags(struct testInfo *info, + bool skipLegacyCPUs, + int gic) +{ + virGICCapability *gicCapabilities = NULL; + size_t ngicCapabilities = 0; + int ret = -1; + + if (!(info->extraFlags = virQEMUCapsNew())) + goto out; + + if (testAddCPUModels(info->extraFlags, skipLegacyCPUs) < 0) + goto out; + + if (VIR_ALLOC_N(gicCapabilities, 2) < 0) + goto out; + +# define IMPL_BOTH \ + VIR_GIC_IMPLEMENTATION_KERNEL|VIR_GIC_IMPLEMENTATION_EMULATED + + if (gic & GIC_V2) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_2; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + if (gic & GIC_V3) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_3; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + +# undef IMPL_BOTH + + virQEMUCapsSetGICCapabilities(info->extraFlags, + gicCapabilities, ngicCapabilities); + + ret = 0; + + out: + return ret; +} + +static int mymain(void) { int ret = 0; @@ -501,14 +551,12 @@ mymain(void) return EXIT_FAILURE; # define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, \ - parseFlags, ...) \ + parseFlags, gic, ...) \ do { \ static struct testInfo info = { \ name, NULL, migrateFrom, migrateFd, (flags), parseFlags \ }; \ - if (!(info.extraFlags = virQEMUCapsNew())) \ - return EXIT_FAILURE; \ - if (testAddCPUModels(info.extraFlags, skipLegacyCPUs) < 0) \ + if (testPrepareExtraFlags(&info, skipLegacyCPUs, gic) < 0) \ return EXIT_FAILURE; \ virQEMUCapsSetList(info.extraFlags, __VA_ARGS__, QEMU_CAPS_LAST);\ if (virtTestRun("QEMU XML-2-ARGV " name, \ @@ -518,23 +566,24 @@ mymain(void) } while (0) # define DO_TEST(name, ...) \ - DO_TEST_FULL(name, NULL, -1, 0, 0, __VA_ARGS__) + DO_TEST_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__) # define DO_TEST_FAILURE(name, ...) \ - DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_FAILURE, 0, __VA_ARGS__) + DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_FAILURE, \ + 0, GIC_NONE, __VA_ARGS__) # define DO_TEST_PARSE_ERROR(name, ...) \ DO_TEST_FULL(name, NULL, -1, \ FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \ - 0, __VA_ARGS__) + 0, GIC_NONE, __VA_ARGS__) # define DO_TEST_PARSE_FLAGS_ERROR(name, parseFlags, ...) \ DO_TEST_FULL(name, NULL, -1, \ FLAG_EXPECT_PARSE_ERROR | FLAG_EXPECT_FAILURE, \ - parseFlags, __VA_ARGS__) + parseFlags, GIC_NONE, __VA_ARGS__) # define DO_TEST_LINUX(name, ...) \ - DO_TEST_LINUX_FULL(name, NULL, -1, 0, 0, __VA_ARGS__) + DO_TEST_LINUX_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__) # ifdef __linux__ /* This is a macro that invokes test only on Linux. It's @@ -1236,12 +1285,12 @@ mymain(void) QEMU_CAPS_PCIDEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_PCI_ROMBAR); - DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, NONE); - DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, NONE); - DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, 0, NONE); - DO_TEST_FULL("migrate", "tcp:10.0.0.1:5000", -1, 0, 0, NONE); + DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, GIC_NONE, NONE); + DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE); + DO_TEST_FULL("restore-v2-fd", "fd:7", 7, 0, 0, GIC_NONE, NONE); + DO_TEST_FULL("migrate", "tcp:10.0.0.1:5000", -1, 0, 0, GIC_NONE, NONE); - DO_TEST_LINUX_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, + DO_TEST_LINUX_FULL("migrate-numa-unaligned", "stdio", 7, 0, 0, GIC_NONE, QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_RAM); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5a43fa9..9391a4e 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -28,6 +28,13 @@ enum { WHEN_BOTH = 3, }; +enum { + GIC_NONE = 0, + GIC_V2, + GIC_V3, + GIC_BOTH, +}; + struct testInfo { char *inName; char *outActiveName; @@ -201,8 +208,12 @@ testInfoFree(struct testInfo *info) static int testInfoSet(struct testInfo *info, const char *name, - int when) + int when, + int gic) { + virGICCapability *gicCapabilities = NULL; + size_t ngicCapabilities = 0; + if (!(info->qemuCaps = virQEMUCapsNew())) goto error; @@ -210,6 +221,28 @@ testInfoSet(struct testInfo *info, QEMU_CAPS_DEVICE, QEMU_CAPS_LAST); + if (VIR_ALLOC_N(gicCapabilities, 2) < 0) + goto error; + +# define IMPL_BOTH \ + VIR_GIC_IMPLEMENTATION_KERNEL|VIR_GIC_IMPLEMENTATION_EMULATED + + if (gic & GIC_V2) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_2; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + if (gic & GIC_V3) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_3; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + +# undef IMPL_BOTH + + virQEMUCapsSetGICCapabilities(info->qemuCaps, + gicCapabilities, ngicCapabilities); + if (qemuTestCapsCacheInsert(driver.qemuCapsCache, name, info->qemuCaps) < 0) goto error; @@ -271,9 +304,9 @@ mymain(void) /* TODO: test with format probing disabled too */ driver.config->allowDiskFormatProbing = true; -# define DO_TEST_FULL(name, when, ...) \ +# define DO_TEST_FULL(name, when, gic, ...) \ do { \ - if (testInfoSet(&info, name, when) < 0) { \ + if (testInfoSet(&info, name, when, gic) < 0) { \ VIR_TEST_DEBUG("Failed to generate test data for '%s'", name); \ return -1; \ } \ @@ -300,7 +333,7 @@ mymain(void) # define NONE QEMU_CAPS_LAST # define DO_TEST(name) \ - DO_TEST_FULL(name, WHEN_BOTH, NONE) + DO_TEST_FULL(name, WHEN_BOTH, GIC_NONE, NONE) @@ -398,36 +431,36 @@ mymain(void) DO_TEST("disk-drive-network-rbd-ipv6"); DO_TEST("disk-drive-network-rbd-ceph-env"); DO_TEST("disk-drive-network-sheepdog"); - DO_TEST_FULL("disk-scsi-device", WHEN_ACTIVE, + DO_TEST_FULL("disk-scsi-device", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_LSI); DO_TEST("disk-scsi-vscsi"); - DO_TEST_FULL("disk-scsi-virtio-scsi", WHEN_ACTIVE, + DO_TEST_FULL("disk-scsi-virtio-scsi", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_FULL("disk-virtio-scsi-num_queues", WHEN_ACTIVE, + DO_TEST_FULL("disk-virtio-scsi-num_queues", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_FULL("disk-virtio-scsi-cmd_per_lun", WHEN_ACTIVE, + DO_TEST_FULL("disk-virtio-scsi-cmd_per_lun", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_FULL("disk-virtio-scsi-max_sectors", WHEN_ACTIVE, + DO_TEST_FULL("disk-virtio-scsi-max_sectors", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_FULL("disk-virtio-scsi-ioeventfd", WHEN_ACTIVE, + DO_TEST_FULL("disk-virtio-scsi-ioeventfd", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_FULL("disk-scsi-megasas", WHEN_ACTIVE, + DO_TEST_FULL("disk-scsi-megasas", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_MEGASAS); - DO_TEST_FULL("disk-scsi-mptsas1068", WHEN_ACTIVE, + DO_TEST_FULL("disk-scsi-mptsas1068", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_MPTSAS1068, QEMU_CAPS_SCSI_DISK_WWN); DO_TEST("disk-mirror-old"); - DO_TEST_FULL("disk-mirror", WHEN_ACTIVE, NONE); - DO_TEST_FULL("disk-mirror", WHEN_INACTIVE, NONE); - DO_TEST_FULL("disk-active-commit", WHEN_ACTIVE, NONE); + DO_TEST_FULL("disk-mirror", WHEN_ACTIVE, GIC_NONE, NONE); + DO_TEST_FULL("disk-mirror", WHEN_INACTIVE, GIC_NONE, NONE); + DO_TEST_FULL("disk-active-commit", WHEN_ACTIVE, GIC_NONE, NONE); DO_TEST("graphics-listen-network"); DO_TEST("graphics-vnc"); DO_TEST("graphics-vnc-websocket"); @@ -501,7 +534,7 @@ mymain(void) DO_TEST("cputune-iothreadsched"); DO_TEST("cputune-iothreadsched-zeropriority"); DO_TEST("cputune-numatune"); - DO_TEST_FULL("vcpu-placement-static", WHEN_ACTIVE, + DO_TEST_FULL("vcpu-placement-static", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE); DO_TEST("smp"); @@ -510,12 +543,12 @@ mymain(void) DO_TEST("iothreads-ids-partial"); DO_TEST("cputune-iothreads"); DO_TEST("iothreads-disk"); - DO_TEST_FULL("iothreads-disk-virtio-ccw", WHEN_ACTIVE, + DO_TEST_FULL("iothreads-disk-virtio-ccw", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FULL("iothreads-virtio-scsi-pci", WHEN_ACTIVE, + DO_TEST_FULL("iothreads-virtio-scsi-pci", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_FULL("iothreads-virtio-scsi-ccw", WHEN_ACTIVE, + DO_TEST_FULL("iothreads-virtio-scsi-ccw", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); @@ -532,24 +565,24 @@ mymain(void) DO_TEST("blkdeviotune"); DO_TEST("controller-usb-order"); - DO_TEST_FULL("seclabel-dynamic-baselabel", WHEN_INACTIVE, NONE); - DO_TEST_FULL("seclabel-dynamic-override", WHEN_INACTIVE, NONE); - DO_TEST_FULL("seclabel-dynamic-labelskip", WHEN_INACTIVE, NONE); - DO_TEST_FULL("seclabel-dynamic-relabel", WHEN_INACTIVE, NONE); + DO_TEST_FULL("seclabel-dynamic-baselabel", WHEN_INACTIVE, GIC_NONE, NONE); + DO_TEST_FULL("seclabel-dynamic-override", WHEN_INACTIVE, GIC_NONE, NONE); + DO_TEST_FULL("seclabel-dynamic-labelskip", WHEN_INACTIVE, GIC_NONE, NONE); + DO_TEST_FULL("seclabel-dynamic-relabel", WHEN_INACTIVE, GIC_NONE, NONE); DO_TEST("seclabel-static"); - DO_TEST_FULL("seclabel-static-labelskip", WHEN_ACTIVE, NONE); + DO_TEST_FULL("seclabel-static-labelskip", WHEN_ACTIVE, GIC_NONE, NONE); DO_TEST("seclabel-none"); DO_TEST("seclabel-dac-none"); DO_TEST("seclabel-dynamic-none"); DO_TEST("seclabel-device-multiple"); - DO_TEST_FULL("seclabel-dynamic-none-relabel", WHEN_INACTIVE, NONE); + DO_TEST_FULL("seclabel-dynamic-none-relabel", WHEN_INACTIVE, GIC_NONE, NONE); DO_TEST("numad-static-vcpu-no-numatune"); - DO_TEST_FULL("disk-scsi-lun-passthrough-sgio", WHEN_ACTIVE, + DO_TEST_FULL("disk-scsi-lun-passthrough-sgio", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN); - DO_TEST_FULL("disk-scsi-disk-vpd", WHEN_ACTIVE, + DO_TEST_FULL("disk-scsi-disk-vpd", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_CD, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_DISK_WWN); @@ -569,7 +602,7 @@ mymain(void) DO_TEST("balloon-device-period"); DO_TEST("channel-virtio-auto"); DO_TEST("console-compat-auto"); - DO_TEST_FULL("disk-scsi-device-auto", WHEN_ACTIVE, + DO_TEST_FULL("disk-scsi-device-auto", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_SCSI_LSI); DO_TEST("console-virtio"); @@ -586,37 +619,37 @@ mymain(void) DO_TEST("metadata"); DO_TEST("metadata-duplicate"); - DO_TEST_FULL("pci-bridge", WHEN_ACTIVE, + DO_TEST_FULL("pci-bridge", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE); - DO_TEST_FULL("pci-bridge-many-disks", WHEN_ACTIVE, + DO_TEST_FULL("pci-bridge-many-disks", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE); - DO_TEST_FULL("pci-autoadd-addr", WHEN_ACTIVE, + DO_TEST_FULL("pci-autoadd-addr", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE); - DO_TEST_FULL("pci-autoadd-idx", WHEN_ACTIVE, + DO_TEST_FULL("pci-autoadd-idx", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE); - DO_TEST_FULL("q35", WHEN_ACTIVE, + DO_TEST_FULL("q35", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("q35-usb2", WHEN_ACTIVE, + DO_TEST_FULL("q35-usb2", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("q35-usb2-multi", WHEN_ACTIVE, + DO_TEST_FULL("q35-usb2-multi", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("q35-usb2-reorder", WHEN_ACTIVE, + DO_TEST_FULL("q35-usb2-reorder", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, @@ -624,38 +657,38 @@ mymain(void) QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("pcie-root", WHEN_ACTIVE, + DO_TEST_FULL("pcie-root", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("pcie-root-port", WHEN_ACTIVE, + DO_TEST_FULL("pcie-root-port", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("pcie-switch-upstream-port", WHEN_ACTIVE, + DO_TEST_FULL("pcie-switch-upstream-port", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("pcie-switch-downstream-port", WHEN_ACTIVE, + DO_TEST_FULL("pcie-switch-downstream-port", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); - DO_TEST_FULL("pci-expander-bus", WHEN_ACTIVE, + DO_TEST_FULL("pci-expander-bus", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PXB); - DO_TEST_FULL("pcie-expander-bus", WHEN_ACTIVE, + DO_TEST_FULL("pcie-expander-bus", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420, @@ -664,59 +697,59 @@ mymain(void) QEMU_CAPS_DEVICE_PXB_PCIE); - DO_TEST_FULL("hostdev-scsi-lsi", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-lsi", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-virtio-scsi", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-virtio-scsi", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-readonly", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-readonly", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-shareable", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-shareable", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-sgio", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-sgio", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-rawio", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-rawio", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-autogen-address", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-autogen-address", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-large-unit", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-large-unit", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-lsi-iscsi", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-lsi-iscsi", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-lsi-iscsi-auth", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-lsi-iscsi-auth", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-virtio-iscsi", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-virtio-iscsi", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("hostdev-scsi-virtio-iscsi-auth", WHEN_ACTIVE, + DO_TEST_FULL("hostdev-scsi-virtio-iscsi-auth", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); - DO_TEST_FULL("s390-defaultconsole", WHEN_ACTIVE, + DO_TEST_FULL("s390-defaultconsole", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FULL("s390-panic", WHEN_BOTH, + DO_TEST_FULL("s390-panic", WHEN_BOTH, GIC_NONE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FULL("s390-panic-missing", WHEN_BOTH, + DO_TEST_FULL("s390-panic-missing", WHEN_BOTH, GIC_NONE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); - DO_TEST_FULL("s390-panic-no-address", WHEN_BOTH, + DO_TEST_FULL("s390-panic-no-address", WHEN_BOTH, GIC_NONE, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); DO_TEST("pcihole64"); DO_TEST("pcihole64-gib"); DO_TEST("pcihole64-none"); - DO_TEST_FULL("pcihole64-q35", WHEN_ACTIVE, + DO_TEST_FULL("pcihole64-q35", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, @@ -754,17 +787,17 @@ mymain(void) DO_TEST("smbios"); DO_TEST("smbios-multiple-type2"); - DO_TEST_FULL("aarch64-aavmf-virtio-mmio", WHEN_ACTIVE, + DO_TEST_FULL("aarch64-aavmf-virtio-mmio", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM); - DO_TEST_FULL("aarch64-virtio-pci-default", WHEN_ACTIVE, + DO_TEST_FULL("aarch64-virtio-pci-default", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST_FULL("aarch64-virtio-pci-manual-addresses", WHEN_ACTIVE, + DO_TEST_FULL("aarch64-virtio-pci-manual-addresses", WHEN_ACTIVE, GIC_NONE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM, @@ -790,7 +823,7 @@ mymain(void) cfg = virQEMUDriverGetConfig(&driver); cfg->vncAutoUnixSocket = true; - DO_TEST_FULL("graphics-vnc-autosocket", WHEN_INACTIVE, NONE); + DO_TEST_FULL("graphics-vnc-autosocket", WHEN_INACTIVE, GIC_NONE, NONE); cfg->vncAutoUnixSocket = false; virObjectUnref(cfg); -- 2.5.5

On 05/10/2016 08:46 AM, Andrea Bolognani wrote:
Now that we choose the GIC version based on hardware features when no <gic/> element has been provided, we need a way to fake the GIC capabilities of the host.
Update the qemuxml2argv and qemuxml2xml tests to allow this. --- tests/qemuxml2argvtest.c | 77 ++++++++++++++++++----- tests/qemuxml2xmltest.c | 159 ++++++++++++++++++++++++++++------------------- 2 files changed, 159 insertions(+), 77 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e41444d..b081634 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -34,6 +34,13 @@ static const char *abs_top_srcdir; static virQEMUDriver driver;
+enum { + GIC_NONE = 0, + GIC_V2, + GIC_V3, + GIC_BOTH, +}; + static unsigned char * fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED, size_t *value_size, @@ -452,6 +459,49 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy)
static int +testPrepareExtraFlags(struct testInfo *info, + bool skipLegacyCPUs, + int gic) +{ + virGICCapability *gicCapabilities = NULL; + size_t ngicCapabilities = 0; + int ret = -1; + + if (!(info->extraFlags = virQEMUCapsNew())) + goto out; + + if (testAddCPUModels(info->extraFlags, skipLegacyCPUs) < 0) + goto out; + + if (VIR_ALLOC_N(gicCapabilities, 2) < 0) + goto out; + +# define IMPL_BOTH \ + VIR_GIC_IMPLEMENTATION_KERNEL|VIR_GIC_IMPLEMENTATION_EMULATED + + if (gic & GIC_V2) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_2; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + if (gic & GIC_V3) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_3; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + +# undef IMPL_BOTH + + virQEMUCapsSetGICCapabilities(info->extraFlags, + gicCapabilities, ngicCapabilities); + + ret = 0; + + out: + return ret; +}
Can this logic be shared in a testutilsqemu.c function, rather than duplicated across both test files? - Cole

On Tue, 2016-05-10 at 18:45 -0400, Cole Robinson wrote:
On 05/10/2016 08:46 AM, Andrea Bolognani wrote:
Now that we choose the GIC version based on hardware features when no <gic/> element has been provided, we need a way to fake the GIC capabilities of the host.
Update the qemuxml2argv and qemuxml2xml tests to allow this. --- tests/qemuxml2argvtest.c | 77 ++++++++++++++++++----- tests/qemuxml2xmltest.c | 159 ++++++++++++++++++++++++++++------------------- 2 files changed, 159 insertions(+), 77 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e41444d..b081634 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -34,6 +34,13 @@ static const char *abs_top_srcdir; static virQEMUDriver driver; +enum { + GIC_NONE = 0, + GIC_V2, + GIC_V3, + GIC_BOTH, +}; + static unsigned char * fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED, size_t *value_size, @@ -452,6 +459,49 @@ testAddCPUModels(virQEMUCapsPtr caps, bool skipLegacy) static int +testPrepareExtraFlags(struct testInfo *info, + bool skipLegacyCPUs, + int gic) +{ + virGICCapability *gicCapabilities = NULL; + size_t ngicCapabilities = 0; + int ret = -1; + + if (!(info->extraFlags = virQEMUCapsNew())) + goto out; + + if (testAddCPUModels(info->extraFlags, skipLegacyCPUs) < 0) + goto out; + + if (VIR_ALLOC_N(gicCapabilities, 2) < 0) + goto out; + +# define IMPL_BOTH \ + VIR_GIC_IMPLEMENTATION_KERNEL|VIR_GIC_IMPLEMENTATION_EMULATED + + if (gic & GIC_V2) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_2; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + if (gic & GIC_V3) { + gicCapabilities[ngicCapabilities].version = VIR_GIC_VERSION_3; + gicCapabilities[ngicCapabilities].implementation = IMPL_BOTH; + ngicCapabilities++; + } + +# undef IMPL_BOTH + + virQEMUCapsSetGICCapabilities(info->extraFlags, + gicCapabilities, ngicCapabilities); + + ret = 0; + + out: + return ret; +}
Can this logic be shared in a testutilsqemu.c function, rather than duplicated across both test files?
Good idea, I'll look into it. -- Andrea Bolognani Software Engineer - Virtualization Team

The only case where the hardware capabilities influence the result is when no <gic/> element was provided. The test programs now ensure both that the correct GIC version is picked in that case, and that hardware capabilities are not taken into account when the user has already picked a GIC version. --- .../qemuxml2argv-aarch64-gic-none-both.args | 1 + .../qemuxml2argv-aarch64-gic-none-both.xml | 1 + .../qemuxml2argv-aarch64-gic-none-v2.args | 1 + .../qemuxml2argv-aarch64-gic-none-v2.xml | 1 + .../qemuxml2argv-aarch64-gic-none-v3.args | 1 + .../qemuxml2argv-aarch64-gic-none-v3.xml | 1 + tests/qemuxml2argvtest.c | 76 ++++++++++++++++++---- .../qemuxml2xmlout-aarch64-gic-none-both.xml | 1 + .../qemuxml2xmlout-aarch64-gic-none-v2.xml | 1 + .../qemuxml2xmlout-aarch64-gic-none-v3.xml | 1 + tests/qemuxml2xmltest.c | 25 +++++-- 11 files changed, 91 insertions(+), 19 deletions(-) create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.args create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.args create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.args create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-both.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v2.xml create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v3.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.args new file mode 120000 index 0000000..5b20f61 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.args @@ -0,0 +1 @@ +qemuxml2argv-aarch64-gic-v3.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.xml new file mode 120000 index 0000000..d859f53 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-both.xml @@ -0,0 +1 @@ +qemuxml2argv-aarch64-gic-none.xml \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.args new file mode 120000 index 0000000..3234039 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.args @@ -0,0 +1 @@ +qemuxml2argv-aarch64-gic-v2.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.xml new file mode 120000 index 0000000..d859f53 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v2.xml @@ -0,0 +1 @@ +qemuxml2argv-aarch64-gic-none.xml \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.args new file mode 120000 index 0000000..5b20f61 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.args @@ -0,0 +1 @@ +qemuxml2argv-aarch64-gic-v3.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.xml new file mode 120000 index 0000000..88c660c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-none-v3.xml @@ -0,0 +1 @@ +qemuxml2argv-aarch64-gic-none-v2.xml \ No newline at end of file diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b081634..fa62838 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -568,6 +568,9 @@ mymain(void) # define DO_TEST(name, ...) \ DO_TEST_FULL(name, NULL, -1, 0, 0, GIC_NONE, __VA_ARGS__) +# define DO_TEST_GIC(name, gic, ...) \ + DO_TEST_FULL(name, NULL, -1, 0, 0, gic, __VA_ARGS__) + # define DO_TEST_FAILURE(name, ...) \ DO_TEST_FULL(name, NULL, -1, FLAG_EXPECT_FAILURE, \ 0, GIC_NONE, __VA_ARGS__) @@ -1759,38 +1762,83 @@ mymain(void) DO_TEST("aarch64-cpu-passthrough", QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_CPU_HOST, QEMU_CAPS_KVM); - DO_TEST("aarch64-gic-none", + DO_TEST_GIC("aarch64-gic-none", GIC_NONE, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST); + DO_TEST_GIC("aarch64-gic-none", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST("aarch64-gic-none", - QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST); - DO_TEST("aarch64-gic-default", + DO_TEST_GIC("aarch64-gic-none-v2", GIC_V2, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-none-v3", GIC_V3, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST("aarch64-gic-default", + DO_TEST_GIC("aarch64-gic-none-both", GIC_BOTH, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-default", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST); - DO_TEST("aarch64-gic-v2", + DO_TEST_GIC("aarch64-gic-default", GIC_NONE, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-default", GIC_V2, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST("aarch64-gic-v2", + DO_TEST_GIC("aarch64-gic-default", GIC_V3, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-default", GIC_BOTH, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-v2", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST); - DO_TEST("aarch64-gic-v3", + DO_TEST_GIC("aarch64-gic-v2", GIC_NONE, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-v2", GIC_V2, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-v2", GIC_V3, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST_FAILURE("aarch64-gic-v3", + DO_TEST_GIC("aarch64-gic-v2", GIC_BOTH, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_FAILURE("aarch64-gic-v3", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST); - DO_TEST("aarch64-gic-host", + DO_TEST_GIC("aarch64-gic-v3", GIC_NONE, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-v3", GIC_V2, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-v3", GIC_V3, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-v3", GIC_BOTH, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST_FAILURE("aarch64-gic-host", + DO_TEST_FAILURE("aarch64-gic-host", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST); - DO_TEST_PARSE_ERROR("aarch64-gic-invalid", + DO_TEST_GIC("aarch64-gic-host", GIC_NONE, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-host", GIC_V2, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-host", GIC_V3, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_GIC("aarch64-gic-host", GIC_BOTH, + QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, + QEMU_CAPS_MACH_VIRT_GIC_VERSION); + DO_TEST_PARSE_ERROR("aarch64-gic-invalid", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST_FAILURE("aarch64-gic-not-virt", + DO_TEST_FAILURE("aarch64-gic-not-virt", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); - DO_TEST_FAILURE("aarch64-gic-not-arm", + DO_TEST_FAILURE("aarch64-gic-not-arm", GIC_NONE, QEMU_CAPS_KVM, QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_CPU_HOST, QEMU_CAPS_MACH_VIRT_GIC_VERSION); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-both.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-both.xml new file mode 120000 index 0000000..f586fa1 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-both.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v2.xml new file mode 120000 index 0000000..80a01c2 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v2.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml \ No newline at end of file diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v3.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v3.xml new file mode 120000 index 0000000..f586fa1 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-gic-none-v3.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 9391a4e..4dc11fe 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -804,11 +804,26 @@ mymain(void) QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI); - DO_TEST("aarch64-gic-none"); - DO_TEST("aarch64-gic-default"); - DO_TEST("aarch64-gic-v2"); - DO_TEST("aarch64-gic-v3"); - DO_TEST("aarch64-gic-host"); + DO_TEST_FULL("aarch64-gic-none", WHEN_BOTH, GIC_NONE, NONE); + DO_TEST_FULL("aarch64-gic-none-v2", WHEN_BOTH, GIC_V2, NONE); + DO_TEST_FULL("aarch64-gic-none-v3", WHEN_BOTH, GIC_V3, NONE); + DO_TEST_FULL("aarch64-gic-none-both", WHEN_BOTH, GIC_BOTH, NONE); + DO_TEST_FULL("aarch64-gic-default", WHEN_BOTH, GIC_NONE, NONE); + DO_TEST_FULL("aarch64-gic-default", WHEN_BOTH, GIC_V2, NONE); + DO_TEST_FULL("aarch64-gic-default", WHEN_BOTH, GIC_V3, NONE); + DO_TEST_FULL("aarch64-gic-default", WHEN_BOTH, GIC_BOTH, NONE); + DO_TEST_FULL("aarch64-gic-v2", WHEN_BOTH, GIC_NONE, NONE); + DO_TEST_FULL("aarch64-gic-v2", WHEN_BOTH, GIC_V2, NONE); + DO_TEST_FULL("aarch64-gic-v2", WHEN_BOTH, GIC_V3, NONE); + DO_TEST_FULL("aarch64-gic-v2", WHEN_BOTH, GIC_BOTH, NONE); + DO_TEST_FULL("aarch64-gic-v3", WHEN_BOTH, GIC_NONE, NONE); + DO_TEST_FULL("aarch64-gic-v3", WHEN_BOTH, GIC_V2, NONE); + DO_TEST_FULL("aarch64-gic-v3", WHEN_BOTH, GIC_V3, NONE); + DO_TEST_FULL("aarch64-gic-v3", WHEN_BOTH, GIC_BOTH, NONE); + DO_TEST_FULL("aarch64-gic-host", WHEN_BOTH, GIC_NONE, NONE); + DO_TEST_FULL("aarch64-gic-host", WHEN_BOTH, GIC_V2, NONE); + DO_TEST_FULL("aarch64-gic-host", WHEN_BOTH, GIC_V3, NONE); + DO_TEST_FULL("aarch64-gic-host", WHEN_BOTH, GIC_BOTH, NONE); DO_TEST("memory-hotplug"); DO_TEST("memory-hotplug-nonuma"); -- 2.5.5
participants (3)
-
Andrea Bolognani
-
Cole Robinson
-
Michal Privoznik