mirror of https://gitee.com/openkylin/libvirt.git
api: add virNodeDevice(Get|Set)Autostart()
This will allow persistent mediated devices to be configured to be restarted automatically when the host reboots. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
51eb680b26
commit
c6607a25b9
|
@ -141,6 +141,12 @@ int virNodeDeviceUndefine(virNodeDevicePtr dev,
|
|||
int virNodeDeviceCreate(virNodeDevicePtr dev,
|
||||
unsigned int flags);
|
||||
|
||||
int virNodeDeviceSetAutostart(virNodeDevicePtr dev,
|
||||
int autostart);
|
||||
|
||||
int virNodeDeviceGetAutostart(virNodeDevicePtr dev,
|
||||
int *autostart);
|
||||
|
||||
/**
|
||||
* VIR_NODE_DEVICE_EVENT_CALLBACK:
|
||||
*
|
||||
|
|
|
@ -87,6 +87,14 @@ typedef int
|
|||
(*virDrvNodeDeviceCreate)(virNodeDevicePtr dev,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvNodeDeviceSetAutostart)(virNodeDevicePtr dev,
|
||||
int autostart);
|
||||
|
||||
typedef int
|
||||
(*virDrvNodeDeviceGetAutostart)(virNodeDevicePtr dev,
|
||||
int *autostart);
|
||||
|
||||
typedef int
|
||||
(*virDrvConnectNodeDeviceEventRegisterAny)(virConnectPtr conn,
|
||||
virNodeDevicePtr dev,
|
||||
|
@ -128,4 +136,6 @@ struct _virNodeDeviceDriver {
|
|||
virDrvNodeDeviceDefineXML nodeDeviceDefineXML;
|
||||
virDrvNodeDeviceUndefine nodeDeviceUndefine;
|
||||
virDrvNodeDeviceCreate nodeDeviceCreate;
|
||||
virDrvNodeDeviceSetAutostart nodeDeviceSetAutostart;
|
||||
virDrvNodeDeviceGetAutostart nodeDeviceGetAutostart;
|
||||
};
|
||||
|
|
|
@ -980,3 +980,79 @@ virConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
|||
virDispatchError(conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* virNodeDeviceSetAutostart:
|
||||
* @dev: the device object
|
||||
* @autostart: whether the device should be automatically started
|
||||
*
|
||||
* Configure the node device to be automatically started when the host machine
|
||||
* boots or the parent device becomes available.
|
||||
*
|
||||
* Returns -1 in case of error, 0 in case of success
|
||||
*/
|
||||
int
|
||||
virNodeDeviceSetAutostart(virNodeDevicePtr dev,
|
||||
int autostart)
|
||||
{
|
||||
VIR_DEBUG("dev=%p", dev);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckNodeDeviceReturn(dev, -1);
|
||||
virCheckReadOnlyGoto(dev->conn->flags, error);
|
||||
|
||||
if (dev->conn->nodeDeviceDriver &&
|
||||
dev->conn->nodeDeviceDriver->nodeDeviceSetAutostart) {
|
||||
int retval = dev->conn->nodeDeviceDriver->nodeDeviceSetAutostart(dev, autostart);
|
||||
if (retval < 0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
|
||||
error:
|
||||
virDispatchError(dev->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virNodeDeviceGetAutostart:
|
||||
* @dev: the device object
|
||||
* @autostart: the value returned
|
||||
*
|
||||
* Provides a boolean value indicating whether the node device is configured to
|
||||
* be automatically started when the host machine boots or the parent device
|
||||
* becomes available.
|
||||
*
|
||||
* Returns -1 in case of error, 0 in case of success
|
||||
*/
|
||||
int
|
||||
virNodeDeviceGetAutostart(virNodeDevicePtr dev,
|
||||
int *autostart)
|
||||
{
|
||||
VIR_DEBUG("dev=%p", dev);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckNodeDeviceReturn(dev, -1);
|
||||
virCheckReadOnlyGoto(dev->conn->flags, error);
|
||||
|
||||
if (dev->conn->nodeDeviceDriver &&
|
||||
dev->conn->nodeDeviceDriver->nodeDeviceGetAutostart) {
|
||||
int retval = dev->conn->nodeDeviceDriver->nodeDeviceGetAutostart(dev, autostart);
|
||||
if (retval < 0)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
|
||||
error:
|
||||
virDispatchError(dev->conn);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -902,4 +902,10 @@ LIBVIRT_7.7.0 {
|
|||
virNetworkDefineXMLFlags;
|
||||
} LIBVIRT_7.3.0;
|
||||
|
||||
LIBVIRT_7.8.0 {
|
||||
global:
|
||||
virNodeDeviceSetAutostart;
|
||||
virNodeDeviceGetAutostart;
|
||||
} LIBVIRT_7.7.0;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
|
|
@ -8673,7 +8673,9 @@ static virNodeDeviceDriver node_device_driver = {
|
|||
.nodeDeviceCreate = remoteNodeDeviceCreate, /* 7.3.0 */
|
||||
.nodeDeviceDefineXML = remoteNodeDeviceDefineXML, /* 7.3.0 */
|
||||
.nodeDeviceUndefine = remoteNodeDeviceUndefine, /* 7.3.0 */
|
||||
.nodeDeviceDestroy = remoteNodeDeviceDestroy /* 0.6.3 */
|
||||
.nodeDeviceDestroy = remoteNodeDeviceDestroy, /* 0.6.3 */
|
||||
.nodeDeviceGetAutostart = remoteNodeDeviceGetAutostart, /* 7.8.0 */
|
||||
.nodeDeviceSetAutostart = remoteNodeDeviceSetAutostart, /* 7.8.0 */
|
||||
};
|
||||
|
||||
static virNWFilterDriver nwfilter_driver = {
|
||||
|
|
|
@ -2182,6 +2182,19 @@ struct remote_node_device_create_args {
|
|||
unsigned int flags;
|
||||
};
|
||||
|
||||
struct remote_node_device_get_autostart_args {
|
||||
remote_nonnull_string name;
|
||||
};
|
||||
|
||||
struct remote_node_device_get_autostart_ret {
|
||||
int autostart;
|
||||
};
|
||||
|
||||
struct remote_node_device_set_autostart_args {
|
||||
remote_nonnull_string name;
|
||||
int autostart;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Events Register/Deregister:
|
||||
|
@ -6818,5 +6831,19 @@ enum remote_procedure {
|
|||
* @acl: network:write
|
||||
* @acl: network:save
|
||||
*/
|
||||
REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432
|
||||
REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432,
|
||||
|
||||
/**
|
||||
* @generate: both
|
||||
* @priority: high
|
||||
* @acl: node_device:read
|
||||
*/
|
||||
REMOTE_PROC_NODE_DEVICE_GET_AUTOSTART = 433,
|
||||
|
||||
/**
|
||||
* @generate: both
|
||||
* @priority: high
|
||||
* @acl: node_device:write
|
||||
*/
|
||||
REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART = 434
|
||||
};
|
||||
|
|
|
@ -1629,6 +1629,16 @@ struct remote_node_device_create_args {
|
|||
remote_nonnull_string name;
|
||||
u_int flags;
|
||||
};
|
||||
struct remote_node_device_get_autostart_args {
|
||||
remote_nonnull_string name;
|
||||
};
|
||||
struct remote_node_device_get_autostart_ret {
|
||||
int autostart;
|
||||
};
|
||||
struct remote_node_device_set_autostart_args {
|
||||
remote_nonnull_string name;
|
||||
int autostart;
|
||||
};
|
||||
struct remote_connect_domain_event_register_ret {
|
||||
int cb_registered;
|
||||
};
|
||||
|
@ -3639,4 +3649,6 @@ enum remote_procedure {
|
|||
REMOTE_PROC_NODE_DEVICE_CREATE = 430,
|
||||
REMOTE_PROC_NWFILTER_DEFINE_XML_FLAGS = 431,
|
||||
REMOTE_PROC_NETWORK_DEFINE_XML_FLAGS = 432,
|
||||
REMOTE_PROC_NODE_DEVICE_GET_AUTOSTART = 433,
|
||||
REMOTE_PROC_NODE_DEVICE_SET_AUTOSTART = 434,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue