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

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



Signed-off-by: Lin Ma <lma suse de>
---
 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


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