qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Chen Hanxiao <chen_han_xiao@126.com>, qemu-devel@nongnu.org
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v5.1 2/2] qga-win: add driver path usage to GuestFilesystemInfo
Date: Fri, 1 Jun 2018 12:15:14 -0500	[thread overview]
Message-ID: <9e9ef45c-25e4-6518-d353-5834cea0eef6@redhat.com> (raw)
In-Reply-To: <20180601165750.25420-3-chen_han_xiao@126.com>

On 06/01/2018 11:57 AM, Chen Hanxiao wrote:
> From: Chen Hanxiao <chenhanxiao@gmail.com>
> 
> This patch adds support for getting the usage of
> windows driver path.
> The usage of fs stored as used_bytes and total_bytes.
> 
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
> ---
> v2:
>    unpack usage as used-bytes and total-bytes
> 

> @@ -699,10 +700,21 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
>       fs_name[sizeof(fs_name) - 1] = 0;
>       fs = g_malloc(sizeof(*fs));
>       fs->name = g_strdup(guid);
> +    fs->has_total_bytes = false;
> +    fs->has_used_bytes = false;

Dead assignments.

>       if (len == 0) {
>           fs->mountpoint = g_strdup("System Reserved");
>       } else {
>           fs->mountpoint = g_strndup(mnt_point, len);
> +        if (GetDiskFreeSpaceEx(fs->mountpoint,
> +                               (PULARGE_INTEGER) & i64FreeBytesToCaller,
> +                               (PULARGE_INTEGER) & i64TotalBytes,
> +                               (PULARGE_INTEGER) & i64FreeBytes)) {
> +            fs->used_bytes = i64TotalBytes - i64FreeBytes;
> +            fs->total_bytes = i64TotalBytes;
> +            fs->has_total_bytes = true;
> +            fs->has_used_bytes = true;
> +        }

I'm less familiar with Windows API, so I won't give this R-b. But now 
that I read this patch, I do have a question: since both statvfs() and 
GetDiskFreeSpaceEx() give you free bytes rather than used bytes, and you 
had to perform a subtraction to report 'used-bytes' over QGA, would it 
make any more sense to instead report 'free-bytes' over QGA for less 
subtraction work on your end and so that the QGA interface is more 
similar to existing interfaces?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-06-01 17:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 16:57 [Qemu-devel] [PATCH v5.1 0/2] qga: report the usage of fs in guests Chen Hanxiao
2018-06-01 16:57 ` [Qemu-devel] [PATCH v5.1 1/2] qga: add mountpoint usage info to GuestFilesystemInfo Chen Hanxiao
2018-06-01 17:11   ` Eric Blake
2018-06-01 16:57 ` [Qemu-devel] [PATCH v5.1 2/2] qga-win: add driver path usage " Chen Hanxiao
2018-06-01 17:15   ` Eric Blake [this message]
2018-06-02  9:34     ` Chen Hanxiao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9e9ef45c-25e4-6518-d353-5834cea0eef6@redhat.com \
    --to=eblake@redhat.com \
    --cc=chen_han_xiao@126.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).