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

Re: [libvirt] [PATCH v2 8/8] virsh: Extend virsh dominfo to display if managed state exists



于 2011年07月16日 05:45, Eric Blake 写道:
On 07/15/2011 03:06 AM, Osier Yang wrote:
---
  tools/virsh.c |    8 ++++++++
  1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 8a62612..120f3c8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2366,6 +2366,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
      int autostart;
      unsigned int id;
      char *str, uuid[VIR_UUID_STRING_BUFLEN];
+    int has_managed_state = 0;

      if (!vshConnectionUsability(ctl, ctl->conn))
          return false;
@@ -2430,6 +2431,13 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
                   autostart ? _("enable") : _("disable") );
      }

+    has_managed_state = virDomainHasManagedSaveImage(dom, 0);
+    if (has_managed_state<  0)
+        vshPrint(ctl, "%-15s %s\n", _("Has managed state:"), _("unknown"));
+    else
+        vshPrint(ctl, "%-15s %s\n", _("Has managed state:"),
+                 has_managed_state ? _("yes") : _("no"));
This changes default output of an existing command, but it's not the
first time we've done that (for example, commit aa2c9726 added the
"Security model" string).  For this particular command, that's fine,
since it remains machine parsable (each line is a name-value pair, and
you search for the line with the name you care about); still, I'd feel
better if your new string came last rather than in the middle in case
existing parsers count a certain number of lines and expect a particular
name on that line.

Agree it's better as a last string, but it's need changes on codes to
print "Security *" strings, to prevent the early return.


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