Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > ebe084c140192657f9094e135a84202c > files > 157

libvirt-0.8.2-29.el5.src.rpm

From fc247ff9727d4196f02eafe0562ae49363e24969 Mon Sep 17 00:00:00 2001
Message-Id: <fc247ff9727d4196f02eafe0562ae49363e24969.1287067706.git.jdenemar@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 1 Oct 2010 16:22:29 +0200
Subject: [PATCH] xen: Make xenDaemon*DeviceFlags errors less confusing

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=638520

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.
(cherry picked from commit 28160e22640f693159d9e793c0fe4941f5f58332)
---
 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 a586b1c..a586e1e 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -3871,6 +3871,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",
@@ -3878,12 +3884,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 &&
@@ -4010,6 +4010,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",
@@ -4017,12 +4023,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 &&
@@ -4121,6 +4121,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",
@@ -4128,12 +4134,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