c401cc
From 3a4a77bb81e54b00fde463ebbab7fba43f19cda7 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <3a4a77bb81e54b00fde463ebbab7fba43f19cda7.1389183250.git.jdenemar@redhat.com>
c401cc
From: Peter Krempa <pkrempa@redhat.com>
c401cc
Date: Wed, 8 Jan 2014 10:47:23 +0100
c401cc
Subject: [PATCH] virsh: Use inactive definition when removing disk from config
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1049529
c401cc
c401cc
The 'detach-disk' command in virsh used the active XML definition of a
c401cc
domain even when attempting to remove a disk from the config only. If
c401cc
the disk was only in the inactive definition the operation failed. Fix
c401cc
this by using the inactive XML in case that only the config is affected.
c401cc
c401cc
(cherry picked from commit f9d06ebcef9faffc085bab68968b8bb78f49f2d0)
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 tools/virsh-domain.c | 7 ++++++-
c401cc
 1 file changed, 6 insertions(+), 1 deletion(-)
c401cc
c401cc
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
c401cc
index 132b359..724ec1a 100644
c401cc
--- a/tools/virsh-domain.c
c401cc
+++ b/tools/virsh-domain.c
c401cc
@@ -10022,7 +10022,12 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
c401cc
     if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
c401cc
         goto cleanup;
c401cc
 
c401cc
-    if (!(doc = virDomainGetXMLDesc(dom, 0)))
c401cc
+    if (flags == VIR_DOMAIN_AFFECT_CONFIG)
c401cc
+        doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE);
c401cc
+    else
c401cc
+        doc = virDomainGetXMLDesc(dom, 0);
c401cc
+
c401cc
+    if (!doc)
c401cc
         goto cleanup;
c401cc
 
c401cc
     if (persistent &&
c401cc
-- 
c401cc
1.8.5.2
c401cc