提交 5be0d28b 编写于 作者: P Pavel Mores 提交者: Ján Tomko

fixed handling of sourceless disks in 'domblkinfo' cmd

virDomainGetBlockInfo() returns error if called on a disk with no
source (a sourceless disk might be a removable media drive with no
media in it, for instance an empty CDROM or floppy drive).

So far this caused the virsh domblkinfo --all command to abort and
ignore any remaining (not yet displayed) disk devices.  This patch
fixes the problem by first checking for existence of a <source>
element in the corresponding XML.  If none is found, we avoid calling
virDomainGetBlockInfo() altogether as we know it's bound to fail in
that case.

https://bugzilla.redhat.com/show_bug.cgi?id=1619625Signed-off-by: NPavel Mores <pmores@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 2de75faa
......@@ -507,12 +507,14 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
protocol = virXPathString("string(./source/@protocol)", ctxt);
target = virXPathString("string(./target/@dev)", ctxt);
if (virXPathBoolean("boolean(./source)", ctxt) == 1) {
rc = virDomainGetBlockInfo(dom, target, &info, 0);
if (rc < 0) {
/* If protocol is present that's an indication of a networked
* storage device which cannot provide statistics, so generate
* 0 based data and get the next disk. */
/* If protocol is present that's an indication of a
* networked storage device which cannot provide statistics,
* so generate 0 based data and get the next disk. */
if (protocol && !active &&
virGetLastErrorCode() == VIR_ERR_INTERNAL_ERROR &&
virGetLastErrorDomain() == VIR_FROM_STORAGE) {
......@@ -522,6 +524,11 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
}
} else {
/* if we don't call virDomainGetBlockInfo() who clears 'info'
* we have to do it manually */
memset(&info, 0, sizeof(info));
}
if (!cmdDomblkinfoGet(ctl, &info, &cap, &alloc, &phy, human))
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册