From nobody Sun Jul 26 11:01:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1783096422; cv=none; d=zohomail.com; s=zohoarc; b=KSCAU4CTzty2zLzSsDv+yI0YMJAiYuWhz2fnGbP9I64EIY0yYSj3lT3f8to7itIfmYtfj7GH++lD4c23LOnx1LAnyetIlWMUbzA4JjQeF2pQHPd1ES2ZGanLz7UXWihW2j8/KY5gfvWVUFRRixDdpIELLg2Jtg9/in6oRUbk5Gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783096422; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/7FC3+hcII7PbFGAgumtBIZjbzmSfLIy5pHfi3j33YY=; b=O8nHQaJNEVVTY5g3pcLwHbWeNhJOZyisFbIKNjOxlR0XDg1BbOFXI2Irr8K4fANQ3VBuADio2sQfdN0qGPO3NRo9A0JguQWXq/KVny/TG29mdY523AuCO0pLFEvCp6Ads9yDRjc7mtA/1ZyStegKHHxAv8Srg23bD0reUk1HXPA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1783096422668232.50096667656692; Fri, 3 Jul 2026 09:33:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wfgp1-0003To-SA; Fri, 03 Jul 2026 12:32:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfgp0-0003Sk-87 for qemu-devel@nongnu.org; Fri, 03 Jul 2026 12:32:58 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wfgox-0005E2-MZ for qemu-devel@nongnu.org; Fri, 03 Jul 2026 12:32:57 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-c029505b389so263638066b.1 for ; Fri, 03 Jul 2026 09:32:54 -0700 (PDT) Received: from tulp.my.domain (2001-1c02-1a15-3000-ee82-4536-a8f2-9e22.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:ee82:4536:a8f2:9e22]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c12b62f38f3sm309931466b.57.2026.07.03.09.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 09:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783096373; x=1783701173; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/7FC3+hcII7PbFGAgumtBIZjbzmSfLIy5pHfi3j33YY=; b=FQU3Gj/1bjxTGyAVSjhE4u9ImZpzNaGyIFQriTY/1i4cr3yo0UypvrO5JwTI556mhS g5KoEDtinSjvxwsCfJKzx+H3YtxMWuPA707L72JOR8y4PmOU9vpKwv6AuyH+P8A3Dlec Rh1L5Mt7wS6gVKY4hSfHYS1JiJhD+mjbV11sb2gJm21rkhbIrKnsdZA5RuYzHBUYs6Wm QRl9C9RLTe4CLYVP+xmLp2frpIa6hEKb/jSr5Pq8Wh4dEzevnEGv8nSmQsSyakJsPuqG fdatHKFfoRQnwawV4PMdgh5eOqdGiX++7ZEPBUKI+Jou0KUPmbB3c7haUqCT8QOi7Jvh bM/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783096373; x=1783701173; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/7FC3+hcII7PbFGAgumtBIZjbzmSfLIy5pHfi3j33YY=; b=V0Jc8Kp4ZUEdBrPFkKdp3gMK6J9WcQAf7h0nC0SjYsnBNUDKVHmQzZ1BRFAzOYC/V0 7loyzpXR5ylN35pVYbgXZNxamTiY3xEwPnEeXqXAuTpiyjM2e++wZkq6bdVkUY2bO2GV ARIGIQixZeF+I9BpXUQ7NUcNJ+Ym03briWlVWHYlo2ISolF5xhN/ykeZxNGL6nZjvPND jMH82EKCtgtqzgMqvkY4bveeA3yVflRPu0nd7Pi7yPPXmNeREEgID1pDqa0k/t3aAcS9 Wm8xw6iMQSbGgojiJ2Q4oUtfeHcMXpLuTjznyDSeV+UF86MTq8Rk9dlCdW/f3yJFkX8s ti3w== X-Gm-Message-State: AOJu0Yx58QIZgdSwbFQq7TwuULNcQXQc6SeuBDxggtiyloDK0rNHUK3V 2+WvEYudLEwp8BGbpWC1rmQiTFsPCBMhhluJt7YfV1edsOHBICmGJNiysiRmKogpkIc= X-Gm-Gg: AfdE7clxHoJKjTvz3yu3FzaVHq6LJr8FTIjHVX7x1Bd373CACPsBR1tCl5byMEHIGqj Ex37+gc1RV8Ng8P89uWB37Gg7hO9Y3+ONWa6d/eOtBlweJtS5ouhK0V//JjenhSRFlzZfklf0kI LYFr3lpAPkkfso5BuXoZKAJXBQN4R2NVKzhlGu3uF3at/vICL3GBfOzQT96fwyunTAb+fajC22p TWST0FUavQtLU8CSOi78pYrjMgJsmhMj37IqvqkHvM87f12L4eZEeWXBFe0m3R9tr/p8nYnURqz lYjLooec4oKo4EYdtPhYte2+nur+73dwCf8/65xb2fiDOqDzOmlEQ6e788StVdktvIj4GXnl69B jJvw90HUaRz/+/qjufVpP66Pfw3NpeV9U0NNZ6MqU4n4ZbW1CPmIEwE3dsBbfjZ3gLkgC30HssY YsZ6lR4ebt5Gp7OmDA4r6dCWrWFHJcfLDpRzh63X2xWgCIPFt6rQIaJ11qILtXGcvja3egzkAG5 TNnJuxRJilq48EmyN9tK0k55Ws= X-Received: by 2002:a17:907:e105:b0:c12:34c3:a452 with SMTP id a640c23a62f3a-c12c9b573d2mr154402466b.0.1783096372656; Fri, 03 Jul 2026 09:32:52 -0700 (PDT) From: Roman Bogorodskiy To: qemu-devel@nongnu.org Cc: Roman Bogorodskiy , Markus Armbruster , Michael Roth , Kostiantyn Kostiuk , Eric Blake Subject: [PATCH v2] qga: implement 'guest-get-fsinfo' for FreeBSD Date: Fri, 3 Jul 2026 18:31:07 +0200 Message-ID: <20260703163107.46469-1-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=bogorodskiy@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783096425371158500 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Markus Armbruster Reviewed-by: Kostiantyn Kostiuk --- 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(-) diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c index 94ff6fee6a..7f65f2b8db 100644 --- a/qga/commands-bsd.c +++ b/qga/commands-bsd.c @@ -20,6 +20,7 @@ #include #include #include +#include #if defined(__NetBSD__) || defined(__OpenBSD__) #include #include @@ -28,7 +29,7 @@ #endif #include =20 -#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) +#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) || defined(__FreeBS= D__) bool build_fs_mount_list(FsMountList *mounts, Error **errp) { FsMount *mount; @@ -55,6 +56,7 @@ bool build_fs_mount_list(FsMountList *mounts, Error **err= p) =20 mount->dirname =3D g_strdup(mntp->f_mntonname); mount->devtype =3D g_strdup(mntp->f_fstypename); + mount->fromname =3D g_strdup(mntp->f_mntfromname); mount->devmajor =3D major(mount->dev); mount->devminor =3D minor(mount->dev); mount->fsid =3D mntp->f_fsid; @@ -178,3 +180,61 @@ bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned c= har *buf, return true; } #endif /* HAVE_GETIFADDRS */ + +#if defined(__FreeBSD__) +static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount, + Error **errp) +{ + GuestFilesystemInfo *fs =3D g_new0(GuestFilesystemInfo, 1); + struct statvfs buf; + unsigned long used, nonroot_total, fr_size; + + fs->mountpoint =3D g_strdup(mount->dirname); + fs->type =3D g_strdup(mount->devtype); + fs->name =3D g_strdup(g_path_get_basename(mount->fromname)); + + if (statvfs(fs->mountpoint, &buf) =3D=3D 0) { + fr_size =3D buf.f_frsize; + used =3D buf.f_blocks - buf.f_bfree; + nonroot_total =3D used + buf.f_bavail; + fs->used_bytes =3D used * fr_size; + fs->total_bytes =3D nonroot_total * fr_size; + fs->total_bytes_privileged =3D buf.f_blocks * fr_size; + + fs->has_total_bytes =3D true; + fs->has_total_bytes_privileged =3D true; + fs->has_used_bytes =3D true; + } + + return fs; +} + +GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) +{ + FsMountList mounts; + struct FsMount *mount; + GuestFilesystemInfoList *ret =3D NULL; + Error *local_err =3D NULL; + + QTAILQ_INIT(&mounts); + if (!build_fs_mount_list(&mounts, &local_err)) { + error_propagate(errp, local_err); + 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 =3D NULL; + break; + } + } + + free_fs_mount_list(&mounts); + return ret; +} +#endif /* __FreeBSD__ */ diff --git a/qga/commands-common.h b/qga/commands-common.h index 263e7c0525..a07d0885f5 100644 --- a/qga/commands-common.h +++ b/qga/commands-common.h @@ -29,6 +29,7 @@ typedef struct FsMount { #if defined(__FreeBSD__) dev_t dev; fsid_t fsid; + char *fromname; #endif QTAILQ_ENTRY(FsMount) next; } FsMount; diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 837be51c40..837e285b6d 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -731,6 +731,9 @@ void free_fs_mount_list(FsMountList *mounts) QTAILQ_REMOVE(mounts, mount, next); g_free(mount->dirname); g_free(mount->devtype); +#if defined(__FreeBSD__) + g_free(mount->fromname); +#endif g_free(mount); } } diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index c57bc9a02f..8cd0ba048b 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -874,7 +874,7 @@ 'data': [ 'ide', 'fdc', 'scsi', 'virtio', 'xen', 'usb', 'uml', 'sata', 'sd', 'unknown', 'ieee1394', 'ssa', 'fibre', 'raid', 'iscsi', 'sas', 'mmc', 'virtual', 'file-backed-virtual', 'nvme' ], - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } =20 ## # @GuestPCIAddress: @@ -892,7 +892,7 @@ { 'struct': 'GuestPCIAddress', 'data': {'domain': 'int', 'bus': 'int', 'slot': 'int', 'function': 'int'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } =20 ## # @GuestCCWAddress: @@ -912,7 +912,7 @@ 'ssid': 'int', 'subchno': 'int', 'devno': 'int'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } =20 ## # @GuestDiskAddress: @@ -942,7 +942,7 @@ 'bus': 'int', 'target': 'int', 'unit': 'int', '*serial': 'str', '*dev': 'str', '*ccw-address': 'GuestCCWAddress'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } =20 ## # @GuestNVMeSmart: @@ -1063,7 +1063,7 @@ 'data': {'name': 'str', 'mountpoint': 'str', 'type': 'str', '*used-bytes': 'uint64', '*total-bytes': 'uint64', '*total-bytes-privileged': 'uint64', 'disk': ['GuestDiskAddress= ']}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } =20 ## # @guest-get-fsinfo: @@ -1077,7 +1077,7 @@ ## { 'command': 'guest-get-fsinfo', 'returns': ['GuestFilesystemInfo'], - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } =20 ## # @guest-set-user-password: --=20 2.52.0