From nobody Sun Jul 26 11:01:58 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=1782923274; cv=none; d=zohomail.com; s=zohoarc; b=Mm0FoyvFilE4F4UB+HnzneDgVSYjUJ3oiYsHCycyd8avoSdgBPGE88Hf7kVg47UbF4B9svlo5jSDjvAjsB0GD48uhvY94QZj4dWaVYp8MDzJKvzwZ6ZXlefK6vVtHCT6yF7uJkgR5SfdtbhtxeElE9reWmtZnZfrSKDyaQk4+68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782923274; 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=0jkUB5ihzKCoeH8C1/e7M+7vhcvxR+AEEQnUIiHrAqA=; b=EGQN9eXj61ydsuD+sD91LkRZ/YoHwKrviesiaeMAZOoUQKmv1NAm3zl2CJ9E9vrJQqxtWqpb2dZIBBNgrmoq7f94G2s7VQq9jCNV9Y5dU6qBgdVO63KgnnubLEfgpkWt2AV+aIs0nPjqql3tzdBe3Oqns1iiUheAbGO22DLo53A= 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 1782923273996688.9376163563497; Wed, 1 Jul 2026 09:27:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wexmV-0002lN-Sq; Wed, 01 Jul 2026 12:27:23 -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 1wexmT-0002kf-OI for qemu-devel@nongnu.org; Wed, 01 Jul 2026 12:27:21 -0400 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wexmS-0005j1-02 for qemu-devel@nongnu.org; Wed, 01 Jul 2026 12:27:21 -0400 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-c126e47a82cso112428166b.2 for ; Wed, 01 Jul 2026 09:27:19 -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-c1288f0dfbdsm300673666b.32.2026.07.01.09.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 09:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782923238; x=1783528038; 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=0jkUB5ihzKCoeH8C1/e7M+7vhcvxR+AEEQnUIiHrAqA=; b=RQbDZO0yENbvC/k0IcCxvin5x0qEA1wSoBNQ06l1ZPESdt5XxVQTM5B2tnvZ0DSVz3 opUEeIhph77OoZhHa8gY+ylcvOUdIAYb5FUBGf+uvnViqtqCuabGUA6FFAIl6t7tZyVG tXSNLKqnaTvyb3dY8pwwSu4lKF0gb+dySMnTSAPSmnra6WNpGYw9z1vwFR2vAluF2vVP /AqCMeoyKFh+wINNg5G2sOYjvFekZnfxBNiPTE+Igtq4PPRxBVTWqq/Ig7WsDWGxlA70 lzdDUfFNUOp3Kz35c1hbmGNvNsIV/aIFC+kSztsaAPxYCBUgSrlKozbd4f7UpLOKlIgh X2ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782923238; x=1783528038; 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=0jkUB5ihzKCoeH8C1/e7M+7vhcvxR+AEEQnUIiHrAqA=; b=CGenVjIgFC/6u99WrT2tl76rWGflb3Ur7S5c/dL5XMCdsxnSJSJkLH0sV2xFa9MSCP ns2KIglieC1g/PKp0CF9MVtJweEk9jdEdBX2ceLXIgRxyxuEa8PWu7lD+gOBewR/jcOQ h5+9kd01A37hKm1V+o5igDE+EWk/FeKQjhPw5/SJNIwVkGLQW1Y9wopjHjJGxKwbi1Wp Xr38asGK4v5NmovPUJYb2k2IDI06nTYLA6EJvxy1b44L9Z3OezRHHbNBf2vjehsA8ABP pIQ3R3zRBoqr7IqgAncwOwip+ucDyTSiSznxxjbUawZnYUIh4XiNE9EttAZNUtYK5mNl v2Zw== X-Gm-Message-State: AOJu0YynPuTSN33d4jycuwHfM9y9Pc+U3XQntPb25T8P3XFOcKRn722y hhi5PebE+XiCh454G4NvBPwALXmiOnF6VFiIpo0ZA05fRX+69mgq3mjRbqdaBGrRWuU= X-Gm-Gg: AfdE7cm5E7zQgC7kdAlOBngOPocl0rmKXsMb4RJENPnDFiOus+cp9gH6+1Uwu0pKJuB oNsL8BIKmmP2eW7yL14iTQSryvNI49whh6/HVAtewj/Zhgke0DYeoJ86uhAtsJt2OL/fa8h8jIk bWwp3h04jy64ZUoQzsbTZTf6irfHHUvnlwR9xT2pxZ7wolgtVSVbUqLjuH7e1F0t23XJGkJKASO ZkA2sCto6tf3wC/XY6Md6tnyhDfpR19Vo1tgeF9iqulg1TjYCABzHy04ziTaS7AKikJtNOV39iq pHxeJneLQuO7BSR4dl4fZpogMb05tR9HDpR/xu+KDNVzcd0JkDuPIAInieXHPutX4poVFyffqZo o2eqNqs5Vdtc6T/Gx5L/8fir4NqtAOP8o1oOgiKqS2shVT1xWEFxnLMb2ja/EEFzRy4/yX8U0Qb iAD8RfgLG2T9BZVgb6S9OxzJlrXEBp3/Da87aU8lZ76rSJ2YatKAKUAnaXD/JH0ESG62Vx/aXpr AfYaQQwH5e0cf850XcaPk9muHc= X-Received: by 2002:a17:906:6bd4:b0:c12:8a79:cc74 with SMTP id a640c23a62f3a-c12aa1418bamr94023566b.42.1782923237439; Wed, 01 Jul 2026 09:27:17 -0700 (PDT) From: Roman Bogorodskiy To: qemu-devel@nongnu.org Cc: Roman Bogorodskiy , Michael Roth , Kostiantyn Kostiuk , Eric Blake , Markus Armbruster Subject: [PATCH] qga: implement 'guest-get-fsinfo' for FreeBSD Date: Wed, 1 Jul 2026 18:25:28 +0200 Message-ID: <20260701162529.10235-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::632; envelope-from=bogorodskiy@gmail.com; helo=mail-ej1-x632.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: 1782923275358158500 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 --- 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..a258133918 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_malloc0(sizeof(*fs)); + 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