mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-07 21:17:55 +03:00
network: Introduce virNetworkObj{Is|Set}Autostart
In preparation for privatizing the virNetworkObj structure, create accessors for the obj->autostart. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
db207a6233
commit
f57d8a7b32
@ -129,6 +129,21 @@ virNetworkObjGetNewDef(virNetworkObjPtr obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
virNetworkObjIsAutostart(virNetworkObjPtr obj)
|
||||||
|
{
|
||||||
|
return obj->autostart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virNetworkObjSetAutostart(virNetworkObjPtr obj,
|
||||||
|
bool autostart)
|
||||||
|
{
|
||||||
|
obj->autostart = autostart;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
virNetworkObjGetDnsmasqPid(virNetworkObjPtr obj)
|
virNetworkObjGetDnsmasqPid(virNetworkObjPtr obj)
|
||||||
{
|
{
|
||||||
@ -973,7 +988,7 @@ virNetworkLoadConfig(virNetworkObjListPtr nets,
|
|||||||
if (!(net = virNetworkObjAssignDef(nets, def, 0)))
|
if (!(net = virNetworkObjAssignDef(nets, def, 0)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
net->autostart = autostart;
|
net->autostart = (autostart == 1);
|
||||||
|
|
||||||
VIR_FREE(configFile);
|
VIR_FREE(configFile);
|
||||||
VIR_FREE(autostartLink);
|
VIR_FREE(autostartLink);
|
||||||
@ -1064,7 +1079,7 @@ virNetworkObjDeleteConfig(const char *configDir,
|
|||||||
|
|
||||||
/* Not fatal if this doesn't work */
|
/* Not fatal if this doesn't work */
|
||||||
unlink(autostartLink);
|
unlink(autostartLink);
|
||||||
net->autostart = 0;
|
net->autostart = false;
|
||||||
|
|
||||||
if (unlink(configFile) < 0) {
|
if (unlink(configFile) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
|
@ -32,7 +32,7 @@ struct _virNetworkObj {
|
|||||||
pid_t dnsmasqPid;
|
pid_t dnsmasqPid;
|
||||||
pid_t radvdPid;
|
pid_t radvdPid;
|
||||||
unsigned int active : 1;
|
unsigned int active : 1;
|
||||||
unsigned int autostart : 1;
|
bool autostart;
|
||||||
unsigned int persistent : 1;
|
unsigned int persistent : 1;
|
||||||
|
|
||||||
virNetworkDefPtr def; /* The current definition */
|
virNetworkDefPtr def; /* The current definition */
|
||||||
@ -60,6 +60,13 @@ virNetworkObjSetDef(virNetworkObjPtr obj,
|
|||||||
virNetworkDefPtr
|
virNetworkDefPtr
|
||||||
virNetworkObjGetNewDef(virNetworkObjPtr obj);
|
virNetworkObjGetNewDef(virNetworkObjPtr obj);
|
||||||
|
|
||||||
|
bool
|
||||||
|
virNetworkObjIsAutostart(virNetworkObjPtr obj);
|
||||||
|
|
||||||
|
void
|
||||||
|
virNetworkObjSetAutostart(virNetworkObjPtr obj,
|
||||||
|
bool autostart);
|
||||||
|
|
||||||
virMacMapPtr
|
virMacMapPtr
|
||||||
virNetworkObjGetMacMap(virNetworkObjPtr obj);
|
virNetworkObjGetMacMap(virNetworkObjPtr obj);
|
||||||
|
|
||||||
|
@ -950,6 +950,7 @@ virNetworkObjGetMacMap;
|
|||||||
virNetworkObjGetNewDef;
|
virNetworkObjGetNewDef;
|
||||||
virNetworkObjGetPersistentDef;
|
virNetworkObjGetPersistentDef;
|
||||||
virNetworkObjGetRadvdPid;
|
virNetworkObjGetRadvdPid;
|
||||||
|
virNetworkObjIsAutostart;
|
||||||
virNetworkObjListExport;
|
virNetworkObjListExport;
|
||||||
virNetworkObjListForEach;
|
virNetworkObjListForEach;
|
||||||
virNetworkObjListGetNames;
|
virNetworkObjListGetNames;
|
||||||
@ -964,6 +965,7 @@ virNetworkObjNew;
|
|||||||
virNetworkObjRemoveInactive;
|
virNetworkObjRemoveInactive;
|
||||||
virNetworkObjReplacePersistentDef;
|
virNetworkObjReplacePersistentDef;
|
||||||
virNetworkObjSaveStatus;
|
virNetworkObjSaveStatus;
|
||||||
|
virNetworkObjSetAutostart;
|
||||||
virNetworkObjSetDef;
|
virNetworkObjSetDef;
|
||||||
virNetworkObjSetDefTransient;
|
virNetworkObjSetDefTransient;
|
||||||
virNetworkObjSetDnsmasqPid;
|
virNetworkObjSetDnsmasqPid;
|
||||||
|
@ -526,7 +526,7 @@ networkAutostartConfig(virNetworkObjPtr obj,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
virObjectLock(obj);
|
virObjectLock(obj);
|
||||||
if (obj->autostart &&
|
if (virNetworkObjIsAutostart(obj) &&
|
||||||
!virNetworkObjIsActive(obj) &&
|
!virNetworkObjIsActive(obj) &&
|
||||||
networkStartNetwork(driver, obj) < 0)
|
networkStartNetwork(driver, obj) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3969,7 +3969,7 @@ networkGetAutostart(virNetworkPtr net,
|
|||||||
if (virNetworkGetAutostartEnsureACL(net->conn, virNetworkObjGetDef(obj)) < 0)
|
if (virNetworkGetAutostartEnsureACL(net->conn, virNetworkObjGetDef(obj)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
*autostart = obj->autostart;
|
*autostart = virNetworkObjIsAutostart(obj) ? 1 : 0;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -3986,6 +3986,8 @@ networkSetAutostart(virNetworkPtr net,
|
|||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
virNetworkDefPtr def;
|
virNetworkDefPtr def;
|
||||||
char *configFile = NULL, *autostartLink = NULL;
|
char *configFile = NULL, *autostartLink = NULL;
|
||||||
|
bool new_autostart;
|
||||||
|
bool cur_autostart;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(obj = networkObjFromNetwork(net)))
|
if (!(obj = networkObjFromNetwork(net)))
|
||||||
@ -4001,9 +4003,9 @@ networkSetAutostart(virNetworkPtr net,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
autostart = (autostart != 0);
|
new_autostart = (autostart != 0);
|
||||||
|
cur_autostart = virNetworkObjIsAutostart(obj);
|
||||||
if (obj->autostart != autostart) {
|
if (cur_autostart != new_autostart) {
|
||||||
if ((configFile = virNetworkConfigFile(driver->networkConfigDir,
|
if ((configFile = virNetworkConfigFile(driver->networkConfigDir,
|
||||||
def->name)) == NULL)
|
def->name)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -4011,7 +4013,7 @@ networkSetAutostart(virNetworkPtr net,
|
|||||||
def->name)) == NULL)
|
def->name)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (autostart) {
|
if (new_autostart) {
|
||||||
if (virFileMakePath(driver->networkAutostartDir) < 0) {
|
if (virFileMakePath(driver->networkAutostartDir) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("cannot create autostart directory '%s'"),
|
_("cannot create autostart directory '%s'"),
|
||||||
@ -4034,8 +4036,9 @@ networkSetAutostart(virNetworkPtr net,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->autostart = autostart;
|
virNetworkObjSetAutostart(obj, new_autostart);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -3647,7 +3647,7 @@ testNetworkGetAutostart(virNetworkPtr net,
|
|||||||
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
*autostart = obj->autostart;
|
*autostart = virNetworkObjIsAutostart(obj) ? 1 : 0;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -3662,12 +3662,14 @@ testNetworkSetAutostart(virNetworkPtr net,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = net->conn->privateData;
|
testDriverPtr privconn = net->conn->privateData;
|
||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
|
bool new_autostart = (autostart != 0);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
obj->autostart = autostart ? 1 : 0;
|
virNetworkObjSetAutostart(obj, new_autostart);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user