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(a)suse.com>
---
docs/formatdomain.html.in | 6 ++++++
docs/schemas/domaincommon.rng | 11 +++++++++++
src/conf/domain_conf.c | 25 +++++++++++++++++++++++++
src/conf/domain_conf.h | 8 ++++++++
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_domain.c | 2 ++
src/qemu/qemu_domain_address.c | 1 +
7 files changed, 54 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index eb00c01d96..35fcdb2f9e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4163,6 +4163,7 @@
<driver iothread='4'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x0b' function='0x0'/>
</controller>
+ <controller type='xenbus' maxGrantFrames='64'/>
...
</devices>
...</pre>
@@ -4218,6 +4219,11 @@
<dd><span class="since">Since 3.10.0</span> for the
vbox driver, the
<code>ide</code> controller has an optional attribute
<code>model</code>, which is one of "piix3",
"piix4" or "ich6".</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>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 80f9f84f70..0814a8f9c8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2335,6 +2335,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">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 995f87bcbe..575a73531d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -347,6 +347,7 @@ VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST,
"ccid",
"usb",
"pci",
+ "xenbus",
);
VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
@@ -2065,6 +2066,9 @@ virDomainControllerDefNew(virDomainControllerType type)
def->opts.pciopts.targetIndex = -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:
@@ -10673,6 +10677,20 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
def->opts.pciopts.numaNode = numaNode;
}
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
+ VIR_AUTOFREE(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);
+ goto error;
+ }
+ }
+ break;
+ }
default:
break;
@@ -24267,6 +24285,13 @@ virDomainControllerDefFormat(virBufferPtr buf,
}
break;
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
+ if (def->opts.xenbusopts.maxGrantFrames != -1) {
+ virBufferAsprintf(&attrBuf, " maxGrantFrames='%d'",
+ def->opts.xenbusopts.maxGrantFrames);
+ }
+ break;
+
default:
break;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c2dcc87ba1..ab8eb16e45 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -709,6 +709,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;
@@ -852,6 +853,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;
@@ -866,6 +873,7 @@ struct _virDomainControllerDef {
virDomainVirtioSerialOpts vioserial;
virDomainPCIControllerOpts pciopts;
virDomainUSBControllerOpts usbopts;
+ virDomainXenbusControllerOpts xenbusopts;
} opts;
virDomainDeviceInfo info;
virDomainVirtioOptionsPtr virtio;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3a2ec7f26c..9644799d0d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3146,6 +3146,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller type: %s"),
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 44453a5a7a..30b4b72edc 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5851,6 +5851,7 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef
*controller,
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
break;
}
@@ -6471,6 +6472,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
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;
}
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 4740536d82..3eccf40eb5 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -685,6 +685,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
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;
--
2.20.1