From nobody Mon Sep 8 02:21:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1756499708; cv=none; d=zohomail.com; s=zohoarc; b=SAgn15zBCjmUv9QKCZ3Q37JG74RGgFCRo3yELjY75f0bH7fi/9MTN1/5+9KHtq7O5FAQpaeSkJt+7p/2tk2R0JZjXZsx0dg8v4JMBFyurHjSbhlK7P5orNRLYpfqiAsIltxd3fQO0PMana1Y0bNOzFim9QN67/dgs1WM7J3pAuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756499708; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=TwUh0oQEmKgiIHhhTVtaeu1VjU/bR5TVRqq40+I2pUQ=; b=g4qXV+RMYwtpZQ+EtnuyV+ZfAOt7Sv6WHjr0oNbQ3iIBRxMOiKVQMQ7nIELR916SdHUeQcof4oAMPg3vhCUNU6H6Ng/SI6pLm4oObjsDI8CtD2H9twTwZsUIuRNGUKmdD+RR+8qzkaePzTtxt6y4dQdKbIzpKAFXL+JXPR0uQGk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1756499708279625.6998780270683; Fri, 29 Aug 2025 13:35:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 226C043E3D; Fri, 29 Aug 2025 16:35:06 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 9A9DA44207; Fri, 29 Aug 2025 16:29:44 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 41FD244137; Fri, 29 Aug 2025 16:28:51 -0400 (EDT) Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 93D1344151 for ; Fri, 29 Aug 2025 16:28:50 -0400 (EDT) Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-315a297f9a3so1683711fac.3 for ; Fri, 29 Aug 2025 13:28:50 -0700 (PDT) Received: from home ([2603:8081:c640:1::1004]) by smtp.gmail.com with ESMTPSA id 5614622812f47-437f423b1d0sm114356b6e.18.2025.08.29.13.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 13:28:49 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756499330; x=1757104130; darn=lists.libvirt.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; bh=TwUh0oQEmKgiIHhhTVtaeu1VjU/bR5TVRqq40+I2pUQ=; b=WIYancc3HS47gbU1fnyOHtqTFLTIkSqn/O3r4GH8aauLEv3xw9HIlUKuEpOTUFNPqV ZwpJUj20uIW0bdOaeP4SXvLK3E2HU+PATp7npp/BWJ1tuhypxCz+zekUncaKoWS10eAV jc2+G9wQ4cnbcqt4kmcuP9qMP/MmbX/6lJ/E7AjL8X4mmMhs+ZLUkBqmmiWkqY3oE26H 0H5vjUrkT4CBAgXwi5cqpx4Omsi6IPpI8WCbuvW3k8/d9mpWfJXEDd6eb4YDnUF380fT 8CFOb6YoL1Elwf0uU/J7Mm7jGdGfyGqOUNIt6NWqyPB66UUXVpx706E1xMVeil0vpFdi M3vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756499330; x=1757104130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TwUh0oQEmKgiIHhhTVtaeu1VjU/bR5TVRqq40+I2pUQ=; b=cuAvNZ16+lcrTpwBO9fASqlF0rYAWc+Du0gexXt4icj8zem26q9itEv4D0fC9JcLbK bDCWOkODwTela4UyBBKCt0f6SQi0i3Zp/HB1voJRn+kIsz/ImNAXw4ivWxVwJblLCFTd jcBftpvo+H/I8dmcD0OksMA4wWDeEjXIxwgvfypQfUakViS7x8DLlH3vpbIfmASpSCVT 1DSrJNpqWAPh1bD+351V6vQMvSlwmj0k4udtiP/CACjmG//ZCLToUfF6V1YelbbVj8hM ng8LEqX0sOyhp1XxcE2zS+8jN7XC5OVxf4PRQYDPhX/8ZJnz1WnMPFOCmFnDk3nNzB6B le6g== X-Gm-Message-State: AOJu0YxOW+rJWHsrlp1niWIugvcDc75v662RFkH8cCYKEvk09345Svy2 gf/jb2ZbUr82CtU7gJ1Zd6G+ywOb7u3Obt85d+TwJ9FfJe306nPRu4Ztg9h0og== X-Gm-Gg: ASbGncu23Vvd1SO3ZnlAhY0wvgDjqdjaDtPpleHYL14d9r9gtq4fKjbPiB/khFBiEE7 xd4kA6Oqo4vxrXWYzeSQnqBVkZzhNZ2WRVSSUrQ8bGrpveE3JMV+vl/aE9Re3vUfhyvvmnnc1E6 FwVh094H//JHvcmmYeMO7AuXViKZyV2FZA9xP5pAwulpvuKgWASLAYbRKNFOn5IvzqHb5gYE8DL ltqfNbPPR7blhLb7yKK0WtXpDwwDms86l993Fn9oMUf2+FSSa9oP1NQO7MBM59cyWCvK6aDe1Cy r9HgniOdHe3bze3BUTFD9JujgTlf9rhsNm/MrPgSqDVF72CeUxf93auu3S73RGWnBVgqKKx35K4 1SsXxHJJFuBp0nA== X-Google-Smtp-Source: AGHT+IEu2O5gXnOAE4/EioVgf1jM/hwhxsWuAAmn0PUNKOyZJ/juqPXu4ny5o8E9/Ean7pDAklkQNQ== X-Received: by 2002:a05:6808:3190:b0:437:d744:dd4a with SMTP id 5614622812f47-437d744df0bmr5076765b6e.5.1756499329646; Fri, 29 Aug 2025 13:28:49 -0700 (PDT) From: Praveen K Paladugu X-Google-Original-From: Praveen K Paladugu To: devel@lists.libvirt.org Subject: [PATCH v3 4/8] qemu: probe mshv capabilities Date: Fri, 29 Aug 2025 15:28:34 -0500 Message-ID: <20250829202838.8550-5-prapal@linux.microsoft.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250829202838.8550-1-prapal@linux.microsoft.com> References: <20250829202838.8550-1-prapal@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MYWECKSK67SS7N6LUUUXX3JMIHU7I7WZ X-Message-ID-Hash: MYWECKSK67SS7N6LUUUXX3JMIHU7I7WZ X-MailFrom: praveenkpaladugu@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: liuwe@microsoft.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1756499708757116600 Content-Type: text/plain; charset="utf-8" Probe mshv capabilities from qemu with QMP commands. Limit probing only to x86_64 architecture with newer versions of QEMU. Signed-off-by: Praveen K Paladugu --- src/qemu/qemu_capabilities.c | 21 +++++++++++++++++++++ src/qemu/qemu_monitor.c | 12 ++++++++++++ src/qemu/qemu_monitor.h | 12 +++++++++--- src/qemu/qemu_monitor_json.c | 32 ++++++++++++++++++++++++++------ src/qemu/qemu_monitor_json.h | 13 +++++++++---- 5 files changed, 77 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 1e069eb0e5..cc7774a58a 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3488,6 +3488,22 @@ virQEMUCapsProbeQMPKVMState(virQEMUCaps *qemuCaps, return 0; } =20 +static int +virQEMUCapsProbeQMPMSHVState(virQEMUCaps *qemuCaps, + qemuMonitor *mon) +{ + bool enabled =3D false; + bool present =3D false; + + if (qemuMonitorGetMSHVState(mon, &enabled, &present) < 0) + return -1; + + if (present && enabled) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_MSHV); + + return 0; +} + #ifdef __APPLE__ bool virQEMUCapsProbeHVF(virQEMUCaps *qemuCaps) @@ -5795,6 +5811,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCaps *qemuCaps, if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon) < 0) return -1; =20 + if (qemuCaps->arch =3D=3D VIR_ARCH_X86_64 && qemuCaps->version >=3D 10= 000092) { + if (virQEMUCapsProbeQMPMSHVState(qemuCaps, mon) < 0) + return -1; + } + if (virQEMUCapsProbeHVF(qemuCaps)) virQEMUCapsSet(qemuCaps, QEMU_CAPS_HVF); =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index c1fef8d5de..5acff4125d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3434,6 +3434,18 @@ qemuMonitorGetKVMState(qemuMonitor *mon, return qemuMonitorJSONGetKVMState(mon, enabled, present); } =20 +int +qemuMonitorGetMSHVState(qemuMonitor *mon, + bool *enabled, + bool *present) +{ + VIR_DEBUG("enabled=3D%p present=3D%p", enabled, present); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetMSHVState(mon, enabled, present); +} + =20 int qemuMonitorGetObjectTypes(qemuMonitor *mon, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 755f347e17..e31a00de56 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1220,9 +1220,15 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig); =20 GHashTable *qemuMonitorGetCommandLineOptions(qemuMonitor *mon); =20 -int qemuMonitorGetKVMState(qemuMonitor *mon, - bool *enabled, - bool *present); +int +qemuMonitorGetMSHVState(qemuMonitor *mon, + bool *enabled, + bool *present); + +int +qemuMonitorGetKVMState(qemuMonitor *mon, + bool *enabled, + bool *present); =20 int qemuMonitorGetObjectTypes(qemuMonitor *mon, char ***types); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9f51421478..2b29399d3b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5520,9 +5520,11 @@ qemuMonitorJSONGetCommandLineOptions(qemuMonitor *mo= n) } =20 =20 -int qemuMonitorJSONGetKVMState(qemuMonitor *mon, - bool *enabled, - bool *present) +static int +qemuMonitorJSONGetHypervisorState(qemuMonitor *mon, + const char *query_cmd, + bool *enabled, + bool *present) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -5531,7 +5533,7 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, /* Safe defaults */ *enabled =3D *present =3D false; =20 - if (!(cmd =3D qemuMonitorJSONMakeCommand("query-kvm", NULL))) + if (!(cmd =3D qemuMonitorJSONMakeCommand(query_cmd, NULL))) return -1; =20 if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) @@ -5542,8 +5544,8 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, =20 if (virJSONValueObjectGetBoolean(data, "enabled", enabled) < 0 || virJSONValueObjectGetBoolean(data, "present", present) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-kvm replied unexpected data")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("%1$s replied unexpected data"), query_cmd); return -1; } =20 @@ -5551,6 +5553,24 @@ int qemuMonitorJSONGetKVMState(qemuMonitor *mon, } =20 =20 +int qemuMonitorJSONGetKVMState(qemuMonitor *mon, + bool *enabled, + bool *present) +{ + return qemuMonitorJSONGetHypervisorState(mon, "query-kvm", + enabled, present); +} + + +int qemuMonitorJSONGetMSHVState(qemuMonitor *mon, + bool *enabled, + bool *present) +{ + return qemuMonitorJSONGetHypervisorState(mon, "query-mshv", + enabled, present); +} + + int qemuMonitorJSONGetObjectTypes(qemuMonitor *mon, char ***types) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index bd437f7938..5c1d626f97 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -451,10 +451,15 @@ qemuMonitorJSONGetCPUModelComparison(qemuMonitor *mon, GHashTable * qemuMonitorJSONGetCommandLineOptions(qemuMonitor *mon); =20 -int -qemuMonitorJSONGetKVMState(qemuMonitor *mon, - bool *enabled, - bool *present) + +int qemuMonitorJSONGetKVMState(qemuMonitor *mon, + bool *enabled, + bool *present) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + +int qemuMonitorJSONGetMSHVState(qemuMonitor *mon, + bool *enabled, + bool *present) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 int --=20 2.50.1