[libvirt] [PATCH 04/12] virsh: domid: Error out if domain is not active
Ján Tomko
jtomko at redhat.com
Sat Sep 12 10:31:02 UTC 2020
On a Friday in 2020, Lin Ma wrote:
>Signed-off-by: Lin Ma <lma at 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"));
I'm not convinced we should change the existing behavior here.
Jano
>+ } else {
> vshPrint(ctl, "%d\n", id);
>+ ret = true;
>+ }
> virshDomainFree(dom);
>- return true;
>+ return ret;
> }
>
> /*
>--
>2.26.0
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20200912/3ea02a6d/attachment-0001.sig>
More information about the libvir-list
mailing list