From nobody Mon Nov 23 04:18:33 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793180546; cv=none; d=zohomail.com; s=zohoarc; b=hFBNEUUDWf1xD9aPXKKbIY+Uk6ADPQ1ZomzVfMxRcTL7/uYIUkmgTWH/3Dl5ZgbgC5paJrwUdsHEcuhALgZYehnr6RqIrJ29JrHG6OfLt4DjfmZaVp06UjFKWLkcuPAibBXvacvwlU7qvE3QeUW09hsR0OAapqzK4+xNDzkDcAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793180546; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=/zfquhvBWrOcEPjTAE/Y7Sndk6dq4R3rCiWhEHx47XM=; b=QV66X6QGnlRZIjCNc45jKzKI4wchJSMaZlVNBZGq3VDK1HHWp3rUpA39CtcEFyCkAN80ZDtv5ZvNBnhbf+QVQ7IB1r+gau5ubQ7Of1YlVDJLpxSxeujG536rMMtUhegcQulcdA4Sr2z64n3czb3x/lrQjk5N/++/XsbTvyY9Oxs= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793180546211833.4614331993203; Wed, 28 Oct 2026 02:42:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM0Al-0006ya-Sq; Wed, 28 Oct 2026 05:42:21 -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 1xM0Aa-0006qk-9X for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM0AX-0008Qr-QS for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:08 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-4pKYPs6cO_O1HV4jL3CiwA-1; Wed, 28 Oct 2026 05:42:00 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D8A4B18011D2; Wed, 28 Oct 2026 09:41:58 +0000 (UTC) Received: from Kostiantyns-MacBook-Pro.redhat.com (unknown [10.44.32.20]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 900A41956086; Wed, 28 Oct 2026 09:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793180523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zfquhvBWrOcEPjTAE/Y7Sndk6dq4R3rCiWhEHx47XM=; b=WCi6nSM1nb3/68n1gRsN1xtyfGcMYnKB36imki70jiq0c8mb6t0rtsrSIbx//ZwmQW0XAi X7zUIllqMaoWJTXoJqYkRtnJ3KFOXdcg+yPSqeAet2YaQaVId9HTsQQH/YD2rXb+K9qhjS 0vLqx2TsrdUNVjN9GwHZymnREQoqhL0= X-MC-Unique: 4pKYPs6cO_O1HV4jL3CiwA-1 X-Mimecast-MFC-AGG-ID: 4pKYPs6cO_O1HV4jL3CiwA_1793180519 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 1/6] qga: implement 'guest-get-fsinfo' for NetBSD and OpenBSD Date: Wed, 28 Oct 2026 11:41:47 +0200 Message-ID: <20261028094152.14934-2-kkostiuk@redhat.com> In-Reply-To: <20261028094152.14934-1-kkostiuk@redhat.com> References: <20261028094152.14934-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1793180553257154100 Content-Type: text/plain; charset="utf-8" From: Brad Smith qga: implement 'guest-get-fsinfo' for NetBSD and OpenBSD Signed-off-by: Brad Smith Reviewed-by: Roman Bogorodskiy Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/aq2m9yuSGK0m2zRb@humpty.home.comst= yle.com Signed-off-by: Kostiantyn Kostiuk --- qga/commands-bsd.c | 19 +++++++++++++------ qga/commands-common.h | 12 +++++++----- qga/commands-posix.c | 4 ++-- qga/qapi-schema.json | 12 ++++++------ 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c index 1c51d099eb..0c6caec4a3 100644 --- a/qga/commands-bsd.c +++ b/qga/commands-bsd.c @@ -28,12 +28,20 @@ #include #endif #include +#ifdef __FreeBSD__ +#include +#endif + +#ifdef __NetBSD__ +typedef struct statvfs bsd_fsinfo_t; +#else +typedef struct statfs bsd_fsinfo_t; +#endif =20 -#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) || defined(__FreeBS= D__) bool build_fs_mount_list(FsMountList *mounts, Error **errp) { FsMount *mount; - struct statfs *mntbuf, *mntp; + bsd_fsinfo_t *mntbuf, *mntp; struct stat statbuf; int i, count, ret; =20 @@ -57,16 +65,17 @@ bool build_fs_mount_list(FsMountList *mounts, Error **e= rrp) 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->dev =3D statbuf.st_dev; mount->devmajor =3D major(mount->dev); mount->devminor =3D minor(mount->dev); +#ifdef CONFIG_FSFREEZE mount->fsid =3D mntp->f_fsid; - mount->dev =3D statbuf.st_dev; +#endif =20 QTAILQ_INSERT_TAIL(mounts, mount, next); } return true; } -#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */ =20 #if defined(CONFIG_FSFREEZE) static int ufssuspend_fd =3D -1; @@ -181,7 +190,6 @@ bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned ch= ar *buf, } #endif /* HAVE_GETIFADDRS */ =20 -#if defined(__FreeBSD__) static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount) { GuestFilesystemInfo *fs =3D g_new0(GuestFilesystemInfo, 1); @@ -228,4 +236,3 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **e= rrp) free_fs_mount_list(&mounts); return ret; } -#endif /* __FreeBSD__ */ diff --git a/qga/commands-common.h b/qga/commands-common.h index a07d0885f5..0d3c69b480 100644 --- a/qga/commands-common.h +++ b/qga/commands-common.h @@ -18,17 +18,19 @@ #endif /* __linux__ */ =20 #ifdef __FreeBSD__ -#include +#include #endif /* __FreeBSD__ */ =20 -#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) +#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) || defined(CONFIG_B= SD) typedef struct FsMount { char *dirname; char *devtype; unsigned int devmajor, devminor; -#if defined(__FreeBSD__) - dev_t dev; +#ifdef __FreeBSD__ fsid_t fsid; +#endif +#ifdef CONFIG_BSD + dev_t dev; char *fromname; #endif QTAILQ_ENTRY(FsMount) next; @@ -38,7 +40,7 @@ typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList; =20 bool build_fs_mount_list(FsMountList *mounts, Error **errp); void free_fs_mount_list(FsMountList *mounts); -#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM */ +#endif /* CONFIG_FSFREEZE || CONFIG_FSTRIM || CONFIG_BSD */ =20 #if defined(CONFIG_FSFREEZE) int64_t qmp_guest_fsfreeze_do_freeze_list(bool has_mountpoints, diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 837e285b6d..dcc683f6c9 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -718,7 +718,7 @@ void qmp_guest_file_flush(int64_t handle, Error **errp) } } =20 -#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) +#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) || defined(CONFIG_B= SD) void free_fs_mount_list(FsMountList *mounts) { FsMount *mount, *temp; @@ -731,7 +731,7 @@ void free_fs_mount_list(FsMountList *mounts) QTAILQ_REMOVE(mounts, mount, next); g_free(mount->dirname); g_free(mount->devtype); -#if defined(__FreeBSD__) +#ifdef CONFIG_BSD g_free(mount->fromname); #endif g_free(mount); diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 05fe4ea484..d81b57de53 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -844,7 +844,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', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } =20 ## # @GuestPCIAddress: @@ -862,7 +862,7 @@ { 'struct': 'GuestPCIAddress', 'data': {'domain': 'int', 'bus': 'int', 'slot': 'int', 'function': 'int'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } =20 ## # @GuestCCWAddress: @@ -882,7 +882,7 @@ 'ssid': 'int', 'subchno': 'int', 'devno': 'int'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } =20 ## # @GuestDiskAddress: @@ -912,7 +912,7 @@ 'bus': 'int', 'target': 'int', 'unit': 'int', '*serial': 'str', '*dev': 'str', '*ccw-address': 'GuestCCWAddress'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } =20 ## # @GuestNVMeSmart: @@ -1031,7 +1031,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', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } =20 ## # @guest-get-fsinfo: @@ -1045,7 +1045,7 @@ ## { 'command': 'guest-get-fsinfo', 'returns': ['GuestFilesystemInfo'], - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_FREEBSD' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LINUX', 'CONFIG_BSD' ] } } =20 ## # @guest-set-user-password: --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:18:33 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793180596; cv=none; d=zohomail.com; s=zohoarc; b=JAMcsOXqsnIvofohp6vh4O1jce4lJaY/j4ro9uBUKw6dkTV3Yl9ASOvpKpES/jtSKq9iDIPNmev1e1SREtGl4pavQGTEW0JP43711zI6G78ROP+yYu8uZ+6ZFVwyBVthjP7KFKDHs0CtIS7OY/o7azt4Hou7+FuRLDcseVeh3Dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793180596; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=47XDrBXBW1aLeI/fz9aR814Fe16gcvng1jajOPf+GmI=; b=d9Umr+OwZEntTFXe2uTYIc1d5vffAAJotritKLundw/u401Be2umQ/MrqBN4uACwIUHwaHyoyqElhBjKjJVhT6gBVlZkDWrXKR6abP/eUxpO+vfklHUwTc3P3LbtfZqhOIb7Mf13250FZaJn3H1jh3sUJjOOKHpYqpRUSW2MKAQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793180596382897.2271010592242; Wed, 28 Oct 2026 02:43:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM0BX-0007Y3-SU; Wed, 28 Oct 2026 05:43:09 -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 1xM0Af-0006uD-J8 for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM0Ad-0008SA-Ow for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:13 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-673-RMSo5KxNOqGHbI6s7u2rnQ-1; Wed, 28 Oct 2026 05:42:02 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 09BA81956071; Wed, 28 Oct 2026 09:42:01 +0000 (UTC) Received: from Kostiantyns-MacBook-Pro.redhat.com (unknown [10.44.32.20]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 821221956086; Wed, 28 Oct 2026 09:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793180530; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=47XDrBXBW1aLeI/fz9aR814Fe16gcvng1jajOPf+GmI=; b=bmF08OvWjxvUGuF3+CpcSppkFI76yqc9A1TdRztCq7eHufKp8RZ5hmJTwnzBRER9U2Gl13 XXILGRlzU9lODsu73JTXAqfn1HIG7yOlcKTBH3JKX9iiMQAcV9H3wM3/oygyYX7/Vggvc3 d9YnS++BVQIYW1yhcIpvTxUR1lDrZtg= X-MC-Unique: RMSo5KxNOqGHbI6s7u2rnQ-1 X-Mimecast-MFC-AGG-ID: RMSo5KxNOqGHbI6s7u2rnQ_1793180521 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 2/6] qga: fix typo in guest-file-read warning Date: Wed, 28 Oct 2026 11:41:48 +0200 Message-ID: <20261028094152.14934-3-kkostiuk@redhat.com> In-Reply-To: <20261028094152.14934-1-kkostiuk@redhat.com> References: <20261028094152.14934-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1793180599709154100 From: Fabian Gr=C3=BCnbichler seems to have been transformed from "read" to "write" during a refactor. Fixes: ead83a136d54 "qga: Extract qmp_guest_file_read() to common commands.= c" Signed-off-by: Fabian Gr=C3=BCnbichler Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/20261009-qga-file-read-typo-v1-1-4= 0c462aefe12@proxmox.com Signed-off-by: Kostiantyn Kostiuk --- qga/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/commands.c b/qga/commands.c index 5f20af25d3..666341a909 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -626,7 +626,7 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool= has_count, =20 read_data =3D guest_file_read_unsafe(gfh, count, errp); if (!read_data) { - slog("guest-file-write failed, handle: %" PRId64, handle); + slog("guest-file-read failed, handle: %" PRId64, handle); } =20 return read_data; --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:18:33 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793180566; cv=none; d=zohomail.com; s=zohoarc; b=W/bvc3fNTtYuo33SV6hbFmiEzkjh5xyKpDayiaww9QOLOd0s46DBa5qfwbk0Lf88SnDf7GiI87y4iNnmK45KvIQ4Obk1fZM46Nl5Cl0fB1b+9dqFrZ0xxv9d527qEfTaknASKo7YFW+Mcasny30fspLonlfta+eIgoKHyzPPNGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793180566; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=sx+oQj4Xo2sYOUw/rp5gYWjgUJbUaulKuWXDuC4vCkE=; b=iCNRv9RPfaUCTGFyb4Qjy8YnxSvLbNyR/wg3f/sywuyp21/ahHR07tXCodiKvA/XzIDxMxEIqblLKcCyoHVnQIM3FKxZYw361B+T5MUduq/+oNvM0pP1GaQb+VNP8IqAZSatAos2lcGUfrmhKfhgzITSTNmNMG4gXhVMi8DWsNI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793180566696612.1794500675236; Wed, 28 Oct 2026 02:42:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM0B5-000750-Sg; Wed, 28 Oct 2026 05:42:41 -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 1xM0Ac-0006sU-AZ for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM0AZ-0008R2-Oa for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:10 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-L_HU3iM2PF26TaZFLGkuow-1; Wed, 28 Oct 2026 05:42:03 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 920221800BD1; Wed, 28 Oct 2026 09:42:02 +0000 (UTC) Received: from Kostiantyns-MacBook-Pro.redhat.com (unknown [10.44.32.20]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5F4D61956086; Wed, 28 Oct 2026 09:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793180526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sx+oQj4Xo2sYOUw/rp5gYWjgUJbUaulKuWXDuC4vCkE=; b=gAGU1cf9iU7+FY5Hk9OD6Zg+xcOs8S4Fuq0EE8IukvgllD0HD+UfMeDAXa00OIMc93EELF iBsmfchGaEff30XOGImXPUpImc0S2oRW2+TW4tpGQ5ASYolUnfF/b//lc7FKmYCkgUT6PW qudJ5NOi7f3guqJj3tzcuuVn1SAlnOY= X-MC-Unique: L_HU3iM2PF26TaZFLGkuow-1 X-Mimecast-MFC-AGG-ID: L_HU3iM2PF26TaZFLGkuow_1793180522 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 3/6] qga: implement 'guest-get-diskstats' for FreeBSD Date: Wed, 28 Oct 2026 11:41:49 +0200 Message-ID: <20261028094152.14934-4-kkostiuk@redhat.com> In-Reply-To: <20261028094152.14934-1-kkostiuk@redhat.com> References: <20261028094152.14934-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1793180569427154100 Content-Type: text/plain; charset="utf-8" From: Roman Bogorodskiy Implement the 'guest-get-diskstats' for FreeBSD. This implementation uses the devstat(3) library which is a part of the FreeBSD base system. The build system is updated to link qga with `-ldevstat`. Signed-off-by: Roman Bogorodskiy Acked-by: Markus Armbruster Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/20260901192732.46190-1-bogorodskiy= @gmail.com Signed-off-by: Kostiantyn Kostiuk --- qga/commands-bsd.c | 121 ++++++++++++++++++++++++++++++++++++++++++- qga/meson.build | 3 ++ qga/qapi-schema.json | 6 +-- 3 files changed, 126 insertions(+), 4 deletions(-) diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c index 0c6caec4a3..7c7616699b 100644 --- a/qga/commands-bsd.c +++ b/qga/commands-bsd.c @@ -14,6 +14,7 @@ #include "qga-qapi-commands.h" #include "qapi/error.h" #include "qemu/queue.h" +#include "block/block-common.h" #include "commands-common.h" #include #include @@ -31,12 +32,14 @@ #ifdef __FreeBSD__ #include #endif - #ifdef __NetBSD__ typedef struct statvfs bsd_fsinfo_t; #else typedef struct statfs bsd_fsinfo_t; #endif +#ifdef CONFIG_FREEBSD +#include +#endif =20 bool build_fs_mount_list(FsMountList *mounts, Error **errp) { @@ -236,3 +239,119 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error *= *errp) free_fs_mount_list(&mounts); return ret; } + +#ifdef CONFIG_FREEBSD +static uint64_t bintime_to_msec(const struct bintime *bt) +{ + return (uint64_t)bt->sec * 1000ULL + (((bt->frac >> 32) * 1000ULL) >> = 32); +} + +static GuestDiskStatsInfo * +guest_diskstats_info_new(const struct devstat *dev) +{ + GuestDiskStatsInfo *diskstatinfo; + GuestDiskStats *diskstat; + + diskstatinfo =3D g_new0(GuestDiskStatsInfo, 1); + diskstatinfo->name =3D g_strdup_printf("%s%d", dev->device_name, + dev->unit_number); + /* + * devstat does not expose Linux-style major/minor numbers. Report the + * devstat device number and unit number in these mandatory QAPI field= s. + */ + diskstatinfo->major =3D dev->device_number; + diskstatinfo->minor =3D dev->unit_number; + + diskstat =3D g_new0(GuestDiskStats, 1); + diskstat->has_read_ios =3D true; + diskstat->read_ios =3D dev->operations[DEVSTAT_READ]; + diskstat->has_read_sectors =3D true; + diskstat->read_sectors =3D dev->bytes[DEVSTAT_READ] / BDRV_SECTOR_SIZE; + diskstat->has_read_ticks =3D true; + diskstat->read_ticks =3D bintime_to_msec(&dev->duration[DEVSTAT_READ]); + + diskstat->has_write_ios =3D true; + diskstat->write_ios =3D dev->operations[DEVSTAT_WRITE]; + diskstat->has_write_sectors =3D true; + diskstat->write_sectors =3D dev->bytes[DEVSTAT_WRITE] / BDRV_SECTOR_SI= ZE; + diskstat->has_write_ticks =3D true; + diskstat->write_ticks =3D bintime_to_msec(&dev->duration[DEVSTAT_WRITE= ]); + + diskstat->has_discard_ios =3D true; + diskstat->discard_ios =3D dev->operations[DEVSTAT_FREE]; + diskstat->has_discard_sectors =3D true; + diskstat->discard_sectors =3D dev->bytes[DEVSTAT_FREE] / BDRV_SECTOR_S= IZE; + diskstat->has_discard_ticks =3D true; + diskstat->discard_ticks =3D bintime_to_msec(&dev->duration[DEVSTAT_FRE= E]); + + diskstat->has_ios_pgr =3D true; + diskstat->ios_pgr =3D dev->start_count - dev->end_count; + + diskstat->has_total_ticks =3D true; + diskstat->total_ticks =3D bintime_to_msec(&dev->busy_time); + + diskstatinfo->stats =3D diskstat; + return diskstatinfo; +} + +GuestDiskStatsInfoList *qmp_guest_get_diskstats(Error **errp) +{ + GuestDiskStatsInfoList *head =3D NULL, **tail =3D &head; + struct devinfo dinfo =3D { 0 }; + struct statinfo stats =3D { .dinfo =3D &dinfo }; + struct device_selection *dev_select =3D NULL; + struct devstat_match matches[] =3D { + { + .match_fields =3D DEVSTAT_MATCH_TYPE, + .device_type =3D DEVSTAT_TYPE_DIRECT, + .num_match_categories =3D 1, + }, + }; + int num_selected =3D 0; + int num_selections =3D 0; + long select_generation =3D 0; + int i; + + if (devstat_checkversion(NULL) =3D=3D -1) { + error_setg(errp, "%s", devstat_errbuf); + return NULL; + } + + if (devstat_getdevs(NULL, &stats) =3D=3D -1) { + error_setg(errp, "%s", devstat_errbuf); + goto error; + } + + if (devstat_selectdevs(&dev_select, &num_selected, &num_selections, + &select_generation, stats.dinfo->generation, + stats.dinfo->devices, stats.dinfo->numdevs, + matches, ARRAY_SIZE(matches), NULL, 0, + DS_SELECT_ONLY, + stats.dinfo->numdevs, 0) =3D=3D -1) { + error_setg(errp, "%s", devstat_errbuf); + goto error; + } + + for (i =3D 0; i < num_selections; i++) { + const struct devstat *dev; + + if (dev_select[i].selected =3D=3D 0) { + continue; + } + + dev =3D &stats.dinfo->devices[dev_select[i].position]; + QAPI_LIST_APPEND(tail, guest_diskstats_info_new(dev)); + } + + free(stats.dinfo->mem_ptr); + free(dev_select); + return head; + +error: + qapi_free_GuestDiskStatsInfoList(head); + free(stats.dinfo->mem_ptr); + free(dev_select); + return NULL; +} + +#endif /* CONFIG_FREEBSD */ diff --git a/qga/meson.build b/qga/meson.build index cfa2157efb..a046ebe305 100644 --- a/qga/meson.build +++ b/qga/meson.build @@ -93,6 +93,9 @@ qga_ss =3D qga_ss.apply({}) =20 gen_tlb =3D [] qga_libs =3D [] +if host_os =3D=3D 'freebsd' + qga_libs +=3D ['-ldevstat'] +endif if host_os =3D=3D 'windows' qga_libs +=3D ['-lws2_32', '-lwinmm', '-lpowrprof', '-lwtsapi32', '-lwin= inet', '-liphlpapi', '-lnetapi32', '-lsetupapi', '-lcfgmgr32', '-luserenv', '-lpdh' ] diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index d81b57de53..308ed9acf1 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1666,7 +1666,7 @@ '*total-ticks': 'uint64', '*weight-ticks': 'uint64' }, - 'if': 'CONFIG_LINUX' } + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_FREEBSD'] } } =20 ## # @GuestDiskStatsInfo: @@ -1684,7 +1684,7 @@ 'major': 'uint64', 'minor': 'uint64', 'stats': 'GuestDiskStats' }, - 'if': 'CONFIG_LINUX' } + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_FREEBSD'] } } =20 ## # @guest-get-diskstats: @@ -1696,7 +1696,7 @@ ## { 'command': 'guest-get-diskstats', 'returns': ['GuestDiskStatsInfo'], - 'if': 'CONFIG_LINUX' + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_FREEBSD'] } } =20 ## --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:18:33 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793180623; cv=none; d=zohomail.com; s=zohoarc; b=gJkK4o2OG17zX92SVhRQ/gKWd+HNIXbJbLI+3yjUlplPa5Hsb9EJjHyOEKtN3UE5NoRm3xHz9wPfzKp6Dx0WxEJObUqeXup4bGFcLF8qGmdZI7LTvgtM8yTEYEkDoGv0RrIS0OQyPu9g+Pt2Xw3VlkXg1UOg61nqAP2dPuIs8BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793180623; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=b54msd3s5LCaRfGkCwsJ1ziMbvtGqsr/nJB0EDM+edg=; b=R0uXyK8qnfQyMM9hP+3BVnHlQo9l8gumt67tK2OU+CVFLT3w57O1q3KkHRPuhP8tWzrQhDqqkwz8u/F+1bojLPbjk7sFaFZbeXFd+fKd+5EI3ymz78Xhi2OZTIF8r6m0I5I/l6FbPVZ0xxLQ07ILlkEx42cwlJmSzJAy6qD9zyU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793180623633311.8519727741814; Wed, 28 Oct 2026 02:43:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM0Bx-0007l7-FT; Wed, 28 Oct 2026 05:43:37 -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 1xM0Ad-0006tZ-SF for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM0Ab-0008Ra-QK for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:11 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-184-qQexNUqENk6xh7N4LdDdkw-1; Wed, 28 Oct 2026 05:42:05 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 38D9E19560B4; Wed, 28 Oct 2026 09:42:04 +0000 (UTC) Received: from Kostiantyns-MacBook-Pro.redhat.com (unknown [10.44.32.20]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 26DDA1956086; Wed, 28 Oct 2026 09:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793180529; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b54msd3s5LCaRfGkCwsJ1ziMbvtGqsr/nJB0EDM+edg=; b=KcRN+OLoR9TN3yFFqsBAoIlzjOzkl+olX2F3vZkr9ANnq1tFJIAgfiUQo0BGJDPTSEcmWp /sYTRMtxEAW+rhx9WrGymVVoXiTiNkAYdq9Ges4NRJMYqGF9bDWj1yImo5wqXK1fcA95xl JLPxayGt93t9xcObPZUuByFu+ce6bYU= X-MC-Unique: qQexNUqENk6xh7N4LdDdkw-1 X-Mimecast-MFC-AGG-ID: qQexNUqENk6xh7N4LdDdkw_1793180524 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 4/6] qga/vss-win32: remove orphaned VSS provider service Date: Wed, 28 Oct 2026 11:41:50 +0200 Message-ID: <20261028094152.14934-5-kkostiuk@redhat.com> In-Reply-To: <20261028094152.14934-1-kkostiuk@redhat.com> References: <20261028094152.14934-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1793180626390158500 From: Abed Agbaria COMRegister() probes the COM+ catalog to decide whether to unregister first, but it is the SCM that blocks installation when a service of the same name is left over. If the COM+ application is gone and the service survives, install fails with 0x80070431 and never recovers. - Check the SCM as well as the COM+ catalog in COMRegister(). - Delete the provider service in COMUnregister() and at the DllUnregisterServer() call sites in DllRegisterServer(). Opening the SCM, opening the provider service and closing both handles is boilerplate that StopService() already contains, so move it into QGAProviderOpenService(), which returns a single service handle and reports the win32 error through an out parameter, and convert StopService() to it. The service handle stays valid after the SCM handle is closed, so the helper closes it and each caller is left with one handle to release. While at it, fix two pre-existing problems in StopService(): - It logged errmsg(E_FAIL, ...) and returned E_FAIL for every failure, discarding the GetLastError() value. It now passes the win32 error code to errmsg() and returns HRESULT_FROM_WIN32(). - It opened the SCM with SC_MANAGER_ALL_ACCESS, which implies SC_MANAGER_CREATE_SERVICE and is therefore refused to non-administrators, and passed that same SCM mask to OpenService() as a service access mask. Each operation now requests only what it needs: SC_MANAGER_CONNECT on the SCM, and SERVICE_QUERY_CONFIG, DELETE or SERVICE_STOP on the service. StopService()'s return value changes from E_FAIL to a specific HRESULT_FROM_WIN32(); its only caller, in requester.cpp, ignores it. Signed-off-by: Abed Agbaria Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/20260917154901.321702-1-aagbaria@r= edhat.com Signed-off-by: Kostiantyn Kostiuk --- qga/vss-win32/install.cpp | 118 ++++++++++++++++++++++++++++++++------ 1 file changed, 101 insertions(+), 17 deletions(-) diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp index 09d94edd4f..431fcd1cbe 100644 --- a/qga/vss-win32/install.cpp +++ b/qga/vss-win32/install.cpp @@ -257,6 +257,96 @@ static void qga_vss_open_log(void) } } =20 +/* + * Open the QGA VSS provider service with the requested access rights. + * + * On success, return a service handle which the caller must release with + * CloseServiceHandle(). On failure, return NULL and store the win32 error + * code in *err. ERROR_SERVICE_DOES_NOT_EXIST just means the service is n= ot + * installed, which is a normal condition for all callers, so it is not + * reported here; the caller decides what it means. + */ +static SC_HANDLE QGAProviderOpenService(DWORD access, DWORD *err) +{ + qga_debug_begin; + + SC_HANDLE service =3D NULL; + SC_HANDLE manager =3D OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT); + + *err =3D ERROR_SUCCESS; + + if (!manager) { + *err =3D GetLastError(); + errmsg(*err, "Failed to open service manager"); + goto out; + } + + service =3D OpenService(manager, QGA_PROVIDER_NAME, access); + if (!service) { + *err =3D GetLastError(); + if (*err !=3D ERROR_SERVICE_DOES_NOT_EXIST) { + errmsg(*err, "Failed to open service"); + } + } + +out: + if (manager) { + CloseServiceHandle(manager); + } + qga_debug_end; + return service; +} + +/* Check whether the QGA VSS provider service is registered with the SCM */ +static bool QGAProviderServiceExists(void) +{ + qga_debug_begin; + + DWORD err; + SC_HANDLE service =3D QGAProviderOpenService(SERVICE_QUERY_CONFIG, &er= r); + + if (service) { + CloseServiceHandle(service); + } + + qga_debug_end; + return service !=3D NULL; +} + +/* Delete a QGA VSS provider service that COM+ no longer owns */ +static HRESULT QGAProviderRemoveService(void) +{ + qga_debug_begin; + + HRESULT hr =3D S_OK; + DWORD err; + SC_HANDLE service =3D QGAProviderOpenService(DELETE, &err); + + if (!service) { + if (err !=3D ERROR_SERVICE_DOES_NOT_EXIST) { + hr =3D HRESULT_FROM_WIN32(err); + } + goto out; + } + + qga_debug("Removing service: %s", QGA_PROVIDER_NAME); + + if (!DeleteService(service)) { + err =3D GetLastError(); + if (err !=3D ERROR_SERVICE_MARKED_FOR_DELETE) { + hr =3D HRESULT_FROM_WIN32(err); + errmsg(err, "Failed to delete service"); + } + } + +out: + if (service) { + CloseServiceHandle(service); + } + qga_debug_end; + return hr; +} + /* Unregister this module from COM+ Applications Catalog */ STDAPI COMUnregister(void); STDAPI COMUnregister(void) @@ -268,6 +358,7 @@ STDAPI COMUnregister(void) =20 DllUnregisterServer(); chk(QGAProviderFind(QGAProviderRemove, NULL)); + chk(QGAProviderRemoveService()); out: qga_debug_end; return hr; @@ -304,7 +395,7 @@ STDAPI COMRegister(void) } =20 chk(QGAProviderFind(QGAProviderCount, (void *)&count)); - if (count) { + if (count || QGAProviderServiceExists()) { qga_debug("QGA VSS Provider is already installed. Attempting to un= register first."); hr =3D COMUnregister(); if (FAILED(hr)) { @@ -517,6 +608,7 @@ STDAPI DllRegisterServer(void) g_gProviderVersion); if (hr =3D=3D (long int) VSS_E_PROVIDER_ALREADY_REGISTERED) { DllUnregisterServer(); + QGAProviderRemoveService(); hr =3D pVssAdmin->RegisterProvider(g_gProviderId, CLSID_QGAVSSProv= ider, const_cast (QGA_PROVIDER_LNAME), @@ -533,6 +625,7 @@ STDAPI DllRegisterServer(void) out: if (FAILED(hr)) { DllUnregisterServer(); + QGAProviderRemoveService(); } =20 qga_debug_end; @@ -594,33 +687,24 @@ STDAPI StopService(void) qga_debug_begin; =20 HRESULT hr =3D S_OK; - SC_HANDLE manager =3D OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - SC_HANDLE service =3D NULL; - - if (!manager) { - errmsg(E_FAIL, "Failed to open service manager"); - hr =3D E_FAIL; - goto out; - } - service =3D OpenService(manager, QGA_PROVIDER_NAME, SC_MANAGER_ALL_ACC= ESS); + DWORD err; + SC_HANDLE service =3D QGAProviderOpenService(SERVICE_STOP, &err); =20 if (!service) { - errmsg(E_FAIL, "Failed to open service"); - hr =3D E_FAIL; + hr =3D HRESULT_FROM_WIN32(err); goto out; } + if (!(ControlService(service, SERVICE_CONTROL_STOP, &status))) { - errmsg(E_FAIL, "Failed to stop service"); - hr =3D E_FAIL; + err =3D GetLastError(); + hr =3D HRESULT_FROM_WIN32(err); + errmsg(err, "Failed to stop service"); } =20 out: if (service) { CloseServiceHandle(service); } - if (manager) { - CloseServiceHandle(manager); - } qga_debug_end; return hr; } --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:18:33 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793180587; cv=none; d=zohomail.com; s=zohoarc; b=Wktmw2agINmMRtyi1WCO4u6lH0IQPEbOL35JWPve4QRmKNnmKxeP9ACKD9C+gQVymsSLQmV/XtL3DFcN+lz+JKUXiD7VkhZdbV4cM3R2In27T5u1OhGj0ZSWKDBq7G/T/YIeUB4HLhsgC2hobiaIzhb41b7zPcOeFY4l7RG1vPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793180587; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=R9iCslM5tBL63stEtpQc9HVGDsEzNqzJAnD367d+6J0=; b=CPcQaCATUcSqxzvvfGg+0FfTT7yIgouaXo4asp0/U8rxZio+w3ah8lBX0W7X63owuraSc7feP2fDWG+YF9iehJHqdrW+zTM5MvlwEfkztq1ahnnKgEoW0jmgM3jUMOFyznlNyOA5EkIcnNvuUDpnFymHnkQykz/oggrnrK4qu9I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793180587184226.93468528862593; Wed, 28 Oct 2026 02:43:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM0BO-0007Op-Ii; Wed, 28 Oct 2026 05:42:58 -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 1xM0Af-0006uC-Cj for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM0Ad-0008SI-LA for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:13 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-3S5yMh9WPSSWZKnUXK6emg-1; Wed, 28 Oct 2026 05:42:07 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0775D1955E9C; Wed, 28 Oct 2026 09:42:06 +0000 (UTC) Received: from Kostiantyns-MacBook-Pro.redhat.com (unknown [10.44.32.20]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AAD6A1956086; Wed, 28 Oct 2026 09:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793180531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R9iCslM5tBL63stEtpQc9HVGDsEzNqzJAnD367d+6J0=; b=HeO+ysCJFGD5AyscGJvjnAxf4tYwVZMPqC4GY5U8gwlnukZPNRYB+cqRPinTzRo/tuOl0K Mx68rEWGYsoEgZND9922NeygmRugYrqBnpzqKzmomqk0V7t/kIFTDJGRF8lKtBJTJPqQ1I HECI0zonstMdHtnuXT1ndZXKZsVwtIc= X-MC-Unique: 3S5yMh9WPSSWZKnUXK6emg-1 X-Mimecast-MFC-AGG-ID: 3S5yMh9WPSSWZKnUXK6emg_1793180526 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 5/6] tests/unit/test-qga: enable on FreeBSD Date: Wed, 28 Oct 2026 11:41:51 +0200 Message-ID: <20261028094152.14934-6-kkostiuk@redhat.com> In-Reply-To: <20261028094152.14934-1-kkostiuk@redhat.com> References: <20261028094152.14934-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1793180589667154100 From: Roman Bogorodskiy FreeBSD has all necessary commands implemented, so enable test-qga for it. Requires only minimal portability fixes for sockets in connect_qga(). Signed-off-by: Roman Bogorodskiy Reviewed-by: Kostiantyn Kostiuk Reviewed-by: Daniel P. Berrang=C3=A9 Link: https://lore.kernel.org/qemu-devel/20260929150100.66035-1-bogorodskiy= @gmail.com Signed-off-by: Kostiantyn Kostiuk --- tests/unit/meson.build | 2 +- tests/unit/test-qga.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/meson.build b/tests/unit/meson.build index d17435c187..295df1a7eb 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -169,7 +169,7 @@ if have_system tests +=3D {'test-qdev': [qom, hwcore]} endif =20 -if have_ga and host_os =3D=3D 'linux' +if have_ga and host_os in ['freebsd', 'linux'] tests +=3D {'test-qga': ['../qtest/libqmp.c', '../qtest/libqtest.c']} test_deps +=3D {'test-qga': qga} endif diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index 01ccf826e6..b1c84c188b 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -18,7 +18,7 @@ typedef struct { static int connect_qga(char *path) { int s, ret, len, i =3D 0; - struct sockaddr_un remote; + struct sockaddr_un remote =3D { 0 }; =20 s =3D socket(AF_UNIX, SOCK_STREAM, 0); g_assert(s !=3D -1); @@ -26,7 +26,7 @@ static int connect_qga(char *path) remote.sun_family =3D AF_UNIX; do { strcpy(remote.sun_path, path); - len =3D strlen(remote.sun_path) + sizeof(remote.sun_family); + len =3D sizeof(remote); ret =3D connect(s, (struct sockaddr *)&remote, len); if (ret =3D=3D -1) { g_usleep(G_USEC_PER_SEC); --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:18:33 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1793180582; cv=none; d=zohomail.com; s=zohoarc; b=DTdghlFMCco27FV5mpUd/R9ogLXUB27DNX6Rc2MGkPMSiXDU0DM5AEind5Q3Mv4F/LI8+jpuu7oZkCJPZSwLsMGDGoQTBpYAqwBVMCuSW6MxvszLBYqAXjJPBWMG/VUJp4sZBLTdOtwPRuthtZXRUZIUncP3DZTij9ViSe0GYJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793180582; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To: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:Cc; bh=HcFcpHWK8R0UlF01J7rf8ed8TzZOVdZWuJn5gK2yT5A=; b=A226gMR1nAlwQwoPAQhAsrbgOmwXzhw2Ap+looHXMlY2DVhwLRXaRRzwwme0RInSjARh/4U1XawckKXLqQzoxdAd582EnOoyFwtH19WhOa7AbiB+ARqEZs4WvpZ2+PQZGfdzz8iq9KKr+yvy7xzkWBCzxJ8CzM/8GzmIui3mGrc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179318058252377.87172699516998; Wed, 28 Oct 2026 02:43:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xM0BF-0007Gf-FA; Wed, 28 Oct 2026 05:42:51 -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 1xM0Ai-0006x9-24 for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xM0Af-0008Sj-Bd for qemu-devel@nongnu.org; Wed, 28 Oct 2026 05:42:15 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-443-ls5lYK0CNcqWFxc5gbVvOA-1; Wed, 28 Oct 2026 05:42:08 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 868F91800620; Wed, 28 Oct 2026 09:42:07 +0000 (UTC) Received: from Kostiantyns-MacBook-Pro.redhat.com (unknown [10.44.32.20]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5A5C81956086; Wed, 28 Oct 2026 09:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793180532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HcFcpHWK8R0UlF01J7rf8ed8TzZOVdZWuJn5gK2yT5A=; b=dd3Xdd7XID6PXksl464um+78tAW7MklS8hHl6LK+/xLxDjWJE/MGr2GQRdPTGbxlel0Ep4 R+i6RhkU1mMohPPpkD4W+eq19bHxbxNGjktH3poQEsGmDp406Q0n3Dx/ZxBrY8JG5LKDWM MhemZSGllH6Py2rQDYpKQSZoOu3HJC4= X-MC-Unique: ls5lYK0CNcqWFxc5gbVvOA-1 X-Mimecast-MFC-AGG-ID: ls5lYK0CNcqWFxc5gbVvOA_1793180527 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 6/6] qga: implement 'guest-network-get-route' for FreeBSD Date: Wed, 28 Oct 2026 11:41:52 +0200 Message-ID: <20261028094152.14934-7-kkostiuk@redhat.com> In-Reply-To: <20261028094152.14934-1-kkostiuk@redhat.com> References: <20261028094152.14934-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 @redhat.com) X-ZM-MESSAGEID: 1793180587849154100 From: Roman Bogorodskiy Implement 'guest-network-get-route' for FreeBSD. This implementation uses the sysctl(3) interface to get the routing table. Limitations: - This implementation does not populate irtt, refcnt, use, window, source, and srcprefixlen fields. - The implementation uses the default FIB (routing table) 0. Selecting QGA's active FIB is left for the follow-up patch. While here, spell Windows correctly in @GuestNetworkRoute documentation in qapi-schema.json. Signed-off-by: Roman Bogorodskiy Acked-by: Markus Armbruster Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/20261026190352.14293-1-bogorodskiy= @gmail.com Signed-off-by: Kostiantyn Kostiuk --- meson.build | 6 ++ qga/commands-bsd.c | 174 ++++++++++++++++++++++++++++++++++++++++++- qga/qapi-schema.json | 31 ++++---- 3 files changed, 195 insertions(+), 16 deletions(-) diff --git a/meson.build b/meson.build index 671511c419..7ec3fb9023 100644 --- a/meson.build +++ b/meson.build @@ -2759,6 +2759,12 @@ config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM', config_host_data.set('HAVE_BLK_ZONE_REP_CAPACITY', cc.has_member('struct blk_zone', 'capacity', prefix: '#include ')) +config_host_data.set('HAVE_STRUCT_RT_METRICS_RMX_METRIC', + cc.has_member('struct rt_metrics', 'rmx_metric', + prefix: ''' + #include + #include + #include ''')) =20 # has_type config_host_data.set('CONFIG_IOVEC', diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c index 7c7616699b..830ad08ac0 100644 --- a/qga/commands-bsd.c +++ b/qga/commands-bsd.c @@ -22,6 +22,11 @@ #include #include #include +#if defined(__FreeBSD__) +#include +#include +#include +#endif #if defined(__NetBSD__) || defined(__OpenBSD__) #include #include @@ -354,4 +359,171 @@ error: return NULL; } =20 -#endif /* CONFIG_FREEBSD */ +GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp) +{ + GuestNetworkRouteList *head =3D NULL, **tail =3D &head; + int mib[] =3D { CTL_NET, PF_ROUTE, 0, AF_UNSPEC, NET_RT_DUMP, 0, 0 }; + g_autofree char *buf =3D NULL; + size_t len; + + if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) =3D=3D -1) { + error_setg_errno(errp, errno, "sysctl size"); + return NULL; + } + + buf =3D g_malloc0(len); + + if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) =3D=3D -1) { + error_setg_errno(errp, errno, "sysctl routes"); + return NULL; + } + + for (char *p =3D buf, *end =3D buf + len; p < end; ) { + struct rt_msghdr *rtm =3D (struct rt_msghdr *)p; + struct sockaddr *addresses[RTAX_MAX] =3D { NULL }; + struct sockaddr *sa; + char destination[NI_MAXHOST]; + char gateway[NI_MAXHOST]; + char ifname[IFNAMSIZ]; + const struct sockaddr *dst =3D NULL; + const struct sockaddr *gw =3D NULL; + const struct sockaddr *netmask =3D NULL; + struct sockaddr_in normalized_mask =3D { 0 }; + char netmask_buf[INET_ADDRSTRLEN]; + + g_autoptr(GuestNetworkRoute) route =3D g_new0(GuestNetworkRoute, 1= ); + + if ((size_t)(end - p) < sizeof(*rtm) || + rtm->rtm_msglen < sizeof(*rtm) || + rtm->rtm_msglen > (size_t)(end - p)) { + break; + } + + p +=3D rtm->rtm_msglen; + + if (rtm->rtm_version !=3D RTM_VERSION) { + continue; + } + + sa =3D (struct sockaddr *)(rtm + 1); + for (int i =3D 0; i < RTAX_MAX; i++) { + if (rtm->rtm_addrs & (1U << i)) { + addresses[i] =3D sa; + sa =3D (struct sockaddr *)((char *)sa + SA_SIZE(sa)); + } + } + + if (if_indextoname(rtm->rtm_index, ifname)) { + route->iface =3D g_strdup(ifname); + } else { + route->iface =3D g_strdup_printf("if%u", rtm->rtm_index); + } + +#if defined(HAVE_STRUCT_RT_METRICS_RMX_METRIC) + route->metric =3D rtm->rtm_rmx.rmx_metric; +#endif + + dst =3D addresses[RTAX_DST]; + if (!dst) { + continue; + } + + if (dst->sa_family =3D=3D AF_INET) { + route->version =3D 4; + } else if (dst->sa_family =3D=3D AF_INET6) { + route->version =3D 6; + } else { + continue; + } + if (getnameinfo(dst, dst->sa_len, + destination, NI_MAXHOST, + NULL, 0, NI_NUMERICHOST) !=3D 0) + continue; + route->destination =3D g_strdup(destination); + + gw =3D addresses[RTAX_GATEWAY]; + if (gw && (gw->sa_family =3D=3D AF_INET || gw->sa_family =3D=3D AF= _INET6)) { + if (getnameinfo(gw, gw->sa_len, + gateway, NI_MAXHOST, + NULL, 0, NI_NUMERICHOST) !=3D 0) { + continue; + } + if (gw->sa_family =3D=3D AF_INET) { + route->gateway =3D g_strdup(gateway); + } else if (gw->sa_family =3D=3D AF_INET6) { + route->nexthop =3D g_strdup(gateway); + } + } + + netmask =3D addresses[RTAX_NETMASK]; + if (dst->sa_family =3D=3D AF_INET) { + if (netmask && netmask->sa_len !=3D 0) { + memcpy(&normalized_mask, netmask, + MIN(netmask->sa_len, sizeof(normalized_mask))); + } else if (rtm->rtm_flags & RTF_HOST) { + normalized_mask.sin_addr.s_addr =3D 0xFFFFFFFF; + } + + if (inet_ntop(AF_INET, &normalized_mask.sin_addr, + netmask_buf, sizeof(netmask_buf)) !=3D NULL) { + route->mask =3D g_strdup(netmask_buf); + } else { + route->mask =3D NULL; + } + } else if (dst->sa_family =3D=3D AF_INET6) { + struct sockaddr_in6 normalized_mask6; + memset(&normalized_mask6, 0, sizeof(normalized_mask6)); + + if (netmask && netmask->sa_len !=3D 0) { + int prefix_len =3D 0; + bool valid_mask =3D true; + bool zero_found =3D false; + + memcpy(&normalized_mask6, netmask, + MIN(netmask->sa_len, sizeof(normalized_mask6))); + + for (int i =3D 0; i < sizeof(normalized_mask6.sin6_addr); = i++) { + uint8_t byte =3D normalized_mask6.sin6_addr.s6_addr[i]; + for (int bit =3D 7; bit >=3D 0; bit--) { + if ((byte >> bit) & 1) { + if (zero_found) { + valid_mask =3D false; + break; + } + prefix_len++; + } else { + zero_found =3D true; + } + } + if (!valid_mask) { + break; + } + } + + if (valid_mask) { + route->desprefixlen =3D g_strdup_printf("%d", prefix_l= en); + } else { + route->desprefixlen =3D NULL; + } + } else if (rtm->rtm_flags & RTF_HOST) { + route->desprefixlen =3D g_strdup("128"); + } else { + route->desprefixlen =3D g_strdup("0"); + } + } + + if (rtm->rtm_rmx.rmx_mtu) { + route->mtu =3D rtm->rtm_rmx.rmx_mtu; + route->has_mtu =3D true; + } + + route->flags =3D (uint32_t)rtm->rtm_flags; + route->has_flags =3D true; + + QAPI_LIST_APPEND(tail, route); + route =3D NULL; + } + + return head; +} +#endif /* __FreeBSD__ */ diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 308ed9acf1..7b937713e6 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1823,8 +1823,8 @@ =20 ## # @GuestNetworkRoute: -# Route information. Supported on Linux (since 9.1) and Windows -# (since 11.0). +# Route information. Supported on Linux (since 9.1), Windows +# (since 11.0), and FreeBSD (since 11.2). # # @iface: The destination network or host's egress network interface # in the routing table @@ -1838,30 +1838,31 @@ # # @mask: Subnet Mask (IPv4 only) # -# @irtt: Initial round-trip delay (not for windows, IPv4 only) +# @irtt: Initial round-trip delay (not for Windows and FreeBSD, +# IPv4 only) # -# @flags: Route flags (not for windows) +# @flags: Route flags (not for Windows) # -# @refcnt: The route's reference count (not for windows) +# @refcnt: The route's reference count (not for Windows and FreeBSD) # -# @use: Route usage count (not for windows) +# @use: Route usage count (not for Windows and FreeBSD) # -# @window: TCP window size, used for flow control (not for windows, -# IPv4 only) +# @window: TCP window size, used for flow control (not for Windows +# and FreeBSD, IPv4 only) # -# @mtu: Data link layer maximum packet size (not for windows) +# @mtu: Data link layer maximum packet size (not for Windows) # # @desprefixlen: Destination prefix length (for IPv6) # -# @source: Source IP address (for IPv6) +# @source: Source IP address (not for FreeBSD, IPv6 only) # -# @srcprefixlen: Source prefix length (for IPv6) +# @srcprefixlen: Source prefix length (not for FreeBSD, IPv6 only) # # @nexthop: Next hop IP address (for IPv6) # # @version: IP version (4 or 6) # -# Since: 9.1 (Linux only); 11.0 (Windows) +# Since: 9.1 (Linux only); 11.0 (Windows); 11.2 (FreeBSD) ## { 'struct': 'GuestNetworkRoute', 'data': {'iface': 'str', @@ -1881,7 +1882,7 @@ '*nexthop': 'str', 'version': 'int' }, - 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } } + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32', 'CONFIG_FREEBSD'] } } =20 ## # @guest-network-get-route: @@ -1889,9 +1890,9 @@ # # Returns: List of route info of guest. # -# Since: 9.1 (Linux only); 11.0 (Windows) +# Since: 9.1 (Linux only); 11.0 (Windows); 11.2 (FreeBSD) ## { 'command': 'guest-network-get-route', 'returns': ['GuestNetworkRoute'], - 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32', 'CONFIG_FREEBSD'] } } --=20 2.54.0 (Apple Git-157)