diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index baef32d809b958e71fd503986072e92809439f2a..0b1a2d6dd4d95a7436258881cd59da46ecbcc83d 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 cb76d8ce58d745978727193efb3465a0780651b9..6ec68aa71770c72d7ebe72d78dd5069189f94d1d 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -10903,13 +10903,22 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * "net..tx.errs" - transmission errors as unsigned long long. * "net..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 of the + * domain (where block.count is equal to the number of disks), but adding + * VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING to @flags will expand the + * array to cover backing chains (block.count corresponds to the number + * of host resources used together to provide the guest disks). * The typed parameter keys are in this format: - * "block.count" - number of block devices on this domain + * "block.count" - number of block devices in the subsequent list, * as unsigned int. * "block..name" - name of the block device as string. * matches the target name (vda/sda/hda) of the - * block device. + * block device. If the backing chain is listed, + * this name is the same for all host resources tied + * to the same guest device. + * "block..backingIndex" - unsigned int giving the index, + * only used when backing images are listed. * "block..path" - string describing the source of block device , * 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 259400ffa843e5c43faa6f70514732ca6765483b..214c0b29eb63945c74d8869b61588025f9dcf056 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 0eba2c1ceb880f09650ec0d5f165f09e5221869b..63b6035109111c8ede6226946b6e7bb73f932392 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -825,7 +825,7 @@ that require a block device name (such as I or I for disk snapshots) will accept either target or unique source names printed by this command. -=item B [I<--raw>] [I<--enforce>] [I<--state>] +=item B [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,9 +880,16 @@ I<--interface> returns: "net..tx.errs" - number of transmission errors, "net..tx.drop" - number of transmit packets dropped -I<--block> returns: -"block.count" - number of block devices on this domain, -"block..name" - name of the target of the block device , +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 being listed, +"block..name" - name of the target of the block device (the +same name for multiple entries if I<--backing> is present), +"block..backingIndex" - when I<--backing> is present, matches up +with the index listed in domain XML for backing files, "block..path" - file source of block device , if it is a local file or block device, "block..rd.reqs" - number of read requests,