render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c401cc
From 4ef5b6a388a9cf0088fc385c3360e83650ac6f5f Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <4ef5b6a388a9cf0088fc385c3360e83650ac6f5f.1389183250.git.jdenemar@redhat.com>
c401cc
From: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
c401cc
Date: Wed, 8 Jan 2014 10:47:21 +0100
c401cc
Subject: [PATCH] virsh: improve usability of '--print-xml' flag for
c401cc
 attach-disk command
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1049529
c401cc
c401cc
'--print-xml' option is very useful for doing some test.
c401cc
But we had to specify a real domain for it.
c401cc
This patch could enable us to specify a fake domain
c401cc
when using --print-xml option.
c401cc
c401cc
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
c401cc
Signed-off-by: Eric Blake <eblake@redhat.com>
c401cc
(cherry picked from commit 21f2d80b0cdf30fe3a6c942f9d7d6b17cb73ec66)
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 tools/virsh-domain.c | 17 +++++++++--------
c401cc
 1 file changed, 9 insertions(+), 8 deletions(-)
c401cc
c401cc
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
c401cc
index 3895f39..b017ec3 100644
c401cc
--- a/tools/virsh-domain.c
c401cc
+++ b/tools/virsh-domain.c
c401cc
@@ -528,13 +528,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
c401cc
     if (live)
c401cc
         flags |= VIR_DOMAIN_AFFECT_LIVE;
c401cc
 
c401cc
-    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
c401cc
-        return false;
c401cc
-
c401cc
-    if (persistent &&
c401cc
-        virDomainIsActive(dom) == 1)
c401cc
-        flags |= VIR_DOMAIN_AFFECT_LIVE;
c401cc
-
c401cc
     if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 ||
c401cc
         vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 ||
c401cc
         vshCommandOptStringReq(ctl, cmd, "driver", &driver) < 0 ||
c401cc
@@ -672,6 +665,13 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
c401cc
         goto cleanup;
c401cc
     }
c401cc
 
c401cc
+    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
c401cc
+        goto cleanup;
c401cc
+
c401cc
+    if (persistent &&
c401cc
+        virDomainIsActive(dom) == 1)
c401cc
+        flags |= VIR_DOMAIN_AFFECT_LIVE;
c401cc
+
c401cc
     if (flags)
c401cc
         ret = virDomainAttachDeviceFlags(dom, xml, flags);
c401cc
     else
c401cc
@@ -686,7 +686,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
c401cc
 
c401cc
  cleanup:
c401cc
     VIR_FREE(xml);
c401cc
-    virDomainFree(dom);
c401cc
+    if (dom)
c401cc
+        virDomainFree(dom);
c401cc
     virBufferFreeAndReset(&buf;;
c401cc
     return functionReturn;
c401cc
 }
c401cc
-- 
c401cc
1.8.5.2
c401cc