diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index df48be4994..e76036fe58 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -33,6 +33,15 @@ VIR_ENUM_IMPL(virDomainCapsCPUUsable, "unknown", "yes", "no", ); + +VIR_ENUM_DECL(virDomainCapsFeature); +VIR_ENUM_IMPL(virDomainCapsFeature, + VIR_DOMAIN_CAPS_FEATURE_LAST, + "iothreads", + "vmcoreinfo", + "genid", +); + static virClassPtr virDomainCapsClass; static virClassPtr virDomainCapsCPUModelsClass; @@ -317,9 +326,10 @@ virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum) void virDomainCapsFeaturesInitUnsupported(virDomainCapsPtr caps) { - caps->iothreads = VIR_TRISTATE_BOOL_NO; - caps->vmcoreinfo = VIR_TRISTATE_BOOL_NO; - caps->genid = VIR_TRISTATE_BOOL_NO; + size_t i; + + for (i = 0; i < VIR_DOMAIN_CAPS_FEATURE_LAST; i++) + caps->features[i] = VIR_TRISTATE_BOOL_NO; } @@ -612,10 +622,19 @@ virDomainCapsFormatFeatures(const virDomainCaps *caps, virBufferPtr buf) { g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); + size_t i; virDomainCapsFeatureGICFormat(&childBuf, &caps->gic); - qemuDomainCapsFeatureFormatSimple(&childBuf, "vmcoreinfo", caps->vmcoreinfo); - qemuDomainCapsFeatureFormatSimple(&childBuf, "genid", caps->genid); + + for (i = 0; i < VIR_DOMAIN_CAPS_FEATURE_LAST; i++) { + if (i == VIR_DOMAIN_CAPS_FEATURE_IOTHREADS) + continue; + + qemuDomainCapsFeatureFormatSimple(&childBuf, + virDomainCapsFeatureTypeToString(i), + caps->features[i]); + } + virDomainCapsFeatureSEVFormat(&childBuf, caps->sev); virXMLFormatElement(buf, "features", NULL, &childBuf); @@ -641,7 +660,8 @@ virDomainCapsFormat(const virDomainCaps *caps) if (caps->maxvcpus) virBufferAsprintf(&buf, "\n", caps->maxvcpus); - qemuDomainCapsFeatureFormatSimple(&buf, "iothreads", caps->iothreads); + qemuDomainCapsFeatureFormatSimple(&buf, "iothreads", + caps->features[VIR_DOMAIN_CAPS_FEATURE_IOTHREADS]); virDomainCapsOSFormat(&buf, &caps->os); virDomainCapsCPUFormat(&buf, &caps->cpu); diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 03192b6f40..a9bf4a8d3f 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -156,6 +156,14 @@ struct _virSEVCapability { unsigned int reduced_phys_bits; }; +typedef enum { + VIR_DOMAIN_CAPS_FEATURE_IOTHREADS = 0, + VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO, + VIR_DOMAIN_CAPS_FEATURE_GENID, + + VIR_DOMAIN_CAPS_FEATURE_LAST +} virDomainCapsFeature; + struct _virDomainCaps { virObjectLockable parent; @@ -166,7 +174,6 @@ struct _virDomainCaps { /* Some machine specific info */ int maxvcpus; - virTristateBool iothreads; /* Whether I/O threads are supported or not. */ virDomainCapsOS os; virDomainCapsCPU cpu; @@ -178,10 +185,10 @@ struct _virDomainCaps { /* add new domain devices here */ virDomainCapsFeatureGIC gic; - virTristateBool vmcoreinfo; - virTristateBool genid; virSEVCapabilityPtr sev; /* add new domain features here */ + + virTristateBool features[VIR_DOMAIN_CAPS_FEATURE_LAST]; }; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainCaps, virObjectUnref); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8838359c04..dc86f28b12 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5285,7 +5285,7 @@ static void virQEMUCapsFillDomainIOThreadCaps(virQEMUCapsPtr qemuCaps, virDomainCapsPtr domCaps) { - domCaps->iothreads = virTristateBoolFromBool( + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_IOTHREADS] = virTristateBoolFromBool( virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)); } @@ -5584,10 +5584,10 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps, domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus); } - domCaps->vmcoreinfo = virTristateBoolFromBool( + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO] = virTristateBoolFromBool( virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO)); - domCaps->genid = virTristateBoolFromBool( + domCaps->features[VIR_DOMAIN_CAPS_FEATURE_GENID] = virTristateBoolFromBool( virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)); if (virQEMUCapsFillDomainOSCaps(os,