Re: [PATCHv2 6/6] Widening API change - accept empty path for virDomainBlockStats

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

 



On 01/20/2014 07:12 PM, 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.
> ---
> 
> Notes on v2:
>  - adapted virDomainBlockStats docs
>  - adapted virsh domblkstat docs
>  - made virsh actually accept empty disk argument
>  - pedaling back a bit on the API change - accepting a NULL ptr
>    for the disk arg would need changing the remote protocol, so
>    better just take the empty string. Makes this less invasive even.
> 
>  src/libvirt.c                |  8 ++++++--
>  src/lxc/lxc_driver.c         | 10 ++++++++++
>  tools/virsh-domain-monitor.c | 11 ++++++++---
>  tools/virsh.pod              |  5 +++--
>  4 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 87a4d46..ead0813 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -7781,7 +7781,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.
> @@ -7847,7 +7849,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/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index bf6fd5c..31f1625 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -2046,6 +2046,16 @@ lxcDomainBlockStats(virDomainPtr dom,
>          goto cleanup;
>      }
>  
> +    if (!*path) {
> +        /* empty path - return entire domain blkstats instead */
> +        ret = virCgroupGetBlkioIoServiced(priv->cgroup,
> +                                          &stats->rd_bytes,
> +                                          &stats->wr_bytes,
> +                                          &stats->rd_req,
> +                                          &stats->wr_req);
> +        goto cleanup;
> +    }
> +
>      if ((idx = virDomainDiskIndexByName(vm->def, path, false)) < 0) {
>          virReportError(VIR_ERR_INVALID_ARG,
>                         _("invalid path: %s"), path);
> diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
> index b29b82a..6be253f 100644
> --- a/tools/virsh-domain-monitor.c
> +++ b/tools/virsh-domain-monitor.c
> @@ -880,7 +880,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",
> @@ -946,8 +946,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 3534b54..c3ca016 100644
> --- a/tools/virsh.pod
> +++ b/tools/virsh.pod
> @@ -616,12 +616,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.
>  
> 

Looks good to me

ACK

thanks!

--
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]