File 09eb1ae0-conf-add-xenbus-controller.patch of Package libvirt.10106
commit 09eb1ae0ec7e592133eb98f4a0fe2f6daa5ba2d9
Author: Jim Fehlig <jfehlig@suse.com>
Date: Wed Mar 6 15:59:29 2019 -0700
conf: Add a new 'xenbus' controller type
xenbus is virtual controller (akin to virtio controllers) for Xen
paravirtual devices. Although all Xen VMs have a xenbus, it has
never been modeled in libvirt, or in Xen native VM config format
for that matter.
Recently there have been requests to support Xen's max_grant_frames
setting in libvirt. max_grant_frames is best modeled as an attribute
of xenbus. It describes the maximum IO buffer space (or DMA space)
available in xenbus for use by connected paravirtual devices. This
patch introduces a new xenbus controller type that includes a
maxGrantFrames attribute.
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Index: libvirt-3.3.0/docs/formatdomain.html.in
===================================================================
--- libvirt-3.3.0.orig/docs/formatdomain.html.in
+++ libvirt-3.3.0/docs/formatdomain.html.in
@@ -3473,6 +3473,7 @@
<driver iothread='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
</controller>
+ <controller type='xenbus' maxGrantFrames='64'/>
...
</devices>
...</pre>
@@ -3516,6 +3517,11 @@
<span class="since">Since 1.3.5</span>, USB controllers accept a
<code>ports</code> attribute to configure how many devices can be
connected to the controller.</dd>
+ <dt><code>xenbus</code></dt>
+ <dd><span class="since">Since 5.2.0</span>, the <code>xenbus</code>
+ controller has an optional attribute <code>maxGrantFrames</code>,
+ which specifies the maximum number of grant frames the controller
+ makes available for connected devices.</dd>
</dl>
<p>
Index: libvirt-3.3.0/docs/schemas/domaincommon.rng
===================================================================
--- libvirt-3.3.0.orig/docs/schemas/domaincommon.rng
+++ libvirt-3.3.0/docs/schemas/domaincommon.rng
@@ -2050,6 +2050,17 @@
</attribute>
</optional>
</group>
+ <!-- xenbus has an optional attribute "maxGrantFrames" -->
+ <group>
+ <attribute name="type">
+ <value>xenbus</value>
+ </attribute>
+ <optional>
+ <attribute name="maxGrantFrames">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
+ </group>
</choice>
<optional>
<element name="driver">
Index: libvirt-3.3.0/src/conf/domain_conf.c
===================================================================
--- libvirt-3.3.0.orig/src/conf/domain_conf.c
+++ libvirt-3.3.0/src/conf/domain_conf.c
@@ -319,7 +319,8 @@ VIR_ENUM_IMPL(virDomainController, VIR_D
"virtio-serial",
"ccid",
"usb",
- "pci")
+ "pci",
+ "xenbus")
VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
"pci-root",
@@ -1806,6 +1807,9 @@ virDomainControllerDefNew(virDomainContr
def->opts.pciopts.busNr = -1;
def->opts.pciopts.numaNode = -1;
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
+ def->opts.xenbusopts.maxGrantFrames = -1;
+ break;
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
@@ -9164,6 +9168,22 @@ virDomainControllerDefParseXML(xmlNodePt
if (numaNode >= 0)
def->opts.pciopts.numaNode = numaNode;
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
+ char *gntframes = virXMLPropString(node, "maxGrantFrames");
+
+ if (gntframes) {
+ int r = virStrToLong_i(gntframes, NULL, 10,
+ &def->opts.xenbusopts.maxGrantFrames);
+ if (r != 0 || def->opts.xenbusopts.maxGrantFrames < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid maxGrantFrames: %s"), gntframes);
+ VIR_FREE(gntframes);
+ goto error;
+ }
+ }
+ VIR_FREE(gntframes);
+ break;
+ }
default:
break;
@@ -21369,6 +21389,13 @@ virDomainControllerDefFormat(virBufferPt
pciTarget = true;
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
+ if (def->opts.xenbusopts.maxGrantFrames != -1) {
+ virBufferAsprintf(buf, " maxGrantFrames='%d'",
+ def->opts.xenbusopts.maxGrantFrames);
+ }
+ break;
+
default:
break;
}
Index: libvirt-3.3.0/src/conf/domain_conf.h
===================================================================
--- libvirt-3.3.0.orig/src/conf/domain_conf.h
+++ libvirt-3.3.0/src/conf/domain_conf.h
@@ -676,6 +676,7 @@ typedef enum {
VIR_DOMAIN_CONTROLLER_TYPE_CCID,
VIR_DOMAIN_CONTROLLER_TYPE_USB,
VIR_DOMAIN_CONTROLLER_TYPE_PCI,
+ VIR_DOMAIN_CONTROLLER_TYPE_XENBUS,
VIR_DOMAIN_CONTROLLER_TYPE_LAST
} virDomainControllerType;
@@ -792,6 +793,12 @@ struct _virDomainUSBControllerOpts {
int ports; /* -1 == undef */
};
+typedef struct _virDomainXenbusControllerOpts virDomainXenbusControllerOpts;
+typedef virDomainXenbusControllerOpts *virDomainXenbusControllerOptsPtr;
+struct _virDomainXenbusControllerOpts {
+ int maxGrantFrames; /* -1 == undef */
+};
+
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
int type;
@@ -806,6 +813,7 @@ struct _virDomainControllerDef {
virDomainVirtioSerialOpts vioserial;
virDomainPCIControllerOpts pciopts;
virDomainUSBControllerOpts usbopts;
+ virDomainXenbusControllerOpts xenbusopts;
} opts;
virDomainDeviceInfo info;
};
Index: libvirt-3.3.0/src/qemu/qemu_domain.c
===================================================================
--- libvirt-3.3.0.orig/src/qemu/qemu_domain.c
+++ libvirt-3.3.0/src/qemu/qemu_domain.c
@@ -3398,6 +3398,7 @@ qemuDomainControllerDefPostParse(virDoma
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
break;
}
Index: libvirt-3.3.0/src/qemu/qemu_domain_address.c
===================================================================
--- libvirt-3.3.0.orig/src/qemu/qemu_domain_address.c
+++ libvirt-3.3.0/src/qemu/qemu_domain_address.c
@@ -549,6 +549,7 @@ qemuDomainDeviceCalculatePCIConnectFlags
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
/* should be 0 */
return pciFlags;