提交 09eb1ae0 编写于 作者: J Jim Fehlig

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: NJim Fehlig <jfehlig@suse.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 411cdaf8
...@@ -4201,6 +4201,7 @@ ...@@ -4201,6 +4201,7 @@
&lt;driver iothread='4'/&gt; &lt;driver iothread='4'/&gt;
&lt;address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/&gt; &lt;address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/&gt;
&lt;/controller&gt; &lt;/controller&gt;
&lt;controller type='xenbus' maxGrantFrames='64'/&gt;
... ...
&lt;/devices&gt; &lt;/devices&gt;
...</pre> ...</pre>
...@@ -4256,6 +4257,11 @@ ...@@ -4256,6 +4257,11 @@
<dd><span class="since">Since 3.10.0</span> for the vbox driver, the <dd><span class="since">Since 3.10.0</span> for the vbox driver, the
<code>ide</code> controller has an optional attribute <code>ide</code> controller has an optional attribute
<code>model</code>, which is one of "piix3", "piix4" or "ich6".</dd> <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> </dl>
<p> <p>
......
...@@ -2345,6 +2345,17 @@ ...@@ -2345,6 +2345,17 @@
</attribute> </attribute>
</optional> </optional>
</group> </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> </choice>
<optional> <optional>
<element name="driver"> <element name="driver">
......
...@@ -347,6 +347,7 @@ VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST, ...@@ -347,6 +347,7 @@ VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST,
"ccid", "ccid",
"usb", "usb",
"pci", "pci",
"xenbus",
); );
VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST, VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST,
...@@ -2073,6 +2074,9 @@ virDomainControllerDefNew(virDomainControllerType type) ...@@ -2073,6 +2074,9 @@ virDomainControllerDefNew(virDomainControllerType type)
def->opts.pciopts.targetIndex = -1; def->opts.pciopts.targetIndex = -1;
def->opts.pciopts.numaNode = -1; def->opts.pciopts.numaNode = -1;
break; break;
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
def->opts.xenbusopts.maxGrantFrames = -1;
break;
case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
...@@ -10718,6 +10722,20 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, ...@@ -10718,6 +10722,20 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
def->opts.pciopts.numaNode = numaNode; def->opts.pciopts.numaNode = numaNode;
} }
break; 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: default:
break; break;
...@@ -24327,6 +24345,13 @@ virDomainControllerDefFormat(virBufferPtr buf, ...@@ -24327,6 +24345,13 @@ virDomainControllerDefFormat(virBufferPtr buf,
} }
break; break;
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
if (def->opts.xenbusopts.maxGrantFrames != -1) {
virBufferAsprintf(&attrBuf, " maxGrantFrames='%d'",
def->opts.xenbusopts.maxGrantFrames);
}
break;
default: default:
break; break;
} }
......
...@@ -709,6 +709,7 @@ typedef enum { ...@@ -709,6 +709,7 @@ typedef enum {
VIR_DOMAIN_CONTROLLER_TYPE_CCID, VIR_DOMAIN_CONTROLLER_TYPE_CCID,
VIR_DOMAIN_CONTROLLER_TYPE_USB, VIR_DOMAIN_CONTROLLER_TYPE_USB,
VIR_DOMAIN_CONTROLLER_TYPE_PCI, VIR_DOMAIN_CONTROLLER_TYPE_PCI,
VIR_DOMAIN_CONTROLLER_TYPE_XENBUS,
VIR_DOMAIN_CONTROLLER_TYPE_LAST VIR_DOMAIN_CONTROLLER_TYPE_LAST
} virDomainControllerType; } virDomainControllerType;
...@@ -852,6 +853,12 @@ struct _virDomainUSBControllerOpts { ...@@ -852,6 +853,12 @@ struct _virDomainUSBControllerOpts {
int ports; /* -1 == undef */ int ports; /* -1 == undef */
}; };
typedef struct _virDomainXenbusControllerOpts virDomainXenbusControllerOpts;
typedef virDomainXenbusControllerOpts *virDomainXenbusControllerOptsPtr;
struct _virDomainXenbusControllerOpts {
int maxGrantFrames; /* -1 == undef */
};
/* Stores the virtual disk controller configuration */ /* Stores the virtual disk controller configuration */
struct _virDomainControllerDef { struct _virDomainControllerDef {
int type; int type;
...@@ -866,6 +873,7 @@ struct _virDomainControllerDef { ...@@ -866,6 +873,7 @@ struct _virDomainControllerDef {
virDomainVirtioSerialOpts vioserial; virDomainVirtioSerialOpts vioserial;
virDomainPCIControllerOpts pciopts; virDomainPCIControllerOpts pciopts;
virDomainUSBControllerOpts usbopts; virDomainUSBControllerOpts usbopts;
virDomainXenbusControllerOpts xenbusopts;
} opts; } opts;
virDomainDeviceInfo info; virDomainDeviceInfo info;
virDomainVirtioOptionsPtr virtio; virDomainVirtioOptionsPtr virtio;
......
...@@ -3146,6 +3146,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, ...@@ -3146,6 +3146,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST: case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller type: %s"), _("Unsupported controller type: %s"),
......
...@@ -5867,6 +5867,7 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller, ...@@ -5867,6 +5867,7 @@ qemuDomainDeviceDefValidateController(const virDomainControllerDef *controller,
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
case VIR_DOMAIN_CONTROLLER_TYPE_CCID: case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_USB: case VIR_DOMAIN_CONTROLLER_TYPE_USB:
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST: case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
break; break;
} }
...@@ -6519,6 +6520,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, ...@@ -6519,6 +6520,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
case VIR_DOMAIN_CONTROLLER_TYPE_CCID: case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST: case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
break; break;
} }
......
...@@ -685,6 +685,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, ...@@ -685,6 +685,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_CONTROLLER_TYPE_FDC: case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_CCID: case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
case VIR_DOMAIN_CONTROLLER_TYPE_LAST: case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
/* should be 0 */ /* should be 0 */
return pciFlags; return pciFlags;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册