mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
api: add virNodeDeviceIsPersistent()/IsActive()
These two public APIs are implemented for almost all other objects that have a concept of persistent definition and activatability. Now that we have node devices (mdevs) that can be defined and inactive, it will be useful to query the persistent/active state of node devices as well. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
16d078eded
commit
6d0b85d792
@ -147,6 +147,10 @@ int virNodeDeviceSetAutostart(virNodeDevicePtr dev,
|
||||
int virNodeDeviceGetAutostart(virNodeDevicePtr dev,
|
||||
int *autostart);
|
||||
|
||||
int virNodeDeviceIsPersistent(virNodeDevicePtr dev);
|
||||
|
||||
int virNodeDeviceIsActive(virNodeDevicePtr dev);
|
||||
|
||||
/**
|
||||
* VIR_NODE_DEVICE_EVENT_CALLBACK:
|
||||
*
|
||||
|
@ -95,6 +95,12 @@ typedef int
|
||||
(*virDrvNodeDeviceGetAutostart)(virNodeDevicePtr dev,
|
||||
int *autostart);
|
||||
|
||||
typedef int
|
||||
(*virDrvNodeDeviceIsPersistent)(virNodeDevicePtr dev);
|
||||
|
||||
typedef int
|
||||
(*virDrvNodeDeviceIsActive)(virNodeDevicePtr dev);
|
||||
|
||||
typedef int
|
||||
(*virDrvConnectNodeDeviceEventRegisterAny)(virConnectPtr conn,
|
||||
virNodeDevicePtr dev,
|
||||
@ -138,4 +144,6 @@ struct _virNodeDeviceDriver {
|
||||
virDrvNodeDeviceCreate nodeDeviceCreate;
|
||||
virDrvNodeDeviceSetAutostart nodeDeviceSetAutostart;
|
||||
virDrvNodeDeviceGetAutostart nodeDeviceGetAutostart;
|
||||
virDrvNodeDeviceIsPersistent nodeDeviceIsPersistent;
|
||||
virDrvNodeDeviceIsActive nodeDeviceIsActive;
|
||||
};
|
||||
|
@ -1056,3 +1056,68 @@ virNodeDeviceGetAutostart(virNodeDevicePtr dev,
|
||||
virDispatchError(dev->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virNodeDeviceIsPersistent:
|
||||
* @dev: pointer to the nodedev object
|
||||
*
|
||||
* Determine if the node device has a persistent configuration
|
||||
* which means it will still exist after shutting down
|
||||
*
|
||||
* Returns 1 if persistent, 0 if transient, -1 on error
|
||||
*/
|
||||
int
|
||||
virNodeDeviceIsPersistent(virNodeDevicePtr dev)
|
||||
{
|
||||
VIR_DEBUG("dev=%p", dev);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckNodeDeviceReturn(dev, -1);
|
||||
|
||||
if (dev->conn->nodeDeviceDriver &&
|
||||
dev->conn->nodeDeviceDriver->nodeDeviceIsPersistent) {
|
||||
int ret;
|
||||
ret = dev->conn->nodeDeviceDriver->nodeDeviceIsPersistent(dev);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
error:
|
||||
virDispatchError(dev->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virNodeDeviceIsActive:
|
||||
* @dev: pointer to the node device object
|
||||
*
|
||||
* Determine if the node device is currently active
|
||||
*
|
||||
* Returns 1 if active, 0 if inactive, -1 on error
|
||||
*/
|
||||
int virNodeDeviceIsActive(virNodeDevicePtr dev)
|
||||
{
|
||||
VIR_DEBUG("dev=%p", dev);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckNodeDeviceReturn(dev, -1);
|
||||
|
||||
if (dev->conn->nodeDeviceDriver &&
|
||||
dev->conn->nodeDeviceDriver->nodeDeviceIsActive) {
|
||||
int ret;
|
||||
ret = dev->conn->nodeDeviceDriver->nodeDeviceIsActive(dev);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
error:
|
||||
virDispatchError(dev->conn);
|
||||
return -1;
|
||||
}
|
||||
|
@ -906,6 +906,8 @@ LIBVIRT_7.8.0 {
|
||||
global:
|
||||
virNodeDeviceSetAutostart;
|
||||
virNodeDeviceGetAutostart;
|
||||
virNodeDeviceIsPersistent;
|
||||
virNodeDeviceIsActive;
|
||||
} LIBVIRT_7.7.0;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
@ -8676,6 +8676,8 @@ static virNodeDeviceDriver node_device_driver = {
|
||||
.nodeDeviceDestroy = remoteNodeDeviceDestroy, /* 0.6.3 */
|
||||
.nodeDeviceGetAutostart = remoteNodeDeviceGetAutostart, /* 7.8.0 */
|
||||
.nodeDeviceSetAutostart = remoteNodeDeviceSetAutostart, /* 7.8.0 */
|
||||
.nodeDeviceIsPersistent = remoteNodeDeviceIsPersistent, /* 7.8.0 */
|
||||
.nodeDeviceIsActive = remoteNodeDeviceIsActive, /* 7.8.0 */
|
||||
};
|
||||
|
||||
static virNWFilterDriver nwfilter_driver = {
|
||||
|
@ -2195,6 +2195,22 @@ struct remote_node_device_set_autostart_args {
|
||||
int autostart;
|
||||
};
|
||||
|
||||
struct remote_node_device_is_persistent_args {
|
||||
remote_nonnull_string name;
|
||||
};
|
||||
|
||||
struct remote_node_device_is_persistent_ret {
|
||||
int persistent;
|
||||
};
|
||||
|
||||
struct remote_node_device_is_active_args {
|
||||
remote_nonnull_string name;
|
||||
};
|
||||
|
||||
struct remote_node_device_is_active_ret {
|
||||
int active;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Events Register/Deregister:
|
||||
@ -6845,5 +6861,20 @@ enum remote_procedure {
|
||||
* @priority: high
|
||||
* @acl: node_device:write
|
||||
*/
|
||||
REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART = 434
|
||||
REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART = 434,
|
||||
|
||||
/**
|
||||
* @generate: both
|
||||
* @priority: high
|
||||
* @acl: node_device:read
|
||||
*/
|
||||
REMOTE_PROC_NODE_DEVICE_IS_PERSISTENT = 435,
|
||||
|
||||
/**
|
||||
* @generate: both
|
||||
* @priority: high
|
||||
* @acl: node_device:read
|
||||
*/
|
||||
REMOTE_PROC_NODE_DEVICE_IS_ACTIVE = 436
|
||||
|
||||
};
|
||||
|
@ -1639,6 +1639,18 @@ struct remote_node_device_set_autostart_args {
|
||||
remote_nonnull_string name;
|
||||
int autostart;
|
||||
};
|
||||
struct remote_node_device_is_persistent_args {
|
||||
remote_nonnull_string name;
|
||||
};
|
||||
struct remote_node_device_is_persistent_ret {
|
||||
int persistent;
|
||||
};
|
||||
struct remote_node_device_is_active_args {
|
||||
remote_nonnull_string name;
|
||||
};
|
||||
struct remote_node_device_is_active_ret {
|
||||
int active;
|
||||
};
|
||||
struct remote_connect_domain_event_register_ret {
|
||||
int cb_registered;
|
||||
};
|
||||
@ -3651,4 +3663,6 @@ enum remote_procedure {
|
||||
REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432,
|
||||
REMOTE_PROC_NODE_DEVICE_GET_AUTOSTART = 433,
|
||||
REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART = 434,
|
||||
REMOTE_PROC_NODE_DEVICE_IS_PERSISTENT = 435,
|
||||
REMOTE_PROC_NODE_DEVICE_IS_ACTIVE = 436,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user