From b71de701b840eede5098ad1df3995b6e2c1025d9 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Thu, 24 Jan 2019 07:23:31 +0400 Subject: [PATCH] conf: introduce 'msrs' feature Introduce the 'msrs' feature element that controls Model Specific Registers related behaviour. At this moment it allows only single tunable attribute "unknown": Which tells hypervisor to ignore accesses to unimplemented Model Specific Registers. The only user of that for now is going to be the bhyve driver. Signed-off-by: Roman Bogorodskiy Reviewed-by: Cole Robinson --- docs/schemas/domaincommon.rng | 14 +++++++++++++ src/conf/domain_conf.c | 38 +++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 16 +++++++++++++++ src/qemu/qemu_domain.c | 1 + 4 files changed, 69 insertions(+) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ba80440c72..5345e54342 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4997,6 +4997,9 @@ + + + @@ -5245,6 +5248,17 @@ + + + + + ignore + fault + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ceeb247ef4..6f96e6bcdb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -157,6 +157,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, "vmcoreinfo", "htm", "nested-hv", + "msrs", ); VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST, @@ -186,6 +187,11 @@ VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST, "hidden", ); +VIR_ENUM_IMPL(virDomainMsrsUnknown, VIR_DOMAIN_MSRS_UNKNOWN_LAST, + "ignore", + "fault", +); + VIR_ENUM_IMPL(virDomainCapsFeature, VIR_DOMAIN_CAPS_FEATURE_LAST, "audit_control", "audit_write", @@ -20365,6 +20371,7 @@ virDomainDefParseXML(xmlDocPtr xml, case VIR_DOMAIN_FEATURE_PRIVNET: case VIR_DOMAIN_FEATURE_HYPERV: case VIR_DOMAIN_FEATURE_KVM: + case VIR_DOMAIN_FEATURE_MSRS: def->features[val] = VIR_TRISTATE_SWITCH_ON; break; @@ -20653,6 +20660,26 @@ virDomainDefParseXML(xmlDocPtr xml, def->tseg_specified = rv; } + if (def->features[VIR_DOMAIN_FEATURE_MSRS] == VIR_TRISTATE_SWITCH_ON) { + if ((node = virXPathNode("./features/msrs", ctxt)) == NULL) + goto error; + + if (!(tmp = virXMLPropString(node, "unknown"))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("missing 'unknown' attribute for feature '%s'"), + virDomainFeatureTypeToString(VIR_DOMAIN_FEATURE_MSRS)); + goto error; + } + + if ((def->msrs_features[VIR_DOMAIN_MSRS_UNKNOWN] = virDomainMsrsUnknownTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown 'unknown' value '%s'"), + tmp); + goto error; + } + VIR_FREE(tmp); + } + if ((n = virXPathNodeSet("./features/capabilities/*", ctxt, &nodes)) < 0) goto error; @@ -22713,6 +22740,9 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, } break; + case VIR_DOMAIN_FEATURE_MSRS: + break; + case VIR_DOMAIN_FEATURE_LAST: break; } @@ -28768,6 +28798,14 @@ virDomainDefFormatInternal(virDomainDefPtr def, } break; + case VIR_DOMAIN_FEATURE_MSRS: + if (def->features[i] != VIR_TRISTATE_SWITCH_ON) + break; + + virBufferAsprintf(buf, "\n", + virDomainMsrsUnknownTypeToString(def->msrs_features[VIR_DOMAIN_MSRS_UNKNOWN])); + break; + /* coverity[dead_error_begin] */ case VIR_DOMAIN_FEATURE_LAST: break; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9bccd8bcd1..1036eb9b10 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1782,6 +1782,7 @@ typedef enum { VIR_DOMAIN_FEATURE_VMCOREINFO, VIR_DOMAIN_FEATURE_HTM, VIR_DOMAIN_FEATURE_NESTED_HV, + VIR_DOMAIN_FEATURE_MSRS, VIR_DOMAIN_FEATURE_LAST } virDomainFeature; @@ -1813,6 +1814,19 @@ typedef enum { VIR_DOMAIN_KVM_LAST } virDomainKVM; +typedef enum { + VIR_DOMAIN_MSRS_UNKNOWN = 0, + + VIR_DOMAIN_MSRS_LAST +} virDomainMsrs; + +typedef enum { + VIR_DOMAIN_MSRS_UNKNOWN_IGNORE = 0, + VIR_DOMAIN_MSRS_UNKNOWN_FAULT, + + VIR_DOMAIN_MSRS_UNKNOWN_LAST +} virDomainMsrsUnknown; + typedef enum { VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT = 0, VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW, @@ -2466,6 +2480,7 @@ struct _virDomainDef { int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST]; int hyperv_features[VIR_DOMAIN_HYPERV_LAST]; int kvm_features[VIR_DOMAIN_KVM_LAST]; + int msrs_features[VIR_DOMAIN_MSRS_LAST]; unsigned int hyperv_spinlocks; virGICVersion gic_version; virDomainHPTResizing hpt_resizing; @@ -3477,6 +3492,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode); VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy); VIR_ENUM_DECL(virDomainHyperv); VIR_ENUM_DECL(virDomainKVM); +VIR_ENUM_DECL(virDomainMsrsUnknown); VIR_ENUM_DECL(virDomainRNGModel); VIR_ENUM_DECL(virDomainRNGBackend); VIR_ENUM_DECL(virDomainTPMModel); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8682b27037..c793c16668 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4021,6 +4021,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def, case VIR_DOMAIN_FEATURE_PMU: case VIR_DOMAIN_FEATURE_VMPORT: case VIR_DOMAIN_FEATURE_VMCOREINFO: + case VIR_DOMAIN_FEATURE_MSRS: case VIR_DOMAIN_FEATURE_LAST: break; }