From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Roman Bogorodskiy <bogorodskiy@gmail.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Michael Roth <michael.roth@amd.com>,
Kostiantyn Kostiuk <kkostiuk@redhat.com>,
Eric Blake <eblake@redhat.com>
Subject: Re: [PATCH v2] qga: implement 'guest-get-fsinfo' for FreeBSD
Date: Tue, 14 Jul 2026 11:45:05 +0100 [thread overview]
Message-ID: <alYTMRfaGKKri3Lr@redhat.com> (raw)
In-Reply-To: <20260703163107.46469-1-bogorodskiy@gmail.com>
On Fri, Jul 03, 2026 at 06:31:07PM +0200, Roman Bogorodskiy wrote:
> Implement the qmp_guest_get_fsinfo() API for FreeBSD.
> To implement it, reuse build_fs_mount_list() which is already
> implemented for FreeBSD. Extend the FsMount type to include
> a string "fromname" attribute to store the disk the FS is mounted from.
>
> Disk mapping info is not covered by this implementation.
>
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> Acked-by: Markus Armbruster <armbru@redhat.com>
> ---
> Changes since v1:
>
> - Replace g_malloc0() with g_new0(.., 1) for GuestFilesystemInfo
>
>
> qga/commands-bsd.c | 62 ++++++++++++++++++++++++++++++++++++++++++-
> qga/commands-common.h | 1 +
> qga/commands-posix.c | 3 +++
> qga/qapi-schema.json | 12 ++++-----
> 4 files changed, 71 insertions(+), 7 deletions(-)
>
> +#if defined(__FreeBSD__)
> +static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount,
> + Error **errp)
Nothing ever sets 'errp' so this method cannot fail. Drop this
parameter.
> +{
> + GuestFilesystemInfo *fs = g_new0(GuestFilesystemInfo, 1);
> + struct statvfs buf;
> + unsigned long used, nonroot_total, fr_size;
> +
> + fs->mountpoint = g_strdup(mount->dirname);
> + fs->type = g_strdup(mount->devtype);
> + fs->name = g_strdup(g_path_get_basename(mount->fromname));
Memoory leak - g_path_get_basename already returns a new heap
allocated string, so drop the g_strdup:
https://docs.gtk.org/glib/func.path_get_basename.html
> +
> + if (statvfs(fs->mountpoint, &buf) == 0) {
> + fr_size = buf.f_frsize;
> + used = buf.f_blocks - buf.f_bfree;
> + nonroot_total = used + buf.f_bavail;
> + fs->used_bytes = used * fr_size;
> + fs->total_bytes = nonroot_total * fr_size;
> + fs->total_bytes_privileged = buf.f_blocks * fr_size;
> +
> + fs->has_total_bytes = true;
> + fs->has_total_bytes_privileged = true;
> + fs->has_used_bytes = true;
> + }
> +
> + return fs;
> +}
> +
> +GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
> +{
> + FsMountList mounts;
> + struct FsMount *mount;
> + GuestFilesystemInfoList *ret = NULL;
> + Error *local_err = NULL;
> +
> + QTAILQ_INIT(&mounts);
> + if (!build_fs_mount_list(&mounts, &local_err)) {
> + error_propagate(errp, local_err);
Pointless use of local_err - pass errp and drop error_propagate
> + return NULL;
> + }
> +
> + QTAILQ_FOREACH(mount, &mounts, next) {
> + g_debug("Building guest fsinfo for '%s'", mount->dirname);
> +
> + QAPI_LIST_PREPEND(ret, build_guest_fsinfo(mount, &local_err));
> + if (local_err) {
> + error_propagate(errp, local_err);
> + qapi_free_GuestFilesystemInfoList(ret);
> + ret = NULL;
> + break;
> + }
build_guest_fsinfo cannot fail so this branch is dead code, which
means local_err can be entirely dropped.
> + }
> +
> + free_fs_mount_list(&mounts);
> + return ret;
> +}
> +#endif /* __FreeBSD__ */
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
prev parent reply other threads:[~2026-07-14 10:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 16:31 [PATCH v2] qga: implement 'guest-get-fsinfo' for FreeBSD Roman Bogorodskiy
2026-07-14 10:04 ` Kostiantyn Kostiuk
2026-07-14 10:45 ` Daniel P. Berrangé [this message]
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=alYTMRfaGKKri3Lr@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=bogorodskiy@gmail.com \
--cc=eblake@redhat.com \
--cc=kkostiuk@redhat.com \
--cc=michael.roth@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.