From nobody Mon Nov 23 04:28:03 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=1795338394; cv=none; d=zohomail.com; s=zohoarc; b=hvcFNC67vbdMiEWOogONNMoAUnQz1UGHaC/Nqy8/BWiWP2Odm+9pKGVEeh12eQwb742VjdTfHDK/BBD4MLrgXQqCuRnYRiQWkfqciCbH/b7iApTVJ8XSUOpDhDwKxk7ADuJWljNTwLe/l0gkYCO6ohuTg4yjIZtIE55R6MeMi7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795338394; h=Content-Transfer-Encoding:Cc:Cc: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; bh=Bka1YaGOsPoNluhHGo3bd3L4HCrXvksDn43R+0D6Aok=; b=RCoHwIb0re+3zlLIRsT/3LO+rmkgkBrCJ1mx4VUHuj9Q3Dv51sYqG8a9c8UUv9Vgf1aj2oDeG0mlEsOb6juTrhUI6JGMIZfcfuwd3I8YZwH6eazKtAk8vAFQiRMTDKn+pFmUVdDnejENWCUd4af/wr604XQfPfCxVhzcrVQDzFs= 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 1795338394042285.1871444902009; Sun, 22 Nov 2026 01:06:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xV3WF-0001X1-7q; Sun, 22 Nov 2026 04:05:55 -0500 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 1xV3W3-0001Vn-TI for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:44 -0500 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xV3W2-0000xx-CA for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:43 -0500 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-c4d581da0aaso295997266b.2 for ; Sun, 22 Nov 2026 01:05:42 -0800 (PST) Received: from tulp.my.domain (2001-1c02-1a15-3000-2727-f7d1-9628-aa81.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:2727:f7d1:9628:aa81]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ad010a6sm298893666b.7.2026.11.22.01.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 01:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795338341; x=1795943141; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Bka1YaGOsPoNluhHGo3bd3L4HCrXvksDn43R+0D6Aok=; b=ZY6fzJIsq1RF984w5wk4k5qtNN4m+XtiRsCwwsNFacfqJew9zZsDrhrFBD3J9QzBtQ GN08+hWnI1vA7ParAg6dn5F5Vf+7S7aQsQM7hkB5ab/WmBIhIoeP8RRSHvnZsQ8df+ED IcUIi9pQf102cYJ6hO79yj+Xl8CEh3tfhSV66U1HhxMw9xb89KaR90bgWn5L8DDJ+kDh +c+zvpp/zvgX5738cA3q2RzXs1qULbc/fb+tjdfIl3hw+hlW+soWhUigmQFUZ7iyr3M/ BMbwd0f+xKm13aE/Co4f+MYdBTp5YFUtkXd0w8QunMdXE3pIto6kGy1vClzbbtdyibOe VHLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795338341; x=1795943141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Bka1YaGOsPoNluhHGo3bd3L4HCrXvksDn43R+0D6Aok=; b=GtMjq0ROIbTKvSfc5MamVGcRa2LkRBh4/bMhyy4YGYz4GQ+tETDS0h4sSlZhiFZgwu VEQBHSuSqSKZHRSo9xrde/qw6z7GwRrdI5qb9rwZwfrJKgi6PW+LsqoJqJjRqy2+2UtK x4yGQJFMKLHTkj134Jja+IbgKyBHDNVzgV6Y9EdRaEGBtyOmHg64GpkJW69uLVvz/zsn eO5oxj/4+GLfseoojP+B1R/jfeWUHwx/zsAaf4aq4dk0T4yxtm9rnbWOX/gJNfe17RUf 0nHQn4U6tCXDqcxMC8aJjuO/XmnSPPICPuygg3/SfXMLnUomPwZgIMuqRjd6VaC2g5SQ Nz4A== X-Gm-Message-State: APuU4Z/cFFr3E4Vhh1tuKVKs01GpIO8xPFBjPmxEHc7yxOuBrrXI7dwX CWc7JF4cTe1/A4dcEmVI0RRzCTvnMXAT266OqGDbteB3sSc8vW4FuibYA0K/w14s X-Gm-Gg: AZFdTZdoUJrccXqcxyFzWPGlMyIjfiWWVCp+YWBgxYxZ1ijiG/OJQFOAdeLPzUwZnDZ E+tzIPFlwL0wi9D9rbFc5RRGVPjmWQPJ8N4pE6ylaJ8OF7W1JGuOf7nHUFwoLitQcUHI0M18Xb+ onOOj5Et8o/PT+U6LfbUD7Wr9JBI1XiOlu6w7keH1Gg1RyOOR0HEqNZ9bXYSE88WrvcpVk2eS6j ryYe854g+JDyqzWPzu8W+mbntQaR+GIBu5gB66YtHFmH+r/p7NBGEjiGSPd1vepqM/SVb793Kft VTQ/i/OkkOQwkPRJ89aF/MN9UmiQTD5ErrCMhb5333sDCI1CekOkLvjZxr3J9ShlJjU+Kr67k6H RW2e6aQ71lPVu/wm9foJvbsOkNF596m/moIOmHuKQUyMbvtohNxvOUu708+juz+Aj1VKwWK9UtD T6C0Huj4QatjnOIyjcQnTLj1+DKcU4rFd/NvLNR8OxO526Rup89U8pnYQVnI92Q4tHC/r9/efau jkrITMU2sb4jYfjnRMhJNLuiEcr3uOTiVoz1ErvBe781IAjw2q5l1redfeWaT8WpYxNTc9cwMOM 9xV7chzyzKTo9j9XCXa92ukpXxJYArACxgAWvrcMeJmoQl4fXL3WktUR+WFXjCbOIThmaTz2LWx +yUV/S+SWo8Vnvmnc3Bkl/pbCqYBkEsSwHQvLDb7SZjzCnfCQd6BT4vU/iZ/+ X-Received: by 2002:a17:906:ccc1:b0:c29:5172:6151 with SMTP id a640c23a62f3a-c513ac9b721mr558048966b.45.1795338340687; Sun, 22 Nov 2026 01:05:40 -0800 (PST) From: Roman Bogorodskiy To: qemu-devel@nongnu.org Cc: Roman Bogorodskiy , Michael Roth , Kostiantyn Kostiuk , Eric Blake , Markus Armbruster Subject: [PATCH 1/5] qga: implement 'guest-get-vcpus' for FreeBSD Date: Sun, 22 Nov 2026 10:05:06 +0100 Message-ID: <20261122090511.15121-2-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261122090511.15121-1-bogorodskiy@gmail.com> References: <20261122090511.15121-1-bogorodskiy@gmail.com> 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::62d; envelope-from=bogorodskiy@gmail.com; helo=mail-ej1-x62d.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: 1795338396635048801 Content-Type: text/plain; charset="utf-8" Use cpuset_getaffinity() to get vCPUs. This function is specific to FreeBSD, and other BSDs use other mechanisms, so just put that under #ifdef __FreeBSD__. FreeBSD does not support offline CPUs, so reported vCPUs are always online. Signed-off-by: Roman Bogorodskiy --- qga/commands-bsd.c | 32 ++++++++++++++++++++++++++++++++ qga/qapi-schema.json | 4 ++-- tests/unit/test-qga.c | 4 ++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c index 830ad08ac0..99657b6796 100644 --- a/qga/commands-bsd.c +++ b/qga/commands-bsd.c @@ -23,6 +23,7 @@ #include #include #if defined(__FreeBSD__) +#include #include #include #include @@ -526,4 +527,35 @@ GuestNetworkRouteList *qmp_guest_network_get_route(Err= or **errp) =20 return head; } + +GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) +{ + cpuset_t mask; + GuestLogicalProcessorList *head, **tail; + int bit; + + head =3D NULL; + tail =3D &head; + + if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_CPUSET, 0, + sizeof(mask), &mask) !=3D 0) { + error_setg_errno(errp, errno, "getaffinity"); + return NULL; + } + + for (bit =3D 0; bit < CPU_SETSIZE; bit++) { + if (CPU_ISSET(bit, &mask)) { + GuestLogicalProcessor *vcpu; + vcpu =3D g_new0(GuestLogicalProcessor, 1); + vcpu->logical_id =3D bit; + vcpu->online =3D true; + vcpu->has_can_offline =3D true; + vcpu->can_offline =3D false; + QAPI_LIST_APPEND(tail, vcpu); + } + } + + return head; +} + #endif /* __FreeBSD__ */ diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index de42dfe77d..d74b94dc8a 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -735,7 +735,7 @@ 'data': {'logical-id': 'int', 'online': 'bool', '*can-offline': 'bool'}, - 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } } + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32', 'CONFIG_FREEBSD'] } } =20 ## # @guest-get-vcpus: @@ -748,7 +748,7 @@ ## { 'command': 'guest-get-vcpus', 'returns': ['GuestLogicalProcessor'], - 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } } + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32', 'CONFIG_FREEBSD'] } } =20 ## # @guest-set-vcpus: diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index b1c84c188b..a8387bd8e8 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -1117,9 +1117,13 @@ int main(int argc, char **argv) g_test_add_data_func("/qga/info", &fix, test_qga_info); g_test_add_data_func("/qga/network-get-interfaces", &fix, test_qga_network_get_interfaces); +#if defined(CONFIG_LINUX) if (!access("/sys/devices/system/cpu/cpu0", F_OK)) { g_test_add_data_func("/qga/get-vcpus", &fix, test_qga_get_vcpus); } +#elif defined(CONFIG_FREEBSD) + g_test_add_data_func("/qga/get-vcpus", &fix, test_qga_get_vcpus); +#endif g_test_add_data_func("/qga/get-fsinfo", &fix, test_qga_get_fsinfo); g_test_add_data_func("/qga/get-load", &fix, test_qga_get_load); g_test_add_data_func("/qga/get-memory-block-info", &fix, --=20 2.56.0 From nobody Mon Nov 23 04:28:03 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=1795338405; cv=none; d=zohomail.com; s=zohoarc; b=lV/OFGfLzxfnCqSCLBblAmaCw/9Ksuq+I6Odef7pYIpYkJZaZrq/qaGLv+jgteOMJIsVZ1d+MUpvd7AdDlzjhFeWL5CzvlUjjEVbsBLh3VfuQFKU4ofVeHaWa2lU1LKMwnLcgzVFURqraSvrz9ruFYV1tm7emMRg9fZ+dL2TsEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795338405; h=Content-Transfer-Encoding:Cc:Cc: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; bh=KvuCmFregauDwjWV7OMG1WO1pVSzPmv+w9JnbsPMbHY=; b=HYO2wndgI3YlN5twS99NnvQl/i2sR6SmpzTcLNw/XJOGN0M76tMWCmX/IwYl+w2EjcZAOCDcJ0Xo+oNNR/i6mVy1lvrK+zTWPaHpz6qyRNqLFeNns2HpLn2BA4+Y+VWsZYwEr1X31dwpn5LAwf4qBIoiVA0MfzOaMBfPVm2AKUg= 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 1795338405698356.6478555345593; Sun, 22 Nov 2026 01:06:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xV3WX-0001Xv-5b; Sun, 22 Nov 2026 04:06:13 -0500 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 1xV3W5-0001W0-68 for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:48 -0500 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xV3W3-0000y3-34 for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:44 -0500 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-c506a231b88so327485466b.3 for ; Sun, 22 Nov 2026 01:05:42 -0800 (PST) Received: from tulp.my.domain (2001-1c02-1a15-3000-2727-f7d1-9628-aa81.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:2727:f7d1:9628:aa81]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ad010a6sm298893666b.7.2026.11.22.01.05.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 01:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795338342; x=1795943142; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KvuCmFregauDwjWV7OMG1WO1pVSzPmv+w9JnbsPMbHY=; b=NGsNMiuVkhfaa/zNu610w65jA/3JNKVli5VH1UBEJB48U94HgUp/pKvEyBZM3Yy9HX iv4u+aLiusvnc5Mgpoa1DnZABwe961G1I0IdsqJRTO9pscXccM2pMr/yogCk94b6hLEl zNhELFkLuJ6qK3V3yJ2dUgto8GXZijbu0lARJ9EyfNfI4otZUet8fwdjV5nYNhwfeLc4 X7Pt4tDxpJTouTuvPbvwl0ypTSCIBu722zLQP8xyC5RWq79kWZZhVlAG+Tow4CDSI1oC nweDFIGgDrwyw/V0cfEy2sr98uLB59dMpbyopuWRHav5ylI4QzelDY3OvIFt1YtMzVdO anjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795338342; x=1795943142; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=KvuCmFregauDwjWV7OMG1WO1pVSzPmv+w9JnbsPMbHY=; b=gcHkEbvjaU0Aff/C9VtVNtzU6grK1udwTgYNqq4aJZ1Bl9f8lWacf2X7lArOULM6Zk akqd126jtQiVhPf99riVuffUUgaHEtLTjlTexlzld//5Jg3Sd9rpiTa5EK+9EryqETcs YS6VHWzG+1TKtNQf/E1ljcmg5TDiJ9XDr7TdejX0qeDgAagL0KgXBfm+xuKu110d4/s6 gKQnztEzoFOucNy4AqLK4iMY6OvW6o4nDIbi5E+ZVY9YS/odY0spaxrANMTi7O238ENk ipAjY32YCvwyWEXyFS096KGSFBBTRfcTbrIsIlDqCP7DWiWn6bI5cI88CzQI2fktTp/Y ec8Q== X-Gm-Message-State: APuU4Z8gYy0K354z8FC7z3i71JTo7G0B167D+hiwYoD356qboyE93AHI BuGxbtE31oCb+IFxs4uLA18hYl8RothqyWJ/2RgFvxA1SwIVNUlMFAp6yQvOfkHD X-Gm-Gg: AZFdTZeta6lsY79Xv5EZz/6u9oOJahZ48HZ+QsjHWxvJJv0CW+tdn1KNh1o9nMv+FNo PKL8mefyJImKdr8K54SvsGKWkvaQbB+fiZeMJp+jGHydMPKWFZKAm5+0vPi+vBhFFiCav3U5PDV cESYW7cffAqtZPR5XwK1ZPEZ/0T7DIKcyCkONBMXFNsfn2Jp0hzjY5SeijincJPr4KdcJOJLywc b20uga13vdnJYQFMTFw28colBzSZCKGzyf51JWTeooI4kWLVuJl0oT6QZfBDMjYO+kArIx83eTc S3mnCr/l31iRb7c1EWLhrx3dz25BdJjkJtntou46Pb9XTcukLSYsC/8gb/ilZ5YCUpvlTh8yTl9 bHrDqc/ueND0WWvt/XLJ9jZ4tXNz2VkoTdADtUr5KpAiRaoIZGaAGagrMZ+V8mbGsd6B5v9/AIS vvLQFUJrJG0Aht7o4+ibuLRKzfpY7qV4SxjBpO0esXs1jSVL+TvnAPITtseAVTvG9FyixAK5d9j rdz8lg9K1hgFAALrOztqHFlGK+twtpwFdhz6ntZGzTKRd1+WYge2zNzd5Et6xIOq1G4NMFFJwq6 Axx7L6Se9kginXQW3/zhQQhOEHVzW6/VV8CnrqcJ5R5wPz/KXe9BLIZvcO1mokujiqmP4A1vqfv qzTNeMwuYtMRZR3NOAGNnqOX8dVUlOimtK1QIAkc= X-Received: by 2002:a17:906:9d04:b0:c44:9a32:b27 with SMTP id a640c23a62f3a-c513a846655mr549758666b.25.1795338341511; Sun, 22 Nov 2026 01:05:41 -0800 (PST) From: Roman Bogorodskiy To: qemu-devel@nongnu.org Cc: Roman Bogorodskiy , Michael Roth , Kostiantyn Kostiuk , Eric Blake , Markus Armbruster Subject: [PATCH 2/5] qga: implement 'guest-get-cpustats' for FreeBSD Date: Sun, 22 Nov 2026 10:05:07 +0100 Message-ID: <20261122090511.15121-3-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261122090511.15121-1-bogorodskiy@gmail.com> References: <20261122090511.15121-1-bogorodskiy@gmail.com> 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::635; envelope-from=bogorodskiy@gmail.com; helo=mail-ej1-x635.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: 1795338406455048800 Content-Type: text/plain; charset="utf-8" Currently, 'guest-get-cpustats' is implemented for Linux and uses a Linux-specific GuestLinuxCpuStats. Introduce a BSD specific type 'GuestBsdCpuStats'. Current implementation adds FreeBSD support, but it's expected that the type could be shared for other BSD implementations. This implementation is built on top of the "kern.cp_times" sysctl. Signed-off-by: Roman Bogorodskiy --- qga/commands-bsd.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ qga/qapi-schema.json | 44 +++++++++++++++++++++++++++---- 2 files changed, 101 insertions(+), 5 deletions(-) diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c index 99657b6796..0f97427d8b 100644 --- a/qga/commands-bsd.c +++ b/qga/commands-bsd.c @@ -558,4 +558,66 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error *= *errp) return head; } =20 +GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp) +{ + GuestCpuStatsList *head =3D NULL, **tail =3D &head; + int maxcpu; + int maxid; + g_autofree long *times =3D NULL; + size_t size; + int i, j, empty; + struct clockinfo clockrate; + int hz; + + size =3D sizeof(clockrate); + if (sysctlbyname("kern.clockrate", &clockrate, &size, NULL, 0) =3D=3D = -1) { + error_setg_errno(errp, errno, "sysctlbyname(kern.clockrate)"); + return NULL; + } + hz =3D clockrate.stathz ? clockrate.stathz : clockrate.hz; + + size =3D sizeof(maxcpu); + if (sysctlbyname("kern.smp.maxcpus", &maxcpu, &size, NULL, 0) =3D=3D -= 1) { + error_setg_errno(errp, errno, "sysctlbyname(kern.smp.maxcpus)"); + return NULL; + } + times =3D g_new0(long, maxcpu * CPUSTATES); + size =3D sizeof(long) * maxcpu * CPUSTATES; + if (sysctlbyname("kern.cp_times", times, &size, NULL, 0) =3D=3D -1) { + error_setg_errno(errp, errno, "sysctlbyname(kern.cp_times)"); + return NULL; + } + + maxid =3D MIN(size / CPUSTATES / sizeof(long) - 1, CPU_SETSIZE - 1); + for (i =3D 0; i <=3D maxid; i++) { + GuestCpuStats *cpustat =3D NULL; + GuestBsdCpuStats *bsdcpustat; + + empty =3D 1; + for (j =3D 0; empty && j < CPUSTATES; j++) { + if (times[i * CPUSTATES + j] !=3D 0) { + empty =3D 0; + } + } + if (empty) { + continue; + } + + cpustat =3D g_new0(GuestCpuStats, 1); + cpustat->type =3D GUEST_CPU_STATS_TYPE_BSD; + + bsdcpustat =3D &cpustat->u.bsd; + bsdcpustat->cpu =3D i; +#define TO_MS(X) ((uint64_t)(unsigned long)(X) * 1000 / hz) + bsdcpustat->user =3D TO_MS(times[i * CPUSTATES + CP_USER]); + bsdcpustat->nice =3D TO_MS(times[i * CPUSTATES + CP_NICE]); + bsdcpustat->system =3D TO_MS(times[i * CPUSTATES + CP_SYS]); + bsdcpustat->idle =3D TO_MS(times[i * CPUSTATES + CP_IDLE]); + bsdcpustat->irq =3D TO_MS(times[i * CPUSTATES + CP_INTR]); +#undef TO_MS + + QAPI_LIST_APPEND(tail, cpustat); + } + return head; +} #endif /* __FreeBSD__ */ diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index d74b94dc8a..4856a549a6 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1700,12 +1700,14 @@ # Guest operating systems supporting CPU statistics # # @linux: Linux +# @bsd: FreeBSD (Since 12.0) # # Since: 7.1 ## { 'enum': 'GuestCpuStatsType', - 'data': [ 'linux' ], - 'if': 'CONFIG_LINUX' } + 'data': [ 'linux', 'bsd' ], + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_FREEBSD'] } +} =20 ## # @GuestLinuxCpuStats: @@ -1751,6 +1753,34 @@ }, 'if': 'CONFIG_LINUX' } =20 +## +# @GuestBsdCpuStats: +# CPU statistics of BSD +# +# @cpu: CPU index in guest OS +# +# @user: Time spent in user mode +# +# @nice: Time spent in user mode with low priority (nice) +# +# @system: Time spent in system mode +# +# @idle: Time spent in the idle task +# +# @irq: Time servicing interrupts +# +# Since: 12.0 +## +{ 'struct': 'GuestBsdCpuStats', + 'data': {'cpu': 'int', + 'user': 'uint64', + 'nice': 'uint64', + 'system': 'uint64', + 'idle': 'uint64', + 'irq': 'uint64' + }, + 'if': 'CONFIG_FREEBSD' } + ## # @GuestCpuStats: # Get statistics of each CPU in millisecond. @@ -1762,8 +1792,12 @@ { 'union': 'GuestCpuStats', 'base': { 'type': 'GuestCpuStatsType' }, 'discriminator': 'type', - 'data': { 'linux': 'GuestLinuxCpuStats' }, - 'if': 'CONFIG_LINUX' } + 'data': { + 'linux': { 'type': 'GuestLinuxCpuStats', 'if': 'CONFIG_LINUX'}, + 'bsd': { 'type': 'GuestBsdCpuStats', 'if': 'CONFIG_FREEBSD' } + }, + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_FREEBSD'] } +} =20 ## # @guest-get-cpustats: @@ -1775,7 +1809,7 @@ ## { 'command': 'guest-get-cpustats', 'returns': ['GuestCpuStats'], - 'if': 'CONFIG_LINUX' + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_FREEBSD'] } } =20 ## --=20 2.56.0 From nobody Mon Nov 23 04:28:03 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=1795338394; cv=none; d=zohomail.com; s=zohoarc; b=mzYsLJ/lxNwEDZml/dwNRDniUboBIA777LRsBoxHfvY+fVSx+o+krlIw5Vz0ay4q5AooaV4VuaYLB5/KLwsIH06ztFEGQ89KPszLhKI5/P6RRlkcFEcxFAUwCG/ZCgppHepCbqeT95/0eEYeOz7FIdz1GO0CK00geQB6t8dRD7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795338394; h=Content-Transfer-Encoding:Cc:Cc: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; bh=tyEg9+jxsUTBODeKM/OLzOBVCxUT43M9pEiybpUpXeQ=; b=TUDZcMbyP1QoLizI8YE/RTNeLcfPOayq5SILEM2G7gtYel+hUlm+cQgf45ufOcRxRit/034sdSmyVmrvSXAmF6QUp6TEHiPtXrglO233FK605O+etEStjY4UjVCvOdo6Rcj7eYzRAh40bMGE0dEeQEaLGMBncxCuHYdPQCkQ/74= 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 1795338394086985.6203369829068; Sun, 22 Nov 2026 01:06:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xV3WY-0001YE-AM; Sun, 22 Nov 2026 04:06:16 -0500 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 1xV3W5-0001W7-Nz for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:48 -0500 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xV3W3-0000y8-UX for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:45 -0500 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-c51373ae637so350607866b.3 for ; Sun, 22 Nov 2026 01:05:43 -0800 (PST) Received: from tulp.my.domain (2001-1c02-1a15-3000-2727-f7d1-9628-aa81.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:2727:f7d1:9628:aa81]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ad010a6sm298893666b.7.2026.11.22.01.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 01:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795338342; x=1795943142; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tyEg9+jxsUTBODeKM/OLzOBVCxUT43M9pEiybpUpXeQ=; b=a4afrHPO2EWZIgmfKyPRiS0werrcEbifgA0UPCeEXsCqBNBuGd4buby7fRnpcfXzrO sJBo75c0NHYDQI0Ka/zWuJYv2bDnkBla2Rzy1Sl0/STsJlAcNjnXv55zTVzbW/07E4sJ 7ZnxVQLcO55by1VrSv/tF0tku5TAmDL9p8zmgCSaglPGcwECgZojPqNcEUx1m+ytPvwD eV8c/19376jpypq+ittcHr+vtMdBDANpgt9Gxg4TwOBVAWL9P0Jb5PgiL/GCDUDk9n5r wqQWe5S9Odl7hT40R+JQbN7lGAUgAA8P8yC99cPhHIO7WXFZlAXRs080hwKY+bfrdhw9 aWIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795338342; x=1795943142; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=tyEg9+jxsUTBODeKM/OLzOBVCxUT43M9pEiybpUpXeQ=; b=JW4MbHjyQIZBazlnNfINymXvYmErCQYTibl53ipggReLDKxHKzkUzhM3ICXYIwzQnv LMsid9ntQxWkyODigfvni3He1Z9ZmkaOP+XcXAPaYjda6tmuItmtvjdRJlV5TtuHkeM3 xItqQnX8nscpfdkst5a/JYelLxnMVfqSVJAzmeBzZfd//1uQEIlL2mYklADggkNeXmjP bTb0jmkokdmemZKyVfveLRr5a4OcezqNhrW13Ku3VntgDhItvsreZh5RHZLy7YCaJDMX brwjGq5N2w+Zvn10llfwJIvebRwzqj1PEGrkjHEPTj1GVEzeSh1TUaLkS3cgnehAIc1N mDUA== X-Gm-Message-State: APuU4Z/njtAeE2iNTfcjC4wurtrwZKI7OuX6gz850shr2ISeTl2x0ugK Mh2BAK/41bG9wVnOODJhoJLyjM2x3v1y0icFVa+p4uc7+Hli0p4aypSw0rsEqqX7 X-Gm-Gg: AZFdTZdFtGaeJg2NtO7pWTVMo9yrTtF2rfNundT4aB32+Yq4USEyVeluR5FJsjDDwd/ W1B1JCS4g132uEROMyl3m9xCyxppW+jCvuvBIoFZu35dtRA9iv04Gev7JHmfxjI0zcP9cdlUrol J4Kaf1a2gt4ZmWs5zvYhBLDP2VOzBRoYlYJz21YSiijZ+Uo4vVbRBOM9334W+1Rm9cnaWc4uqkM u8zkuTy9zIY7Y61FL4HsBUxcCIi/fNxWGx6mjKpZznutqUpy42wBKaq5ErSRcQUX0rUAOGrgliz NY/ypC86OLMyorhwLRJqwhs4qWHp5UFifmdS3C8GKwl2J876qptIF81YQz+SifbfMATLkkqLOxx M7oU6zDufTRa1KjVY+fXI/mNR83FhPoyGjaKFXgcdNnvX9br0Hi9PcnJtKFVqUx3EqsLazAUj6h Zn8Hk+rs6yZIDAIcbrns1m8/WuQ2Q0lGRXGEKk13lO7eO9yPIZst1lp9Y8N+w6TFGHZB1zeHjqV 7TVMghWlp4rRyVk4lh3KbkUQWbNVTUpasDCoZENjieDl8/KZgNvLPoAOItiLccb1wd3ZYJsl2IM QsZBIwg0xpv0peDUAdex8JeTrh5F7OtqAexjvbyaf9pauDSEsfSBR5CIGp6MHKF8+3a5nUb7f1H dUGjEx3NX5EVE2YQuPm3fvsgIEw0US+5y6+wfRZ8= X-Received: by 2002:a17:906:8316:b0:c40:b59:f with SMTP id a640c23a62f3a-c513ab2c7admr545109066b.47.1795338342284; Sun, 22 Nov 2026 01:05:42 -0800 (PST) From: Roman Bogorodskiy To: qemu-devel@nongnu.org Cc: Roman Bogorodskiy , Michael Roth , Kostiantyn Kostiuk , Eric Blake , Markus Armbruster Subject: [PATCH 3/5] qga: implement 'guest-get-disks' for FreeBSD Date: Sun, 22 Nov 2026 10:05:08 +0100 Message-ID: <20261122090511.15121-4-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261122090511.15121-1-bogorodskiy@gmail.com> References: <20261122090511.15121-1-bogorodskiy@gmail.com> 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::62e; envelope-from=bogorodskiy@gmail.com; helo=mail-ej1-x62e.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: 1795338396666048800 Content-Type: text/plain; charset="utf-8" The implementation uses the "kern.geom.conftxt" sysctl. It resides under the "#ifdef __FreeBSD__" block as other BSDs do not have GEOM. Signed-off-by: Roman Bogorodskiy --- qga/commands-bsd.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ qga/qapi-schema.json | 13 ++++---- 2 files changed, 84 insertions(+), 6 deletions(-) diff --git a/qga/commands-bsd.c b/qga/commands-bsd.c index 0f97427d8b..f8b4ffd175 100644 --- a/qga/commands-bsd.c +++ b/qga/commands-bsd.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "qga-qapi-commands.h" #include "qapi/error.h" +#include "qemu/cutils.h" #include "qemu/queue.h" #include "block/block-common.h" #include "commands-common.h" @@ -620,4 +621,80 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp) } return head; } + +GuestDiskInfoList *qmp_guest_get_disks(Error **errp) +{ + GuestDiskInfoList *ret =3D NULL; + GuestDiskInfo *disk; + g_autofree char *buf =3D NULL; + g_auto(GStrv) lines =3D NULL; + g_autoptr(GHashTable) providers =3D NULL; + size_t len; + int i; + + if (sysctlbyname("kern.geom.conftxt", NULL, &len, NULL, 0) =3D=3D -1) { + error_setg_errno(errp, errno, "sysctlbyname(kern.geom.conftxt)"); + return NULL; + } + + buf =3D g_malloc0(len); + + if (sysctlbyname("kern.geom.conftxt", buf, &len, NULL, 0) =3D=3D -1) { + error_setg_errno(errp, errno, "sysctlbyname(kern.geom.conftxt)"); + return NULL; + } + + providers =3D g_hash_table_new_full(g_str_hash, g_str_equal, g_free, N= ULL); + lines =3D g_strsplit(buf, "\n", -1); + for (i =3D 0; lines[i] !=3D NULL; ++i) { + g_auto(GStrv) tokens =3D NULL; + bool is_part =3D false; + uint64_t mediasize; + + if (strlen(lines[i]) =3D=3D 0) { + continue; + } + + tokens =3D g_strsplit(lines[i], " ", -1); + + /* + * kern.geom.conftxt format: + * + * 0 DISK ada0 8001563222016 512 hd 16 sc 63 + * 1 PART ada0p1 8001563181056 512 i 1 o 20480 ty freebsd-ufs xs G= PT xt + */ + if (g_strv_length(tokens) < 5) { + continue; + } + + if (g_str_equal(tokens[1], "DISK")) { + /* nada */ + } else if (g_str_equal(tokens[1], "PART")) { + is_part =3D true; + } else { + continue; + } + + if (qemu_strtou64(tokens[3], NULL, 10, &mediasize) < 0 || + mediasize =3D=3D 0) { + continue; + } + + /* Filter out duplicate providers, for example for mirrors */ + if (g_hash_table_contains(providers, tokens[2])) { + continue; + } else { + g_hash_table_add(providers, g_strdup(tokens[2])); + } + + disk =3D g_new0(GuestDiskInfo, 1); + disk->name =3D g_strdup_printf("/dev/%s", tokens[2]); + disk->partition =3D is_part; + + QAPI_LIST_PREPEND(ret, disk); + } + + return ret; +} + #endif /* __FreeBSD__ */ diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 4856a549a6..35aaa040cf 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -947,7 +947,7 @@ 'media-errors-hi': 'uint64', 'number-of-error-log-entries-lo': 'uint64', 'number-of-error-log-entries-hi': 'uint64' }, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV', 'CONFIG_FREEBSD' ] } } =20 ## # @GuestDiskSmart: @@ -961,12 +961,12 @@ 'base': { 'type': 'GuestDiskBusType' }, 'discriminator': 'type', 'data': { 'nvme': 'GuestNVMeSmart' }, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV', 'CONFIG_FREEBSD' ] } } =20 ## # @GuestDiskInfo: # -# @name: device node (Linux) or device UNC (Windows) +# @name: device node (Linux, FreeBSD) or device UNC (Windows) # # @partition: whether this is a partition or disk # @@ -987,7 +987,7 @@ 'data': {'name': 'str', 'partition': 'bool', '*dependencies': ['str'], '*address': 'GuestDiskAddress', '*alias': 'str', '*smart': 'GuestDiskSmart'}, - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV', 'CONFIG_FREEBSD' ] } } =20 ## # @guest-get-disks: @@ -995,13 +995,14 @@ # Returns: The list of disks in the guest. For Windows these are only # the physical disks. On Linux these are all root block devices # of non-zero size including e.g. removable devices, loop devices, -# NBD, etc. +# NBD, etc. On FreeBSD these are nonzero-size GEOM DISK and PART +# providers (since 12.0). # # Since: 5.2 ## { 'command': 'guest-get-disks', 'returns': ['GuestDiskInfo'], - 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV' ] } } + 'if': { 'any': [ 'CONFIG_WIN32', 'CONFIG_LIBUDEV', 'CONFIG_FREEBSD' ] } } =20 ## # @GuestFilesystemInfo: --=20 2.56.0 From nobody Mon Nov 23 04:28:03 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=1795338395; cv=none; d=zohomail.com; s=zohoarc; b=Bv3sPZ360uzkuowNTW7bEmijzGE4/pVp5hEceMUp30WyxnGL0Gxev6czKp8aZra1xDHXHJefAdbNijebocLSTXvMZTzc9321BJskqcnzc+y0Y9x9dnqj3C5QOcl68B6Xmy4VzP4UQi5xag9GHfng78iSuKiGU6iHXjad1U78xfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795338395; h=Content-Transfer-Encoding:Cc:Cc: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; bh=fsRPD7Cc+S/296aJvonbzWsh07yAOmWSmVYGCBL5gPw=; b=ZTUF/cPu6Kd7G4d/M5op6L844kVGAyrx2jU7O5vPvjFagOaNKlknxcyqOxN6SzybqaWLv8yQxKpSck9XwF7AE4O4qzRS0KHtuWZRMOHthRCoYU+IVcc7Ej+M7t+JtPrN22iGlMCTsX+hb1ac9MdtkWVAQOD2CAWubb5SEu0TpqE= 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 1795338395358169.92841561643604; Sun, 22 Nov 2026 01:06:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xV3WU-0001Xc-KD; Sun, 22 Nov 2026 04:06:12 -0500 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 1xV3W7-0001W9-3e for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:48 -0500 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 1xV3W5-0000yO-EK for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:46 -0500 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-c511c0e2826so274455066b.0 for ; Sun, 22 Nov 2026 01:05:45 -0800 (PST) Received: from tulp.my.domain (2001-1c02-1a15-3000-2727-f7d1-9628-aa81.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:2727:f7d1:9628:aa81]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ad010a6sm298893666b.7.2026.11.22.01.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 01:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795338344; x=1795943144; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fsRPD7Cc+S/296aJvonbzWsh07yAOmWSmVYGCBL5gPw=; b=Tm/nV/QxsBcAmzWZ6ifLGDVtubEajT/AxPlU9X72HcNTrHmdo1OcaZfUiEY29+GbLg i/lKINKbZmagwxrhQqKcSsac6ub1psypfLks2liuB+PhdPA6DLuo3mKkcO/NWAD8dapx abF8epDBJ57GYvZcqP3gEDwJy+eu1jHqjVimXApfY/+18Ox6jJyFRzBDK5oY5BdrVjnr hvEXoaN3g9swpPtvXYRqtzOtjMMnldUAvqNXteGIW+VYAuHSc7nOE99qCToqeRNp0WOc 3ByoGRRdi9utnpoKGKfdzHb7M2MkoRwRjIIScinq/i42/z1D1JXQBtwTJeYHfNiOY6p8 VEoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795338344; x=1795943144; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=fsRPD7Cc+S/296aJvonbzWsh07yAOmWSmVYGCBL5gPw=; b=sMEedk2lo8mLL4Sb79jeJrgssoNgxaJb1T628gOPHeYtJ9tHd41V/PoabR8jghshF5 qzJKZmmiKEtxPEbJblalLdObpHkAW4csTQJxXG1LhcQPatVeEkCg8mofQ04TnqdbO0Wi 64SQg5S7GS/tzlTuvbPXcPkZj242Cn13tvrkX5o/kIuN1wG1U8a1O0TqYoGWBm3SnfWO E4NCTeHyL/FO/Wz1A6YEyJf4DPzuYLzhQIm7gzFiLAlQzbPf3J+/FNnESI5HFZY3Sq1R KpVvVt/KHSQx2kgusuPOue2RCGJdqGBccABkcG1ZdFvSEGTE+yupqiEQii/taWrCrQ06 64qQ== X-Gm-Message-State: APuU4Z+IPkOPRp22t1rsYJDCWO9YLCLhYYpGdJY2yvq1PORK1Fq6tedL XqkxraNVkbjoKPA3BdoFA5Okl/7R14lR+08MT3gxfmIswzt4jaWi7AJT7K6qVdOk X-Gm-Gg: AZFdTZev9Q59wBvBhHVB0y31NumpLmHJ6gOulwOylRHaiscUZ4wctouq+zQLfXuMv/4 9X4eXLCDNWUhe+Lnd3gebQzJ1LRvlYH1vPkj9kM2k7J3wCrQZntn8pj+P1VPE0tU4cszJTOCKPm W4EKvLOCI8MTPR14Ppf1NAr84hdP4rmAVLFfZJDlUCutYyCkdNdJs93h6dOYizFs6hvmBAGSY63 55XFwcBeqtJXZvc6sth0bu77wAlmjtJOLx2Sz8zwysyE6SS0NkINme862/HesNNmz6/7iQ2Z/X4 CKd5871qrCIuJ2cYyYy7veDizDY+Bghf5dBJuClGDzJCvXy7o4XMghgX3kb7aCmCt/78I1w8Udi IBZmCIq2vGPzu2UHk7qG7wawrlN4Jd/Mg1nk9PmEE63uawlMXwwBhdKdwznTXpvWeM37xr3NkB1 N5hum6cnARc7udrwYu6RR+xuMDTvQDtchgmbT3BkO1GO1lpltEL6sijUnNLWlj8OUAZTMWKru0U T015QW3Xqtd9imv2IDaDE7YXnyT0v0JfcXCJu9vFN21fZi70v2Y5LhyaxRbqGCwzd4F4gQdhGN3 jMLBx51cHeU34gTkFLPnym4O8NgOPtQCcvxyFJpEzXm55jeWw0nNJbGYogxv/IJWVt5gV/cWHfF 5q7RedjhSvbWKA1cROIAfP13UyzLODnwGiiUO80w= X-Received: by 2002:a17:906:81da:b0:c51:1d9a:323c with SMTP id a640c23a62f3a-c513a88b0d1mr533350266b.15.1795338343644; Sun, 22 Nov 2026 01:05:43 -0800 (PST) From: Roman Bogorodskiy To: qemu-devel@nongnu.org Cc: Roman Bogorodskiy , Michael Roth , Kostiantyn Kostiuk Subject: [PATCH 4/5] tests/unit/test-qga: test 'guest-get-disks' Date: Sun, 22 Nov 2026 10:05:09 +0100 Message-ID: <20261122090511.15121-5-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261122090511.15121-1-bogorodskiy@gmail.com> References: <20261122090511.15121-1-bogorodskiy@gmail.com> 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: 1795338396596048800 Content-Type: text/plain; charset="utf-8" Add a test for the 'guest-get-disks' command. As it's implemented only for CONFIG_WIN32, CONFIG_LIBUDEV, and CONFIG_FREEBSD, guard the test similarly. Signed-off-by: Roman Bogorodskiy --- tests/unit/test-qga.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index a8387bd8e8..a8ef6b0e21 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -1095,6 +1095,30 @@ static void test_qga_guest_get_osinfo(gconstpointer = data) fixture_tear_down(&fixture, NULL); } =20 +#if defined(CONFIG_WIN32) || defined(CONFIG_LIBUDEV) || defined(CONFIG_FRE= EBSD) +static void test_qga_get_disks(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + g_autoptr(QDict) ret =3D NULL; + QList *list; + const QListEntry *entry; + + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-disks'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + list =3D qdict_get_qlist(ret, "return"); + QLIST_FOREACH_ENTRY(list, entry) { + QDict *qdict; + + qdict =3D qobject_to(QDict, entry->value); + g_assert(qdict); + g_assert_cmpuint(strlen(qdict_get_str(qdict, "name")), >, 0); + g_assert_nonnull(qobject_to(QBool, qdict_get(qdict, "partition"))); + } +} +#endif + int main(int argc, char **argv) { TestFixture fix; @@ -1158,6 +1182,9 @@ int main(int argc, char **argv) test_qga_guest_get_timezone); g_test_add_data_func("/qga/guest-get-users", &fix, test_qga_guest_get_users); +#if defined(CONFIG_WIN32) || defined(CONFIG_LIBUDEV) || defined(CONFIG_FRE= EBSD) + g_test_add_data_func("/qga/get-disks", &fix, test_qga_get_disks); +#endif =20 ret =3D g_test_run(); =20 --=20 2.56.0 From nobody Mon Nov 23 04:28:03 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=1795338394; cv=none; d=zohomail.com; s=zohoarc; b=GbjHYrvZ7mBs50IFTOZRQl4H6tSkGITUCnTMO6iS6rtzC270FKgcC1qlExbInzXKutUSv2WwgJTBrq1+8O8YJ12LdEuQ07kMWK6W+fFi18bGI7hkfD2FuQDrc7dM2ePm4d1AoCKuj/MoVzOg3zEbVMxh80SPJHl33kUFIh9Uf3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795338394; h=Content-Transfer-Encoding:Cc:Cc: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; bh=ZlG5sNKBkvXvY9Mqh0mDtE4lKYoM32I/uSr5hNM8NDQ=; b=BYTZL9P0qIHT7dOhoA4WRyz56iJD78yv798+AfbqLrggqjbu69/Nn83cTBOvKVUc6XjBfZCNN/YNfHLEC63AAv2YQIKdVe2rpcy4q3pxQG7ab0C1/FwQ6DYPDTiKBcqSIhv8F8ENyabwI3xN4lURuk1DRS6MYWyfOHj+W/XSiO8= 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 1795338394027416.2978966137491; Sun, 22 Nov 2026 01:06:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xV3WU-0001Xd-KI; Sun, 22 Nov 2026 04:06:12 -0500 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 1xV3W8-0001WC-Av for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:48 -0500 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 1xV3W6-0000ya-Rl for qemu-devel@nongnu.org; Sun, 22 Nov 2026 04:05:48 -0500 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-c4d5b2db4bbso526485266b.0 for ; Sun, 22 Nov 2026 01:05:46 -0800 (PST) Received: from tulp.my.domain (2001-1c02-1a15-3000-2727-f7d1-9628-aa81.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:2727:f7d1:9628:aa81]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513ad010a6sm298893666b.7.2026.11.22.01.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2026 01:05:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795338345; x=1795943145; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZlG5sNKBkvXvY9Mqh0mDtE4lKYoM32I/uSr5hNM8NDQ=; b=pdp1BB9vVRNXnS/XbVXOMzCjdjvJhiR7I7UBJL4rCXXbNwrxRf0DIeqFsABMb6qVOb IITMOW3CyUm9QTRg/RHYnobzaJIkmOmaKwUwAWg9JiWkeJyGz0PNYzkFffn4CBorXaBR 7fsQrY7M27mjywMkoF30i0eeA6qxeoM+apwSoOagBYTcg5WWXHSaTy660g1TeT22zMHo yHCFak+0Or2eV2mV17yEB5YWINNaB4O3ZjC0vt0b5KXoLa9OZWvNhZQ3dCENRiLhXSjA I8ipcQEobiXoQpg8Z0P3jRxKhofEBc6mUYGm560OMNELO7iNsg3BzkVks3DxStw4Xynl Rw5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795338345; x=1795943145; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZlG5sNKBkvXvY9Mqh0mDtE4lKYoM32I/uSr5hNM8NDQ=; b=uETibEOcDiVZQY8rFxO756JpWhG4Y6gc7AeHTqOt1NsAozpa2fU8ZqPCHXKIRIyCUn u9St1JM5FNYGK7mL0tsCO9XceOnWrtQBX8HT9+qWhd20tqgQEXcsBOVB18P9siiIAkyj 1Kf/YJHiuEvOUvxROQ+fWL/gjo4woo9t6CHcZtt4FFfcJ5rPA6ekAIjowX5R6C0FI2hu fLJ3atY4Wi9lhwv/88k2MaZC/ggUCLNSZoDqCR1jb5qNBjLClHnBWINyhdPHmyZkjVW4 c0XVKThGp5xqFv5jgWM0Upzu2J5R9KQXwot4cqy7g/dGwpcSkh8vvxi0bgcBaoQDHidD Z+gw== X-Gm-Message-State: APuU4Z9iOPhU2RLlsyEjx+NzvtHFSiWOIvFn1DIt2H8k4C1RHBT9buU8 CGbP2lWiJlePjBpUGySaho0gygdItO+kK0tdKUDiJM6dIcCxBqHZujQ8dcy5+wBL X-Gm-Gg: AZFdTZf7ROsTcFIgbHK9yezFfDkulbT1Q6ri9Ajo7diLO0gfSlQVAXh8Mkgg1o4FjX+ N6ARoXdrvjCEVBhgWhjwJgHoRir6B2yr5VGqjkf1+xdHOAzAjm/g4B/ycmlMdKRm8/SGtrGOCWZ QZzZtzsl0KOUpnHZuN8++4GoE3Erz4Rq0EbbHaOVpThQvrcsCzAa/znoi4vJMPkoRgmdZtwK1v/ LwYcjYdjeSmXL7BqD3zf4E7jrgxVZnz1Ca65qDF1ExktpUSjexKkTjRbxclsTXFWg7HE4/Z+d9s Kmf0EKB6g6wcWhq7OHR4XAN46gAF0cZv7ow9KyOfCyrUKDuUHrEU2HqlPO38KK5A99aCGqG2jm7 tP5N6PlNOL4+i8A1+GFZYa1l0Toad3E99X324dGa3YiqlnZemoCbizNE+awYBCicfCo//6qwh9X 4CX2vRp5juJlAQUz79xsMi+mJl1mxqfzArlNJgUgIAHtSqfsIc4enruYyD5GK8T8FLd0yV21V+C Wg6YP84UJtbSY6nHJkdK5kbrkPDjXo6nCCj3IyDDxW+u4tXmAy0g12XVyKS/Ef/vD8Dli6hFOdL kNd6l3KWSoetS7EbdKjudFIRNZG7srqpaFIWXX85KiFyM3JC1n+t1sZwI6EmCz0nIKtxzMFNALQ I5XMbCZS4H0iTeRD/HbF9sgASFQseqepGS325XnI= X-Received: by 2002:a17:907:3d4e:b0:c4c:e91f:e1db with SMTP id a640c23a62f3a-c51319a7850mr830662266b.25.1795338344574; Sun, 22 Nov 2026 01:05:44 -0800 (PST) From: Roman Bogorodskiy To: qemu-devel@nongnu.org Cc: Roman Bogorodskiy , Michael Roth , Kostiantyn Kostiuk Subject: [PATCH 5/5] tests/unit/test-qga: test 'guest-get-cpustats' Date: Sun, 22 Nov 2026 10:05:10 +0100 Message-ID: <20261122090511.15121-6-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261122090511.15121-1-bogorodskiy@gmail.com> References: <20261122090511.15121-1-bogorodskiy@gmail.com> 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: 1795338396618048800 Content-Type: text/plain; charset="utf-8" Add a test for 'guest-get-cpustats'. As it works only on Linux and FreeBSD, guard the test accordingly. Validate that the result is not empty and all the required fields are present. Signed-off-by: Roman Bogorodskiy --- tests/unit/test-qga.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index a8ef6b0e21..530bf97fd1 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -1119,6 +1119,38 @@ static void test_qga_get_disks(gconstpointer fix) } #endif =20 +static void test_qga_get_cpustats(gconstpointer fix) +{ + const TestFixture *fixture =3D fix; + g_autoptr(QDict) ret =3D NULL; + QList *list; + const QListEntry *entry; + + ret =3D qmp_fd(fixture->fd, "{'execute': 'guest-get-cpustats'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + list =3D qdict_get_qlist(ret, "return"); + g_assert(!qlist_empty(list)); + QLIST_FOREACH_ENTRY(list, entry) { + QDict *qdict; + + qdict =3D qobject_to(QDict, entry->value); + g_assert(qdict); +#if defined(CONFIG_LINUX) + g_assert_cmpstr(qdict_get_str(qdict, "type"), =3D=3D, "linux"); +#else + g_assert_cmpstr(qdict_get_str(qdict, "type"), =3D=3D, "bsd"); + g_assert(qdict_haskey(qdict, "irq")); +#endif + g_assert(qdict_haskey(qdict, "cpu")); + g_assert(qdict_haskey(qdict, "user")); + g_assert(qdict_haskey(qdict, "nice")); + g_assert(qdict_haskey(qdict, "system")); + g_assert(qdict_haskey(qdict, "idle")); + } +} + int main(int argc, char **argv) { TestFixture fix; @@ -1185,6 +1217,9 @@ int main(int argc, char **argv) #if defined(CONFIG_WIN32) || defined(CONFIG_LIBUDEV) || defined(CONFIG_FRE= EBSD) g_test_add_data_func("/qga/get-disks", &fix, test_qga_get_disks); #endif +#if defined(CONFIG_LINUX) || defined(CONFIG_FREEBSD) + g_test_add_data_func("/qga/get-cpustats", &fix, test_qga_get_cpustats); +#endif =20 ret =3D g_test_run(); =20 --=20 2.56.0