Adding availability of s390-pv in domain capabilities and adjust tests. Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx> --- docs/schemas/domaincaps.rng | 9 +++++++++ src/conf/domain_capabilities.c | 1 + src/conf/domain_capabilities.h | 1 + src/qemu/qemu_capabilities.c | 16 ++++++++++++++++ tests/domaincapsdata/qemu_2.11.0.s390x.xml | 1 + tests/domaincapsdata/qemu_2.12.0.s390x.xml | 1 + tests/domaincapsdata/qemu_3.0.0.s390x.xml | 1 + tests/domaincapsdata/qemu_4.0.0.s390x.xml | 1 + tests/domaincapsdata/qemu_4.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_5.2.0.s390x.xml | 1 + tests/domaincapsdata/qemu_6.0.0.s390x.xml | 1 + tests/domaincapsmock.c | 17 +++++++++++++++++ 12 files changed, 51 insertions(+) diff --git a/docs/schemas/domaincaps.rng b/docs/schemas/domaincaps.rng index fc668e0c78..d7ee60dd16 100644 --- a/docs/schemas/domaincaps.rng +++ b/docs/schemas/domaincaps.rng @@ -247,6 +247,9 @@ <optional> <ref name="backup"/> </optional> + <optional> + <ref name="s390-pv"/> + </optional> <optional> <ref name="sev"/> </optional> @@ -284,6 +287,12 @@ </element> </define> + <define name="s390-pv"> + <element name="s390-pv"> + <ref name="supported"/> + </element> + </define> + <define name="sev"> <element name="sev"> <ref name="supported"/> diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index cb90ae0176..83d3320980 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -42,6 +42,7 @@ VIR_ENUM_IMPL(virDomainCapsFeature, "genid", "backingStoreInput", "backup", + "s390-pv", ); static virClass *virDomainCapsClass; diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index b6433b20c9..34b9b8a693 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -179,6 +179,7 @@ typedef enum { VIR_DOMAIN_CAPS_FEATURE_GENID, VIR_DOMAIN_CAPS_FEATURE_BACKING_STORE_INPUT, VIR_DOMAIN_CAPS_FEATURE_BACKUP, + VIR_DOMAIN_CAPS_FEATURE_S390_PV, VIR_DOMAIN_CAPS_FEATURE_LAST } virDomainCapsFeature; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 69c4f1a592..0d93cc2052 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6315,6 +6315,21 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCaps *qemuCaps, } +static void +virQEMUCapsFillDomainFeatureS390PVCaps(virQEMUCaps *qemuCaps, + virDomainCaps *domCaps) +{ + if (ARCH_IS_S390(qemuCaps->arch)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_S390_PV_GUEST) && + virQEMUCapsGetKVMSupportsSecureGuest(qemuCaps)) + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_S390_PV] = VIR_TRISTATE_BOOL_YES; + else + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_S390_PV] = VIR_TRISTATE_BOOL_NO; + } +} + + int virQEMUCapsFillDomainCaps(virQEMUCaps *qemuCaps, virArch hostarch, @@ -6361,6 +6376,7 @@ virQEMUCapsFillDomainCaps(virQEMUCaps *qemuCaps, virQEMUCapsFillDomainDeviceFSCaps(qemuCaps, filesystem); virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps); virQEMUCapsFillDomainFeatureSEVCaps(qemuCaps, domCaps); + virQEMUCapsFillDomainFeatureS390PVCaps(qemuCaps, domCaps); return 0; } diff --git a/tests/domaincapsdata/qemu_2.11.0.s390x.xml b/tests/domaincapsdata/qemu_2.11.0.s390x.xml index cd3ab38bc4..be2f0c6c66 100644 --- a/tests/domaincapsdata/qemu_2.11.0.s390x.xml +++ b/tests/domaincapsdata/qemu_2.11.0.s390x.xml @@ -206,6 +206,7 @@ <genid supported='no'/> <backingStoreInput supported='no'/> <backup supported='no'/> + <s390-pv supported='no'/> <sev supported='no'/> </features> </domainCapabilities> diff --git a/tests/domaincapsdata/qemu_2.12.0.s390x.xml b/tests/domaincapsdata/qemu_2.12.0.s390x.xml index 418db98294..55da03d928 100644 --- a/tests/domaincapsdata/qemu_2.12.0.s390x.xml +++ b/tests/domaincapsdata/qemu_2.12.0.s390x.xml @@ -205,6 +205,7 @@ <genid supported='no'/> <backingStoreInput supported='no'/> <backup supported='no'/> + <s390-pv supported='no'/> <sev supported='no'/> </features> </domainCapabilities> diff --git a/tests/domaincapsdata/qemu_3.0.0.s390x.xml b/tests/domaincapsdata/qemu_3.0.0.s390x.xml index d4443bde20..3440c4d936 100644 --- a/tests/domaincapsdata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsdata/qemu_3.0.0.s390x.xml @@ -212,6 +212,7 @@ <genid supported='no'/> <backingStoreInput supported='no'/> <backup supported='no'/> + <s390-pv supported='no'/> <sev supported='no'/> </features> </domainCapabilities> diff --git a/tests/domaincapsdata/qemu_4.0.0.s390x.xml b/tests/domaincapsdata/qemu_4.0.0.s390x.xml index e0ff109ead..1d3b5465d1 100644 --- a/tests/domaincapsdata/qemu_4.0.0.s390x.xml +++ b/tests/domaincapsdata/qemu_4.0.0.s390x.xml @@ -222,6 +222,7 @@ <genid supported='no'/> <backingStoreInput supported='no'/> <backup supported='no'/> + <s390-pv supported='no'/> <sev supported='no'/> </features> </domainCapabilities> diff --git a/tests/domaincapsdata/qemu_4.2.0.s390x.xml b/tests/domaincapsdata/qemu_4.2.0.s390x.xml index a610c417f7..1719cc49a8 100644 --- a/tests/domaincapsdata/qemu_4.2.0.s390x.xml +++ b/tests/domaincapsdata/qemu_4.2.0.s390x.xml @@ -237,6 +237,7 @@ <genid supported='no'/> <backingStoreInput supported='yes'/> <backup supported='no'/> + <s390-pv supported='no'/> <sev supported='no'/> </features> </domainCapabilities> diff --git a/tests/domaincapsdata/qemu_5.2.0.s390x.xml b/tests/domaincapsdata/qemu_5.2.0.s390x.xml index 43905a6a85..876cb8b2f8 100644 --- a/tests/domaincapsdata/qemu_5.2.0.s390x.xml +++ b/tests/domaincapsdata/qemu_5.2.0.s390x.xml @@ -239,6 +239,7 @@ <genid supported='no'/> <backingStoreInput supported='yes'/> <backup supported='no'/> + <s390-pv supported='no'/> <sev supported='no'/> </features> </domainCapabilities> diff --git a/tests/domaincapsdata/qemu_6.0.0.s390x.xml b/tests/domaincapsdata/qemu_6.0.0.s390x.xml index d384f0859b..5f2278b57e 100644 --- a/tests/domaincapsdata/qemu_6.0.0.s390x.xml +++ b/tests/domaincapsdata/qemu_6.0.0.s390x.xml @@ -240,6 +240,7 @@ <genid supported='no'/> <backingStoreInput supported='yes'/> <backup supported='no'/> + <s390-pv supported='yes'/> <sev supported='no'/> </features> </domainCapabilities> diff --git a/tests/domaincapsmock.c b/tests/domaincapsmock.c index b03f75199b..7b02c0e890 100644 --- a/tests/domaincapsmock.c +++ b/tests/domaincapsmock.c @@ -17,6 +17,8 @@ #include <config.h> #include "virhostcpu.h" +#include "virmock.h" +#include "qemu/qemu_capabilities.h" int virHostCPUGetKVMMaxVCPUs(void) @@ -29,3 +31,18 @@ virHostCPUGetMicrocodeVersion(virArch hostArch G_GNUC_UNUSED) { return 0; } + +static bool (*real_virQEMUCapsGetKVMSupportsSecureGuest)(virQEMUCaps *qemuCaps); + +bool +virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuCaps) +{ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_S390_PV_GUEST)) + return true; + + if (!real_virQEMUCapsGetKVMSupportsSecureGuest) + VIR_MOCK_REAL_INIT(virQEMUCapsGetKVMSupportsSecureGuest); + + return real_virQEMUCapsGetKVMSupportsSecureGuest(qemuCaps); +} -- 2.31.1