|
|
9119d9 |
From 1ee014e89e853b83dc0d384e67f4d073034b4995 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <1ee014e89e853b83dc0d384e67f4d073034b4995@dist-git>
|
|
|
9119d9 |
From: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
Date: Wed, 17 Dec 2014 03:09:07 -0700
|
|
|
9119d9 |
Subject: [PATCH] getstats: add new flag for block backing chain
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1041569
|
|
|
9119d9 |
|
|
|
9119d9 |
This patch introduces access to allocation information about
|
|
|
9119d9 |
a backing chain of a live domain. While querying storage
|
|
|
9119d9 |
volumes for read-only disks could provide some of the details,
|
|
|
9119d9 |
we do NOT want to read() a file while qemu is writing it.
|
|
|
9119d9 |
Also, there is one case where we have to rely on qemu: when
|
|
|
9119d9 |
doing a block commit into a backing file, where that file is
|
|
|
9119d9 |
stored in qcow2 format on a host block device, we want to know
|
|
|
9119d9 |
the current highest write offset into that image, in order to
|
|
|
9119d9 |
know if the disk must be resized larger. qemu-img does not
|
|
|
9119d9 |
(currently) show this information, and none of the earlier
|
|
|
9119d9 |
block APIs were extensible enough to expose it. But
|
|
|
9119d9 |
virDomainListGetStats is perfect for the job!
|
|
|
9119d9 |
|
|
|
9119d9 |
We don't need a new group of statistics, as the existing block
|
|
|
9119d9 |
group is sufficient. On the other hand, as existing libvirt
|
|
|
9119d9 |
releases already report 1:1 mapping of block.count to <disk>
|
|
|
9119d9 |
devices, changing the array size could confuse older clients;
|
|
|
9119d9 |
and even with newer clients, the time and memory taken to
|
|
|
9119d9 |
report additional statistics is not always necessary (backing
|
|
|
9119d9 |
files are generally read-only except for block-commit, so while
|
|
|
9119d9 |
read statistics may change, sizing statistics will not). So
|
|
|
9119d9 |
the choice here is to add a new flag that only newer callers
|
|
|
9119d9 |
will pass, when they are prepared for the additional information.
|
|
|
9119d9 |
|
|
|
9119d9 |
This patch introduces the new API, but it will take more
|
|
|
9119d9 |
patches to get it implemented for qemu.
|
|
|
9119d9 |
|
|
|
9119d9 |
* include/libvirt/libvirt-domain.h
|
|
|
9119d9 |
(VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING): New flag.
|
|
|
9119d9 |
* src/libvirt-domain.c (virConnectGetAllDomainStats): Document it,
|
|
|
9119d9 |
and add a new field when it is in use.
|
|
|
9119d9 |
* tools/virsh-domain-monitor.c (cmdDomstats): Use new flag.
|
|
|
9119d9 |
* tools/virsh.pod (domstats): Document it.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 4bffafb2eb076255dbd7e0d96f2b33a4fea0650e)
|
|
|
9119d9 |
|
|
|
9119d9 |
Conflicts:
|
|
|
9119d9 |
include/libvirt/libvirt-domain.h - file split from libvirt.h.in
|
|
|
9119d9 |
src/libvirt-domain.c - file split from libvirt.c
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
include/libvirt/libvirt.h.in | 1 +
|
|
|
9119d9 |
src/libvirt.c | 15 ++++++++++++---
|
|
|
9119d9 |
tools/virsh-domain-monitor.c | 7 +++++++
|
|
|
9119d9 |
tools/virsh.pod | 15 +++++++++++----
|
|
|
9119d9 |
4 files changed, 31 insertions(+), 7 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
|
|
|
9119d9 |
index 9099cc4..94de8a6 100644
|
|
|
9119d9 |
--- a/include/libvirt/libvirt.h.in
|
|
|
9119d9 |
+++ b/include/libvirt/libvirt.h.in
|
|
|
9119d9 |
@@ -2533,6 +2533,7 @@ typedef enum {
|
|
|
9119d9 |
VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF = VIR_CONNECT_LIST_DOMAINS_SHUTOFF,
|
|
|
9119d9 |
VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER = VIR_CONNECT_LIST_DOMAINS_OTHER,
|
|
|
9119d9 |
|
|
|
9119d9 |
+ VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING = 1 << 30, /* include backing chain for block stats */
|
|
|
9119d9 |
VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */
|
|
|
9119d9 |
} virConnectGetAllDomainStatsFlags;
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/libvirt.c b/src/libvirt.c
|
|
|
9119d9 |
index 2885965..5315881 100644
|
|
|
9119d9 |
--- a/src/libvirt.c
|
|
|
9119d9 |
+++ b/src/libvirt.c
|
|
|
9119d9 |
@@ -21596,13 +21596,22 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
|
|
|
9119d9 |
* "net.<num>.tx.errs" - transmission errors as unsigned long long.
|
|
|
9119d9 |
* "net.<num>.tx.drop" - transmit packets dropped as unsigned long long.
|
|
|
9119d9 |
*
|
|
|
9119d9 |
- * VIR_DOMAIN_STATS_BLOCK: Return block devices statistics.
|
|
|
9119d9 |
+ * VIR_DOMAIN_STATS_BLOCK: Return block devices statistics. By default,
|
|
|
9119d9 |
+ * this information is limited to the active layer of each <disk> of the
|
|
|
9119d9 |
+ * domain (where block.count is equal to the number of disks), but adding
|
|
|
9119d9 |
+ * VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING to @flags will expand the
|
|
|
9119d9 |
+ * array to cover backing chains (block.count corresponds to the number
|
|
|
9119d9 |
+ * of host resources used together to provide the guest disks).
|
|
|
9119d9 |
* The typed parameter keys are in this format:
|
|
|
9119d9 |
- * "block.count" - number of block devices on this domain
|
|
|
9119d9 |
+ * "block.count" - number of block devices in the subsequent list,
|
|
|
9119d9 |
* as unsigned int.
|
|
|
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 device. If the backing chain is listed,
|
|
|
9119d9 |
+ * this name is the same for all host resources tied
|
|
|
9119d9 |
+ * to the same guest device.
|
|
|
9119d9 |
+ * "block.<num>.backingIndex" - unsigned int giving the <backingStore> index,
|
|
|
9119d9 |
+ * only used when backing images are listed.
|
|
|
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 |
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
|
|
|
9119d9 |
index d013ca8..5c758cd 100644
|
|
|
9119d9 |
--- a/tools/virsh-domain-monitor.c
|
|
|
9119d9 |
+++ b/tools/virsh-domain-monitor.c
|
|
|
9119d9 |
@@ -2032,6 +2032,10 @@ static const vshCmdOptDef opts_domstats[] = {
|
|
|
9119d9 |
.type = VSH_OT_BOOL,
|
|
|
9119d9 |
.help = N_("enforce requested stats parameters"),
|
|
|
9119d9 |
},
|
|
|
9119d9 |
+ {.name = "backing",
|
|
|
9119d9 |
+ .type = VSH_OT_BOOL,
|
|
|
9119d9 |
+ .help = N_("add backing chain information to block stats"),
|
|
|
9119d9 |
+ },
|
|
|
9119d9 |
{.name = "domain",
|
|
|
9119d9 |
.type = VSH_OT_ARGV,
|
|
|
9119d9 |
.flags = VSH_OFLAG_NONE,
|
|
|
9119d9 |
@@ -2125,6 +2129,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
|
|
|
9119d9 |
if (vshCommandOptBool(cmd, "enforce"))
|
|
|
9119d9 |
flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (vshCommandOptBool(cmd, "backing"))
|
|
|
9119d9 |
+ flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
if (vshCommandOptBool(cmd, "domain")) {
|
|
|
9119d9 |
if (VIR_ALLOC_N(domlist, 1) < 0)
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
diff --git a/tools/virsh.pod b/tools/virsh.pod
|
|
|
9119d9 |
index beef855..c5b176a 100644
|
|
|
9119d9 |
--- a/tools/virsh.pod
|
|
|
9119d9 |
+++ b/tools/virsh.pod
|
|
|
9119d9 |
@@ -813,7 +813,7 @@ that require a block device name (such as I<domblkinfo> or
|
|
|
9119d9 |
I<snapshot-create> for disk snapshots) will accept either target
|
|
|
9119d9 |
or unique source names printed by this command.
|
|
|
9119d9 |
|
|
|
9119d9 |
-=item B<domstats> [I<--raw>] [I<--enforce>] [I<--state>]
|
|
|
9119d9 |
+=item B<domstats> [I<--raw>] [I<--enforce>] [I<--backing>] [I<--state>]
|
|
|
9119d9 |
[I<--cpu-total>] [I<--balloon>] [I<--vcpu>] [I<--interface>] [I<--block>]
|
|
|
9119d9 |
[[I<--list-active>] [I<--list-inactive>] [I<--list-persistent>]
|
|
|
9119d9 |
[I<--list-transient>] [I<--list-running>] [I<--list-paused>]
|
|
|
9119d9 |
@@ -868,9 +868,16 @@ I<--interface> returns:
|
|
|
9119d9 |
"net.<num>.tx.errs" - number of transmission errors,
|
|
|
9119d9 |
"net.<num>.tx.drop" - number of transmit packets dropped
|
|
|
9119d9 |
|
|
|
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 |
+I<--block> returns information about disks associated with each
|
|
|
9119d9 |
+domain. Using the I<--backing> flag extends this information to
|
|
|
9119d9 |
+cover all resources in the backing chain, rather than the default
|
|
|
9119d9 |
+of limiting information to the active layer for each guest disk.
|
|
|
9119d9 |
+Information listed includes:
|
|
|
9119d9 |
+"block.count" - number of block devices being listed,
|
|
|
9119d9 |
+"block.<num>.name" - name of the target of the block device <num> (the
|
|
|
9119d9 |
+same name for multiple entries if I<--backing> is present),
|
|
|
9119d9 |
+"block.<num>.backingIndex" - when I<--backing> is present, matches up
|
|
|
9119d9 |
+with the <backingStore> index listed in domain XML for backing files,
|
|
|
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 |
--
|
|
|
9119d9 |
2.2.0
|
|
|
9119d9 |
|