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