src: add driver support for networkCreateXMLFlags()

I added new driver functions to handle creating network with
given flags. I also replaced definitions of the functions without
flags with function calls to the new ones.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Kristina Hanicova 2021-09-15 13:07:28 +02:00 committed by Michal Privoznik
parent 6a0a2840cf
commit 00182251d0
3 changed files with 34 additions and 4 deletions

View File

@ -3464,8 +3464,9 @@ networkValidate(virNetworkDriverState *driver,
static virNetworkPtr static virNetworkPtr
networkCreateXML(virConnectPtr conn, networkCreateXMLFlags(virConnectPtr conn,
const char *xml) const char *xml,
unsigned int flags)
{ {
virNetworkDriverState *driver = networkGetDriver(); virNetworkDriverState *driver = networkGetDriver();
virNetworkDef *newDef; virNetworkDef *newDef;
@ -3474,10 +3475,12 @@ networkCreateXML(virConnectPtr conn,
virNetworkPtr net = NULL; virNetworkPtr net = NULL;
virObjectEvent *event = NULL; virObjectEvent *event = NULL;
virCheckFlags(0, NULL);
if (!(newDef = virNetworkDefParseString(xml, network_driver->xmlopt, false))) if (!(newDef = virNetworkDefParseString(xml, network_driver->xmlopt, false)))
goto cleanup; goto cleanup;
if (virNetworkCreateXMLEnsureACL(conn, newDef) < 0) if (virNetworkCreateXMLFlagsEnsureACL(conn, newDef) < 0)
goto cleanup; goto cleanup;
if (networkValidate(driver, newDef) < 0) if (networkValidate(driver, newDef) < 0)
@ -3515,6 +3518,14 @@ networkCreateXML(virConnectPtr conn,
} }
static virNetworkPtr
networkCreateXML(virConnectPtr conn,
const char *xml)
{
return networkCreateXMLFlags(conn, xml, 0);
}
static virNetworkPtr static virNetworkPtr
networkDefineXMLFlags(virConnectPtr conn, networkDefineXMLFlags(virConnectPtr conn,
const char *xml, const char *xml,
@ -5630,6 +5641,7 @@ static virNetworkDriver networkDriver = {
.networkLookupByUUID = networkLookupByUUID, /* 0.2.0 */ .networkLookupByUUID = networkLookupByUUID, /* 0.2.0 */
.networkLookupByName = networkLookupByName, /* 0.2.0 */ .networkLookupByName = networkLookupByName, /* 0.2.0 */
.networkCreateXML = networkCreateXML, /* 0.2.0 */ .networkCreateXML = networkCreateXML, /* 0.2.0 */
.networkCreateXMLFlags = networkCreateXMLFlags, /* 7.8.0 */
.networkDefineXML = networkDefineXML, /* 0.2.0 */ .networkDefineXML = networkDefineXML, /* 0.2.0 */
.networkDefineXMLFlags = networkDefineXMLFlags, /* 7.7.0 */ .networkDefineXMLFlags = networkDefineXMLFlags, /* 7.7.0 */
.networkUndefine = networkUndefine, /* 0.2.0 */ .networkUndefine = networkUndefine, /* 0.2.0 */

View File

@ -5572,7 +5572,8 @@ testNetworkIsPersistent(virNetworkPtr net)
static virNetworkPtr static virNetworkPtr
testNetworkCreateXML(virConnectPtr conn, const char *xml) testNetworkCreateXMLFlags(virConnectPtr conn, const char *xml,
unsigned int flags)
{ {
testDriver *privconn = conn->privateData; testDriver *privconn = conn->privateData;
virNetworkDef *newDef; virNetworkDef *newDef;
@ -5581,6 +5582,8 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml)
virNetworkPtr net = NULL; virNetworkPtr net = NULL;
virObjectEvent *event = NULL; virObjectEvent *event = NULL;
virCheckFlags(0, NULL);
if ((newDef = virNetworkDefParseString(xml, NULL, false)) == NULL) if ((newDef = virNetworkDefParseString(xml, NULL, false)) == NULL)
goto cleanup; goto cleanup;
@ -5606,6 +5609,13 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml)
} }
static virNetworkPtr
testNetworkCreateXML(virConnectPtr conn, const char *xml)
{
return testNetworkCreateXMLFlags(conn, xml, 0);
}
static virNetworkPtr static virNetworkPtr
testNetworkDefineXMLFlags(virConnectPtr conn, testNetworkDefineXMLFlags(virConnectPtr conn,
const char *xml, const char *xml,
@ -9723,6 +9733,7 @@ static virNetworkDriver testNetworkDriver = {
.networkLookupByUUID = testNetworkLookupByUUID, /* 0.3.2 */ .networkLookupByUUID = testNetworkLookupByUUID, /* 0.3.2 */
.networkLookupByName = testNetworkLookupByName, /* 0.3.2 */ .networkLookupByName = testNetworkLookupByName, /* 0.3.2 */
.networkCreateXML = testNetworkCreateXML, /* 0.3.2 */ .networkCreateXML = testNetworkCreateXML, /* 0.3.2 */
.networkCreateXMLFlags = testNetworkCreateXMLFlags, /* 7.8.0 */
.networkDefineXML = testNetworkDefineXML, /* 0.3.2 */ .networkDefineXML = testNetworkDefineXML, /* 0.3.2 */
.networkDefineXMLFlags = testNetworkDefineXMLFlags, /* 7.7.0 */ .networkDefineXMLFlags = testNetworkDefineXMLFlags, /* 7.7.0 */
.networkUndefine = testNetworkUndefine, /* 0.3.2 */ .networkUndefine = testNetworkUndefine, /* 0.3.2 */

View File

@ -561,6 +561,12 @@ static virNetworkPtr vboxNetworkCreateXML(virConnectPtr conn, const char *xml)
return vboxNetworkDefineCreateXML(conn, xml, true, 0); return vboxNetworkDefineCreateXML(conn, xml, true, 0);
} }
static virNetworkPtr vboxNetworkCreateXMLFlags(virConnectPtr conn, const char *xml,
unsigned int flags)
{
return vboxNetworkDefineCreateXML(conn, xml, true, flags);
}
static virNetworkPtr vboxNetworkDefineXML(virConnectPtr conn, const char *xml) static virNetworkPtr vboxNetworkDefineXML(virConnectPtr conn, const char *xml)
{ {
return vboxNetworkDefineCreateXML(conn, xml, false, 0); return vboxNetworkDefineCreateXML(conn, xml, false, 0);
@ -930,6 +936,7 @@ virNetworkDriver vboxNetworkDriver = {
.networkLookupByUUID = vboxNetworkLookupByUUID, /* 0.6.4 */ .networkLookupByUUID = vboxNetworkLookupByUUID, /* 0.6.4 */
.networkLookupByName = vboxNetworkLookupByName, /* 0.6.4 */ .networkLookupByName = vboxNetworkLookupByName, /* 0.6.4 */
.networkCreateXML = vboxNetworkCreateXML, /* 0.6.4 */ .networkCreateXML = vboxNetworkCreateXML, /* 0.6.4 */
.networkCreateXMLFlags = vboxNetworkCreateXMLFlags, /* 7.8.0 */
.networkDefineXML = vboxNetworkDefineXML, /* 0.6.4 */ .networkDefineXML = vboxNetworkDefineXML, /* 0.6.4 */
.networkDefineXMLFlags = vboxNetworkDefineXMLFlags, /* 7.7.0 */ .networkDefineXMLFlags = vboxNetworkDefineXMLFlags, /* 7.7.0 */
.networkUndefine = vboxNetworkUndefine, /* 0.6.4 */ .networkUndefine = vboxNetworkUndefine, /* 0.6.4 */