|
|
9119d9 |
From fce8dc52172734630bd5d274dd4bdf9845948f92 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <fce8dc52172734630bd5d274dd4bdf9845948f92@dist-git>
|
|
|
9119d9 |
From: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
Date: Wed, 17 Dec 2014 03:09:02 -0700
|
|
|
9119d9 |
Subject: [PATCH] getstats: add block.n.path stat
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1041569
|
|
|
9119d9 |
|
|
|
9119d9 |
I'm about to make block stats optionally more complex to cover
|
|
|
9119d9 |
backing chains, where block.count will no longer equal the number
|
|
|
9119d9 |
of <disks> for a domain. For these reasons, it is nicer if the
|
|
|
9119d9 |
statistics output includes the source path (for local files).
|
|
|
9119d9 |
This patch doesn't add anything for network disks, although we
|
|
|
9119d9 |
may decide to add that later.
|
|
|
9119d9 |
|
|
|
9119d9 |
With this patch, I now see the following for the same domain as
|
|
|
9119d9 |
in the previous patch (one qcow2 file, and an empty cdrom drive):
|
|
|
9119d9 |
$ virsh domstats --block foo
|
|
|
9119d9 |
Domain: 'foo'
|
|
|
9119d9 |
block.count=2
|
|
|
9119d9 |
block.0.name=hda
|
|
|
9119d9 |
block.0.path=/var/lib/libvirt/images/foo.qcow2
|
|
|
9119d9 |
block.1.name=hdc
|
|
|
9119d9 |
|
|
|
9119d9 |
* src/libvirt-domain.c (virConnectGetAllDomainStats): Document
|
|
|
9119d9 |
new field.
|
|
|
9119d9 |
* tools/virsh.pod (domstats): Document new field.
|
|
|
9119d9 |
* src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Return the new
|
|
|
9119d9 |
stat for local files/block devices.
|
|
|
9119d9 |
(QEMU_ADD_NAME_PARAM): Add parameter.
|
|
|
9119d9 |
(qemuDomainGetStatsInterface): Update caller.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 7b499262cb6d2bc2361bc4cd3742c0cea331666f)
|
|
|
9119d9 |
|
|
|
9119d9 |
Conflicts:
|
|
|
9119d9 |
src/libvirt-domain.c - file split from libvirt.c
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/libvirt.c | 3 +++
|
|
|
9119d9 |
src/qemu/qemu_driver.c | 11 +++++++----
|
|
|
9119d9 |
tools/virsh.pod | 2 ++
|
|
|
9119d9 |
3 files changed, 12 insertions(+), 4 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/libvirt.c b/src/libvirt.c
|
|
|
9119d9 |
index 1097693..2885965 100644
|
|
|
9119d9 |
--- a/src/libvirt.c
|
|
|
9119d9 |
+++ b/src/libvirt.c
|
|
|
9119d9 |
@@ -21603,6 +21603,9 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
|
|
|
9119d9 |
* "block.<num>.name" - name of the block device <num> as string.
|
|
|
9119d9 |
* matches the target name (vda/sda/hda) of the
|
|
|
9119d9 |
* block device.
|
|
|
9119d9 |
+ * "block.<num>.path" - string describing the source of block device <num>,
|
|
|
9119d9 |
+ * if it is a file or block device (omitted for network
|
|
|
9119d9 |
+ * sources and drives with no media inserted).
|
|
|
9119d9 |
* "block.<num>.rd.reqs" - number of read requests as unsigned long long.
|
|
|
9119d9 |
* "block.<num>.rd.bytes" - number of read bytes as unsigned long long.
|
|
|
9119d9 |
* "block.<num>.rd.times" - total time (ns) spent on reads as
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
index f0935d6..03b62d8 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_driver.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
@@ -17898,11 +17898,11 @@ do { \
|
|
|
9119d9 |
goto cleanup; \
|
|
|
9119d9 |
} while (0)
|
|
|
9119d9 |
|
|
|
9119d9 |
-#define QEMU_ADD_NAME_PARAM(record, maxparams, type, num, name) \
|
|
|
9119d9 |
+#define QEMU_ADD_NAME_PARAM(record, maxparams, type, subtype, num, name) \
|
|
|
9119d9 |
do { \
|
|
|
9119d9 |
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \
|
|
|
9119d9 |
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
|
|
|
9119d9 |
- "%s.%zu.name", type, num); \
|
|
|
9119d9 |
+ "%s.%zu.%s", type, num, subtype); \
|
|
|
9119d9 |
if (virTypedParamsAddString(&(record)->params, \
|
|
|
9119d9 |
&(record)->nparams, \
|
|
|
9119d9 |
maxparams, \
|
|
|
9119d9 |
@@ -17948,7 +17948,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
|
|
9119d9 |
memset(&tmp, 0, sizeof(tmp));
|
|
|
9119d9 |
|
|
|
9119d9 |
QEMU_ADD_NAME_PARAM(record, maxparams,
|
|
|
9119d9 |
- "net", i, dom->def->nets[i]->ifname);
|
|
|
9119d9 |
+ "net", "name", i, dom->def->nets[i]->ifname);
|
|
|
9119d9 |
|
|
|
9119d9 |
if (virNetInterfaceStats(dom->def->nets[i]->ifname, &tmp) < 0) {
|
|
|
9119d9 |
virResetLastError();
|
|
|
9119d9 |
@@ -18041,7 +18041,10 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|
|
9119d9 |
qemuBlockStats *entry;
|
|
|
9119d9 |
virDomainDiskDefPtr disk = dom->def->disks[i];
|
|
|
9119d9 |
|
|
|
9119d9 |
- QEMU_ADD_NAME_PARAM(record, maxparams, "block", i, disk->dst);
|
|
|
9119d9 |
+ QEMU_ADD_NAME_PARAM(record, maxparams, "block", "name", i, disk->dst);
|
|
|
9119d9 |
+ if (virStorageSourceIsLocalStorage(disk->src) && disk->src->path)
|
|
|
9119d9 |
+ QEMU_ADD_NAME_PARAM(record, maxparams, "block", "path",
|
|
|
9119d9 |
+ i, disk->src->path);
|
|
|
9119d9 |
|
|
|
9119d9 |
if (abbreviated || !disk->info.alias ||
|
|
|
9119d9 |
!(entry = virHashLookup(stats, disk->info.alias))) {
|
|
|
9119d9 |
diff --git a/tools/virsh.pod b/tools/virsh.pod
|
|
|
9119d9 |
index d88fa9f..beef855 100644
|
|
|
9119d9 |
--- a/tools/virsh.pod
|
|
|
9119d9 |
+++ b/tools/virsh.pod
|
|
|
9119d9 |
@@ -871,6 +871,8 @@ I<--interface> returns:
|
|
|
9119d9 |
I<--block> returns:
|
|
|
9119d9 |
"block.count" - number of block devices on this domain,
|
|
|
9119d9 |
"block.<num>.name" - name of the target of the block device <num>,
|
|
|
9119d9 |
+"block.<num>.path" - file source of block device <num>, if it is a
|
|
|
9119d9 |
+local file or block device,
|
|
|
9119d9 |
"block.<num>.rd.reqs" - number of read requests,
|
|
|
9119d9 |
"block.<num>.rd.bytes" - number of read bytes,
|
|
|
9119d9 |
"block.<num>.rd.times" - total time (ns) spent on reads,
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.0
|
|
|
9119d9 |
|