[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/3] 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 "ignoreUnknownWrites":

 <msrs ignoreUnknownWrites='yes'/>

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 <bogorodskiy gmail com>
---
 docs/formatdomain.html.in     |  1 +
 docs/schemas/domaincommon.rng | 14 ++++++++++++++
 src/conf/domain_conf.c        | 33 +++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h        |  8 ++++++++
 src/qemu/qemu_domain.c        |  1 +
 5 files changed, 57 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 7f07bb7f55..b6496c63db 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2010,6 +2010,7 @@
     &lt;tlbflush state='on'/&gt;
     &lt;ipi state='on'/&gt;
     &lt;evmcs state='on'/&gt;
+    &lt;msrs ignoreUnknownWrites='yes'/&gt;
   &lt;/hyperv&gt;
   &lt;kvm&gt;
     &lt;hidden state='on'/&gt;
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index aa50eac424..e9dd99ab3a 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4994,6 +4994,9 @@
               <ref name="featurestate"/>
             </element>
           </optional>
+          <optional>
+            <ref name="msrs"/>
+          </optional>
         </interleave>
       </element>
     </optional>
@@ -5242,6 +5245,17 @@
     </element>
   </define>
 
+  <define name="msrs">
+    <element name="msrs">
+      <attribute name="ignoreUnknownWrites">
+        <choice>
+          <value>yes</value>
+          <value>no</value>
+        </choice>
+      </attribute>
+    </element>
+  </define>
+
   <define name="address">
     <element name="address">
       <choice>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 22979e6c4e..c8ec3a9011 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -153,6 +153,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
               "vmcoreinfo",
               "htm",
               "nested-hv",
+              "msrs",
 );
 
 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
@@ -20232,6 +20233,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;
 
@@ -20520,6 +20522,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, "ignoreUnknownWrites"))) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("missing ignoreUnknownWrites attribute for feature '%s'"),
+                           virDomainFeatureTypeToString(VIR_DOMAIN_FEATURE_MSRS));
+            goto error;
+        }
+
+        if ((def->msrs_features[VIR_DOMAIN_MSRS_IGNORE_UNKNOWN_WRITES] = virTristateBoolTypeFromString(tmp)) <= 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unknown ignoreUnknownWrites value '%s'"),
+                           tmp);
+            goto error;
+        }
+        VIR_FREE(tmp);
+    }
+
     if ((n = virXPathNodeSet("./features/capabilities/*", ctxt, &nodes)) < 0)
         goto error;
 
@@ -22582,6 +22604,9 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
             }
             break;
 
+        case VIR_DOMAIN_FEATURE_MSRS:
+            break;
+
         case VIR_DOMAIN_FEATURE_LAST:
             break;
         }
@@ -28647,6 +28672,14 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                 }
                 break;
 
+            case VIR_DOMAIN_FEATURE_MSRS:
+                if (def->features[i] != VIR_TRISTATE_SWITCH_ON)
+                    break;
+
+                virBufferAsprintf(buf, "<msrs ignoreUnknownWrites='%s'/>\n",
+                                  virTristateBoolTypeToString(def->msrs_features[VIR_DOMAIN_MSRS_IGNORE_UNKNOWN_WRITES]));
+                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 f1e6e4e8b7..36926d5e1d 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,12 @@ typedef enum {
     VIR_DOMAIN_KVM_LAST
 } virDomainKVM;
 
+typedef enum {
+    VIR_DOMAIN_MSRS_IGNORE_UNKNOWN_WRITES = 0,
+
+    VIR_DOMAIN_MSRS_LAST
+} virDomainMsrs;
+
 typedef enum {
     VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT = 0,
     VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW,
@@ -2466,6 +2473,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;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f42903a343..f484814977 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4030,6 +4030,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;
         }
-- 
2.20.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]