"unassigned",
);
+
+int
+virDeviceHostdevPCIDriverInfoParseXML(xmlNodePtr node,
+ virDeviceHostdevPCIDriverInfo *driver)
+{
+ if (virXMLPropEnum(node, "name",
+ virDeviceHostdevPCIDriverNameTypeFromString,
+ VIR_XML_PROP_NONZERO,
+ &driver->name) < 0) {
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int
+virDeviceHostdevPCIDriverInfoFormat(virBuffer *buf,
+ const virDeviceHostdevPCIDriverInfo *driver)
+{
+ g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
+
+ if (driver->name != VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) {
+ const char *driverName = virDeviceHostdevPCIDriverNameTypeToString(driver->name);
+
+ if (!driverName) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected pci hostdev driver name %1$d"),
+ driver->name);
+ return -1;
+ }
+
+ virBufferAsprintf(&driverAttrBuf, " name='%s'", driverName);
+ }
+
+ virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
+ return 0;
+}
+
+
static int
virZPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddress *addr)
#include <libxml/xpath.h>
#include "internal.h"
+#include "virconftypes.h"
#include "virbuffer.h"
#include "virccw.h"
#include "virpci.h"
bool isolationGroupLocked;
};
+int virDeviceHostdevPCIDriverInfoParseXML(xmlNodePtr node,
+ virDeviceHostdevPCIDriverInfo *driver);
+
+int virDeviceHostdevPCIDriverInfoFormat(virBuffer *buf,
+ const virDeviceHostdevPCIDriverInfo *driver);
+
void virDomainDeviceInfoClear(virDomainDeviceInfo *info);
void virDomainDeviceInfoFree(virDomainDeviceInfo *info);
if (virDomainHostdevSubsysPCIDefParseXML(sourcenode, ctxt, def, flags) < 0)
return -1;
- if ((driver_node = virXPathNode("./driver", ctxt))) {
- if (virXMLPropEnum(driver_node, "name",
- virDeviceHostdevPCIDriverNameTypeFromString,
- VIR_XML_PROP_NONZERO,
- &pcisrc->driver.name) < 0) {
- return -1;
- }
+ if ((driver_node = virXPathNode("./driver", ctxt)) &&
+ virDeviceHostdevPCIDriverInfoParseXML(driver_node, &pcisrc->driver) < 0) {
+ return -1;
}
break;
unsigned int flags,
bool includeTypeInAddr)
{
- g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) sourceAttrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) sourceChildBuf = VIR_BUFFER_INIT_CHILD(buf);
virDomainHostdevSubsysPCI *pcisrc = &def->source.subsys.u.pci;
- if (pcisrc->driver.name != VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_DEFAULT) {
- const char *driverName = virDeviceHostdevPCIDriverNameTypeToString(pcisrc->driver.name);
-
- if (!driverName) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected pci hostdev driver type %1$d"),
- pcisrc->driver.name);
- return -1;
- }
-
- virBufferAsprintf(&driverAttrBuf, " name='%s'", driverName);
- }
-
- virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
+ if (virDeviceHostdevPCIDriverInfoFormat(buf, &pcisrc->driver) < 0)
+ return -1;
if (def->writeFiltering != VIR_TRISTATE_BOOL_ABSENT)
virBufferAsprintf(&sourceAttrBuf, " writeFiltering='%s'",