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

[libvirt] [PATCH 2/3] conf: Add support for HyperV Enlightenment features



Hypervisors are starting to support HyperV englightenment features that
improve behavior of guests running Microsoft Windows operating systems.

This patch adds support for the "relaxed" feature that improves timer
behavior and also establishes a framework to add these features in
future.
---
 docs/formatdomain.html.in     | 21 ++++++++++++
 docs/schemas/domaincommon.rng | 28 +++++++++++++++-
 src/conf/domain_conf.c        | 74 +++++++++++++++++++++++++++++++++++++++++--
 src/conf/domain_conf.h        | 10 ++++++
 src/libvirt_private.syms      |  2 ++
 5 files changed, 132 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index ad8a41b..2417943 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1047,6 +1047,10 @@
     <apic/>
     <hap/>
     <privnet/>
+    <hyperv>
+      <relaxed state='on'>
+    </hyperv>
+
   </features>
   ...</pre>

@@ -1087,6 +1091,23 @@
         This feature is only relevant for container based
         virtualization drivers, such as LXC.
       </dd>
+      <dt><code>hyperv</code></dt>
+      <dd>Enable various features improving behavior of guests
+        running Microsoft Windows.
+      <table class="top_table">
+        <tr>
+          <th>Feature</th>
+          <th>Description</th>
+          <th>Value</th>
+        </tr>
+        <tr>
+          <td>relaxed</td>
+          <td>Relax contstraints on timers</td>
+          <td> on, off</td>
+        </tr>
+      </table>
+      <span class="since">Since 1.0.0 (QEMU only)</span>
+      </dd>
     </dl>

     <h3><a name="elementsTime">Time keeping</a></h3>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 70bc0e2..17ad86b 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2946,7 +2946,8 @@
     </element>
   </define>
   <!--
-      A set of optional features: PAE, APIC, ACPI, and HAP support
+      A set of optional features: PAE, APIC, ACPI,
+      HyperV Enlightenment and HAP support
     -->
   <define name="features">
     <optional>
@@ -2980,6 +2981,9 @@
             </element>
           </optional>
           <optional>
+            <ref name="hyperv"/>
+          </optional>
+          <optional>
             <element name="viridian">
               <empty/>
             </element>
@@ -3434,6 +3438,28 @@
     </element>
   </define>

+  <!-- Optional HyperV Enlightenment features -->
+  <define name="hyperv">
+    <element name="hyperv">
+      <interleave>
+        <optional>
+          <element name="relaxed">
+            <ref name="hypervtristate"/>
+          </element>
+        </optional>
+      </interleave>
+    </element>
+  </define>
+
+  <define name="hypervtristate">
+    <attribute name="state">
+      <choice>
+        <value>on</value>
+        <value>off</value>
+      </choice>
+    </attribute>
+  </define>
+
   <!--
        Optional hypervisor extensions in their own namespace:
          QEmu
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b6bb080..7d38114 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -113,13 +113,17 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
               "pae",
               "hap",
               "viridian",
-              "privnet")
+              "privnet",
+              "hyperv")

 VIR_ENUM_IMPL(virDomainFeatureState, VIR_DOMAIN_FEATURE_STATE_LAST,
               "default",
               "on",
               "off")

+VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
+              "relaxed")
+
 VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST,
               "destroy",
               "restart",
@@ -9074,6 +9078,53 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         VIR_FREE(nodes);
     }

+    if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
+        int feature;
+        int value;
+        node = ctxt->node;
+        if ((n = virXPathNodeSet("./features/hyperv/*", ctxt, &nodes)) < 0)
+            goto error;
+
+        for (i = 0; i < n; i++) {
+            feature = virDomainHypervTypeFromString((const char *)nodes[i]->name);
+            if (feature < 0) {
+                virReportError(VIR_ERR_XML_ERROR,
+                               _("unsupported HyperV Enlightenment feature: %s"),
+                               nodes[i]->name);
+                goto error;
+            }
+
+            ctxt->node = nodes[i];
+
+            switch ((enum virDomainHyperv) feature) {
+                case VIR_DOMAIN_HYPERV_RELAXED:
+                    if (!(tmp = virXPathString("string(./@state)", ctxt))) {
+                        virReportError(VIR_ERR_XML_ERROR,
+                                       _("missing 'state' attribute for "
+                                         "HyperV Enlightenment feature '%s'"),
+                                       nodes[i]->name);
+                        goto error;
+                    }
+
+                    if ((value = virDomainFeatureStateTypeFromString(tmp)) < 0) {
+                        virReportError(VIR_ERR_XML_ERROR,
+                                       _("invalid value of state argument "
+                                         "for HyperV Enlightenment feature '%s'"),
+                                       nodes[i]->name);
+                        goto error;
+                    }
+
+                    def->hyperv_features[feature] = value;
+                    break;
+
+                case VIR_DOMAIN_HYPERV_LAST:
+                    break;
+            }
+        }
+        VIR_FREE(nodes);
+        ctxt->node = node;
+    }
+
     if (virDomainEventActionParseXML(ctxt, "on_reboot",
                                      "string(./on_reboot[1])",
                                      &def->onReboot,
@@ -13817,7 +13868,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     if (def->features) {
         virBufferAddLit(buf, "  <features>\n");
         for (i = 0 ; i < VIR_DOMAIN_FEATURE_LAST ; i++) {
-            if (def->features & (1 << i)) {
+            if (def->features & (1 << i) && i != VIR_DOMAIN_FEATURE_HYPERV) {
                 const char *name = virDomainFeatureTypeToString(i);
                 if (!name) {
                     virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -13833,6 +13884,25 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                 virBufferAddLit(buf, "/>\n");
             }
         }
+
+        if (def->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
+            virBufferAddLit(buf, "    <hyperv>\n");
+            for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
+                switch ((enum virDomainHyperv) i) {
+                case VIR_DOMAIN_HYPERV_RELAXED:
+                    if (def->hyperv_features[i])
+                        virBufferAsprintf(buf, "      <%s state='%s'/>\n",
+                                          virDomainHypervTypeToString(i),
+                                          virDomainFeatureStateTypeToString(def->hyperv_features[i]));
+                    break;
+
+                case VIR_DOMAIN_HYPERV_LAST:
+                    break;
+                }
+            }
+            virBufferAddLit(buf, "    </hyperv>\n");
+        }
+
         virBufferAddLit(buf, "  </features>\n");
     }

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ed53d44..ac6311f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1385,6 +1385,7 @@ enum virDomainFeature {
     VIR_DOMAIN_FEATURE_HAP,
     VIR_DOMAIN_FEATURE_VIRIDIAN,
     VIR_DOMAIN_FEATURE_PRIVNET,
+    VIR_DOMAIN_FEATURE_HYPERV,

     VIR_DOMAIN_FEATURE_LAST
 };
@@ -1397,6 +1398,12 @@ enum virDomainFeatureState {
     VIR_DOMAIN_FEATURE_STATE_LAST
 };

+enum virDomainHyperv {
+    VIR_DOMAIN_HYPERV_RELAXED = 0,
+
+    VIR_DOMAIN_HYPERV_LAST
+};
+
 enum virDomainLifecycleAction {
     VIR_DOMAIN_LIFECYCLE_DESTROY,
     VIR_DOMAIN_LIFECYCLE_RESTART,
@@ -1710,6 +1717,8 @@ struct _virDomainDef {
     int features;
     /* enum virDomainFeatureState */
     int apic_eoi;
+    /* These options are of type virDomainFeatureState */
+    int hyperv_features[VIR_DOMAIN_HYPERV_LAST];

     virDomainClockDef clock;

@@ -2239,6 +2248,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste)
 VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
 VIR_ENUM_DECL(virDomainNumatuneMemMode)
 VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode)
+VIR_ENUM_DECL(virDomainHyperv)
 /* from libvirt.h */
 VIR_ENUM_DECL(virDomainState)
 VIR_ENUM_DECL(virDomainNostateReason)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0801c6c..1a0c2f6 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -406,6 +406,8 @@ virDomainHostdevRemove;
 virDomainHostdevSubsysTypeToString;
 virDomainHubTypeFromString;
 virDomainHubTypeToString;
+virDomainHypervTypeFromString;
+virDomainHypervTypeToString;
 virDomainInputDefFree;
 virDomainIoEventFdTypeFromString;
 virDomainIoEventFdTypeToString;
-- 
1.7.12.3


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