From patchwork Mon Jul 15 00:03:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 168976 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3689363ilk; Sun, 14 Jul 2019 17:05:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbzIEcCigyAc1oetvvtMkI39TPdGkxWz+JKs4KPf0bxz6sRbQpe/G8d3PRFmYL5viDRhXg X-Received: by 2002:ac8:2f66:: with SMTP id k35mr15749710qta.174.1563149113735; Sun, 14 Jul 2019 17:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563149113; cv=none; d=google.com; s=arc-20160816; b=y2f+9IM4bMT/2AIjMPJRCVZJVzkhjqFpT9MWr6P0Ng9D2vIviJZX7kdpeahdVsqyfn 62fui89gOno9xlS5kp0wYptkS/FLOXZkMQYajPP6eqYjytv7D5Lk/adXk3/ADnmX7XYE bazKXZSqJeD3aet7mEgS0igBVIjt2Fg9RSJCSj89q4GlwARaiEKbNjQhlXh6PRJlrkBn //XV7vNKHFGd2W0/+giP/7Zjd4jefgc9vRoXuAgbyaNXDIvOGS8C6a86yix2M0zCxzkS kTGqQW0r4GKzVxM6f9iVXouStJbeOQFmGmmh9K2RprRHqRZyNG2G5KkDdV+FIUd9A4zd fymg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=A9IZBuWze29LPjtjzD9HhzyL0Q3EGF10OjZrFWvYUNA=; b=kmbq7Wgr9OlSrBmqnxdfzUIChjvuBC593yu9S0css86gsfrstGURCfq05pJgaTL/mW wstM/h6Wh1tA1fzYK5uK96NSB7S477XIHoSJnPAGcah6usT3BWEMaCCjYXL8YnIJx7pM Kg0k+JC5zcKvsiEEdI0uennSJijTaPOVUfhlnlwvL8iG80R3p9vt4qLzJmzCzFYWZUR7 BFNdlUXtDx02zoIYIxD7V+ee65VRt+I9dYDyWqx4OaHB8fhqV4cebxyrV6O4RUw/+AIX 2Ed2+OCxpb/Sxca5FjqvUA/AOSbWXlwCo9lFvoh2ggLEyperHrzb/ARn9vXEPHGMZf2A NvDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id t8si10080119qtq.119.2019.07.14.17.05.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jul 2019 17:05:13 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B51F308A9E0; Mon, 15 Jul 2019 00:05:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12F3F5D9DE; Mon, 15 Jul 2019 00:05:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C2F8F18184A5; Mon, 15 Jul 2019 00:05:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6F04HV0030300 for ; Sun, 14 Jul 2019 20:04:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDF4B60C44; Mon, 15 Jul 2019 00:04:17 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-121-2.rdu2.redhat.com [10.10.121.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FA5E60BFB; Mon, 15 Jul 2019 00:04:17 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Sun, 14 Jul 2019 20:03:58 -0400 Message-Id: <02c594154833b5ad79fd0883f5ab84f6b648c4aa.1563148979.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] conf: Add network xmlopt argument X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 15 Jul 2019 00:05:12 +0000 (UTC) Pass an xmlopt argument through all the needed network conf functions, like is done for domain XML handling. No functional change for now Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 2 +- src/conf/network_conf.c | 40 +++++++++++++++---------- src/conf/network_conf.h | 21 ++++++++++---- src/conf/virnetworkobj.c | 50 ++++++++++++++++++++------------ src/conf/virnetworkobj.h | 13 ++++++--- src/esx/esx_network_driver.c | 4 +-- src/network/bridge_driver.c | 46 ++++++++++++++++++----------- src/qemu/qemu_process.c | 2 +- src/test/test_driver.c | 11 +++---- src/vbox/vbox_network.c | 4 +-- tests/networkxml2conftest.c | 2 +- tests/networkxml2firewalltest.c | 2 +- tests/networkxml2xmltest.c | 4 +-- tests/networkxml2xmlupdatetest.c | 4 +-- 14 files changed, 128 insertions(+), 77 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3323c9a5b1..740da645c4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30932,7 +30932,7 @@ virDomainNetResolveActualType(virDomainNetDefPtr iface) if (!(xml = virNetworkGetXMLDesc(net, 0))) goto cleanup; - if (!(def = virNetworkDefParseString(xml))) + if (!(def = virNetworkDefParseString(xml, NULL))) goto cleanup; switch ((virNetworkForwardType) def->forward.type) { diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index ca4b9986ad..067adf7936 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -282,7 +282,9 @@ virNetworkDefFree(virNetworkDefPtr def) * Returns a new NetworkDef on success, or NULL on failure. */ virNetworkDefPtr -virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags) +virNetworkDefCopy(virNetworkDefPtr def, + virNetworkXMLOptionPtr xmlopt, + unsigned int flags) { char *xml = NULL; virNetworkDefPtr newDef = NULL; @@ -294,9 +296,9 @@ virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags) } /* deep copy with a format/parse cycle */ - if (!(xml = virNetworkDefFormat(def, flags))) + if (!(xml = virNetworkDefFormat(def, xmlopt, flags))) goto cleanup; - newDef = virNetworkDefParseString(xml); + newDef = virNetworkDefParseString(xml, xmlopt); cleanup: VIR_FREE(xml); return newDef; @@ -1619,7 +1621,8 @@ virNetworkForwardDefParseXML(const char *networkName, virNetworkDefPtr -virNetworkDefParseXML(xmlXPathContextPtr ctxt) +virNetworkDefParseXML(xmlXPathContextPtr ctxt, + virNetworkXMLOptionPtr xmlopt ATTRIBUTE_UNUSED) { virNetworkDefPtr def; char *tmp = NULL; @@ -2059,14 +2062,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) static virNetworkDefPtr virNetworkDefParse(const char *xmlStr, - const char *filename) + const char *filename, + virNetworkXMLOptionPtr xmlopt) { xmlDocPtr xml; virNetworkDefPtr def = NULL; int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParse(filename, xmlStr, _("(network_definition)")))) { - def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml)); + def = virNetworkDefParseNode(xml, xmlDocGetRootElement(xml), xmlopt); xmlFreeDoc(xml); } @@ -2076,22 +2080,25 @@ virNetworkDefParse(const char *xmlStr, virNetworkDefPtr -virNetworkDefParseString(const char *xmlStr) +virNetworkDefParseString(const char *xmlStr, + virNetworkXMLOptionPtr xmlopt) { - return virNetworkDefParse(xmlStr, NULL); + return virNetworkDefParse(xmlStr, NULL, xmlopt); } virNetworkDefPtr -virNetworkDefParseFile(const char *filename) +virNetworkDefParseFile(const char *filename, + virNetworkXMLOptionPtr xmlopt) { - return virNetworkDefParse(NULL, filename); + return virNetworkDefParse(NULL, filename, xmlopt); } virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml, - xmlNodePtr root) + xmlNodePtr root, + virNetworkXMLOptionPtr xmlopt) { xmlXPathContextPtr ctxt = NULL; virNetworkDefPtr def = NULL; @@ -2111,7 +2118,7 @@ virNetworkDefParseNode(xmlDocPtr xml, } ctxt->node = root; - def = virNetworkDefParseXML(ctxt); + def = virNetworkDefParseXML(ctxt, xmlopt); cleanup: xmlXPathFreeContext(ctxt); @@ -2405,6 +2412,7 @@ virNetworkForwardNatDefFormat(virBufferPtr buf, int virNetworkDefFormatBuf(virBufferPtr buf, const virNetworkDef *def, + virNetworkXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, unsigned int flags) { const unsigned char *uuid; @@ -2631,11 +2639,12 @@ virNetworkDefFormatBuf(virBufferPtr buf, char * virNetworkDefFormat(const virNetworkDef *def, + virNetworkXMLOptionPtr xmlopt, unsigned int flags) { virBuffer buf = VIR_BUFFER_INITIALIZER; - if (virNetworkDefFormatBuf(&buf, def, flags) < 0) + if (virNetworkDefFormatBuf(&buf, def, xmlopt, flags) < 0) goto error; if (virBufferCheckError(&buf) < 0) @@ -2709,12 +2718,13 @@ virNetworkSaveXML(const char *configDir, int virNetworkSaveConfig(const char *configDir, - virNetworkDefPtr def) + virNetworkDefPtr def, + virNetworkXMLOptionPtr xmlopt) { int ret = -1; char *xml; - if (!(xml = virNetworkDefFormat(def, VIR_NETWORK_XML_INACTIVE))) + if (!(xml = virNetworkDefFormat(def, xmlopt, VIR_NETWORK_XML_INACTIVE))) goto cleanup; if (virNetworkSaveXML(configDir, def, xml)) diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index edd9f51f44..b7ce569d4a 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -301,28 +301,36 @@ virNetworkXMLOptionPtr virNetworkXMLOptionNew(void); virNetworkDefPtr -virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags); +virNetworkDefCopy(virNetworkDefPtr def, + virNetworkXMLOptionPtr xmlopt, + unsigned int flags); virNetworkDefPtr -virNetworkDefParseXML(xmlXPathContextPtr ctxt); +virNetworkDefParseXML(xmlXPathContextPtr ctxt, + virNetworkXMLOptionPtr xmlopt); virNetworkDefPtr -virNetworkDefParseString(const char *xmlStr); +virNetworkDefParseString(const char *xmlStr, + virNetworkXMLOptionPtr xmlopt); virNetworkDefPtr -virNetworkDefParseFile(const char *filename); +virNetworkDefParseFile(const char *filename, + virNetworkXMLOptionPtr xmlopt); virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml, - xmlNodePtr root); + xmlNodePtr root, + virNetworkXMLOptionPtr xmlopt); char * virNetworkDefFormat(const virNetworkDef *def, + virNetworkXMLOptionPtr xmlopt, unsigned int flags); int virNetworkDefFormatBuf(virBufferPtr buf, const virNetworkDef *def, + virNetworkXMLOptionPtr xmlopt, unsigned int flags); const char * @@ -357,7 +365,8 @@ virNetworkSaveXML(const char *configDir, int virNetworkSaveConfig(const char *configDir, - virNetworkDefPtr def); + virNetworkDefPtr def, + virNetworkXMLOptionPtr xmlopt); char * virNetworkConfigFile(const char *dir, diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 476f66affc..d63ead7fac 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -673,7 +673,8 @@ virNetworkObjAssignDef(virNetworkObjListPtr nets, */ int virNetworkObjSetDefTransient(virNetworkObjPtr obj, - bool live) + bool live, + virNetworkXMLOptionPtr xmlopt) { if (!virNetworkObjIsActive(obj) && !live) return 0; @@ -681,7 +682,9 @@ virNetworkObjSetDefTransient(virNetworkObjPtr obj, if (!obj->persistent || obj->newDef) return 0; - obj->newDef = virNetworkDefCopy(obj->def, VIR_NETWORK_XML_INACTIVE); + obj->newDef = virNetworkDefCopy(obj->def, + xmlopt, + VIR_NETWORK_XML_INACTIVE); return obj->newDef ? 0 : -1; } @@ -759,6 +762,7 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr obj, */ static int virNetworkObjConfigChangeSetup(virNetworkObjPtr obj, + virNetworkXMLOptionPtr xmlopt, unsigned int flags) { bool isActive; @@ -782,7 +786,7 @@ virNetworkObjConfigChangeSetup(virNetworkObjPtr obj, /* this should already have been done by the driver, but do it * anyway just in case. */ - if (isActive && (virNetworkObjSetDefTransient(obj, false) < 0)) + if (isActive && (virNetworkObjSetDefTransient(obj, false, xmlopt) < 0)) goto cleanup; } @@ -811,6 +815,7 @@ virNetworkObjRemoveInactive(virNetworkObjListPtr nets, static char * virNetworkObjFormat(virNetworkObjPtr obj, + virNetworkXMLOptionPtr xmlopt, unsigned int flags) { virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -832,7 +837,7 @@ virNetworkObjFormat(virNetworkObjPtr obj, virNetworkTaintTypeToString(i)); } - if (virNetworkDefFormatBuf(&buf, obj->def, flags) < 0) + if (virNetworkDefFormatBuf(&buf, obj->def, xmlopt, flags) < 0) goto error; virBufferAdjustIndent(&buf, -2); @@ -851,13 +856,14 @@ virNetworkObjFormat(virNetworkObjPtr obj, int virNetworkObjSaveStatus(const char *statusDir, - virNetworkObjPtr obj) + virNetworkObjPtr obj, + virNetworkXMLOptionPtr xmlopt) { int ret = -1; int flags = 0; char *xml; - if (!(xml = virNetworkObjFormat(obj, flags))) + if (!(xml = virNetworkObjFormat(obj, xmlopt, flags))) goto cleanup; if (virNetworkSaveXML(statusDir, obj->def, xml)) @@ -873,7 +879,8 @@ virNetworkObjSaveStatus(const char *statusDir, static virNetworkObjPtr virNetworkLoadState(virNetworkObjListPtr nets, const char *stateDir, - const char *name) + const char *name, + virNetworkXMLOptionPtr xmlopt) { char *configFile = NULL; virNetworkDefPtr def = NULL; @@ -902,7 +909,7 @@ virNetworkLoadState(virNetworkObjListPtr nets, /* parse the definition first */ ctxt->node = node; - if (!(def = virNetworkDefParseXML(ctxt))) + if (!(def = virNetworkDefParseXML(ctxt, xmlopt))) goto error; if (STRNEQ(name, def->name)) { @@ -1000,7 +1007,8 @@ static virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets, const char *configDir, const char *autostartDir, - const char *name) + const char *name, + virNetworkXMLOptionPtr xmlopt) { char *configFile = NULL, *autostartLink = NULL; virNetworkDefPtr def = NULL; @@ -1015,7 +1023,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets, if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; - if (!(def = virNetworkDefParseFile(configFile))) + if (!(def = virNetworkDefParseFile(configFile, xmlopt))) goto error; if (STRNEQ(name, def->name)) { @@ -1033,7 +1041,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets, case VIR_NETWORK_FORWARD_OPEN: if (!def->mac_specified) { virNetworkSetBridgeMacAddr(def); - virNetworkSaveConfig(configDir, def); + virNetworkSaveConfig(configDir, def, xmlopt); } break; @@ -1073,7 +1081,8 @@ virNetworkLoadConfig(virNetworkObjListPtr nets, int virNetworkObjLoadAllState(virNetworkObjListPtr nets, - const char *stateDir) + const char *stateDir, + virNetworkXMLOptionPtr xmlopt) { DIR *dir; struct dirent *entry; @@ -1089,7 +1098,7 @@ virNetworkObjLoadAllState(virNetworkObjListPtr nets, if (!virStringStripSuffix(entry->d_name, ".xml")) continue; - obj = virNetworkLoadState(nets, stateDir, entry->d_name); + obj = virNetworkLoadState(nets, stateDir, entry->d_name, xmlopt); if (obj && virNetworkObjLoadAllPorts(obj, stateDir) < 0) { @@ -1108,7 +1117,8 @@ virNetworkObjLoadAllState(virNetworkObjListPtr nets, int virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets, const char *configDir, - const char *autostartDir) + const char *autostartDir, + virNetworkXMLOptionPtr xmlopt) { DIR *dir; struct dirent *entry; @@ -1129,7 +1139,8 @@ virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets, obj = virNetworkLoadConfig(nets, configDir, autostartDir, - entry->d_name); + entry->d_name, + xmlopt); virNetworkObjEndAPI(&obj); } @@ -1239,20 +1250,21 @@ virNetworkObjUpdate(virNetworkObjPtr obj, unsigned int section, /* virNetworkUpdateSection */ int parentIndex, const char *xml, + virNetworkXMLOptionPtr xmlopt, unsigned int flags) /* virNetworkUpdateFlags */ { int ret = -1; virNetworkDefPtr livedef = NULL, configdef = NULL; /* normalize config data, and check for common invalid requests. */ - if (virNetworkObjConfigChangeSetup(obj, flags) < 0) + if (virNetworkObjConfigChangeSetup(obj, xmlopt, flags) < 0) goto cleanup; if (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE) { virNetworkDefPtr checkdef; /* work on a copy of the def */ - if (!(livedef = virNetworkDefCopy(obj->def, 0))) + if (!(livedef = virNetworkDefCopy(obj->def, xmlopt, 0))) goto cleanup; if (virNetworkDefUpdateSection(livedef, command, section, parentIndex, xml, flags) < 0) { @@ -1261,7 +1273,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, /* run a final format/parse cycle to make sure we didn't * add anything illegal to the def */ - if (!(checkdef = virNetworkDefCopy(livedef, 0))) + if (!(checkdef = virNetworkDefCopy(livedef, xmlopt, 0))) goto cleanup; virNetworkDefFree(checkdef); } @@ -1271,6 +1283,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, /* work on a copy of the def */ if (!(configdef = virNetworkDefCopy(virNetworkObjGetPersistentDef(obj), + xmlopt, VIR_NETWORK_XML_INACTIVE))) { goto cleanup; } @@ -1279,6 +1292,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, goto cleanup; } if (!(checkdef = virNetworkDefCopy(configdef, + xmlopt, VIR_NETWORK_XML_INACTIVE))) { goto cleanup; } diff --git a/src/conf/virnetworkobj.h b/src/conf/virnetworkobj.h index e649b6b350..1c28f0888c 100644 --- a/src/conf/virnetworkobj.h +++ b/src/conf/virnetworkobj.h @@ -140,7 +140,8 @@ virNetworkObjUpdateAssignDef(virNetworkObjPtr network, int virNetworkObjSetDefTransient(virNetworkObjPtr network, - bool live); + bool live, + virNetworkXMLOptionPtr xmlopt); void virNetworkObjUnsetDefTransient(virNetworkObjPtr network); @@ -191,16 +192,19 @@ virNetworkObjPortListExport(virNetworkPtr net, int virNetworkObjSaveStatus(const char *statusDir, - virNetworkObjPtr net) ATTRIBUTE_RETURN_CHECK; + virNetworkObjPtr net, + virNetworkXMLOptionPtr xmlopt) ATTRIBUTE_RETURN_CHECK; int virNetworkObjLoadAllConfigs(virNetworkObjListPtr nets, const char *configDir, - const char *autostartDir); + const char *autostartDir, + virNetworkXMLOptionPtr xmlopt); int virNetworkObjLoadAllState(virNetworkObjListPtr nets, - const char *stateDir); + const char *stateDir, + virNetworkXMLOptionPtr xmlopt); int virNetworkObjDeleteConfig(const char *configDir, @@ -218,6 +222,7 @@ virNetworkObjUpdate(virNetworkObjPtr obj, unsigned int section, /* virNetworkUpdateSection */ int parentIndex, const char *xml, + virNetworkXMLOptionPtr xmlopt, unsigned int flags); /* virNetworkUpdateFlags */ int diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index 31bceb7bff..40bd5c2168 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -298,7 +298,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) return NULL; /* Parse network XML */ - def = virNetworkDefParseString(xml); + def = virNetworkDefParseString(xml, NULL); if (!def) return NULL; @@ -806,7 +806,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) } } - xml = virNetworkDefFormat(def, flags); + xml = virNetworkDefFormat(def, NULL, flags); cleanup: esxVI_HostVirtualSwitch_Free(&hostVirtualSwitch); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 5be6f1ba45..3353754eb5 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -231,7 +231,7 @@ networkRunHook(virNetworkObjPtr obj, virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); - if (virNetworkDefFormatBuf(&buf, def, 0) < 0) + if (virNetworkDefFormatBuf(&buf, def, network_driver->xmlopt, 0) < 0) goto cleanup; if (port && virNetworkPortDefFormatBuf(&buf, port) < 0) goto cleanup; @@ -673,12 +673,14 @@ networkStateInitialize(bool privileged, goto error; if (virNetworkObjLoadAllState(network_driver->networks, - network_driver->stateDir) < 0) + network_driver->stateDir, + network_driver->xmlopt) < 0) goto error; if (virNetworkObjLoadAllConfigs(network_driver->networks, network_driver->networkConfigDir, - network_driver->networkAutostartDir) < 0) + network_driver->networkAutostartDir, + network_driver->xmlopt) < 0) goto error; /* Update the internal status of all allegedly active @@ -750,10 +752,12 @@ networkStateReload(void) return 0; virNetworkObjLoadAllState(network_driver->networks, - network_driver->stateDir); + network_driver->stateDir, + network_driver->xmlopt); virNetworkObjLoadAllConfigs(network_driver->networks, network_driver->networkConfigDir, - network_driver->networkAutostartDir); + network_driver->networkAutostartDir, + network_driver->xmlopt); networkReloadFirewallRules(network_driver, false); networkRefreshDaemons(network_driver); virNetworkObjListForEach(network_driver->networks, @@ -2789,7 +2793,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver, virNetworkObjDeleteAllPorts(obj, driver->stateDir); VIR_DEBUG("Setting current network def as transient"); - if (virNetworkObjSetDefTransient(obj, true) < 0) + if (virNetworkObjSetDefTransient(obj, true, network_driver->xmlopt) < 0) goto cleanup; /* Run an early hook to set-up missing devices. @@ -2847,7 +2851,8 @@ networkStartNetwork(virNetworkDriverStatePtr driver, * is setup. */ VIR_DEBUG("Writing network status to disk"); - if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) + if (virNetworkObjSaveStatus(driver->stateDir, + obj, network_driver->xmlopt) < 0) goto cleanup; virNetworkObjSetActive(obj, true); @@ -3563,7 +3568,7 @@ networkCreateXML(virConnectPtr conn, virNetworkPtr net = NULL; virObjectEventPtr event = NULL; - if (!(newDef = virNetworkDefParseString(xml))) + if (!(newDef = virNetworkDefParseString(xml, network_driver->xmlopt))) goto cleanup; if (virNetworkCreateXMLEnsureACL(conn, newDef) < 0) @@ -3615,7 +3620,7 @@ networkDefineXML(virConnectPtr conn, virNetworkPtr net = NULL; virObjectEventPtr event = NULL; - if (!(def = virNetworkDefParseString(xml))) + if (!(def = virNetworkDefParseString(xml, network_driver->xmlopt))) goto cleanup; if (virNetworkDefineXMLEnsureACL(conn, def) < 0) @@ -3630,7 +3635,8 @@ networkDefineXML(virConnectPtr conn, /* def was assigned to network object */ freeDef = false; - if (virNetworkSaveConfig(driver->networkConfigDir, def) < 0) { + if (virNetworkSaveConfig(driver->networkConfigDir, + def, network_driver->xmlopt) < 0) { if (!virNetworkObjIsActive(obj)) { virNetworkObjRemoveInactive(driver->networks, obj); goto cleanup; @@ -3811,7 +3817,9 @@ networkUpdate(virNetworkPtr net, } /* update the network config in memory/on disk */ - if (virNetworkObjUpdate(obj, command, section, parentIndex, xml, flags) < 0) { + if (virNetworkObjUpdate(obj, command, section, + parentIndex, xml, + network_driver->xmlopt, flags) < 0) { if (needFirewallRefresh) ignore_value(networkAddFirewallRules(def)); goto cleanup; @@ -3826,7 +3834,8 @@ networkUpdate(virNetworkPtr net, if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) { /* save updated persistent config to disk */ if (virNetworkSaveConfig(driver->networkConfigDir, - virNetworkObjGetPersistentDef(obj)) < 0) { + virNetworkObjGetPersistentDef(obj), + network_driver->xmlopt) < 0) { goto cleanup; } } @@ -3893,7 +3902,8 @@ networkUpdate(virNetworkPtr net, } /* save current network state to disk */ - if ((ret = virNetworkObjSaveStatus(driver->stateDir, obj)) < 0) + if ((ret = virNetworkObjSaveStatus(driver->stateDir, + obj, network_driver->xmlopt)) < 0) goto cleanup; } @@ -4014,7 +4024,7 @@ networkGetXMLDesc(virNetworkPtr net, else curDef = def; - ret = virNetworkDefFormat(curDef, flags); + ret = virNetworkDefFormat(curDef, network_driver->xmlopt, flags); cleanup: virNetworkObjEndAPI(&obj); @@ -5153,7 +5163,7 @@ networkPlugBandwidthImpl(virNetworkObjPtr obj, tmp_floor_sum += ifaceBand->in->floor; virNetworkObjSetFloorSum(obj, tmp_floor_sum); /* update status file */ - if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { + if (virNetworkObjSaveStatus(driver->stateDir, obj, network_driver->xmlopt) < 0) { ignore_value(virBitmapClearBit(classIdMap, next_id)); tmp_floor_sum -= ifaceBand->in->floor; virNetworkObjSetFloorSum(obj, tmp_floor_sum); @@ -5243,7 +5253,8 @@ networkUnplugBandwidth(virNetworkObjPtr obj, /* return class ID */ ignore_value(virBitmapClearBit(classIdMap, *class_id)); /* update status file */ - if (virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { + if (virNetworkObjSaveStatus(driver->stateDir, + obj, network_driver->xmlopt) < 0) { tmp_floor_sum += ifaceBand->in->floor; virNetworkObjSetFloorSum(obj, tmp_floor_sum); ignore_value(virBitmapSetBit(classIdMap, *class_id)); @@ -5337,7 +5348,8 @@ networkUpdatePortBandwidth(virNetworkObjPtr obj, if (virNetDevBandwidthUpdateRate(def->bridge, 2, def->bandwidth, new_rate) < 0 || - virNetworkObjSaveStatus(driver->stateDir, obj) < 0) { + virNetworkObjSaveStatus(driver->stateDir, + obj, network_driver->xmlopt) < 0) { /* Ouch, rollback */ tmp_floor_sum -= newBandwidth->in->floor; tmp_floor_sum += oldBandwidth->in->floor; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index aa09ef175a..746d701640 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4713,7 +4713,7 @@ qemuProcessGetNetworkAddress(const char *netname, if (!xml) goto cleanup; - netdef = virNetworkDefParseString(xml); + netdef = virNetworkDefParseString(xml, NULL); if (!netdef) goto cleanup; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index c10344f6cd..dff384392e 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -971,7 +971,7 @@ testParseNetworks(testDriverPtr privconn, if (!node) return -1; - def = virNetworkDefParseNode(ctxt->doc, node); + def = virNetworkDefParseNode(ctxt->doc, node, NULL); if (!def) return -1; @@ -4148,7 +4148,7 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml) virNetworkPtr net = NULL; virObjectEventPtr event = NULL; - if ((newDef = virNetworkDefParseString(xml)) == NULL) + if ((newDef = virNetworkDefParseString(xml, NULL)) == NULL) goto cleanup; if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, @@ -4184,7 +4184,7 @@ testNetworkDefineXML(virConnectPtr conn, virNetworkPtr net = NULL; virObjectEventPtr event = NULL; - if ((newDef = virNetworkDefParseString(xml)) == NULL) + if ((newDef = virNetworkDefParseString(xml, NULL)) == NULL) goto cleanup; if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, 0))) @@ -4270,7 +4270,8 @@ testNetworkUpdate(virNetworkPtr net, } /* update the network config in memory/on disk */ - if (virNetworkObjUpdate(obj, command, section, parentIndex, xml, flags) < 0) + if (virNetworkObjUpdate(obj, command, section, + parentIndex, xml, NULL, flags) < 0) goto cleanup; ret = 0; @@ -4354,7 +4355,7 @@ testNetworkGetXMLDesc(virNetworkPtr net, if (!(obj = testNetworkObjFindByName(privconn, net->name))) goto cleanup; - ret = virNetworkDefFormat(virNetworkObjGetDef(obj), flags); + ret = virNetworkDefFormat(virNetworkObjGetDef(obj), NULL, flags); cleanup: virNetworkObjEndAPI(&obj); diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 7326ae7d07..814f27155f 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -375,7 +375,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const char *xml, bool start) PRUnichar *networkNameUtf16 = NULL; char *networkNameUtf8 = NULL; IHostNetworkInterface *networkInterface = NULL; - virNetworkDefPtr def = virNetworkDefParseString(xml); + virNetworkDefPtr def = virNetworkDefParseString(xml, NULL); virNetworkIPDefPtr ipdef = NULL; unsigned char uuid[VIR_UUID_BUFLEN]; vboxIID vboxnetiid; @@ -911,7 +911,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) } DEBUGIID("Network UUID", &vboxnet0IID); - ret = virNetworkDefFormat(def, 0); + ret = virNetworkDefFormat(def, NULL, 0); cleanup: vboxIIDUnalloc(&vboxnet0IID); diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index bf9675838d..c445551099 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -26,7 +26,7 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr char *pidfile = NULL; dnsmasqContext *dctx = NULL; - if (!(def = virNetworkDefParseFile(inxml))) + if (!(def = virNetworkDefParseFile(inxml, NULL))) goto fail; if (!(obj = virNetworkObjNew())) diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c index c25282ebb1..78844085a0 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -70,7 +70,7 @@ static int testCompareXMLToArgvFiles(const char *xml, virCommandSetDryRun(&buf, testCommandDryRun, NULL); - if (!(def = virNetworkDefParseFile(xml))) + if (!(def = virNetworkDefParseFile(xml, NULL))) goto cleanup; if (networkAddFirewallRules(def) < 0) diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index b19a365ff4..cd76ce5375 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -30,14 +30,14 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS; virNetworkDefPtr dev = NULL; - if (!(dev = virNetworkDefParseFile(inxml))) { + if (!(dev = virNetworkDefParseFile(inxml, NULL))) { result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE; goto cleanup; } if (expectResult == TEST_COMPARE_NET_XML2XML_RESULT_FAIL_PARSE) goto cleanup; - if (!(actual = virNetworkDefFormat(dev, flags))) { + if (!(actual = virNetworkDefFormat(dev, NULL, flags))) { result = TEST_COMPARE_NET_XML2XML_RESULT_FAIL_FORMAT; goto cleanup; } diff --git a/tests/networkxml2xmlupdatetest.c b/tests/networkxml2xmlupdatetest.c index 46cb4c2f0b..69c19e800d 100644 --- a/tests/networkxml2xmlupdatetest.c +++ b/tests/networkxml2xmlupdatetest.c @@ -27,14 +27,14 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml, if (virTestLoadFile(updatexml, &updateXmlData) < 0) goto error; - if (!(def = virNetworkDefParseFile(netxml))) + if (!(def = virNetworkDefParseFile(netxml, NULL))) goto fail; if (virNetworkDefUpdateSection(def, command, section, parentIndex, updateXmlData, 0) < 0) goto fail; - if (!(actual = virNetworkDefFormat(def, flags))) + if (!(actual = virNetworkDefFormat(def, NULL, flags))) goto fail; if (!expectFailure) {