mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
nodedev: add <uuid> element to mdev caps
It will be useful to be able to specify a particular UUID for a mediated device when defining the node device. To accomodate that, allow this to be specified in the xml schema. This patch also parses and formats that value to the xml, but does not yet use it. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
45741a4a2d
commit
07666e292e
@ -606,27 +606,34 @@
|
|||||||
</define>
|
</define>
|
||||||
|
|
||||||
<define name="capmdev">
|
<define name="capmdev">
|
||||||
<attribute name="type">
|
<interleave>
|
||||||
<value>mdev</value>
|
<attribute name="type">
|
||||||
</attribute>
|
<value>mdev</value>
|
||||||
<element name="type">
|
|
||||||
<attribute name="id">
|
|
||||||
<data type="string"/>
|
|
||||||
</attribute>
|
</attribute>
|
||||||
</element>
|
<element name="type">
|
||||||
<optional>
|
<attribute name="id">
|
||||||
<element name="iommuGroup">
|
<data type="string"/>
|
||||||
<attribute name="number">
|
|
||||||
<ref name="unsignedInt"/>
|
|
||||||
</attribute>
|
</attribute>
|
||||||
</element>
|
</element>
|
||||||
</optional>
|
<optional>
|
||||||
<zeroOrMore>
|
<element name="iommuGroup">
|
||||||
<element name="attr">
|
<attribute name="number">
|
||||||
<attribute name="name"/>
|
<ref name="unsignedInt"/>
|
||||||
<attribute name="value"/>
|
</attribute>
|
||||||
</element>
|
</element>
|
||||||
</zeroOrMore>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<element name="uuid">
|
||||||
|
<ref name="UUID"/>
|
||||||
|
</element>
|
||||||
|
</optional>
|
||||||
|
<zeroOrMore>
|
||||||
|
<element name="attr">
|
||||||
|
<attribute name="name"/>
|
||||||
|
<attribute name="value"/>
|
||||||
|
</element>
|
||||||
|
</zeroOrMore>
|
||||||
|
</interleave>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
<define name="capccwdev">
|
<define name="capccwdev">
|
||||||
|
@ -527,6 +527,7 @@ virNodeDeviceCapMdevDefFormat(virBufferPtr buf,
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virBufferEscapeString(buf, "<type id='%s'/>\n", data->mdev.type);
|
virBufferEscapeString(buf, "<type id='%s'/>\n", data->mdev.type);
|
||||||
|
virBufferEscapeString(buf, "<uuid>%s</uuid>\n", data->mdev.uuid);
|
||||||
virBufferAsprintf(buf, "<iommuGroup number='%u'/>\n",
|
virBufferAsprintf(buf, "<iommuGroup number='%u'/>\n",
|
||||||
data->mdev.iommuGroupNumber);
|
data->mdev.iommuGroupNumber);
|
||||||
|
|
||||||
@ -1948,6 +1949,7 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt,
|
|||||||
int nattrs = 0;
|
int nattrs = 0;
|
||||||
g_autofree xmlNodePtr *attrs = NULL;
|
g_autofree xmlNodePtr *attrs = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
g_autofree char *uuidstr = NULL;
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
@ -1957,6 +1959,18 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((uuidstr = virXPathString("string(./uuid[1])", ctxt))) {
|
||||||
|
unsigned char uuidbuf[VIR_UUID_BUFLEN];
|
||||||
|
/* make sure that the provided uuid is valid */
|
||||||
|
if (virUUIDParse(uuidstr, uuidbuf) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Invalid uuid '%s' for new mdev device"), uuidstr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
mdev->uuid = g_new0(char, VIR_UUID_STRING_BUFLEN);
|
||||||
|
virUUIDFormat(uuidbuf, mdev->uuid);
|
||||||
|
}
|
||||||
|
|
||||||
/* 'iommuGroup' is optional, only report an error if the supplied value is
|
/* 'iommuGroup' is optional, only report an error if the supplied value is
|
||||||
* invalid (-2), not if it's missing (-1) */
|
* invalid (-2), not if it's missing (-1) */
|
||||||
if (virXPathUInt("number(./iommuGroup[1]/@number)",
|
if (virXPathUInt("number(./iommuGroup[1]/@number)",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<parent>0000:00:02.0</parent>
|
<parent>0000:00:02.0</parent>
|
||||||
<capability type='mdev'>
|
<capability type='mdev'>
|
||||||
<type id='i915-GVTg_V5_4'/>
|
<type id='i915-GVTg_V5_4'/>
|
||||||
|
<uuid>200f228a-c80a-4d50-bfb7-f5a0e4e34045</uuid>
|
||||||
<iommuGroup number='0'/>
|
<iommuGroup number='0'/>
|
||||||
</capability>
|
</capability>
|
||||||
</device>
|
</device>
|
||||||
@ -11,6 +12,7 @@
|
|||||||
<parent>0000:00:02.0</parent>
|
<parent>0000:00:02.0</parent>
|
||||||
<capability type='mdev'>
|
<capability type='mdev'>
|
||||||
<type id='i915-GVTg_V5_4'/>
|
<type id='i915-GVTg_V5_4'/>
|
||||||
|
<uuid>de807ffc-1923-4d5f-b6c9-b20ecebc6d4b</uuid>
|
||||||
<iommuGroup number='0'/>
|
<iommuGroup number='0'/>
|
||||||
</capability>
|
</capability>
|
||||||
</device>
|
</device>
|
||||||
@ -19,6 +21,7 @@
|
|||||||
<parent>0000:00:02.0</parent>
|
<parent>0000:00:02.0</parent>
|
||||||
<capability type='mdev'>
|
<capability type='mdev'>
|
||||||
<type id='i915-GVTg_V5_8'/>
|
<type id='i915-GVTg_V5_8'/>
|
||||||
|
<uuid>435722ea-5f43-468a-874f-da34f1217f13</uuid>
|
||||||
<iommuGroup number='0'/>
|
<iommuGroup number='0'/>
|
||||||
<attr name='testattr' value='42'/>
|
<attr name='testattr' value='42'/>
|
||||||
</capability>
|
</capability>
|
||||||
@ -28,6 +31,7 @@
|
|||||||
<parent>matrix</parent>
|
<parent>matrix</parent>
|
||||||
<capability type='mdev'>
|
<capability type='mdev'>
|
||||||
<type id='vfio_ap-passthrough'/>
|
<type id='vfio_ap-passthrough'/>
|
||||||
|
<uuid>783e6dbb-ea0e-411f-94e2-717eaad438bf</uuid>
|
||||||
<iommuGroup number='0'/>
|
<iommuGroup number='0'/>
|
||||||
<attr name='assign_adapter' value='5'/>
|
<attr name='assign_adapter' value='5'/>
|
||||||
<attr name='assign_adapter' value='6'/>
|
<attr name='assign_adapter' value='6'/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user