于 2011年07月16日 11:11, Osier Yang 写道:
于 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.
I'm inclined to keep this patch unchanged, as for the "security" strings,
there will be no strings printed out if virNodeGetSecurityModel is not
supported. So it still may break the script which parse a certain number
of lines.
And if we print "security" strings regardless of whether is supported or
not, success or failure, (just like "persistent", "autostart" do), it
might
break the scripts too.
Regards
Osier
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list