mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-13 08:58:33 +03:00
conf: node_device: refactor capability mdev_types formatting
Extract the XML formatting for mdev_types from PCI capability into a generic standalone method for later reuse. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f1b08901f7
commit
9f0d3981ce
@ -207,6 +207,37 @@ virNodeDeviceCapSystemDefFormat(virBufferPtr buf,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virNodeDeviceCapMdevTypesFormat(virBufferPtr buf,
|
||||
virMediatedDeviceTypePtr *mdev_types,
|
||||
const size_t nmdev_types)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (nmdev_types > 0) {
|
||||
virBufferAddLit(buf, "<capability type='mdev_types'>\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
for (i = 0; i < nmdev_types; i++) {
|
||||
virMediatedDeviceTypePtr type = mdev_types[i];
|
||||
virBufferEscapeString(buf, "<type id='%s'>\n", type->id);
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
if (type->name)
|
||||
virBufferEscapeString(buf, "<name>%s</name>\n",
|
||||
type->name);
|
||||
virBufferEscapeString(buf, "<deviceAPI>%s</deviceAPI>\n",
|
||||
type->device_api);
|
||||
virBufferAsprintf(buf,
|
||||
"<availableInstances>%u</availableInstances>\n",
|
||||
type->available_instances);
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</type>\n");
|
||||
}
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</capability>\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
|
||||
const virNodeDevCapData *data)
|
||||
@ -277,27 +308,9 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf,
|
||||
virPCIHeaderTypeToString(data->pci_dev.hdrType));
|
||||
}
|
||||
if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) {
|
||||
if (data->pci_dev.nmdev_types > 0) {
|
||||
virBufferAddLit(buf, "<capability type='mdev_types'>\n");
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
for (i = 0; i < data->pci_dev.nmdev_types; i++) {
|
||||
virMediatedDeviceTypePtr type = data->pci_dev.mdev_types[i];
|
||||
virBufferEscapeString(buf, "<type id='%s'>\n", type->id);
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
if (type->name)
|
||||
virBufferEscapeString(buf, "<name>%s</name>\n",
|
||||
type->name);
|
||||
virBufferEscapeString(buf, "<deviceAPI>%s</deviceAPI>\n",
|
||||
type->device_api);
|
||||
virBufferAsprintf(buf,
|
||||
"<availableInstances>%u</availableInstances>\n",
|
||||
type->available_instances);
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</type>\n");
|
||||
}
|
||||
virBufferAdjustIndent(buf, -2);
|
||||
virBufferAddLit(buf, "</capability>\n");
|
||||
}
|
||||
virNodeDeviceCapMdevTypesFormat(buf,
|
||||
data->pci_dev.mdev_types,
|
||||
data->pci_dev.nmdev_types);
|
||||
}
|
||||
if (data->pci_dev.nIommuGroupDevices) {
|
||||
virBufferAsprintf(buf, "<iommuGroup number='%d'>\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user