[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 10/23] domain-conf: add network def private data



From: Marc-André Lureau <marcandre lureau redhat com>

Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
---
 src/conf/domain_conf.c | 21 ++++++++++++++++++++-
 src/conf/domain_conf.h |  6 ++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0456369d55..fb0904177f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2454,6 +2454,7 @@ virDomainNetDefFree(virDomainNetDefPtr def)
     if (!def)
         return;
     virDomainNetDefClear(def);
+    virObjectUnref(def->privateData);
     VIR_FREE(def);
 }
 
@@ -11441,7 +11442,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
     VIR_AUTOFREE(char *) trustGuestRxFilters = NULL;
     VIR_AUTOFREE(char *) vhost_path = NULL;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainNetDefNew(xmlopt)))
         return NULL;
 
     ctxt->node = node;
@@ -14337,6 +14338,24 @@ virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt)
 }
 
 
+virDomainNetDefPtr
+virDomainNetDefNew(virDomainXMLOptionPtr xmlopt)
+{
+    virDomainNetDefPtr def = NULL;
+
+    if (VIR_ALLOC(def) < 0)
+        return NULL;
+
+    if (xmlopt && xmlopt->privateData.networkNew &&
+        !(def->privateData = xmlopt->privateData.networkNew())) {
+        VIR_FREE(def);
+        def = NULL;
+    }
+
+    return def;
+}
+
+
 /* Parse the XML definition for a graphics device */
 static virDomainGraphicsDefPtr
 virDomainGraphicsDefParseXML(virDomainXMLOptionPtr xmlopt,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 57ca2a8ad1..9bd196b53c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1018,6 +1018,7 @@ struct _virDomainNetDef {
     unsigned int mtu;
     virNetDevCoalescePtr coalesce;
     virDomainVirtioOptionsPtr virtio;
+    virObjectPtr privateData;
 };
 
 typedef enum {
@@ -2711,6 +2712,7 @@ struct _virDomainXMLPrivateDataCallbacks {
     virDomainXMLPrivateDataNewFunc    chrSourceNew;
     virDomainXMLPrivateDataNewFunc    vsockNew;
     virDomainXMLPrivateDataNewFunc    graphicsNew;
+    virDomainXMLPrivateDataNewFunc    networkNew;
     virDomainXMLPrivateDataFormatFunc format;
     virDomainXMLPrivateDataParseFunc  parse;
     /* following function shall return a pointer which will be used as the
@@ -2894,6 +2896,10 @@ virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
 
 virDomainGraphicsDefPtr
 virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlopt);
+
+virDomainNetDefPtr
+virDomainNetDefNew(virDomainXMLOptionPtr xmlopt);
+
 virDomainDefPtr virDomainDefNew(void);
 
 void virDomainObjAssignDef(virDomainObjPtr domain,
-- 
2.23.0.rc1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]