An object for storing driver-specific data related to the network
definition.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/domain_conf.c | 11 +++++++++++
src/conf/domain_conf.h | 3 +++
2 files changed, 14 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f58d354ddd..ee5fba40c9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2036,7 +2036,16 @@ virDomainNetDefNew(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED)
if (VIR_ALLOC(net) < 0)
return NULL;
+ if (xmlopt &&
+ xmlopt->privateData.netNew &&
+ !(net->privateData = xmlopt->privateData.netNew()))
+ goto error;
+
return net;
+
+ error:
+ virDomainNetDefFree(net);
+ return NULL;
}
@@ -2113,6 +2122,8 @@ virDomainNetDefClear(virDomainNetDefPtr def)
virNetDevBandwidthFree(def->bandwidth);
def->bandwidth = NULL;
virNetDevVlanClear(&def->vlan);
+ virObjectUnref(def->privateData);
+ def->privateData = NULL;
}
void
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5de058c64d..ea72d4810d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -969,6 +969,8 @@ struct _virDomainActualNetDef {
/* Stores the virtual network interface configuration */
struct _virDomainNetDef {
+ virObjectPtr privateData;
+
virDomainNetType type;
virMacAddr mac;
bool mac_generated; /* true if mac was *just now* auto-generated by libvirt */
@@ -2672,6 +2674,7 @@ struct _virDomainXMLPrivateDataCallbacks {
virDomainXMLPrivateDataNewFunc diskNew;
virDomainXMLPrivateDataNewFunc vcpuNew;
virDomainXMLPrivateDataNewFunc chrSourceNew;
+ virDomainXMLPrivateDataNewFunc netNew;
virDomainXMLPrivateDataFormatFunc format;
virDomainXMLPrivateDataParseFunc parse;
virDomainXMLPrivateDataStorageSourceParseFunc storageParse;
--
2.16.1