提交 3bd2ee5d 编写于 作者: M Michal Privoznik

virsh: Don't fetch status for all domains in cmdList

We are getting the list of domains and after that we iterate over
the list and try to get status for each domain hoping it will
skip over domains that disappeared meanwhile. However, this
solution to race is bogus - domain may disappear right after we
have checked its state and before we exec another API over it
(e.g. virDomainHasManagedSaveImage()). Also, when printing just
names or uuids (list --name / --uuid) we issue APIs to obtain the
values, however these require no RPC call as all requested info
is in virDomain object that client already has.
Therefore move the status obtaining only to the place that really
needs it.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 a6cfd22e
......@@ -1876,17 +1876,17 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
else
ignore_value(virStrcpyStatic(id_buf, "-"));
state = virshDomainState(ctl, dom, NULL);
if (optTable) {
state = virshDomainState(ctl, dom, NULL);
/* Domain could've been removed in the meantime */
if (state < 0)
continue;
/* 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;
if (managed && state == VIR_DOMAIN_SHUTOFF &&
virDomainHasManagedSaveImage(dom, 0) > 0)
state = -2;
if (optTable) {
if (optTitle) {
if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册