diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9be3ef7651636c58953dfd6193e7a1a9e2407f7e..cedbe687acba321ccd67f71a0b2d01b1577c1e93 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11454,7 +11454,6 @@ static virDomainNetDefPtr virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, - char *prefix, unsigned int flags) { virDomainNetDefPtr def; @@ -11502,6 +11501,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *vhostuser_type = NULL; g_autofree char *trustGuestRxFilters = NULL; g_autofree char *vhost_path = NULL; + const char *prefix = xmlopt ? xmlopt->config.netPrefix : NULL; if (!(def = virDomainNetDefNew(xmlopt))) return NULL; @@ -16433,7 +16433,6 @@ virDomainDeviceDefParse(const char *xmlStr, xmlNodePtr node; g_autoptr(xmlXPathContext) ctxt = NULL; g_autofree virDomainDeviceDefPtr dev = NULL; - char *netprefix; if (!(xml = virXMLParseStringCtxt(xmlStr, _("(device_definition)"), &ctxt))) return NULL; @@ -16476,9 +16475,7 @@ virDomainDeviceDefParse(const char *xmlStr, return NULL; break; case VIR_DOMAIN_DEVICE_NET: - netprefix = caps->host.netprefix; - if (!(dev->data.net = virDomainNetDefParseXML(xmlopt, node, ctxt, - netprefix, flags))) + if (!(dev->data.net = virDomainNetDefParseXML(xmlopt, node, ctxt, flags))) return NULL; break; case VIR_DOMAIN_DEVICE_INPUT: @@ -19807,7 +19804,6 @@ virDomainDefParseXML(xmlDocPtr xml, bool usb_none = false; bool usb_other = false; bool usb_master = false; - char *netprefix = NULL; g_autofree xmlNodePtr *nodes = NULL; g_autofree char *tmp = NULL; @@ -20920,12 +20916,10 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; if (n && VIR_ALLOC_N(def->nets, n) < 0) goto error; - netprefix = caps->host.netprefix; for (i = 0; i < n; i++) { virDomainNetDefPtr net = virDomainNetDefParseXML(xmlopt, nodes[i], ctxt, - netprefix, flags); if (!net) goto error; @@ -25410,7 +25404,7 @@ virDomainChrSourceReconnectDefFormat(virBufferPtr buf, int virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefPtr def, - char *prefix, + virDomainXMLOptionPtr xmlopt, unsigned int flags) { virDomainNetType actualType = virDomainNetGetActualType(def); @@ -25420,6 +25414,7 @@ virDomainNetDefFormat(virBufferPtr buf, virDomainHostdevDefPtr hostdef = NULL; char macstr[VIR_MAC_STRING_BUFLEN]; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; + const char *prefix = xmlopt ? xmlopt->config.netPrefix : NULL; /* publicActual is true if we should report the current state in * def->data.network.actual *instead of* the config (*not* in @@ -28342,7 +28337,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, int virDomainDefFormatInternalSetRootName(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, - virCapsPtr caps, + virCapsPtr caps G_GNUC_UNUSED, virBufferPtr buf, const char *rootname, unsigned int flags) @@ -28352,7 +28347,6 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def, const char *type = NULL; int n; size_t i; - char *netprefix = NULL; virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS | VIR_DOMAIN_DEF_FORMAT_STATUS | @@ -28708,10 +28702,8 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def, if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) goto error; - if (caps) - netprefix = caps->host.netprefix; for (n = 0; n < def->nnets; n++) - if (virDomainNetDefFormat(buf, def->nets[n], netprefix, flags) < 0) + if (virDomainNetDefFormat(buf, def->nets[n], xmlopt, flags) < 0) goto error; for (n = 0; n < def->nsmartcards; n++) @@ -29882,7 +29874,6 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; int flags = VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_SECURE; int rc = -1; - char *netprefix; g_autofree char *xmlStr = NULL; switch ((virDomainDeviceType) src->type) { @@ -29896,8 +29887,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, rc = virDomainFSDefFormat(&buf, src->data.fs, flags); break; case VIR_DOMAIN_DEVICE_NET: - netprefix = caps->host.netprefix; - rc = virDomainNetDefFormat(&buf, src->data.net, netprefix, flags); + rc = virDomainNetDefFormat(&buf, src->data.net, xmlopt, flags); break; case VIR_DOMAIN_DEVICE_INPUT: rc = virDomainInputDefFormat(&buf, src->data.input, flags); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 462323ec76b4e861cb498a2f4da5c809d359b0b4..5a149792f3ee7437f342d0fc7124b0b85963f0b6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2706,6 +2706,7 @@ struct _virDomainDefParserConfig { unsigned int features; /* virDomainDefFeatures */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; virArch defArch; + const char *netPrefix; }; typedef void *(*virDomainXMLPrivateDataAllocFunc)(void *); @@ -3149,7 +3150,7 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, int virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefPtr def, - char *prefix, + virDomainXMLOptionPtr xmlopt, unsigned int flags); typedef enum { diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index f202f0fc3e2a27e21fa853e5063ff0249750e09c..dfac04bf597d1f6d9014b2968ce3f8957606baae 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -437,6 +437,7 @@ libxlDomainDefPostParse(virDomainDefPtr def, virDomainDefParserConfig libxlDomainDefParserConfig = { .macPrefix = { 0x00, 0x16, 0x3e }, + .netPrefix = LIBXL_GENERATED_PREFIX_XEN, .devicesPostParseCallback = libxlDomainDeviceDefPostParse, .domainPostParseCallback = libxlDomainDefPostParse, .features = VIR_DOMAIN_DEF_FEATURE_NET_MODEL_STRING,