mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Introduce a new virDomainUpdateDeviceFlags public API
The current virDomainAttachDevice API can be (ab)used to change the media of an existing CDROM/Floppy device. Going forward there will be more devices that can be configured on the fly and overloading virDomainAttachDevice for this is not too pleasant. This patch adds a new virDomainUpdateDeviceFlags() explicitly just for modifying existing devices. * include/libvirt/libvirt.h.in: Add virDomainUpdateDeviceFlags * src/driver.h: Internal API for virDomainUpdateDeviceFlags * src/libvirt.c, src/libvirt_public.syms: Glue public API to driver API * src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c, src/openvz/openvz_driver.c, src/phyp/phyp_driver.c, src/qemu/qemu_driver.c, src/remote/remote_driver.c, src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c, src/xen/xen_driver.c, src/xenapi/xenapi_driver.c: Add stubs for new driver entry point
This commit is contained in:
parent
987e31edc9
commit
46a2ea3689
@ -878,6 +878,8 @@ int virDomainAttachDeviceFlags(virDomainPtr domain,
|
|||||||
const char *xml, unsigned int flags);
|
const char *xml, unsigned int flags);
|
||||||
int virDomainDetachDeviceFlags(virDomainPtr domain,
|
int virDomainDetachDeviceFlags(virDomainPtr domain,
|
||||||
const char *xml, unsigned int flags);
|
const char *xml, unsigned int flags);
|
||||||
|
int virDomainUpdateDeviceFlags(virDomainPtr domain,
|
||||||
|
const char *xml, unsigned int flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NUMA support
|
* NUMA support
|
||||||
|
@ -203,6 +203,10 @@ typedef int
|
|||||||
(*virDrvDomainDetachDeviceFlags) (virDomainPtr domain,
|
(*virDrvDomainDetachDeviceFlags) (virDomainPtr domain,
|
||||||
const char *xml,
|
const char *xml,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
typedef int
|
||||||
|
(*virDrvDomainUpdateDeviceFlags) (virDomainPtr domain,
|
||||||
|
const char *xml,
|
||||||
|
unsigned int flags);
|
||||||
typedef int
|
typedef int
|
||||||
(*virDrvDomainGetAutostart) (virDomainPtr domain,
|
(*virDrvDomainGetAutostart) (virDomainPtr domain,
|
||||||
int *autostart);
|
int *autostart);
|
||||||
@ -460,6 +464,7 @@ struct _virDriver {
|
|||||||
virDrvDomainAttachDeviceFlags domainAttachDeviceFlags;
|
virDrvDomainAttachDeviceFlags domainAttachDeviceFlags;
|
||||||
virDrvDomainDetachDevice domainDetachDevice;
|
virDrvDomainDetachDevice domainDetachDevice;
|
||||||
virDrvDomainDetachDeviceFlags domainDetachDeviceFlags;
|
virDrvDomainDetachDeviceFlags domainDetachDeviceFlags;
|
||||||
|
virDrvDomainUpdateDeviceFlags domainUpdateDeviceFlags;
|
||||||
virDrvDomainGetAutostart domainGetAutostart;
|
virDrvDomainGetAutostart domainGetAutostart;
|
||||||
virDrvDomainSetAutostart domainSetAutostart;
|
virDrvDomainSetAutostart domainSetAutostart;
|
||||||
virDrvDomainGetSchedulerType domainGetSchedulerType;
|
virDrvDomainGetSchedulerType domainGetSchedulerType;
|
||||||
|
@ -3367,6 +3367,7 @@ static virDriver esxDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
NULL, /* domainGetAutostart */
|
NULL, /* domainGetAutostart */
|
||||||
NULL, /* domainSetAutostart */
|
NULL, /* domainSetAutostart */
|
||||||
esxDomainGetSchedulerType, /* domainGetSchedulerType */
|
esxDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||||
|
@ -1868,7 +1868,7 @@ error:
|
|||||||
*
|
*
|
||||||
* Deprecated after 0.4.6.
|
* Deprecated after 0.4.6.
|
||||||
* Renamed to virDomainCreateXML() providing identical functionality.
|
* Renamed to virDomainCreateXML() providing identical functionality.
|
||||||
* This existing name will left indefinitely for API compatability.
|
* This existing name will left indefinitely for API compatibility.
|
||||||
*
|
*
|
||||||
* Returns a new domain object or NULL in case of failure
|
* Returns a new domain object or NULL in case of failure
|
||||||
*/
|
*/
|
||||||
@ -5147,6 +5147,10 @@ error:
|
|||||||
* Create a virtual device attachment to backend. This function,
|
* Create a virtual device attachment to backend. This function,
|
||||||
* having hotplug semantics, is only allowed on an active domain.
|
* having hotplug semantics, is only allowed on an active domain.
|
||||||
*
|
*
|
||||||
|
* For compatibility, this method can also be used to change the media
|
||||||
|
* in an existing CDROM/Floppy device, however, applications are
|
||||||
|
* recommended to use the virDomainUpdateDeviceFlag method instead.
|
||||||
|
*
|
||||||
* Returns 0 in case of success, -1 in case of failure.
|
* Returns 0 in case of success, -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -5201,6 +5205,10 @@ error:
|
|||||||
* return failure if LIVE is specified but it only supports modifying the
|
* return failure if LIVE is specified but it only supports modifying the
|
||||||
* persisted device allocation.
|
* persisted device allocation.
|
||||||
*
|
*
|
||||||
|
* For compatibility, this method can also be used to change the media
|
||||||
|
* in an existing CDROM/Floppy device, however, applications are
|
||||||
|
* recommended to use the virDomainUpdateDeviceFlag method instead.
|
||||||
|
*
|
||||||
* Returns 0 in case of success, -1 in case of failure.
|
* Returns 0 in case of success, -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -5335,6 +5343,64 @@ error:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDomainUpdateDeviceFlags:
|
||||||
|
* @domain: pointer to domain object
|
||||||
|
* @xml: pointer to XML description of one device
|
||||||
|
* @flags: an OR'ed set of virDomainDeviceModifyFlags
|
||||||
|
*
|
||||||
|
* Change a virtual device on a domain, using the flags parameter
|
||||||
|
* to control how the device is changed. VIR_DOMAIN_DEVICE_MODIFY_CURRENT
|
||||||
|
* specifies that the device change is made based on current domain
|
||||||
|
* state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be
|
||||||
|
* changed on the active domain instance only and is not added to the
|
||||||
|
* persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG
|
||||||
|
* specifies that the device shall be changed on the persisted domain
|
||||||
|
* configuration only. Note that the target hypervisor must return an
|
||||||
|
* error if unable to satisfy flags. E.g. the hypervisor driver will
|
||||||
|
* return failure if LIVE is specified but it only supports modifying the
|
||||||
|
* persisted device allocation.
|
||||||
|
*
|
||||||
|
* This method is used for actions such changing CDROM/Floppy device
|
||||||
|
* media, altering the graphics configuration such as password,
|
||||||
|
* reconfiguring the NIC device backend connectivity, etc.
|
||||||
|
*
|
||||||
|
* Returns 0 in case of success, -1 in case of failure.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
virDomainUpdateDeviceFlags(virDomainPtr domain,
|
||||||
|
const char *xml, unsigned int flags)
|
||||||
|
{
|
||||||
|
virConnectPtr conn;
|
||||||
|
DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
|
||||||
|
|
||||||
|
virResetLastError();
|
||||||
|
|
||||||
|
if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
|
||||||
|
virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
if (domain->conn->flags & VIR_CONNECT_RO) {
|
||||||
|
virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
conn = domain->conn;
|
||||||
|
|
||||||
|
if (conn->driver->domainUpdateDeviceFlags) {
|
||||||
|
int ret;
|
||||||
|
ret = conn->driver->domainUpdateDeviceFlags(domain, xml, flags);
|
||||||
|
if (ret < 0)
|
||||||
|
goto error;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
|
||||||
|
|
||||||
|
error:
|
||||||
|
virDispatchError(domain->conn);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virNodeGetCellsFreeMemory:
|
* virNodeGetCellsFreeMemory:
|
||||||
* @conn: pointer to the hypervisor connection
|
* @conn: pointer to the hypervisor connection
|
||||||
|
@ -364,6 +364,7 @@ LIBVIRT_0.7.8 {
|
|||||||
virDomainMigrateSetMaxDowntime;
|
virDomainMigrateSetMaxDowntime;
|
||||||
virConnectDomainEventRegisterAny;
|
virConnectDomainEventRegisterAny;
|
||||||
virConnectDomainEventDeregisterAny;
|
virConnectDomainEventDeregisterAny;
|
||||||
|
virDomainUpdateDeviceFlags;
|
||||||
} LIBVIRT_0.7.7;
|
} LIBVIRT_0.7.7;
|
||||||
|
|
||||||
# .... define new API here using predicted next version number ....
|
# .... define new API here using predicted next version number ....
|
||||||
|
@ -2472,6 +2472,7 @@ static virDriver lxcDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
lxcDomainGetAutostart, /* domainGetAutostart */
|
lxcDomainGetAutostart, /* domainGetAutostart */
|
||||||
lxcDomainSetAutostart, /* domainSetAutostart */
|
lxcDomainSetAutostart, /* domainSetAutostart */
|
||||||
lxcGetSchedulerType, /* domainGetSchedulerType */
|
lxcGetSchedulerType, /* domainGetSchedulerType */
|
||||||
|
@ -757,6 +757,7 @@ static virDriver oneDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
oneGetAutostart, /* domainGetAutostart */
|
oneGetAutostart, /* domainGetAutostart */
|
||||||
NULL, /* domainSetAutostart */
|
NULL, /* domainSetAutostart */
|
||||||
NULL, /* domainGetSchedulerType */
|
NULL, /* domainGetSchedulerType */
|
||||||
|
@ -1509,6 +1509,7 @@ static virDriver openvzDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
openvzDomainGetAutostart, /* domainGetAutostart */
|
openvzDomainGetAutostart, /* domainGetAutostart */
|
||||||
openvzDomainSetAutostart, /* domainSetAutostart */
|
openvzDomainSetAutostart, /* domainSetAutostart */
|
||||||
NULL, /* domainGetSchedulerType */
|
NULL, /* domainGetSchedulerType */
|
||||||
|
@ -1616,6 +1616,7 @@ virDriver phypDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
NULL, /* domainGetAutostart */
|
NULL, /* domainGetAutostart */
|
||||||
NULL, /* domainSetAutostart */
|
NULL, /* domainSetAutostart */
|
||||||
NULL, /* domainGetSchedulerType */
|
NULL, /* domainGetSchedulerType */
|
||||||
|
@ -9914,6 +9914,7 @@ static virDriver qemuDriver = {
|
|||||||
qemudDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
qemudDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||||
qemudDomainDetachDevice, /* domainDetachDevice */
|
qemudDomainDetachDevice, /* domainDetachDevice */
|
||||||
qemudDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
qemudDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
qemudDomainGetAutostart, /* domainGetAutostart */
|
qemudDomainGetAutostart, /* domainGetAutostart */
|
||||||
qemudDomainSetAutostart, /* domainSetAutostart */
|
qemudDomainSetAutostart, /* domainSetAutostart */
|
||||||
qemuGetSchedulerType, /* domainGetSchedulerType */
|
qemuGetSchedulerType, /* domainGetSchedulerType */
|
||||||
|
@ -9460,6 +9460,7 @@ static virDriver remote_driver = {
|
|||||||
remoteDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
remoteDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||||
remoteDomainDetachDevice, /* domainDetachDevice */
|
remoteDomainDetachDevice, /* domainDetachDevice */
|
||||||
remoteDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
remoteDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
remoteDomainGetAutostart, /* domainGetAutostart */
|
remoteDomainGetAutostart, /* domainGetAutostart */
|
||||||
remoteDomainSetAutostart, /* domainSetAutostart */
|
remoteDomainSetAutostart, /* domainSetAutostart */
|
||||||
remoteDomainGetSchedulerType, /* domainGetSchedulerType */
|
remoteDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||||
|
@ -5255,6 +5255,7 @@ static virDriver testDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
testDomainGetAutostart, /* domainGetAutostart */
|
testDomainGetAutostart, /* domainGetAutostart */
|
||||||
testDomainSetAutostart, /* domainSetAutostart */
|
testDomainSetAutostart, /* domainSetAutostart */
|
||||||
testDomainGetSchedulerType, /* domainGetSchedulerType */
|
testDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||||
|
@ -1901,6 +1901,7 @@ static virDriver umlDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
umlDomainGetAutostart, /* domainGetAutostart */
|
umlDomainGetAutostart, /* domainGetAutostart */
|
||||||
umlDomainSetAutostart, /* domainSetAutostart */
|
umlDomainSetAutostart, /* domainSetAutostart */
|
||||||
NULL, /* domainGetSchedulerType */
|
NULL, /* domainGetSchedulerType */
|
||||||
|
@ -7126,6 +7126,7 @@ virDriver NAME(Driver) = {
|
|||||||
vboxDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
vboxDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||||
vboxDomainDetachDevice, /* domainDetachDevice */
|
vboxDomainDetachDevice, /* domainDetachDevice */
|
||||||
vboxDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
vboxDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
NULL, /* domainGetAutostart */
|
NULL, /* domainGetAutostart */
|
||||||
NULL, /* domainSetAutostart */
|
NULL, /* domainSetAutostart */
|
||||||
NULL, /* domainGetSchedulerType */
|
NULL, /* domainGetSchedulerType */
|
||||||
|
@ -1930,6 +1930,7 @@ static virDriver xenUnifiedDriver = {
|
|||||||
xenUnifiedDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
xenUnifiedDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||||
xenUnifiedDomainDetachDevice, /* domainDetachDevice */
|
xenUnifiedDomainDetachDevice, /* domainDetachDevice */
|
||||||
xenUnifiedDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
xenUnifiedDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
xenUnifiedDomainGetAutostart, /* domainGetAutostart */
|
xenUnifiedDomainGetAutostart, /* domainGetAutostart */
|
||||||
xenUnifiedDomainSetAutostart, /* domainSetAutostart */
|
xenUnifiedDomainSetAutostart, /* domainSetAutostart */
|
||||||
xenUnifiedDomainGetSchedulerType, /* domainGetSchedulerType */
|
xenUnifiedDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||||
|
@ -1716,6 +1716,7 @@ static virDriver xenapiDriver = {
|
|||||||
NULL, /* domainAttachDeviceFlags */
|
NULL, /* domainAttachDeviceFlags */
|
||||||
NULL, /* domainDetachDevice */
|
NULL, /* domainDetachDevice */
|
||||||
NULL, /* domainDetachDeviceFlags */
|
NULL, /* domainDetachDeviceFlags */
|
||||||
|
NULL, /* domainUpdateDeviceFlags */
|
||||||
xenapiDomainGetAutostart, /* domainGetAutostart */
|
xenapiDomainGetAutostart, /* domainGetAutostart */
|
||||||
xenapiDomainSetAutostart, /* domainSetAutostart */
|
xenapiDomainSetAutostart, /* domainSetAutostart */
|
||||||
xenapiDomainGetSchedulerType, /* domainGetSchedulerType */
|
xenapiDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||||
|
Loading…
Reference in New Issue
Block a user