mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
nodedev: Implement virNodeDeviceIsPersistent()/IsActive()
Implement these new API functions in the nodedev driver. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
6d0b85d792
commit
24ffeef09c
@ -1989,3 +1989,53 @@ int nodeDeviceDefValidate(virNodeDeviceDef *def,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
nodeDeviceIsPersistent(virNodeDevice *device)
|
||||
{
|
||||
virNodeDeviceObj *obj = NULL;
|
||||
virNodeDeviceDef *def = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (nodeDeviceInitWait() < 0)
|
||||
return -1;
|
||||
|
||||
if (!(obj = nodeDeviceObjFindByName(device->name)))
|
||||
return -1;
|
||||
def = virNodeDeviceObjGetDef(obj);
|
||||
|
||||
if (virNodeDeviceIsPersistentEnsureACL(device->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virNodeDeviceObjIsPersistent(obj);
|
||||
|
||||
cleanup:
|
||||
virNodeDeviceObjEndAPI(&obj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
nodeDeviceIsActive(virNodeDevice *device)
|
||||
{
|
||||
virNodeDeviceObj *obj = NULL;
|
||||
virNodeDeviceDef *def = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (nodeDeviceInitWait() < 0)
|
||||
return -1;
|
||||
|
||||
if (!(obj = nodeDeviceObjFindByName(device->name)))
|
||||
return -1;
|
||||
def = virNodeDeviceObjGetDef(obj);
|
||||
|
||||
if (virNodeDeviceIsActiveEnsureACL(device->conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virNodeDeviceObjIsActive(obj);
|
||||
|
||||
cleanup:
|
||||
virNodeDeviceObjEndAPI(&obj);
|
||||
return ret;
|
||||
}
|
||||
|
@ -186,6 +186,12 @@ int
|
||||
nodeDeviceGetAutostart(virNodeDevice *dev,
|
||||
int *autostart);
|
||||
|
||||
int
|
||||
nodeDeviceIsPersistent(virNodeDevice *dev);
|
||||
|
||||
int
|
||||
nodeDeviceIsActive(virNodeDevice *dev);
|
||||
|
||||
virCommand*
|
||||
nodeDeviceGetMdevctlSetAutostartCommand(virNodeDeviceDef *def,
|
||||
bool autostart,
|
||||
|
@ -1503,7 +1503,7 @@ udevAddOneDevice(struct udev_device *device)
|
||||
virObjectEvent *event = NULL;
|
||||
bool new_device = true;
|
||||
int ret = -1;
|
||||
bool was_persistent = false;
|
||||
bool persistent = false;
|
||||
bool autostart = false;
|
||||
bool is_mdev;
|
||||
|
||||
@ -1534,7 +1534,8 @@ udevAddOneDevice(struct udev_device *device)
|
||||
|
||||
if (is_mdev)
|
||||
nodeDeviceDefCopyFromMdevctl(def, objdef);
|
||||
was_persistent = virNodeDeviceObjIsPersistent(obj);
|
||||
|
||||
persistent = virNodeDeviceObjIsPersistent(obj);
|
||||
autostart = virNodeDeviceObjIsAutostart(obj);
|
||||
|
||||
/* If the device was defined by mdevctl and was never instantiated, it
|
||||
@ -1548,7 +1549,7 @@ udevAddOneDevice(struct udev_device *device)
|
||||
* and the current definition will take its place. */
|
||||
if (!(obj = virNodeDeviceObjListAssignDef(driver->devs, def)))
|
||||
goto cleanup;
|
||||
virNodeDeviceObjSetPersistent(obj, was_persistent);
|
||||
virNodeDeviceObjSetPersistent(obj, persistent);
|
||||
virNodeDeviceObjSetAutostart(obj, autostart);
|
||||
objdef = virNodeDeviceObjGetDef(obj);
|
||||
|
||||
@ -1954,6 +1955,7 @@ udevSetupSystemDev(void)
|
||||
|
||||
virNodeDeviceObjSetActive(obj, true);
|
||||
virNodeDeviceObjSetAutostart(obj, true);
|
||||
virNodeDeviceObjSetPersistent(obj, true);
|
||||
|
||||
virNodeDeviceObjEndAPI(&obj);
|
||||
|
||||
@ -2360,6 +2362,8 @@ static virNodeDeviceDriver udevNodeDeviceDriver = {
|
||||
.nodeDeviceCreate = nodeDeviceCreate, /* 7.3.0 */
|
||||
.nodeDeviceSetAutostart = nodeDeviceSetAutostart, /* 7.8.0 */
|
||||
.nodeDeviceGetAutostart = nodeDeviceGetAutostart, /* 7.8.0 */
|
||||
.nodeDeviceIsPersistent = nodeDeviceIsPersistent, /* 7.8.0 */
|
||||
.nodeDeviceIsActive = nodeDeviceIsActive, /* 7.8.0 */
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user