[libvirt] [PATCH 1/3] virsh: don't list unknown domains
Michal Privoznik
mprivozn at redhat.com
Thu Oct 30 17:43:09 UTC 2014
On 30.10.2014 16:04, Martin Kletzander wrote:
> When the list of domains is fetched and being printed, but in the
> meantime one domain was undefined before its status was fetched, the
> output then includes domain with "no state". With this patch, such
> domain is skipped over as consecutive 'virsh list --all' (or the same
> one ran a second later) wouldn't list it anyway.
>
> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
> tools/virsh-domain-monitor.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
> index 2af0d4f..4e434f8 100644
> --- a/tools/virsh-domain-monitor.c
> +++ b/tools/virsh-domain-monitor.c
> @@ -1916,6 +1916,11 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
> ignore_value(virStrcpyStatic(id_buf, "-"));
>
> state = vshDomainState(ctl, dom, NULL);
> +
> + /* Domain could've been removed in the meantime */
> + if (state < 0)
> + continue;
> +
> if (optTable && managed && state == VIR_DOMAIN_SHUTOFF &&
> virDomainHasManagedSaveImage(dom, 0) > 0)
> state = -2;
>
ACK and safe for freeze. This may happen esp. when using the old,
non-atomic APIs to list domains. For instance, domain is shutoff, then
undefine happens and then we query the domain state.
Michal
More information about the libvir-list
mailing list