This new API creates network with given flags. Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- include/libvirt/libvirt-network.h | 3 +++ src/driver-network.h | 6 +++++ src/libvirt-network.c | 41 +++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 18 +++++++++++++- src/remote_protocol-structs | 8 ++++++ 7 files changed, 81 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-network.h b/include/libvirt/libvirt-network.h index 0a49c1888e..0be4d64b75 100644 --- a/include/libvirt/libvirt-network.h +++ b/include/libvirt/libvirt-network.h @@ -118,6 +118,9 @@ virNetworkPtr virNetworkLookupByUUIDString (virConnectPtr conn, */ virNetworkPtr virNetworkCreateXML (virConnectPtr conn, const char *xmlDesc); +virNetworkPtr virNetworkCreateXMLFlags(virConnectPtr conn, + const char *xmlDesc, + unsigned int flags); typedef enum { VIR_NETWORK_DEFINE_VALIDATE = 1 << 0, /* Validate the XML document against schema */ diff --git a/src/driver-network.h b/src/driver-network.h index d31d7c667d..99efd4c8aa 100644 --- a/src/driver-network.h +++ b/src/driver-network.h @@ -69,6 +69,11 @@ typedef virNetworkPtr (*virDrvNetworkCreateXML)(virConnectPtr conn, const char *xmlDesc); +typedef virNetworkPtr +(*virDrvNetworkCreateXMLFlags)(virConnectPtr conn, + const char *xmlDesc, + unsigned int flags); + typedef virNetworkPtr (*virDrvNetworkDefineXML)(virConnectPtr conn, const char *xml); @@ -176,6 +181,7 @@ struct _virNetworkDriver { virDrvNetworkLookupByUUID networkLookupByUUID; virDrvNetworkLookupByName networkLookupByName; virDrvNetworkCreateXML networkCreateXML; + virDrvNetworkCreateXMLFlags networkCreateXMLFlags; virDrvNetworkDefineXML networkDefineXML; virDrvNetworkDefineXMLFlags networkDefineXMLFlags; virDrvNetworkUndefine networkUndefine; diff --git a/src/libvirt-network.c b/src/libvirt-network.c index 5829996301..32ade1a2aa 100644 --- a/src/libvirt-network.c +++ b/src/libvirt-network.c @@ -427,6 +427,47 @@ virNetworkCreateXML(virConnectPtr conn, const char *xmlDesc) } +/** + * virNetworkCreateXMLFlags: + * @conn: pointer to the hypervisor connection + * @xmlDesc: an XML description of the network + * @flags: extra flags; not used yet, so callers should always pass 0 + * + * Create and start a new virtual network, based on an XML description + * similar to the one returned by virNetworkGetXMLDesc() + * + * virNetworkFree should be used to free the resources after the + * network object is no longer needed. + * + * Returns a new network object or NULL in case of failure + */ +virNetworkPtr +virNetworkCreateXMLFlags(virConnectPtr conn, const char *xmlDesc, unsigned int flags) +{ + VIR_DEBUG("conn=%p, xmlDesc=%s, flags=0x%x", conn, NULLSTR(xmlDesc), flags); + + virResetLastError(); + + virCheckConnectReturn(conn, NULL); + virCheckNonNullArgGoto(xmlDesc, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->networkDriver && conn->networkDriver->networkCreateXMLFlags) { + virNetworkPtr ret; + ret = conn->networkDriver->networkCreateXMLFlags(conn, xmlDesc, flags); + if (!ret) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return NULL; +} + + /** * virNetworkDefineXML: * @conn: pointer to the hypervisor connection diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 3a5fa7cb09..a5fd889ccc 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -902,4 +902,9 @@ LIBVIRT_7.7.0 { virNetworkDefineXMLFlags; } LIBVIRT_7.3.0; +LIBVIRT_7.8.0 { + global: + virNetworkCreateXMLFlags; +} LIBVIRT_7.7.0; + # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index b64a86af63..9bb796db01 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8552,6 +8552,7 @@ static virNetworkDriver network_driver = { .networkLookupByUUID = remoteNetworkLookupByUUID, /* 0.3.0 */ .networkLookupByName = remoteNetworkLookupByName, /* 0.3.0 */ .networkCreateXML = remoteNetworkCreateXML, /* 0.3.0 */ + .networkCreateXMLFlags = remoteNetworkCreateXMLFlags, /* 7.8.0 */ .networkDefineXML = remoteNetworkDefineXML, /* 0.3.0 */ .networkDefineXMLFlags = remoteNetworkDefineXMLFlags, /* 7.7.0 */ .networkUndefine = remoteNetworkUndefine, /* 0.3.0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index df1b126b0c..42a1714afb 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1530,6 +1530,15 @@ struct remote_network_create_xml_ret { remote_nonnull_network net; }; +struct remote_network_create_xml_flags_args { + remote_nonnull_string xml; + unsigned int flags; +}; + +struct remote_network_create_xml_flags_ret { + remote_nonnull_network net; +}; + struct remote_network_define_xml_args { remote_nonnull_string xml; }; @@ -6818,5 +6827,12 @@ enum remote_procedure { * @acl: network:write * @acl: network:save */ - REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432 + REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432, + + /** + * @generate: both + * @acl: network:write + * @acl: network:start + */ + REMOTE_PROC_NETWORK_CREATE_XML_FLAGS = 433 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index dad83361fa..100cdbc6b7 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1098,6 +1098,13 @@ struct remote_network_create_xml_args { struct remote_network_create_xml_ret { remote_nonnull_network net; }; +struct remote_network_create_xml_flags_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_network_create_xml_flags_ret { + remote_nonnull_network net; +}; struct remote_network_define_xml_args { remote_nonnull_string xml; }; @@ -3639,4 +3646,5 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_CREATE = 430, REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431, REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432, + REMOTE_PROC_NETWORK_CREATE_XML_FLAGS = 433, }; -- 2.31.1