]> xenbits.xensource.com Git - libvirt.git/commitdiff
xen: Make xenDaemon*DeviceFlags errors less confusing
authorJiri Denemark <jdenemar@redhat.com>
Fri, 1 Oct 2010 14:22:29 +0000 (16:22 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 12 Oct 2010 10:16:12 +0000 (12:16 +0200)
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

index fce0233c3cc26f36450cc8df68a551294ef36466..1318bd4e71561d04710b03e82c6f1eb279887cfc 100644 (file)
@@ -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 &&