[libvirt] [PATCHv3 06/10] Widening API change - accept empty path for virDomainBlockStats
Michal Privoznik
mprivozn at redhat.com
Thu Feb 6 11:46:19 UTC 2014
On 03.02.2014 18:44, Thorsten Behrens wrote:
> And provide domain summary stat in that case, for lxc backend.
> Use case is a container inheriting all devices from the host,
> e.g. when doing application containerization.
> ---
> src/libvirt.c | 8 ++++++--
> tools/virsh-domain-monitor.c | 11 ++++++++---
> tools/virsh.pod | 5 +++--
> 3 files changed, 17 insertions(+), 7 deletions(-)
>
Aah, I didn't see this coming :)
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 9cc5b1c..64da438 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -7747,7 +7747,9 @@ error:
> * an unambiguous source name of the block device (the <source
> * file='...'/> sub-element, such as "/path/to/image"). Valid names
> * can be found by calling virDomainGetXMLDesc() and inspecting
> - * elements within //domain/devices/disk.
> + * elements within //domain/devices/disk. Some drivers might also
> + * accept the empty string for the @disk parameter, and then yield
> + * summary stats for the entire domain.
> *
> * Domains may have more than one block device. To get stats for
> * each you should make multiple calls to this function.
> @@ -7813,7 +7815,9 @@ error:
> * an unambiguous source name of the block device (the <source
> * file='...'/> sub-element, such as "/path/to/image"). Valid names
> * can be found by calling virDomainGetXMLDesc() and inspecting
> - * elements within //domain/devices/disk.
> + * elements within //domain/devices/disk. Some drivers might also
> + * accept the empty string for the @disk parameter, and then yield
> + * summary stats for the entire domain.
> *
> * Domains may have more than one block device. To get stats for
> * each you should make multiple calls to this function.
> diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
> index de4afbb..105f841 100644
> --- a/tools/virsh-domain-monitor.c
> +++ b/tools/virsh-domain-monitor.c
> @@ -888,7 +888,7 @@ static const vshCmdOptDef opts_domblkstat[] = {
> },
> {.name = "device",
> .type = VSH_OT_DATA,
> - .flags = VSH_OFLAG_REQ,
> + .flags = VSH_OFLAG_EMPTY_OK,
> .help = N_("block device")
> },
> {.name = "human",
> @@ -954,8 +954,13 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
> if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
> return false;
>
> - if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0)
> - goto cleanup;
> + /* device argument is optional now. if it's missing, supply empty
> + string to denote 'all devices'. A NULL device arg would violate
> + API contract.
> + */
> + rc = vshCommandOptStringReq(ctl, cmd, "device", &device); /* and ignore rc */
> + if (!device)
> + device = "";
>
> rc = virDomainBlockStatsFlags(dom, device, NULL, &nparams, 0);
>
> diff --git a/tools/virsh.pod b/tools/virsh.pod
> index 9e670da..3e45177 100644
> --- a/tools/virsh.pod
> +++ b/tools/virsh.pod
> @@ -623,12 +623,13 @@ If I<--graceful> is specified, don't resort to extreme measures
> (e.g. SIGKILL) when the guest doesn't stop after a reasonable timeout;
> return an error instead.
>
> -=item B<domblkstat> I<domain> I<block-device> [I<--human>]
> +=item B<domblkstat> I<domain> [I<block-device>] [I<--human>]
>
> Get device block stats for a running domain. A I<block-device> corresponds
> to a unique target name (<target dev='name'/>) or source file (<source
> file='name'/>) for one of the disk devices attached to I<domain> (see
> -also B<domblklist> for listing these names).
> +also B<domblklist> for listing these names). On a lxc domain, omitting the
> +I<block-device> yields device block stats summarily for the entire domain.
>
> Use I<--human> for a more human readable output.
>
>
ACK to this one and the previous one too then.
Michal
More information about the libvir-list
mailing list