conf,qemu: implement RISC-V 'aia' virt domain feature

This feature is implemented as a string that can range from "none",
"aplic" and "aplic-imsic".

If the feature isn't present in the domain XML the hypervisor default
will be used. For QEMU, at least up to 9.2, the default is "none".

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2024-10-23 17:40:58 -03:00
parent 34d7f53d1b
commit 817eabd0cc
6 changed files with 92 additions and 0 deletions

View File

@ -2043,6 +2043,7 @@ Hypervisors may allow certain CPU / machine features to be toggled on/off.
<async-teardown enabled='yes'/>
<ras state='on'/>
<ps2 state='on'/>
<aia value='aplic-imsic'/>
</features>
...
@ -2290,6 +2291,13 @@ are:
disable the emulation of a PS/2 controller used by ``ps2`` bus input devices.
If the attribute is not defined, the hypervisor default will be used.
:since:`Since 10.7.0` (QEMU only)
``aia``
Configure aia (Advanced Interrupt Architecture) for RISC-V 'virt'
guests. Possible values for the ``value`` attribute are ``aplic`` (one
emulated APLIC device present per socket), ``aplic-imsic`` (one APLIC and
one IMSIC device present per core), or ``none`` (no support for AIA).
If the attribute is not defined, the hypervisor default
will be used. :since:`Since 11.1.0` (QEMU/KVM and RISC-V guests only)
Time keeping
------------

View File

@ -186,6 +186,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"async-teardown",
"ras",
"ps2",
"aia",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@ -1536,6 +1537,14 @@ VIR_ENUM_IMPL(virDomainPstoreBackend,
"acpi-erst",
);
VIR_ENUM_IMPL(virDomainAIA,
VIR_DOMAIN_AIA_LAST,
"default",
"none",
"aplic",
"aplic-imsic",
);
typedef enum {
VIR_DOMAIN_NET_VHOSTUSER_MODE_NONE,
VIR_DOMAIN_NET_VHOSTUSER_MODE_CLIENT,
@ -17171,6 +17180,18 @@ virDomainFeaturesDefParse(virDomainDef *def,
break;
}
case VIR_DOMAIN_FEATURE_AIA: {
virDomainAIA value;
if (virXMLPropEnumDefault(nodes[i], "value", virDomainAIATypeFromString,
VIR_XML_PROP_NONZERO, &value,
VIR_DOMAIN_AIA_DEFAULT) < 0)
return -1;
def->features[val] = value;
break;
}
case VIR_DOMAIN_FEATURE_TCG:
if (virDomainFeaturesTCGDefParse(def, ctxt, nodes[i]) < 0)
return -1;
@ -21161,6 +21182,17 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src,
}
break;
case VIR_DOMAIN_FEATURE_AIA:
if (src->features[i] != dst->features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%1$s' differs: source: '%2$s=%3$s', destination: '%4$s=%5$s'"),
featureName,
"value", virDomainAIATypeToString(src->features[i]),
"value", virDomainAIATypeToString(dst->features[i]));
return false;
}
break;
case VIR_DOMAIN_FEATURE_MSRS:
case VIR_DOMAIN_FEATURE_TCG:
case VIR_DOMAIN_FEATURE_ASYNC_TEARDOWN:
@ -28219,6 +28251,14 @@ virDomainDefFormatFeatures(virBuffer *buf,
virTristateBoolTypeToString(def->features[i]));
break;
case VIR_DOMAIN_FEATURE_AIA:
if (def->features[i] == VIR_DOMAIN_AIA_DEFAULT)
break;
virBufferAsprintf(&childBuf, "<aia value='%s'/>\n",
virDomainAIATypeToString(def->features[i]));
break;
case VIR_DOMAIN_FEATURE_LAST:
break;
}

View File

@ -2206,6 +2206,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_ASYNC_TEARDOWN,
VIR_DOMAIN_FEATURE_RAS,
VIR_DOMAIN_FEATURE_PS2,
VIR_DOMAIN_FEATURE_AIA,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
@ -2423,6 +2424,17 @@ typedef enum {
VIR_ENUM_DECL(virDomainIBS);
typedef enum {
VIR_DOMAIN_AIA_DEFAULT = 0,
VIR_DOMAIN_AIA_NONE,
VIR_DOMAIN_AIA_APLIC,
VIR_DOMAIN_AIA_APLIC_IMSIC,
VIR_DOMAIN_AIA_LAST
} virDomainAIA;
VIR_ENUM_DECL(virDomainAIA);
typedef struct _virDomainFeatureKVM virDomainFeatureKVM;
struct _virDomainFeatureKVM {
int features[VIR_DOMAIN_KVM_LAST];

View File

@ -6996,6 +6996,9 @@
<ref name="featurestate"/>
</element>
</optional>
<optional>
<ref name="aia"/>
</optional>
</interleave>
</element>
</optional>
@ -7294,6 +7297,18 @@
</element>
</define>
<define name="aia">
<element name="aia">
<attribute name="value">
<choice>
<value>none</value>
<value>aplic</value>
<value>aplic-imsic</value>
</choice>
</attribute>
</element>
</define>
<define name="address">
<element name="address">
<choice>

View File

@ -229,6 +229,8 @@ virDiskNameParse;
virDiskNameToBusDeviceIndex;
virDiskNameToIndex;
virDomainActualNetDefFree;
virDomainAIATypeFromString;
virDomainAIATypeToString;
virDomainAudioDefFree;
virDomainAudioFormatTypeFromString;
virDomainAudioFormatTypeToString;

View File

@ -264,6 +264,21 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
}
break;
case VIR_DOMAIN_FEATURE_AIA:
if (def->features[i] != VIR_DOMAIN_AIA_DEFAULT &&
!qemuDomainIsRISCVVirt(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("aia feature is only supported with RISC-V Virt machines"));
return -1;
}
if (def->features[i] != VIR_DOMAIN_AIA_DEFAULT &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_VIRT_AIA)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("aia feature is not available with this QEMU binary"));
return -1;
}
break;
case VIR_DOMAIN_FEATURE_SMM:
case VIR_DOMAIN_FEATURE_KVM:
case VIR_DOMAIN_FEATURE_XEN: