提交 7b499262 编写于 作者: E Eric Blake

getstats: add block.n.path stat

I'm about to make block stats optionally more complex to cover
backing chains, where block.count will no longer equal the number
of <disks> for a domain.  For these reasons, it is nicer if the
statistics output includes the source path (for local files).
This patch doesn't add anything for network disks, although we
may decide to add that later.

With this patch, I now see the following for the same domain as
in the previous patch (one qcow2 file, and an empty cdrom drive):
$ virsh domstats --block foo
Domain: 'foo'
  block.count=2
  block.0.name=hda
  block.0.path=/var/lib/libvirt/images/foo.qcow2
  block.1.name=hdc

* src/libvirt-domain.c (virConnectGetAllDomainStats): Document
new field.
* tools/virsh.pod (domstats): Document new field.
* src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Return the new
stat for local files/block devices.
(QEMU_ADD_NAME_PARAM): Add parameter.
(qemuDomainGetStatsInterface): Update caller.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 56b21dfe
...@@ -10910,6 +10910,9 @@ virConnectGetDomainCapabilities(virConnectPtr conn, ...@@ -10910,6 +10910,9 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
* "block.<num>.name" - name of the block device <num> as string. * "block.<num>.name" - name of the block device <num> as string.
* matches the target name (vda/sda/hda) of the * matches the target name (vda/sda/hda) of the
* block device. * block device.
* "block.<num>.path" - string describing the source of block device <num>,
* if it is a file or block device (omitted for network
* sources and drives with no media inserted).
* "block.<num>.rd.reqs" - number of read requests as unsigned long long. * "block.<num>.rd.reqs" - number of read requests as unsigned long long.
* "block.<num>.rd.bytes" - number of read bytes as unsigned long long. * "block.<num>.rd.bytes" - number of read bytes as unsigned long long.
* "block.<num>.rd.times" - total time (ns) spent on reads as * "block.<num>.rd.times" - total time (ns) spent on reads as
......
...@@ -18374,11 +18374,11 @@ do { \ ...@@ -18374,11 +18374,11 @@ do { \
goto cleanup; \ goto cleanup; \
} while (0) } while (0)
#define QEMU_ADD_NAME_PARAM(record, maxparams, type, num, name) \ #define QEMU_ADD_NAME_PARAM(record, maxparams, type, subtype, num, name) \
do { \ do { \
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \ char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \ snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
"%s.%zu.name", type, num); \ "%s.%zu.%s", type, num, subtype); \
if (virTypedParamsAddString(&(record)->params, \ if (virTypedParamsAddString(&(record)->params, \
&(record)->nparams, \ &(record)->nparams, \
maxparams, \ maxparams, \
...@@ -18424,7 +18424,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED, ...@@ -18424,7 +18424,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
memset(&tmp, 0, sizeof(tmp)); memset(&tmp, 0, sizeof(tmp));
QEMU_ADD_NAME_PARAM(record, maxparams, QEMU_ADD_NAME_PARAM(record, maxparams,
"net", i, dom->def->nets[i]->ifname); "net", "name", i, dom->def->nets[i]->ifname);
if (virNetInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) { if (virNetInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) {
virResetLastError(); virResetLastError();
...@@ -18517,7 +18517,10 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver, ...@@ -18517,7 +18517,10 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
qemuBlockStats *entry; qemuBlockStats *entry;
virDomainDiskDefPtr disk = dom->def->disks[i]; virDomainDiskDefPtr disk = dom->def->disks[i];
QEMU_ADD_NAME_PARAM(record, maxparams, "block", i, disk->dst); QEMU_ADD_NAME_PARAM(record, maxparams, "block", "name", i, disk->dst);
if (virStorageSourceIsLocalStorage(disk->src) && disk->src->path)
QEMU_ADD_NAME_PARAM(record, maxparams, "block", "path",
i, disk->src->path);
if (abbreviated || !disk->info.alias || if (abbreviated || !disk->info.alias ||
!(entry = virHashLookup(stats, disk->info.alias))) { !(entry = virHashLookup(stats, disk->info.alias))) {
......
...@@ -883,6 +883,8 @@ I<--interface> returns: ...@@ -883,6 +883,8 @@ I<--interface> returns:
I<--block> returns: I<--block> returns:
"block.count" - number of block devices on this domain, "block.count" - number of block devices on this domain,
"block.<num>.name" - name of the target of the block device <num>, "block.<num>.name" - name of the target of the block device <num>,
"block.<num>.path" - file source of block device <num>, if it is a
local file or block device,
"block.<num>.rd.reqs" - number of read requests, "block.<num>.rd.reqs" - number of read requests,
"block.<num>.rd.bytes" - number of read bytes, "block.<num>.rd.bytes" - number of read bytes,
"block.<num>.rd.times" - total time (ns) spent on reads, "block.<num>.rd.times" - total time (ns) spent on reads,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册