[libvirt] [PATCH 1/4] xen: Make xenDaemon*DeviceFlags errors less confusing

Jiri Denemark jdenemar at redhat.com
Fri Oct 1 20:09:17 UTC 2010


When a user calls to virDomain{Attach,Detach,Update}DeviceFlags() with
flags == VIR_DOMAIN_DEVICE_MODIFY_LIVE on an inactive guest running on
an old Xen hypervisor (such as RHEL-5) xend_internal driver reports:

    Xend version does not support modifying persistent config

which is pretty confusing since no-one requested to modify persistent
config.
---
 src/xen/xend_internal.c |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index fce0233..1318bd4 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -3878,6 +3878,12 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
     priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
 
     if (domain->id < 0) {
+        /* Cannot modify live config if domain is inactive */
+        if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
+            virXendError(VIR_ERR_OPERATION_INVALID, "%s",
+                         _("Cannot modify live config if domain is inactive"));
+            return -1;
+        }
         /* If xendConfigVersion < 3 only live config can be changed */
         if (priv->xendConfigVersion < 3) {
             virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -3885,12 +3891,6 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
                            "persistent config"));
             return -1;
         }
-        /* Cannot modify live config if domain is inactive */
-        if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
-            virXendError(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 &&
@@ -4017,6 +4017,12 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
     priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
 
     if (domain->id < 0) {
+        /* Cannot modify live config if domain is inactive */
+        if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
+            virXendError(VIR_ERR_OPERATION_INVALID, "%s",
+                         _("Cannot modify live config if domain is inactive"));
+            return -1;
+        }
         /* If xendConfigVersion < 3 only live config can be changed */
         if (priv->xendConfigVersion < 3) {
             virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -4024,12 +4030,6 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
                            "persistent config"));
             return -1;
         }
-        /* Cannot modify live config if domain is inactive */
-        if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
-            virXendError(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 &&
@@ -4128,6 +4128,12 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
     priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
 
     if (domain->id < 0) {
+        /* Cannot modify live config if domain is inactive */
+        if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
+            virXendError(VIR_ERR_OPERATION_INVALID, "%s",
+                         _("Cannot modify live config if domain is inactive"));
+            return -1;
+        }
         /* If xendConfigVersion < 3 only live config can be changed */
         if (priv->xendConfigVersion < 3) {
             virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -4135,12 +4141,6 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
                            "persistent config"));
             return -1;
         }
-        /* Cannot modify live config if domain is inactive */
-        if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) {
-            virXendError(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 &&
-- 
1.7.3.1




More information about the libvir-list mailing list