提交 a7b6e49d 编写于 作者: D Daniel P. Berrangé

conf: pass netprefix in the domain parser config struct

Instead of using the virCapsPtr information, pass the driver specific
netprefix in the domain parser struct. This eliminates one more use of
virCapsPtr from the XML parsing/formatting code.
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 4a4132b4
......@@ -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);
......
......@@ -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 {
......
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册