mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
domain{Attach,Detach}DeviceFlags handler for drivers
Implementation of domain{Attach,Detach}DeviceFlags handlers in the drivers.
This commit is contained in:
parent
ce039c3ea5
commit
ed9c14a7ef
@ -3372,7 +3372,9 @@ static virDriver esxDriver = {
|
||||
esxDomainDefineXML, /* domainDefineXML */
|
||||
esxDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
esxDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||
|
@ -2427,7 +2427,9 @@ static virDriver lxcDriver = {
|
||||
lxcDomainDefine, /* domainDefineXML */
|
||||
lxcDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
lxcDomainGetAutostart, /* domainGetAutostart */
|
||||
lxcDomainSetAutostart, /* domainSetAutostart */
|
||||
lxcGetSchedulerType, /* domainGetSchedulerType */
|
||||
|
@ -754,7 +754,9 @@ static virDriver oneDriver = {
|
||||
oneDomainDefine, /* domainDefineXML */
|
||||
oneDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
oneGetAutostart, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
@ -1506,7 +1506,9 @@ static virDriver openvzDriver = {
|
||||
openvzDomainDefineXML, /* domainDefineXML */
|
||||
openvzDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
openvzDomainGetAutostart, /* domainGetAutostart */
|
||||
openvzDomainSetAutostart, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
@ -1622,7 +1622,9 @@ virDriver phypDriver = {
|
||||
NULL, /* domainDefineXML */
|
||||
NULL, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
@ -6057,6 +6057,18 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int qemudDomainAttachDeviceFlags(virDomainPtr dom,
|
||||
const char *xml,
|
||||
unsigned int flags) {
|
||||
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("cannot modify the persistent configuration of a domain"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return qemudDomainAttachDevice(dom, xml);
|
||||
}
|
||||
|
||||
static int qemudDomainDetachPciDiskDevice(virConnectPtr conn,
|
||||
struct qemud_driver *driver,
|
||||
virDomainObjPtr vm,
|
||||
@ -6464,6 +6476,18 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int qemudDomainDetachDeviceFlags(virDomainPtr dom,
|
||||
const char *xml,
|
||||
unsigned int flags) {
|
||||
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("cannot modify the persistent configuration of a domain"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return qemudDomainDetachDevice(dom, xml);
|
||||
}
|
||||
|
||||
static int qemudDomainGetAutostart(virDomainPtr dom,
|
||||
int *autostart) {
|
||||
struct qemud_driver *driver = dom->conn->privateData;
|
||||
@ -8577,7 +8601,9 @@ static virDriver qemuDriver = {
|
||||
qemudDomainDefine, /* domainDefineXML */
|
||||
qemudDomainUndefine, /* domainUndefine */
|
||||
qemudDomainAttachDevice, /* domainAttachDevice */
|
||||
qemudDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||
qemudDomainDetachDevice, /* domainDetachDevice */
|
||||
qemudDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||
qemudDomainGetAutostart, /* domainGetAutostart */
|
||||
qemudDomainSetAutostart, /* domainSetAutostart */
|
||||
qemuGetSchedulerType, /* domainGetSchedulerType */
|
||||
|
@ -5209,7 +5209,9 @@ static virDriver testDriver = {
|
||||
testDomainDefineXML, /* domainDefineXML */
|
||||
testDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
testDomainGetAutostart, /* domainGetAutostart */
|
||||
testDomainSetAutostart, /* domainSetAutostart */
|
||||
testDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||
|
@ -1895,7 +1895,9 @@ static virDriver umlDriver = {
|
||||
umlDomainDefine, /* domainDefineXML */
|
||||
umlDomainUndefine, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
umlDomainGetAutostart, /* domainGetAutostart */
|
||||
umlDomainSetAutostart, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
@ -4835,6 +4835,17 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
unsigned int flags) {
|
||||
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
|
||||
vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("cannot modify the persistent configuration of a domain"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return vboxDomainAttachDevice(dom, xml);
|
||||
}
|
||||
|
||||
static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
|
||||
VBOX_OBJECT_CHECK(dom->conn, int, -1);
|
||||
IMachine *machine = NULL;
|
||||
@ -4965,6 +4976,17 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
unsigned int flags) {
|
||||
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
|
||||
vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("cannot modify the persistent configuration of a domain"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return vboxDomainDetachDevice(dom, xml);
|
||||
}
|
||||
|
||||
#if VBOX_API_VERSION == 2002
|
||||
/* No Callback support for VirtualBox 2.2.* series */
|
||||
#else /* !(VBOX_API_VERSION == 2002) */
|
||||
@ -7001,7 +7023,9 @@ virDriver NAME(Driver) = {
|
||||
vboxDomainDefineXML, /* domainDefineXML */
|
||||
vboxDomainUndefine, /* domainUndefine */
|
||||
vboxDomainAttachDevice, /* domainAttachDevice */
|
||||
vboxDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||
vboxDomainDetachDevice, /* domainDetachDevice */
|
||||
vboxDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
@ -76,8 +76,8 @@ struct xenUnifiedDriver xenProxyDriver = {
|
||||
NULL, /* domainCreate */
|
||||
NULL, /* domainDefineXML */
|
||||
NULL, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
@ -1428,10 +1428,29 @@ xenUnifiedDomainAttachDevice (virDomainPtr dom, const char *xml)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
|
||||
|
||||
if (dom->id >= 0)
|
||||
flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] && drivers[i]->domainAttachDevice &&
|
||||
drivers[i]->domainAttachDevice (dom, xml) == 0)
|
||||
if (priv->opened[i] && drivers[i]->domainAttachDeviceFlags &&
|
||||
drivers[i]->domainAttachDeviceFlags(dom, xml, flags) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
xenUnifiedDomainAttachDeviceFlags (virDomainPtr dom, const char *xml,
|
||||
unsigned int flags)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] && drivers[i]->domainAttachDeviceFlags &&
|
||||
drivers[i]->domainAttachDeviceFlags(dom, xml, flags) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
@ -1442,10 +1461,29 @@ xenUnifiedDomainDetachDevice (virDomainPtr dom, const char *xml)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
unsigned int flags = VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
|
||||
|
||||
if (dom->id >= 0)
|
||||
flags |= VIR_DOMAIN_DEVICE_MODIFY_LIVE;
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] && drivers[i]->domainDetachDevice &&
|
||||
drivers[i]->domainDetachDevice (dom, xml) == 0)
|
||||
if (priv->opened[i] && drivers[i]->domainDetachDeviceFlags &&
|
||||
drivers[i]->domainDetachDeviceFlags(dom, xml, flags) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
xenUnifiedDomainDetachDeviceFlags (virDomainPtr dom, const char *xml,
|
||||
unsigned int flags)
|
||||
{
|
||||
GET_PRIVATE(dom->conn);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (priv->opened[i] && drivers[i]->domainDetachDeviceFlags &&
|
||||
drivers[i]->domainDetachDeviceFlags(dom, xml, flags) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
@ -1835,7 +1873,9 @@ static virDriver xenUnifiedDriver = {
|
||||
xenUnifiedDomainDefineXML, /* domainDefineXML */
|
||||
xenUnifiedDomainUndefine, /* domainUndefine */
|
||||
xenUnifiedDomainAttachDevice, /* domainAttachDevice */
|
||||
xenUnifiedDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||
xenUnifiedDomainDetachDevice, /* domainDetachDevice */
|
||||
xenUnifiedDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||
xenUnifiedDomainGetAutostart, /* domainGetAutostart */
|
||||
xenUnifiedDomainSetAutostart, /* domainSetAutostart */
|
||||
xenUnifiedDomainGetSchedulerType, /* domainGetSchedulerType */
|
||||
|
@ -93,8 +93,8 @@ struct xenUnifiedDriver {
|
||||
virDrvDomainCreate domainCreate;
|
||||
virDrvDomainDefineXML domainDefineXML;
|
||||
virDrvDomainUndefine domainUndefine;
|
||||
virDrvDomainAttachDevice domainAttachDevice;
|
||||
virDrvDomainDetachDevice domainDetachDevice;
|
||||
virDrvDomainAttachDeviceFlags domainAttachDeviceFlags;
|
||||
virDrvDomainDetachDeviceFlags domainDetachDeviceFlags;
|
||||
virDrvDomainGetAutostart domainGetAutostart;
|
||||
virDrvDomainSetAutostart domainSetAutostart;
|
||||
virDrvDomainGetSchedulerType domainGetSchedulerType;
|
||||
|
@ -793,8 +793,8 @@ struct xenUnifiedDriver xenHypervisorDriver = {
|
||||
NULL, /* domainCreate */
|
||||
NULL, /* domainDefineXML */
|
||||
NULL, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
xenHypervisorGetSchedulerType, /* domainGetSchedulerType */
|
||||
|
@ -79,8 +79,8 @@ struct xenUnifiedDriver xenInotifyDriver = {
|
||||
NULL, /* domainCreate */
|
||||
NULL, /* domainDefineXML */
|
||||
NULL, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
@ -4096,9 +4096,10 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
|
||||
}
|
||||
|
||||
/**
|
||||
* xenDaemonAttachDevice:
|
||||
* xenDaemonAttachDeviceFlags:
|
||||
* @domain: pointer to domain object
|
||||
* @xml: pointer to XML description of device
|
||||
* @flags: an OR'ed set of virDomainDeviceModifyFlags
|
||||
*
|
||||
* Create a virtual device attachment to backend.
|
||||
* XML description is translated into S-expression.
|
||||
@ -4106,7 +4107,8 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
|
||||
* Returns 0 in case of success, -1 in case of failure.
|
||||
*/
|
||||
static int
|
||||
xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
|
||||
xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv;
|
||||
char *sexpr = NULL;
|
||||
@ -4124,12 +4126,41 @@ xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
|
||||
|
||||
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
|
||||
|
||||
/*
|
||||
* on older Xen without the inactive guests management
|
||||
* avoid doing this on inactive guests
|
||||
*/
|
||||
if ((domain->id < 0) && (priv->xendConfigVersion < 3))
|
||||
return -1;
|
||||
if (domain->id < 0) {
|
||||
/* If xendConfigVersion < 3 only live config can be changed */
|
||||
if (priv->xendConfigVersion < 3) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Xend version does not support modifying "
|
||||
"persisted config"));
|
||||
return -1;
|
||||
}
|
||||
/* Cannot modify live config if domain is inactive */
|
||||
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Cannot modify live config if domain is inactive"));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
/* Only live config can be changed if xendConfigVersion < 3 */
|
||||
if (priv->xendConfigVersion < 3 &&
|
||||
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT ||
|
||||
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Xend version does not support modifying "
|
||||
"persisted config"));
|
||||
return -1;
|
||||
}
|
||||
/* Xen only supports modifying both live and persisted config if
|
||||
* xendConfigVersion >= 3
|
||||
*/
|
||||
if (flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Xend only supports modifying both live and "
|
||||
"persisted config"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(def = xenDaemonDomainFetch(domain->conn,
|
||||
domain->id,
|
||||
@ -4203,16 +4234,18 @@ cleanup:
|
||||
}
|
||||
|
||||
/**
|
||||
* xenDaemonDetachDevice:
|
||||
* xenDaemonDetachDeviceFlags:
|
||||
* @domain: pointer to domain object
|
||||
* @xml: pointer to XML description of device
|
||||
* @flags: an OR'ed set of virDomainDeviceModifyFlags
|
||||
*
|
||||
* Destroy a virtual device attachment to backend.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of failure.
|
||||
*/
|
||||
static int
|
||||
xenDaemonDetachDevice(virDomainPtr domain, const char *xml)
|
||||
xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv;
|
||||
char class[8], ref[80];
|
||||
@ -4230,12 +4263,41 @@ xenDaemonDetachDevice(virDomainPtr domain, const char *xml)
|
||||
|
||||
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
|
||||
|
||||
/*
|
||||
* on older Xen without the inactive guests management
|
||||
* avoid doing this on inactive guests
|
||||
*/
|
||||
if ((domain->id < 0) && (priv->xendConfigVersion < 3))
|
||||
return -1;
|
||||
if (domain->id < 0) {
|
||||
/* If xendConfigVersion < 3 only live config can be changed */
|
||||
if (priv->xendConfigVersion < 3) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Xend version does not support modifying "
|
||||
"persisted config"));
|
||||
return -1;
|
||||
}
|
||||
/* Cannot modify live config if domain is inactive */
|
||||
if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Cannot modify live config if domain is inactive"));
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
/* Only live config can be changed if xendConfigVersion < 3 */
|
||||
if (priv->xendConfigVersion < 3 &&
|
||||
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT ||
|
||||
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Xend version does not support modifying "
|
||||
"persisted config"));
|
||||
return -1;
|
||||
}
|
||||
/* Xen only supports modifying both live and persisted config if
|
||||
* xendConfigVersion >= 3
|
||||
*/
|
||||
if (flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
|
||||
VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
|
||||
virXendError(domain->conn, VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Xend only supports modifying both live and "
|
||||
"persisted config"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(def = xenDaemonDomainFetch(domain->conn,
|
||||
domain->id,
|
||||
@ -5165,8 +5227,8 @@ struct xenUnifiedDriver xenDaemonDriver = {
|
||||
xenDaemonDomainCreate, /* domainCreate */
|
||||
xenDaemonDomainDefineXML, /* domainDefineXML */
|
||||
xenDaemonDomainUndefine, /* domainUndefine */
|
||||
xenDaemonAttachDevice, /* domainAttachDevice */
|
||||
xenDaemonDetachDevice, /* domainDetachDevice */
|
||||
xenDaemonAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||
xenDaemonDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||
xenDaemonDomainGetAutostart, /* domainGetAutostart */
|
||||
xenDaemonDomainSetAutostart, /* domainSetAutostart */
|
||||
xenDaemonGetSchedulerType, /* domainGetSchedulerType */
|
||||
|
@ -65,8 +65,10 @@
|
||||
static int xenXMConfigSetString(virConfPtr conf, const char *setting,
|
||||
const char *str);
|
||||
char * xenXMAutoAssignMac(void);
|
||||
static int xenXMDomainAttachDevice(virDomainPtr domain, const char *xml);
|
||||
static int xenXMDomainDetachDevice(virDomainPtr domain, const char *xml);
|
||||
static int xenXMDomainAttachDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags);
|
||||
static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags);
|
||||
|
||||
#define XM_REFRESH_INTERVAL 10
|
||||
|
||||
@ -109,8 +111,8 @@ struct xenUnifiedDriver xenXMDriver = {
|
||||
xenXMDomainCreate, /* domainCreate */
|
||||
xenXMDomainDefineXML, /* domainDefineXML */
|
||||
xenXMDomainUndefine, /* domainUndefine */
|
||||
xenXMDomainAttachDevice, /* domainAttachDevice */
|
||||
xenXMDomainDetachDevice, /* domainDetachDevice */
|
||||
xenXMDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
|
||||
xenXMDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
@ -2914,17 +2916,21 @@ cleanup:
|
||||
|
||||
|
||||
/**
|
||||
* xenXMDomainAttachDevice:
|
||||
* xenXMDomainAttachDeviceFlags:
|
||||
* @domain: pointer to domain object
|
||||
* @xml: pointer to XML description of device
|
||||
* @flags: an OR'ed set of virDomainDeviceModifyFlags
|
||||
*
|
||||
* Create a virtual device attachment to backend.
|
||||
* XML description is translated into config file.
|
||||
* This driver only supports device allocation to
|
||||
* persisted config.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of failure.
|
||||
*/
|
||||
static int
|
||||
xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
|
||||
xenXMDomainAttachDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags) {
|
||||
const char *filename = NULL;
|
||||
xenXMConfCachePtr entry = NULL;
|
||||
int ret = -1;
|
||||
@ -2940,7 +2946,7 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
|
||||
|
||||
if (domain->conn->flags & VIR_CONNECT_RO)
|
||||
return -1;
|
||||
if (domain->id != -1)
|
||||
if (domain->id != -1 && !(flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG))
|
||||
return -1;
|
||||
|
||||
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
|
||||
@ -3002,16 +3008,20 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
|
||||
|
||||
|
||||
/**
|
||||
* xenXMDomainDetachDevice:
|
||||
* xenXMDomainDetachDeviceFlags:
|
||||
* @domain: pointer to domain object
|
||||
* @xml: pointer to XML description of device
|
||||
* @flags: an OR'ed set of virDomainDeviceModifyFlags
|
||||
*
|
||||
* Destroy a virtual device attachment to backend.
|
||||
* This driver only supports device deallocation from
|
||||
* persisted config.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of failure.
|
||||
*/
|
||||
static int
|
||||
xenXMDomainDetachDevice(virDomainPtr domain, const char *xml) {
|
||||
xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
|
||||
unsigned int flags) {
|
||||
const char *filename = NULL;
|
||||
xenXMConfCachePtr entry = NULL;
|
||||
virDomainDeviceDefPtr dev = NULL;
|
||||
@ -3029,7 +3039,7 @@ xenXMDomainDetachDevice(virDomainPtr domain, const char *xml) {
|
||||
|
||||
if (domain->conn->flags & VIR_CONNECT_RO)
|
||||
return -1;
|
||||
if (domain->id != -1)
|
||||
if (domain->id != -1 && !(flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG))
|
||||
return -1;
|
||||
|
||||
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
|
||||
|
@ -76,8 +76,8 @@ struct xenUnifiedDriver xenStoreDriver = {
|
||||
NULL, /* domainCreate */
|
||||
NULL, /* domainDefineXML */
|
||||
NULL, /* domainUndefine */
|
||||
NULL, /* domainAttachDevice */
|
||||
NULL, /* domainDetachDevice */
|
||||
NULL, /* domainAttachDeviceFlags */
|
||||
NULL, /* domainDetachDeviceFlags */
|
||||
NULL, /* domainGetAutostart */
|
||||
NULL, /* domainSetAutostart */
|
||||
NULL, /* domainGetSchedulerType */
|
||||
|
Loading…
x
Reference in New Issue
Block a user