SHA256
1
0
forked from pool/libvirt
libvirt/devflag-08.patch

610 lines
25 KiB
Diff
Raw Normal View History

commit ff9fce67120771b0ec1e21a98afc96360a7bbb36
Author: Jim Fehlig <jfehlig@novell.com>
Date: Wed Jan 13 18:44:26 2010 -0700
domain{Attach,Detach}DeviceFlags handler for drivers
Implementation of domain{Attach,Detach}DeviceFlags handlers
in the drivers.
Index: libvirt-0.7.6/src/esx/esx_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/esx/esx_driver.c
+++ libvirt-0.7.6/src/esx/esx_driver.c
@@ -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 */
Index: libvirt-0.7.6/src/lxc/lxc_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/lxc/lxc_driver.c
+++ libvirt-0.7.6/src/lxc/lxc_driver.c
@@ -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 */
Index: libvirt-0.7.6/src/opennebula/one_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/opennebula/one_driver.c
+++ libvirt-0.7.6/src/opennebula/one_driver.c
@@ -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 */
Index: libvirt-0.7.6/src/openvz/openvz_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/openvz/openvz_driver.c
+++ libvirt-0.7.6/src/openvz/openvz_driver.c
@@ -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 */
Index: libvirt-0.7.6/src/phyp/phyp_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/phyp/phyp_driver.c
+++ libvirt-0.7.6/src/phyp/phyp_driver.c
@@ -1622,7 +1622,9 @@ virDriver phypDriver = {
NULL, /* domainDefineXML */
NULL, /* domainUndefine */
NULL, /* domainAttachDevice */
+ NULL, /* domainAttachDeviceFlags */
NULL, /* domainDetachDevice */
+ NULL, /* domainDetachDeviceFlags */
NULL, /* domainGetAutostart */
NULL, /* domainSetAutostart */
NULL, /* domainGetSchedulerType */
Index: libvirt-0.7.6/src/qemu/qemu_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/qemu/qemu_driver.c
+++ libvirt-0.7.6/src/qemu/qemu_driver.c
@@ -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 */
Index: libvirt-0.7.6/src/test/test_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/test/test_driver.c
+++ libvirt-0.7.6/src/test/test_driver.c
@@ -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 */
Index: libvirt-0.7.6/src/uml/uml_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/uml/uml_driver.c
+++ libvirt-0.7.6/src/uml/uml_driver.c
@@ -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 */
Index: libvirt-0.7.6/src/vbox/vbox_tmpl.c
===================================================================
--- libvirt-0.7.6.orig/src/vbox/vbox_tmpl.c
+++ libvirt-0.7.6/src/vbox/vbox_tmpl.c
@@ -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 */
Index: libvirt-0.7.6/src/xen/proxy_internal.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/proxy_internal.c
+++ libvirt-0.7.6/src/xen/proxy_internal.c
@@ -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 */
Index: libvirt-0.7.6/src/xen/xen_driver.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/xen_driver.c
+++ libvirt-0.7.6/src/xen/xen_driver.c
@@ -1428,10 +1428,29 @@ xenUnifiedDomainAttachDevice (virDomainP
{
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]->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]->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;
@@ -1442,10 +1461,29 @@ xenUnifiedDomainDetachDevice (virDomainP
{
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]->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]->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;
@@ -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 */
Index: libvirt-0.7.6/src/xen/xen_driver.h
===================================================================
--- libvirt-0.7.6.orig/src/xen/xen_driver.h
+++ libvirt-0.7.6/src/xen/xen_driver.h
@@ -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;
Index: libvirt-0.7.6/src/xen/xen_hypervisor.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/xen_hypervisor.c
+++ libvirt-0.7.6/src/xen/xen_hypervisor.c
@@ -793,8 +793,8 @@ struct xenUnifiedDriver xenHypervisorDri
NULL, /* domainCreate */
NULL, /* domainDefineXML */
NULL, /* domainUndefine */
- NULL, /* domainAttachDevice */
- NULL, /* domainDetachDevice */
+ NULL, /* domainAttachDeviceFlags */
+ NULL, /* domainDetachDeviceFlags */
NULL, /* domainGetAutostart */
NULL, /* domainSetAutostart */
xenHypervisorGetSchedulerType, /* domainGetSchedulerType */
Index: libvirt-0.7.6/src/xen/xen_inotify.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/xen_inotify.c
+++ libvirt-0.7.6/src/xen/xen_inotify.c
@@ -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 */
Index: libvirt-0.7.6/src/xen/xend_internal.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/xend_internal.c
+++ libvirt-0.7.6/src/xen/xend_internal.c
@@ -4096,9 +4096,10 @@ xenDaemonCreateXML(virConnectPtr conn, c
}
/**
- * 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, c
* 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 domai
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 domai
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 */
Index: libvirt-0.7.6/src/xen/xm_internal.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/xm_internal.c
+++ libvirt-0.7.6/src/xen/xm_internal.c
@@ -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 dom
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 dom
/**
- * 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 dom
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;
Index: libvirt-0.7.6/src/xen/xs_internal.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/xs_internal.c
+++ libvirt-0.7.6/src/xen/xs_internal.c
@@ -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 */