forked from pool/libvirt
06eb24a4dd
- libxl: Add support for 'passthrough' and 'e820_host' settings b7d6648d-conf-add-e820-host.patch, 5749395b-libxl-e820-host.patch, f3ef7daf-xenconfig-e820-host.patch, 34077c1b-tests-check-e820-host.patch, fadbaa23-conf-add-passthrough.patch, 9529e007-libxl-passthrough.patch, 9cb8bc6f-xenconfig-refactor-features.patch, b523e225-xenconfig-passthrough.patch, bed32525-tests-check-passthrough.patch bsc#1167217 OBS-URL: https://build.opensuse.org/request/show/796123 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=823
292 lines
12 KiB
Diff
292 lines
12 KiB
Diff
commit fadbaa23757ff9dca329bdb8d3447c27599f6884
|
|
Author: Jim Fehlig <jfehlig@suse.com>
|
|
Date: Wed Apr 15 16:34:54 2020 -0600
|
|
|
|
conf: add xen hypervisor feature 'passthrough'
|
|
|
|
'passthrough' is Xen-Specific guest configuration option new to Xen 4.13
|
|
that enables IOMMU mappings for a guest and hence whether it supports PCI
|
|
passthrough. The default is disabled. See the xl.cfg(5) man page and
|
|
xen.git commit babde47a3fe for more details.
|
|
|
|
The default state of disabled prevents hotlugging PCI devices. However,
|
|
if the guest configuration contains a PCI passthrough device at time of
|
|
creation, libxl will automatically enable 'passthrough' and subsequent
|
|
hotplugging of PCI devices will also be possible. It is not possible to
|
|
unconditionally enable 'passthrough' since it would introduce a migration
|
|
incompatibility due to guest ABI change. Instead, introduce another Xen
|
|
hypervisor feature that can be used to enable guest PCI passthrough
|
|
|
|
<features>
|
|
<xen>
|
|
<passthrough state='on'/>
|
|
</xen>
|
|
</features>
|
|
|
|
To allow finer control over how IOMMU maps to guest P2M table, the
|
|
passthrough element also supports a 'mode' attribute with values
|
|
restricted to snyc_pt and share_pt, similar to xl.cfg(5) 'passthrough'
|
|
setting .
|
|
|
|
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
|
|
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
|
Index: libvirt-6.2.0/docs/formatdomain.html.in
|
|
===================================================================
|
|
--- libvirt-6.2.0.orig/docs/formatdomain.html.in
|
|
+++ libvirt-6.2.0/docs/formatdomain.html.in
|
|
@@ -2057,6 +2057,7 @@
|
|
</kvm>
|
|
<xen>
|
|
<e820_host state='on'/>
|
|
+ <passthrough state='on' mode='share_pt'/>
|
|
</xen>
|
|
<pvspinlock state='on'/>
|
|
<gic version='2'/>
|
|
@@ -2254,6 +2255,12 @@
|
|
<td>on, off</td>
|
|
<td><span class="since">6.3.0</span></td>
|
|
</tr>
|
|
+ <tr>
|
|
+ <td>passthrough</td>
|
|
+ <td>Enable IOMMU mappings allowing PCI passthrough)</td>
|
|
+ <td>on, off; mode - optional string sync_pt or share_pt</td>
|
|
+ <td><span class="since">6.3.0</span></td>
|
|
+ </tr>
|
|
</table>
|
|
</dd>
|
|
<dt><code>pmu</code></dt>
|
|
Index: libvirt-6.2.0/docs/schemas/domaincommon.rng
|
|
===================================================================
|
|
--- libvirt-6.2.0.orig/docs/schemas/domaincommon.rng
|
|
+++ libvirt-6.2.0/docs/schemas/domaincommon.rng
|
|
@@ -6329,6 +6329,18 @@
|
|
<ref name="featurestate"/>
|
|
</element>
|
|
</optional>
|
|
+ <optional>
|
|
+ <element name="passthrough">
|
|
+ <ref name="featurestate"/>
|
|
+ <optional>
|
|
+ <attribute name="mode">
|
|
+ <data type="string">
|
|
+ <param name='pattern'>(sync_pt|share_pt)</param>
|
|
+ </data>
|
|
+ </attribute>
|
|
+ </optional>
|
|
+ </element>
|
|
+ </optional>
|
|
</interleave>
|
|
</element>
|
|
</define>
|
|
Index: libvirt-6.2.0/src/conf/domain_conf.c
|
|
===================================================================
|
|
--- libvirt-6.2.0.orig/src/conf/domain_conf.c
|
|
+++ libvirt-6.2.0/src/conf/domain_conf.c
|
|
@@ -210,7 +210,15 @@ VIR_ENUM_IMPL(virDomainKVM,
|
|
|
|
VIR_ENUM_IMPL(virDomainXen,
|
|
VIR_DOMAIN_XEN_LAST,
|
|
- "e820_host"
|
|
+ "e820_host",
|
|
+ "passthrough",
|
|
+);
|
|
+
|
|
+VIR_ENUM_IMPL(virDomainXenPassthroughMode,
|
|
+ VIR_DOMAIN_XEN_PASSTHROUGH_MODE_LAST,
|
|
+ "default",
|
|
+ "sync_pt",
|
|
+ "share_pt",
|
|
);
|
|
|
|
VIR_ENUM_IMPL(virDomainMsrsUnknown,
|
|
@@ -21130,6 +21138,8 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|
if (def->features[VIR_DOMAIN_FEATURE_XEN] == VIR_TRISTATE_SWITCH_ON) {
|
|
int feature;
|
|
int value;
|
|
+ g_autofree char *ptval = NULL;
|
|
+
|
|
if ((n = virXPathNodeSet("./features/xen/*", ctxt, &nodes)) < 0)
|
|
goto error;
|
|
|
|
@@ -21142,27 +21152,53 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|
goto error;
|
|
}
|
|
|
|
+ if (!(tmp = virXMLPropString(nodes[i], "state"))) {
|
|
+ virReportError(VIR_ERR_XML_ERROR,
|
|
+ _("missing 'state' attribute for "
|
|
+ "Xen feature '%s'"),
|
|
+ nodes[i]->name);
|
|
+ goto error;
|
|
+ }
|
|
+
|
|
+ if ((value = virTristateSwitchTypeFromString(tmp)) < 0) {
|
|
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
+ _("invalid value of state argument "
|
|
+ "for Xen feature '%s'"),
|
|
+ nodes[i]->name);
|
|
+ goto error;
|
|
+ }
|
|
+
|
|
+ VIR_FREE(tmp);
|
|
+ def->xen_features[feature] = value;
|
|
+
|
|
switch ((virDomainXen) feature) {
|
|
case VIR_DOMAIN_XEN_E820_HOST:
|
|
- if (!(tmp = virXMLPropString(nodes[i], "state"))) {
|
|
- virReportError(VIR_ERR_XML_ERROR,
|
|
- _("missing 'state' attribute for "
|
|
- "Xen feature '%s'"),
|
|
- nodes[i]->name);
|
|
- goto error;
|
|
- }
|
|
+ break;
|
|
|
|
- if ((value = virTristateSwitchTypeFromString(tmp)) < 0) {
|
|
+ case VIR_DOMAIN_XEN_PASSTHROUGH:
|
|
+ if (value != VIR_TRISTATE_SWITCH_ON)
|
|
+ break;
|
|
+
|
|
+ if ((ptval = virXMLPropString(nodes[i], "mode"))) {
|
|
+ int mode = virDomainXenPassthroughModeTypeFromString(ptval);
|
|
+
|
|
+ if (mode < 0) {
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
- _("invalid value of state argument "
|
|
- "for Xen feature '%s'"),
|
|
- nodes[i]->name);
|
|
+ _("unsupported mode '%s' for Xen passthrough feature"),
|
|
+ ptval);
|
|
goto error;
|
|
}
|
|
|
|
- VIR_FREE(tmp);
|
|
- def->xen_features[feature] = value;
|
|
- break;
|
|
+ if (mode != VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SYNC_PT &&
|
|
+ mode != VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SHARE_PT) {
|
|
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
+ _("'mode' attribute for Xen feature "
|
|
+ "'passthrough' must be 'sync_pt' or 'share_pt'"));
|
|
+ goto error;
|
|
+ }
|
|
+ def->xen_passthrough_mode = mode;
|
|
+ }
|
|
+ break;
|
|
|
|
/* coverity[dead_error_begin] */
|
|
case VIR_DOMAIN_XEN_LAST:
|
|
@@ -23340,18 +23376,28 @@ virDomainDefFeaturesCheckABIStability(vi
|
|
/* xen */
|
|
if (src->features[VIR_DOMAIN_FEATURE_XEN] == VIR_TRISTATE_SWITCH_ON) {
|
|
for (i = 0; i < VIR_DOMAIN_XEN_LAST; i++) {
|
|
+ if (src->xen_features[i] != dst->xen_features[i]) {
|
|
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
+ _("State of Xen feature '%s' differs: "
|
|
+ "source: '%s', destination: '%s'"),
|
|
+ virDomainXenTypeToString(i),
|
|
+ virTristateSwitchTypeToString(src->xen_features[i]),
|
|
+ virTristateSwitchTypeToString(dst->xen_features[i]));
|
|
+ return false;
|
|
+ }
|
|
switch ((virDomainXen) i) {
|
|
case VIR_DOMAIN_XEN_E820_HOST:
|
|
- if (src->xen_features[i] != dst->xen_features[i]) {
|
|
+ break;
|
|
+
|
|
+ case VIR_DOMAIN_XEN_PASSTHROUGH:
|
|
+ if (src->xen_passthrough_mode != dst->xen_passthrough_mode) {
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
- _("State of Xen feature '%s' differs: "
|
|
+ _("'mode' of Xen passthrough feature differs: "
|
|
"source: '%s', destination: '%s'"),
|
|
- virDomainXenTypeToString(i),
|
|
- virTristateSwitchTypeToString(src->xen_features[i]),
|
|
- virTristateSwitchTypeToString(dst->xen_features[i]));
|
|
+ virDomainXenPassthroughModeTypeToString(src->xen_passthrough_mode),
|
|
+ virDomainXenPassthroughModeTypeToString(dst->xen_passthrough_mode));
|
|
return false;
|
|
}
|
|
-
|
|
break;
|
|
|
|
/* coverity[dead_error_begin] */
|
|
@@ -28969,13 +29015,30 @@ virDomainDefFormatFeatures(virBufferPtr
|
|
virBufferAddLit(&childBuf, "<xen>\n");
|
|
virBufferAdjustIndent(&childBuf, 2);
|
|
for (j = 0; j < VIR_DOMAIN_XEN_LAST; j++) {
|
|
+ if (def->xen_features[j] == VIR_TRISTATE_SWITCH_ABSENT)
|
|
+ continue;
|
|
+
|
|
+ virBufferAsprintf(&childBuf, "<%s state='%s'",
|
|
+ virDomainXenTypeToString(j),
|
|
+ virTristateSwitchTypeToString(
|
|
+ def->xen_features[j]));
|
|
+
|
|
switch ((virDomainXen) j) {
|
|
case VIR_DOMAIN_XEN_E820_HOST:
|
|
- if (def->xen_features[j])
|
|
- virBufferAsprintf(&childBuf, "<%s state='%s'/>\n",
|
|
- virDomainXenTypeToString(j),
|
|
- virTristateSwitchTypeToString(
|
|
- def->xen_features[j]));
|
|
+ virBufferAddLit(&childBuf, "/>\n");
|
|
+ break;
|
|
+ case VIR_DOMAIN_XEN_PASSTHROUGH:
|
|
+ if (def->xen_features[j] != VIR_TRISTATE_SWITCH_ON) {
|
|
+ virBufferAddLit(&childBuf, "/>\n");
|
|
+ break;
|
|
+ }
|
|
+ if (def->xen_passthrough_mode == VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SYNC_PT ||
|
|
+ def->xen_passthrough_mode == VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SHARE_PT) {
|
|
+ virBufferEscapeString(&childBuf, " mode='%s'/>\n",
|
|
+ virDomainXenPassthroughModeTypeToString(def->xen_passthrough_mode));
|
|
+ } else {
|
|
+ virBufferAddLit(&childBuf, "/>\n");
|
|
+ }
|
|
break;
|
|
|
|
/* coverity[dead_error_begin] */
|
|
Index: libvirt-6.2.0/src/conf/domain_conf.h
|
|
===================================================================
|
|
--- libvirt-6.2.0.orig/src/conf/domain_conf.h
|
|
+++ libvirt-6.2.0/src/conf/domain_conf.h
|
|
@@ -1848,11 +1848,20 @@ typedef enum {
|
|
|
|
typedef enum {
|
|
VIR_DOMAIN_XEN_E820_HOST = 0,
|
|
+ VIR_DOMAIN_XEN_PASSTHROUGH,
|
|
|
|
VIR_DOMAIN_XEN_LAST
|
|
} virDomainXen;
|
|
|
|
typedef enum {
|
|
+ VIR_DOMAIN_XEN_PASSTHROUGH_MODE_DEFAULT = 0,
|
|
+ VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SYNC_PT,
|
|
+ VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SHARE_PT,
|
|
+
|
|
+ VIR_DOMAIN_XEN_PASSTHROUGH_MODE_LAST
|
|
+} virDomainXenPassthroughMode;
|
|
+
|
|
+typedef enum {
|
|
VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT = 0,
|
|
VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW,
|
|
VIR_DOMAIN_CAPABILITIES_POLICY_DENY,
|
|
@@ -2477,6 +2486,7 @@ struct _virDomainDef {
|
|
int kvm_features[VIR_DOMAIN_KVM_LAST];
|
|
int msrs_features[VIR_DOMAIN_MSRS_LAST];
|
|
int xen_features[VIR_DOMAIN_XEN_LAST];
|
|
+ int xen_passthrough_mode;
|
|
unsigned int hyperv_spinlocks;
|
|
int hyperv_stimer_direct;
|
|
virGICVersion gic_version;
|
|
@@ -3523,6 +3533,7 @@ VIR_ENUM_DECL(virDomainGraphicsVNCShareP
|
|
VIR_ENUM_DECL(virDomainHyperv);
|
|
VIR_ENUM_DECL(virDomainKVM);
|
|
VIR_ENUM_DECL(virDomainXen);
|
|
+VIR_ENUM_DECL(virDomainXenPassthroughMode);
|
|
VIR_ENUM_DECL(virDomainMsrsUnknown);
|
|
VIR_ENUM_DECL(virDomainRNGModel);
|
|
VIR_ENUM_DECL(virDomainRNGBackend);
|