[libvirt] [PATCH 8/9] domain{Attach, Detach}DeviceFlags handler for drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implementation of domain{Attach,Detach}DeviceFlags handlers
in the drivers.
---
 src/esx/esx_driver.c        |    2 +
 src/lxc/lxc_driver.c        |    2 +
 src/opennebula/one_driver.c |    2 +
 src/openvz/openvz_driver.c  |    2 +
 src/phyp/phyp_driver.c      |    2 +
 src/qemu/qemu_driver.c      |   26 +++++++++++
 src/test/test_driver.c      |    2 +
 src/uml/uml_driver.c        |    2 +
 src/vbox/vbox_tmpl.c        |   24 ++++++++++
 src/xen/proxy_internal.c    |    4 +-
 src/xen/xen_driver.c        |   42 +++++++++++++++++--
 src/xen/xen_driver.h        |    4 +-
 src/xen/xen_hypervisor.c    |    4 +-
 src/xen/xen_inotify.c       |    4 +-
 src/xen/xend_internal.c     |   98 +++++++++++++++++++++++++++++++++++--------
 src/xen/xm_internal.c       |   30 +++++++++----
 src/xen/xs_internal.c       |    4 +-
 17 files changed, 212 insertions(+), 42 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index ddda66e..577c1c7 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3443,7 +3443,9 @@ static virDriver esxDriver = {
     esxDomainDefineXML,              /* domainDefineXML */
     esxDomainUndefine,               /* domainUndefine */
     NULL,                            /* domainAttachDevice */
+    NULL,                            /* domainAttachDeviceFlags */
     NULL,                            /* domainDetachDevice */
+    NULL,                            /* domainDetachDeviceFlags */
     NULL,                            /* domainGetAutostart */
     NULL,                            /* domainSetAutostart */
     esxDomainGetSchedulerType,       /* domainGetSchedulerType */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 86606c7..d80f20c 100644
--- a/src/lxc/lxc_driver.c
+++ b/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 */
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index ad7faca..509cbc3 100644
--- a/src/opennebula/one_driver.c
+++ b/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 */
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 196fd8c..b16efef 100644
--- a/src/openvz/openvz_driver.c
+++ b/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 */
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index bd5cfc7..5474bda 100644
--- a/src/phyp/phyp_driver.c
+++ b/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 */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index deb8adc..02a6212 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5544,6 +5544,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,
@@ -5872,6 +5884,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;
@@ -7985,7 +8009,9 @@ static virDriver qemuDriver = {
     qemudDomainDefine, /* domainDefineXML */
     qemudDomainUndefine, /* domainUndefine */
     qemudDomainAttachDevice, /* domainAttachDevice */
+    qemudDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
     qemudDomainDetachDevice, /* domainDetachDevice */
+    qemudDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
     qemudDomainGetAutostart, /* domainGetAutostart */
     qemudDomainSetAutostart, /* domainSetAutostart */
     qemuGetSchedulerType, /* domainGetSchedulerType */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 2122a1b..1feca1c 100644
--- a/src/test/test_driver.c
+++ b/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 */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index b808090..6adaf9f 100644
--- a/src/uml/uml_driver.c
+++ b/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 */
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 07696c0..79915c2 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -4837,6 +4837,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;
@@ -4967,6 +4978,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) */
@@ -7013,7 +7035,9 @@ virDriver NAME(Driver) = {
     vboxDomainDefineXML, /* domainDefineXML */
     vboxDomainUndefine, /* domainUndefine */
     vboxDomainAttachDevice, /* domainAttachDevice */
+    vboxDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
     vboxDomainDetachDevice, /* domainDetachDevice */
+    vboxDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
     NULL, /* domainGetAutostart */
     NULL, /* domainSetAutostart */
     NULL, /* domainGetSchedulerType */
diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c
index 73a0469..33f82c2 100644
--- a/src/xen/proxy_internal.c
+++ b/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 */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 4911c9e..141e415 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1426,10 +1426,26 @@ xenUnifiedDomainAttachDevice (virDomainPtr dom, const char *xml)
 {
     GET_PRIVATE(dom->conn);
     int i;
+    unsigned int 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;
@@ -1440,10 +1456,26 @@ xenUnifiedDomainDetachDevice (virDomainPtr dom, const char *xml)
 {
     GET_PRIVATE(dom->conn);
     int i;
+    unsigned int 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;
@@ -1833,7 +1865,9 @@ static virDriver xenUnifiedDriver = {
     xenUnifiedDomainDefineXML, /* domainDefineXML */
     xenUnifiedDomainUndefine, /* domainUndefine */
     xenUnifiedDomainAttachDevice, /* domainAttachDevice */
+    xenUnifiedDomainAttachDeviceFlags, /* domainAttachDeviceFlags */
     xenUnifiedDomainDetachDevice, /* domainDetachDevice */
+    xenUnifiedDomainDetachDeviceFlags, /* domainDetachDeviceFlags */
     xenUnifiedDomainGetAutostart, /* domainGetAutostart */
     xenUnifiedDomainSetAutostart, /* domainSetAutostart */
     xenUnifiedDomainGetSchedulerType, /* domainGetSchedulerType */
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index 185eb2b..defe6e2 100644
--- a/src/xen/xen_driver.h
+++ b/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;
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 6d8accc..baa626f 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -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 */
diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index d9dfbb7..e3845d8 100644
--- a/src/xen/xen_inotify.c
+++ b/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 */
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index d9bfa15..665bc47 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -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 */
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 944d5d5..43efe08 100644
--- a/src/xen/xm_internal.c
+++ b/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 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;
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 8a64d4e..1db0397 100644
--- a/src/xen/xs_internal.c
+++ b/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 */
-- 
1.6.0.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]