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 | 1 + src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 18 +++++++++++++- src/remote_protocol-structs | 8 ++++++ 7 files changed, 77 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-network.h b/include/libvirt/libvirt-network.h index df29aabd5f..e505c3eb7e 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 cf32912063..ee53b9f2c5 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 905072a21e..788a967df7 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -908,6 +908,7 @@ LIBVIRT_7.8.0 { virNodeDeviceGetAutostart; virNodeDeviceIsPersistent; virNodeDeviceIsActive; + 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 49afcc9924..83ea33e91b 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 9d8a66786b..296610a94d 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; }; @@ -6875,6 +6884,13 @@ enum remote_procedure { * @priority: high * @acl: node_device:read */ - REMOTE_PROC_NODE_DEVICE_IS_ACTIVE = 436 + REMOTE_PROC_NODE_DEVICE_IS_ACTIVE = 436, + /** + * @generate: both + * @priority: high + * @acl: network:write + * @acl: network:start + */ + REMOTE_PROC_NETWORK_CREATE_XML_FLAGS = 437 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 8d012dc8a0..de06895d53 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; }; @@ -3665,4 +3672,5 @@ enum remote_procedure { REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART = 434, REMOTE_PROC_NODE_DEVICE_IS_PERSISTENT = 435, REMOTE_PROC_NODE_DEVICE_IS_ACTIVE = 436, + REMOTE_PROC_NETWORK_CREATE_XML_FLAGS = 437, }; -- 2.31.1