[PATCH v2 10/12] getstats: add new flag for block backing chain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch introduces access to allocation information about
a backing chain of a live domain.  While querying storage
volumes for read-only disks could provide some of the details,
there is one case where we have to rely on qemu: when doing
a block commit into a backing file, where that file is stored
in qcow2 format on a host block device, we want to know the
current highest write offset into that image, in order to know
if the disk must be resized larger.  qemu-img does not
(currently) show this information, and none of the earlier
block APIs were extensible enough to expose it.  But
virDomainListGetStats is perfect for the job!

We don't need a new group of statistics, as the existing block
group is sufficient.  On the other hand, as existing libvirt
releases already report 1:1 mapping of block.count to <disk>
devices, changing the array size could confuse older clients;
and even with newer clients, the time and memory taken to
report additional statistics is not always necessary (backing
files are generally read-only except for block-commit, so while
read statistics may change, sizing statistics will not).  So
the choice here is to add a new flag that only newer callers
will pass, when they are prepared for the additional information.

This patch introduces the new API, but it will take more
patches to get it implemented for qemu.

* include/libvirt/libvirt-domain.h
(VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING): New flag.
* src/libvirt-domain.c (virConnectGetAllDomainStats): Document it,
and add a new field when it is in use.
* tools/virsh-domain-monitor.c (cmdDomstats): Use new flag.
* tools/virsh.pod (domstats): Document it.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h | 1 +
 src/libvirt-domain.c             | 7 ++++++-
 tools/virsh-domain-monitor.c     | 7 +++++++
 tools/virsh.pod                  | 8 ++++++--
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index baef32d..0b1a2d6 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1705,6 +1705,7 @@ typedef enum {
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF = VIR_CONNECT_LIST_DOMAINS_SHUTOFF,
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER = VIR_CONNECT_LIST_DOMAINS_OTHER,

+    VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING = 1 << 30, /* include backing chain for block stats */
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */
 } virConnectGetAllDomainStatsFlags;

diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index cb76d8c..8c4ad7b 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -10903,13 +10903,18 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
  * "net.<num>.tx.errs" - transmission errors as unsigned long long.
  * "net.<num>.tx.drop" - transmit packets dropped as unsigned long long.
  *
- * VIR_DOMAIN_STATS_BLOCK: Return block devices statistics.
+ * VIR_DOMAIN_STATS_BLOCK: Return block devices statistics.  By default,
+ * this information is limited to the active layer of each <disk> of the
+ * domain, but adding VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING to @flags
+ * will expand the array to cover backing chains.
  * The typed parameter keys are in this format:
  * "block.count" - number of block devices on this domain
  *                 as unsigned int.
  * "block.<num>.name" - name of the block device <num> as string.
  *                      matches the target name (vda/sda/hda) of the
  *                      block device.
+ * "block.<num>.backingIndex" - unsigned int giving the <backingStore> index,
+ *                              when backing images are listed.
  * "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).
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 259400f..214c0b2 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2037,6 +2037,10 @@ static const vshCmdOptDef opts_domstats[] = {
      .type = VSH_OT_BOOL,
      .help = N_("enforce requested stats parameters"),
     },
+    {.name = "backing",
+     .type = VSH_OT_BOOL,
+     .help = N_("add backing chain information to block stats"),
+    },
     {.name = "domain",
      .type = VSH_OT_ARGV,
      .flags = VSH_OFLAG_NONE,
@@ -2130,6 +2134,9 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "enforce"))
         flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS;

+    if (vshCommandOptBool(cmd, "backing"))
+        flags |= VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING;
+
     if (vshCommandOptBool(cmd, "domain")) {
         if (VIR_ALLOC_N(domlist, 1) < 0)
             goto cleanup;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 0eba2c1..8c5e426 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -825,7 +825,7 @@ that require a block device name (such as I<domblkinfo> or
 I<snapshot-create> for disk snapshots) will accept either target
 or unique source names printed by this command.

-=item B<domstats> [I<--raw>] [I<--enforce>] [I<--state>]
+=item B<domstats> [I<--raw>] [I<--enforce>] [I<--backing>] [I<--state>]
 [I<--cpu-total>] [I<--balloon>] [I<--vcpu>] [I<--interface>] [I<--block>]
 [[I<--list-active>] [I<--list-inactive>] [I<--list-persistent>]
 [I<--list-transient>] [I<--list-running>] [I<--list-paused>]
@@ -880,7 +880,11 @@ I<--interface> returns:
 "net.<num>.tx.errs" - number of transmission errors,
 "net.<num>.tx.drop" - number of transmit packets dropped

-I<--block> returns:
+I<--block> returns information about disks associated with each
+domain.  Using the I<--backing> flag extends this information to
+cover all resources in the backing chain, rather than the default
+of limiting information to the active layer for each guest disk.
+Information listed includes:
 "block.count" - number of block devices on this domain,
 "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
-- 
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]