[PATCH 04/12] virsh: domid: Error out if domain is not active

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Lin Ma <lma@xxxxxxx>
---
 tools/virsh-domain.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d1d3f8e566..86152a53b1 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10458,18 +10458,21 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
     unsigned int id;
+    bool ret = false;
 
     if (!(dom = virshCommandOptDomainBy(ctl, cmd, NULL,
                                         VIRSH_BYNAME|VIRSH_BYUUID)))
-        return false;
+        return ret;
 
     id = virDomainGetID(dom);
-    if (id == ((unsigned int)-1))
-        vshPrint(ctl, "%s\n", "-");
-    else
+    if (id == ((unsigned int)-1)) {
+        vshError(ctl, "%s", _("Domain is not active"));
+    } else {
         vshPrint(ctl, "%d\n", id);
+        ret = true;
+    }
     virshDomainFree(dom);
-    return true;
+    return ret;
 }
 
 /*
-- 
2.26.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux