mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
api: add public virNetworkDefineXMLFlags() and remote protocol
This new API allows to define network with given flags. Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
59281d9dc7
commit
8105fbe8e6
@ -124,6 +124,9 @@ virNetworkPtr virNetworkCreateXML (virConnectPtr conn,
|
||||
*/
|
||||
virNetworkPtr virNetworkDefineXML (virConnectPtr conn,
|
||||
const char *xmlDesc);
|
||||
virNetworkPtr virNetworkDefineXMLFlags(virConnectPtr conn,
|
||||
const char *xmlDesc,
|
||||
unsigned int flags);
|
||||
|
||||
/*
|
||||
* Delete persistent network
|
||||
|
@ -73,6 +73,11 @@ typedef virNetworkPtr
|
||||
(*virDrvNetworkDefineXML)(virConnectPtr conn,
|
||||
const char *xml);
|
||||
|
||||
typedef virNetworkPtr
|
||||
(*virDrvNetworkDefineXMLFlags)(virConnectPtr conn,
|
||||
const char *xml,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvNetworkUndefine)(virNetworkPtr network);
|
||||
|
||||
@ -172,6 +177,7 @@ struct _virNetworkDriver {
|
||||
virDrvNetworkLookupByName networkLookupByName;
|
||||
virDrvNetworkCreateXML networkCreateXML;
|
||||
virDrvNetworkDefineXML networkDefineXML;
|
||||
virDrvNetworkDefineXMLFlags networkDefineXMLFlags;
|
||||
virDrvNetworkUndefine networkUndefine;
|
||||
virDrvNetworkUpdate networkUpdate;
|
||||
virDrvNetworkCreate networkCreate;
|
||||
|
@ -465,6 +465,47 @@ virNetworkDefineXML(virConnectPtr conn, const char *xml)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virNetworkDefineXMLFlags:
|
||||
* @conn: pointer to the hypervisor connection
|
||||
* @xml: the XML description for the network, preferably in UTF-8
|
||||
* @flags: extra flags; not used yet, so callers should always pass 0
|
||||
*
|
||||
* Define an inactive persistent virtual network or modify an existing
|
||||
* persistent one from the XML description.
|
||||
*
|
||||
* virNetworkFree should be used to free the resources after the
|
||||
* network object is no longer needed.
|
||||
*
|
||||
* Returns NULL in case of error, a pointer to the network otherwise
|
||||
*/
|
||||
virNetworkPtr
|
||||
virNetworkDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
|
||||
{
|
||||
VIR_DEBUG("conn=%p, xml=%s, flags=0x%x", conn, NULLSTR(xml), flags);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckConnectReturn(conn, NULL);
|
||||
virCheckReadOnlyGoto(conn->flags, error);
|
||||
virCheckNonNullArgGoto(xml, error);
|
||||
|
||||
if (conn->networkDriver && conn->networkDriver->networkDefineXMLFlags) {
|
||||
virNetworkPtr ret;
|
||||
ret = conn->networkDriver->networkDefineXMLFlags(conn, xml, flags);
|
||||
if (!ret)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
|
||||
error:
|
||||
virDispatchError(conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virNetworkUndefine:
|
||||
* @network: pointer to a defined network
|
||||
|
@ -899,6 +899,7 @@ LIBVIRT_7.3.0 {
|
||||
LIBVIRT_7.7.0 {
|
||||
global:
|
||||
virNWFilterDefineXMLFlags;
|
||||
virNetworkDefineXMLFlags;
|
||||
} LIBVIRT_7.3.0;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
@ -8553,6 +8553,7 @@ static virNetworkDriver network_driver = {
|
||||
.networkLookupByName = remoteNetworkLookupByName, /* 0.3.0 */
|
||||
.networkCreateXML = remoteNetworkCreateXML, /* 0.3.0 */
|
||||
.networkDefineXML = remoteNetworkDefineXML, /* 0.3.0 */
|
||||
.networkDefineXMLFlags = remoteNetworkDefineXMLFlags, /* 7.7.0 */
|
||||
.networkUndefine = remoteNetworkUndefine, /* 0.3.0 */
|
||||
.networkUpdate = remoteNetworkUpdate, /* 0.10.2 */
|
||||
.networkCreate = remoteNetworkCreate, /* 0.3.0 */
|
||||
|
@ -1538,6 +1538,15 @@ struct remote_network_define_xml_ret {
|
||||
remote_nonnull_network net;
|
||||
};
|
||||
|
||||
struct remote_network_define_xml_flags_args {
|
||||
remote_nonnull_string xml;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
struct remote_network_define_xml_flags_ret {
|
||||
remote_nonnull_network net;
|
||||
};
|
||||
|
||||
struct remote_network_undefine_args {
|
||||
remote_nonnull_network net;
|
||||
};
|
||||
@ -6801,5 +6810,13 @@ enum remote_procedure {
|
||||
* @acl: nwfilter:write
|
||||
* @acl: nwfilter:save
|
||||
*/
|
||||
REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431
|
||||
REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431,
|
||||
|
||||
/**
|
||||
* @generate: both
|
||||
* @priority: high
|
||||
* @acl: network:write
|
||||
* @acl: network:save
|
||||
*/
|
||||
REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432
|
||||
};
|
||||
|
@ -1104,6 +1104,13 @@ struct remote_network_define_xml_args {
|
||||
struct remote_network_define_xml_ret {
|
||||
remote_nonnull_network net;
|
||||
};
|
||||
struct remote_network_define_xml_flags_args {
|
||||
remote_nonnull_string xml;
|
||||
u_int flags;
|
||||
};
|
||||
struct remote_network_define_xml_flags_ret {
|
||||
remote_nonnull_network net;
|
||||
};
|
||||
struct remote_network_undefine_args {
|
||||
remote_nonnull_network net;
|
||||
};
|
||||
@ -3631,4 +3638,5 @@ enum remote_procedure {
|
||||
REMOTE_PROC_NODE_DEVICE_UNDEFINE = 429,
|
||||
REMOTE_PROC_NODE_DEVICE_CREATE = 430,
|
||||
REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431,
|
||||
REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user