提交 cc922fdd 编写于 作者: P Peter Krempa

conf: Add support for HyperV Enlightenment features

Hypervisors are starting to support HyperV Enlightenment 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.
上级 88cac66d
...@@ -1047,6 +1047,10 @@ ...@@ -1047,6 +1047,10 @@
<apic/> <apic/>
<hap/> <hap/>
<privnet/> <privnet/>
<hyperv>
<relaxed state='on'>
</hyperv>
</features> </features>
...</pre> ...</pre>
...@@ -1087,6 +1091,23 @@ ...@@ -1087,6 +1091,23 @@
This feature is only relevant for container based This feature is only relevant for container based
virtualization drivers, such as LXC. virtualization drivers, such as LXC.
</dd> </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> </dl>
<h3><a name="elementsTime">Time keeping</a></h3> <h3><a name="elementsTime">Time keeping</a></h3>
......
...@@ -2946,7 +2946,8 @@ ...@@ -2946,7 +2946,8 @@
</element> </element>
</define> </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"> <define name="features">
<optional> <optional>
...@@ -2979,6 +2980,9 @@ ...@@ -2979,6 +2980,9 @@
<empty/> <empty/>
</element> </element>
</optional> </optional>
<optional>
<ref name="hyperv"/>
</optional>
<optional> <optional>
<element name="viridian"> <element name="viridian">
<empty/> <empty/>
...@@ -3434,6 +3438,28 @@ ...@@ -3434,6 +3438,28 @@
</element> </element>
</define> </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: Optional hypervisor extensions in their own namespace:
QEmu QEmu
......
...@@ -113,13 +113,17 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, ...@@ -113,13 +113,17 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
"pae", "pae",
"hap", "hap",
"viridian", "viridian",
"privnet") "privnet",
"hyperv")
VIR_ENUM_IMPL(virDomainFeatureState, VIR_DOMAIN_FEATURE_STATE_LAST, VIR_ENUM_IMPL(virDomainFeatureState, VIR_DOMAIN_FEATURE_STATE_LAST,
"default", "default",
"on", "on",
"off") "off")
VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
"relaxed")
VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST, VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST,
"destroy", "destroy",
"restart", "restart",
...@@ -9074,6 +9078,53 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, ...@@ -9074,6 +9078,53 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
VIR_FREE(nodes); 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", if (virDomainEventActionParseXML(ctxt, "on_reboot",
"string(./on_reboot[1])", "string(./on_reboot[1])",
&def->onReboot, &def->onReboot,
...@@ -13817,7 +13868,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, ...@@ -13817,7 +13868,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (def->features) { if (def->features) {
virBufferAddLit(buf, " <features>\n"); virBufferAddLit(buf, " <features>\n");
for (i = 0 ; i < VIR_DOMAIN_FEATURE_LAST ; i++) { 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); const char *name = virDomainFeatureTypeToString(i);
if (!name) { if (!name) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -13833,6 +13884,25 @@ virDomainDefFormatInternal(virDomainDefPtr def, ...@@ -13833,6 +13884,25 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAddLit(buf, "/>\n"); 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"); virBufferAddLit(buf, " </features>\n");
} }
......
...@@ -1385,6 +1385,7 @@ enum virDomainFeature { ...@@ -1385,6 +1385,7 @@ enum virDomainFeature {
VIR_DOMAIN_FEATURE_HAP, VIR_DOMAIN_FEATURE_HAP,
VIR_DOMAIN_FEATURE_VIRIDIAN, VIR_DOMAIN_FEATURE_VIRIDIAN,
VIR_DOMAIN_FEATURE_PRIVNET, VIR_DOMAIN_FEATURE_PRIVNET,
VIR_DOMAIN_FEATURE_HYPERV,
VIR_DOMAIN_FEATURE_LAST VIR_DOMAIN_FEATURE_LAST
}; };
...@@ -1397,6 +1398,12 @@ enum virDomainFeatureState { ...@@ -1397,6 +1398,12 @@ enum virDomainFeatureState {
VIR_DOMAIN_FEATURE_STATE_LAST VIR_DOMAIN_FEATURE_STATE_LAST
}; };
enum virDomainHyperv {
VIR_DOMAIN_HYPERV_RELAXED = 0,
VIR_DOMAIN_HYPERV_LAST
};
enum virDomainLifecycleAction { enum virDomainLifecycleAction {
VIR_DOMAIN_LIFECYCLE_DESTROY, VIR_DOMAIN_LIFECYCLE_DESTROY,
VIR_DOMAIN_LIFECYCLE_RESTART, VIR_DOMAIN_LIFECYCLE_RESTART,
...@@ -1710,6 +1717,8 @@ struct _virDomainDef { ...@@ -1710,6 +1717,8 @@ struct _virDomainDef {
int features; int features;
/* enum virDomainFeatureState */ /* enum virDomainFeatureState */
int apic_eoi; int apic_eoi;
/* These options are of type virDomainFeatureState */
int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
virDomainClockDef clock; virDomainClockDef clock;
...@@ -2239,6 +2248,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste) ...@@ -2239,6 +2248,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste)
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode) VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
VIR_ENUM_DECL(virDomainNumatuneMemMode) VIR_ENUM_DECL(virDomainNumatuneMemMode)
VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode) VIR_ENUM_DECL(virDomainNumatuneMemPlacementMode)
VIR_ENUM_DECL(virDomainHyperv)
/* from libvirt.h */ /* from libvirt.h */
VIR_ENUM_DECL(virDomainState) VIR_ENUM_DECL(virDomainState)
VIR_ENUM_DECL(virDomainNostateReason) VIR_ENUM_DECL(virDomainNostateReason)
......
...@@ -406,6 +406,8 @@ virDomainHostdevRemove; ...@@ -406,6 +406,8 @@ virDomainHostdevRemove;
virDomainHostdevSubsysTypeToString; virDomainHostdevSubsysTypeToString;
virDomainHubTypeFromString; virDomainHubTypeFromString;
virDomainHubTypeToString; virDomainHubTypeToString;
virDomainHypervTypeFromString;
virDomainHypervTypeToString;
virDomainInputDefFree; virDomainInputDefFree;
virDomainIoEventFdTypeFromString; virDomainIoEventFdTypeFromString;
virDomainIoEventFdTypeToString; virDomainIoEventFdTypeToString;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册