def->managed = true;
}
- if ((driverNode = virXPathNode("./driver", ctxt))) {
- if (virXMLPropEnum(driverNode, "name",
- virDeviceHostdevPCIDriverNameTypeFromString,
- VIR_XML_PROP_NONZERO,
- &def->driver.name) < 0) {
+ if ((driverNode = virXPathNode("./driver", ctxt)) &&
+ virDeviceHostdevPCIDriverInfoParseXML(driverNode, &def->driver) < 0) {
return -1;
- }
}
/* bridge and hostdev modes can use a pool of physical interfaces */
if (def->forward.type != VIR_NETWORK_FORWARD_NONE) {
const char *dev = NULL;
const char *mode = virNetworkForwardTypeToString(def->forward.type);
- g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
if (!def->forward.npfs)
dev = virNetworkDefForwardIf(def, 0);
virBufferAsprintf(buf, "%s>\n", shortforward ? "/" : "");
virBufferAdjustIndent(buf, 2);
- if (def->forward.driver.name) {
- const char *driverName = virDeviceHostdevPCIDriverNameTypeToString(def->forward.driver.name);
- if (!driverName) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("unexpected hostdev driver name %1$d "),
- def->forward.driver.name);
- return -1;
- }
- virBufferAsprintf(&driverAttrBuf, " name='%s'", driverName);
- }
-
- virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
+ if (virDeviceHostdevPCIDriverInfoFormat(buf, &def->forward.driver) < 0)
+ return -1;
if (def->forward.type == VIR_NETWORK_FORWARD_NAT) {
if (virNetworkForwardNatDefFormat(buf, &def->forward) < 0)
&def->plug.hostdevpci.managed) < 0)
return NULL;
- if ((driverNode = virXPathNode("./plug/driver", ctxt))) {
- if (virXMLPropEnum(driverNode, "name",
- virDeviceHostdevPCIDriverNameTypeFromString,
- VIR_XML_PROP_NONZERO,
- &def->plug.hostdevpci.driver.name) < 0) {
- return NULL;
- }
+ if ((driverNode = virXPathNode("./plug/driver", ctxt)) &&
+ virDeviceHostdevPCIDriverInfoParseXML(driverNode,
+ &def->plug.hostdevpci.driver) < 0) {
+ return NULL;
}
if (!(addressNode = virXPathNode("./plug/address", ctxt))) {
virTristateBoolTypeToString(def->trustGuestRxFilters));
if (def->plugtype != VIR_NETWORK_PORT_PLUG_TYPE_NONE) {
- g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
virBufferAsprintf(buf, "<plug type='%s'",
virNetworkPortPlugTypeToString(def->plugtype));
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
- if (def->plug.hostdevpci.driver.name) {
- virBufferEscapeString(&driverAttrBuf, " name='%s'",
- virDeviceHostdevPCIDriverNameTypeToString(def->plug.hostdevpci.driver.name));
- }
-
- virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
+ if (virDeviceHostdevPCIDriverInfoFormat(buf, &def->plug.hostdevpci.driver) < 0)
+ return -1;
virPCIDeviceAddressFormat(buf, def->plug.hostdevpci.addr, false);
virBufferAdjustIndent(buf, -2);