From nobody Sun Apr 12 05:51:24 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=1771237919; cv=none; d=zohomail.com; s=zohoarc; b=M8xy6UtJV6Krur4kjMKMLq45MCEog7JcjtgKmcaWp7ttAOyrgtR2+TY7Wa6qGnrCe19FInqYluqLs68WEm14UMMOmGknY8g4WozzvjWmIPsEEfDkIRiHmWhRoRhvmFLDv0pZuQmnnGp5eOBaljL163eyN2MADH+5gTIqYC7CHco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771237919; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=hQ5tRuWYImee0j/eSuZeoovu/KfdCpgO6d8EXV9epJA=; b=XuEinH71oE14/b7UzbhoYdDtSBHJf6BOkQnaOrPlGvGcXvS4XhgKayelZ4i5KMP9JIEiat3R0sFThqKu86iVyrCTL97FL5gGw+5qMcNeToqkqlJkWSsgyD/itwk2Y3fG1MW28U1sAF8PPqpmacRU0smeRcfXJ+/N2e2Bq9g816M= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771237919487703.0908306323204; Mon, 16 Feb 2026 02:31:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vrvrs-0005xU-4l; Mon, 16 Feb 2026 05:30:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vrvrj-0005wQ-Rp for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:09 -0500 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 1vrvrf-0006hB-Rh for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:06 -0500 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-426-2KfgfwZ5Mt2p6a2K1rirQQ-1; Mon, 16 Feb 2026 05:29:58 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 465F518004AD; Mon, 16 Feb 2026 10:29:57 +0000 (UTC) Received: from srv1.redhat.com (unknown [10.44.32.156]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F2DFC1800669; Mon, 16 Feb 2026 10:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771237802; 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=hQ5tRuWYImee0j/eSuZeoovu/KfdCpgO6d8EXV9epJA=; b=bYxmzcVleyqEtyQ9Izoc8fxlmJrOaW4bOmwHmYTMmOHrk7+T4YinL2FK66/amUU/4ojeRN XSpPGtpdLMLR4wnQ8kNq3C7CxjO/wMKWP5YgJ+ieAUS6cUKnp7yk3SeqvM+3ppVbJoyF37 dnndSRLxirMBD7P6hOOmalCfKfO2MBE= X-MC-Unique: 2KfgfwZ5Mt2p6a2K1rirQQ-1 X-Mimecast-MFC-AGG-ID: 2KfgfwZ5Mt2p6a2K1rirQQ_1771237797 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 1/5] qga/vss-win32: Fix ConvertStringToBSTR redefinition with newer MinGW Date: Mon, 16 Feb 2026 12:29:47 +0200 Message-ID: <20260216102951.150381-2-kkostiuk@redhat.com> In-Reply-To: <20260216102951.150381-1-kkostiuk@redhat.com> References: <20260216102951.150381-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1771237922476158500 Content-Type: text/plain; charset="utf-8" From: Nguyen Dinh Phi Newer versions of MinGW-w64 provide ConvertStringToBSTR() in the _com_util namespace via . This causes a redefinition error when building qemu-ga on Windows with these toolchains. Add a meson check to detect whether ConvertStringToBSTR is already available, and conditionally compile our fallback implementation only when the system does not provide one. Signed-off-by: Nguyen Dinh Phi Suggested-by: Pierrick Bouvier Reviewed-by: Pierrick Bouvier Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/20251218085446.462827-2-phind.uet@= gmail.com Signed-off-by: Kostiantyn Kostiuk --- meson.build | 12 ++++++++++++ qga/vss-win32/install.cpp | 2 ++ 2 files changed, 14 insertions(+) diff --git a/meson.build b/meson.build index 8ad37c992b..47e46c1d9f 100644 --- a/meson.build +++ b/meson.build @@ -3299,6 +3299,18 @@ endif # Detect host pointer size for the target configuration loop. host_long_bits =3D cc.sizeof('void *') * 8 =20 +# Detect if ConvertStringToBSTR has been defined in _com_util namespace +if host_os =3D=3D 'windows' + has_convert_string_to_bstr =3D cxx.links(''' + #include + int main() { + BSTR b =3D _com_util::ConvertStringToBSTR("test"); + return b ? 0 : 1; + } + ''') + config_host_data.set('CONFIG_CONVERT_STRING_TO_BSTR', has_convert_string= _to_bstr) +endif + ######################## # Target configuration # ######################## diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp index 7b25d9098b..5b7a8e9bc5 100644 --- a/qga/vss-win32/install.cpp +++ b/qga/vss-win32/install.cpp @@ -549,6 +549,7 @@ STDAPI DllUnregisterServer(void) =20 =20 /* Support function to convert ASCII string into BSTR (used in _bstr_t) */ +#ifndef CONFIG_CONVERT_STRING_TO_BSTR namespace _com_util { BSTR WINAPI ConvertStringToBSTR(const char *ascii) { @@ -566,6 +567,7 @@ namespace _com_util return bstr; } } +#endif =20 /* Stop QGA VSS provider service using Winsvc API */ STDAPI StopService(void) --=20 2.52.0 From nobody Sun Apr 12 05:51:24 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=1771237892; cv=none; d=zohomail.com; s=zohoarc; b=JRZhxQ1e3NdGu0Y7X/B5bBeCiHamodjAz+WpKQa2vso1TMGFzv49mwFBY7KQpqb62/6uXXrw5Rqm/LLWElsbRirlD9a/nxBD8fqMT2jb5+q7EyqZUc82gAdDtRnf4eJylFuj5ju11rZDMJ7KS7VyZEpdlSulPwBppVQzO8SmPCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771237892; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=9y4jIW3yOBt9OHzqVap3xId+tC7KWpl0iJxMP328cPk=; b=QDnEXVdGCu90nY++Z3/MW8CZPDcnUb2cYFo6uZcUtl6cg6qiYIspoXf4a0OUfNC4zp500GcSu/LnmxzWSqcGPGaJIwCzb7GRbkgOu+vl/kcTrXUyf1LhRRaaKBhy1SGmDq0uw3hgRGaSemI2Wly+vabDjTsTD2bQ6LiDt1Gw/4I= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771237892838445.73699632226305; Mon, 16 Feb 2026 02:31:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vrvrs-0005xY-Bj; Mon, 16 Feb 2026 05:30:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vrvrl-0005we-EH for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:10 -0500 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 1vrvri-0006m7-Od for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:08 -0500 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-464-AfG6aiP6NfiKNsxDsSjSnw-1; Mon, 16 Feb 2026 05:29:59 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 E8F8A180025A; Mon, 16 Feb 2026 10:29:58 +0000 (UTC) Received: from srv1.redhat.com (unknown [10.44.32.156]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6E551800666; Mon, 16 Feb 2026 10:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771237803; 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=9y4jIW3yOBt9OHzqVap3xId+tC7KWpl0iJxMP328cPk=; b=XL7uEidiWzBkEtA9JMprH0cejeT4pLwmP95DonogJVl8DhNIQYnByy6wWL5aWk+K9sq1zG c22/vY9qMDCrLnlu+PfPMSIWhzUtEWxJ60wgnZ18R+kPSh+saQDb32Iyfs8d4GTYEoyjaf wtzxlIv2GCQMnjb5XcBSycxAS+XNEn4= X-MC-Unique: AfG6aiP6NfiKNsxDsSjSnw-1 X-Mimecast-MFC-AGG-ID: AfG6aiP6NfiKNsxDsSjSnw_1771237799 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 2/5] util: Move qemu_ftruncate64 from block/file-win32.c to oslib-win32.c Date: Mon, 16 Feb 2026 12:29:48 +0200 Message-ID: <20260216102951.150381-3-kkostiuk@redhat.com> In-Reply-To: <20260216102951.150381-1-kkostiuk@redhat.com> References: <20260216102951.150381-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.4.1 on 10.30.177.93 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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1771237894222154100 From: Nguyen Dinh Phi qemu_ftruncate64() is a general-purpose utility function that may be used outside of the block layer. Move it to util/oslib-win32.c where other Windows-specific utility functions reside. Signed-off-by: Nguyen Dinh Phi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Link: https://lore.kernel.org/qemu-devel/20251218085446.462827-3-phind.uet@= gmail.com Signed-off-by: Kostiantyn Kostiuk --- block/file-win32.c | 32 -------------------------------- util/oslib-win32.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/block/file-win32.c b/block/file-win32.c index af9aea631c..8a44853389 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -170,38 +170,6 @@ static BlockAIOCB *paio_submit(BlockDriverState *bs, H= ANDLE hfile, return thread_pool_submit_aio(aio_worker, acb, cb, opaque); } =20 -int qemu_ftruncate64(int fd, int64_t length) -{ - LARGE_INTEGER li; - DWORD dw; - LONG high; - HANDLE h; - BOOL res; - - if ((GetVersion() & 0x80000000UL) && (length >> 32) !=3D 0) - return -1; - - h =3D (HANDLE)_get_osfhandle(fd); - - /* get current position, ftruncate do not change position */ - li.HighPart =3D 0; - li.LowPart =3D SetFilePointer (h, 0, &li.HighPart, FILE_CURRENT); - if (li.LowPart =3D=3D INVALID_SET_FILE_POINTER && GetLastError() !=3D = NO_ERROR) { - return -1; - } - - high =3D length >> 32; - dw =3D SetFilePointer(h, (DWORD) length, &high, FILE_BEGIN); - if (dw =3D=3D INVALID_SET_FILE_POINTER && GetLastError() !=3D NO_ERROR= ) { - return -1; - } - res =3D SetEndOfFile(h); - - /* back to old position */ - SetFilePointer(h, li.LowPart, &li.HighPart, FILE_BEGIN); - return res ? 0 : -1; -} - static int set_sparse(int fd) { DWORD returned; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 839b8a4170..766c602172 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -899,3 +899,37 @@ int qemu_shm_alloc(size_t size, Error **errp) error_setg(errp, "Shared memory is not supported."); return -1; } + +int qemu_ftruncate64(int fd, int64_t length) +{ + LARGE_INTEGER li; + DWORD dw; + LONG high; + HANDLE h; + BOOL res; + + if ((GetVersion()&0x80000000UL) && (length >> 32) !=3D 0) { + return -1; + } + + h =3D (HANDLE)_get_osfhandle(fd); + + /* get current position, ftruncate do not change position */ + li.HighPart =3D 0; + li.LowPart =3D SetFilePointer (h, 0, &li.HighPart, FILE_CURRENT); + if (li.LowPart =3D=3D INVALID_SET_FILE_POINTER && GetLastError() !=3D = NO_ERROR) { + return -1; + } + + high =3D length >> 32; + dw =3D SetFilePointer(h, (DWORD) length, &high, FILE_BEGIN); + if (dw =3D=3D INVALID_SET_FILE_POINTER && GetLastError() !=3D NO_ERROR= ) { + return -1; + } + res =3D SetEndOfFile(h); + + /* back to old position */ + SetFilePointer(h, li.LowPart, &li.HighPart, FILE_BEGIN); + return res ? 0 : -1; +} + --=20 2.52.0 From nobody Sun Apr 12 05:51:24 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=1771237852; cv=none; d=zohomail.com; s=zohoarc; b=aE/s/tR3zTtXd0cz90vWYyC2OzVNZwMDJTFb9r2BG3Iwo9WW6ckM9LpzCBmdHeV2388Y3DpUx5xfJQbgzRxSMsT9rAtx6KWu+f8wO8H9A0v27v5Wk6wiU8p9xLwlnzSnGsMbCufXopyPTsVBVKeqtBc8d7C6Mr7tXU9tVwoyrYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771237852; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=WvUaSFB8HP1XCS6dInIhNCPXrB8b8qtH6GVNa9LJnTk=; b=RB1rvJfQnjVQMek8W56LCspO/rmwo6MjZy+nXAjnjTKbSL4Mpza1X55CLhB5ZflG0M0n72TidnoTwZnO5C9j7KFlsLJ/i6yVhQizHR475h/UuzM1f+2pA7i87/xamczwsnDT2PoSnUHH9zzC0xe0ikznaJSa0LlZcgc6RCxwBqg= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771237852678374.6134552713986; Mon, 16 Feb 2026 02:30:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vrvrv-0005xp-O2; Mon, 16 Feb 2026 05:30:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vrvrp-0005wy-7E for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:14 -0500 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 1vrvrj-0006tR-6p for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:10 -0500 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-391-UvMDd7-mMFSPHsHTYaOhDw-1; Mon, 16 Feb 2026 05:30:01 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 A3B4218004BB; Mon, 16 Feb 2026 10:30:00 +0000 (UTC) Received: from srv1.redhat.com (unknown [10.44.32.156]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6548B1800465; Mon, 16 Feb 2026 10:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771237806; 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=WvUaSFB8HP1XCS6dInIhNCPXrB8b8qtH6GVNa9LJnTk=; b=e5d26VFEsGLYfS/D96PpTIesMnDwsuqFpjK5kX3eva8Pvg62hiZNKKj2hXUrRTRq0xiQRu DCB25Pfvb+2gRH1PZdhwH5rYJrZ/4vL7oISCeDZWOelXRNhUTCF9+2zORVVwgAFRHS/R6T kmAJvAaluGR5e0uNry5m8A0PVr8FnF8= X-MC-Unique: UvMDd7-mMFSPHsHTYaOhDw-1 X-Mimecast-MFC-AGG-ID: UvMDd7-mMFSPHsHTYaOhDw_1771237800 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 3/5] qga: implement guest-network-get-route for Windows Date: Mon, 16 Feb 2026 12:29:49 +0200 Message-ID: <20260216102951.150381-4-kkostiuk@redhat.com> In-Reply-To: <20260216102951.150381-1-kkostiuk@redhat.com> References: <20260216102951.150381-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1771237854698158500 Content-Type: text/plain; charset="utf-8" From: Elizabeth Ashurov Add Windows implementation of guest-network-get-route command to provide network routing information on Windows guests. Features implemented: - IPv4 and IPv6 route information retrieval using GetIpForwardTable2 - Human-readable interface names via GetAdaptersAddresses - Proper route metrics combining route and interface metrics - MTU information for network interfaces - Support for destination, gateway, mask, and metric fields for IPv4 - Support for destination, nexthop, and desprefixlen fields for IPv6 Implementation uses modern Windows IP Helper API (GetIpForwardTable2, GetIfEntry2). Signed-off-by: Elizabeth Ashurov Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/20251222144031.3115317-1-eashurov@= redhat.com Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 172 +++++++++++++++++++++++++++++++++++++++++++ qga/qapi-schema.json | 12 +-- 2 files changed, 178 insertions(+), 6 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 8227480810..d892cf5773 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -2592,3 +2592,175 @@ GuestLoadAverage *qmp_guest_get_load(Error **errp) ret->load15m =3D load_avg_15m; return ret; } + +/* Helper function to get interface name with fallbacks */ +static char *get_interface_name(const MIB_IPFORWARD_ROW2 *row, + IP_ADAPTER_ADDRESSES *adptr_addrs) +{ + IP_ADAPTER_ADDRESSES *adapter; + char *iface_name =3D NULL; + + if (adptr_addrs) { + for (adapter =3D adptr_addrs; adapter; adapter =3D adapter->Next) { + if (adapter->Luid.Value =3D=3D row->InterfaceLuid.Value) { + iface_name =3D guest_wctomb_dup(adapter->FriendlyName); + break; + } + } + } + + if (!iface_name) { + iface_name =3D g_strdup_printf("if%lu", row->InterfaceIndex); + } + + return iface_name; +} + +/* Helper function to fill IPv4 route information */ +static void fill_ipv4_route_info(GuestNetworkRoute *route, + const MIB_IPFORWARD_ROW2 *row) +{ + struct sockaddr_in *addr_in; + char addr_str[INET_ADDRSTRLEN]; + + addr_in =3D (struct sockaddr_in *)&row->DestinationPrefix.Prefix; + if (inet_ntop(AF_INET, &addr_in->sin_addr, addr_str, INET_ADDRSTRLEN))= { + route->destination =3D g_strdup(addr_str); + } else { + route->destination =3D g_strdup("0.0.0.0"); + } + + if (row->DestinationPrefix.PrefixLength =3D=3D 0) { + route->mask =3D g_strdup("0.0.0.0"); + } else { + uint32_t mask =3D htonl(0xFFFFFFFF << (32 - + row->DestinationPrefix.PrefixLength)); + struct in_addr mask_addr =3D { .s_addr =3D mask }; + route->mask =3D g_strdup(inet_ntoa(mask_addr)); + } + + addr_in =3D (struct sockaddr_in *)&row->NextHop; + if (inet_ntop(AF_INET, &addr_in->sin_addr, addr_str, INET_ADDRSTRLEN))= { + route->gateway =3D g_strdup(addr_str); + } else { + route->gateway =3D g_strdup("0.0.0.0"); + } + + route->version =3D 4; +} + +/* Helper function to fill IPv6 route information */ +static void fill_ipv6_route_info(GuestNetworkRoute *route, + const MIB_IPFORWARD_ROW2 *row) +{ + struct sockaddr_in6 *addr_in6; + char addr_str[INET6_ADDRSTRLEN]; + + addr_in6 =3D (struct sockaddr_in6 *)&row->DestinationPrefix.Prefix; + if (inet_ntop(AF_INET6, &addr_in6->sin6_addr, addr_str, INET6_ADDRSTRL= EN)) { + route->destination =3D g_strdup(addr_str); + } else { + route->destination =3D g_strdup("::"); + } + + addr_in6 =3D (struct sockaddr_in6 *)&row->NextHop; + if (inet_ntop(AF_INET6, &addr_in6->sin6_addr, addr_str, INET6_ADDRSTRL= EN)) { + route->nexthop =3D g_strdup(addr_str); + } else { + route->nexthop =3D g_strdup("::"); + } + + route->desprefixlen =3D g_strdup_printf("%u", + row->DestinationPrefix.PrefixLen= gth); + route->version =3D 6; +} + +GuestNetworkRouteList *qmp_guest_network_get_route(Error **errp) +{ + GuestNetworkRouteList *head =3D NULL, **tail =3D &head; + PMIB_IPFORWARD_TABLE2 pIpForwardTable2; + DWORD dwRetVal =3D 0; + DWORD i; + PMIB_IPFORWARD_ROW2 row; + GuestNetworkRoute *route; + IP_ADAPTER_ADDRESSES *adptr_addrs; + MIB_IPINTERFACE_ROW ipifrow; + MIB_IF_ROW2 ifrow2; + Error *local_err =3D NULL; + GHashTable *interface_metric_cache; + + dwRetVal =3D GetIpForwardTable2(AF_UNSPEC, &pIpForwardTable2); + if (dwRetVal !=3D NO_ERROR) { + error_setg_win32(errp, dwRetVal, "failed to get IP routes"); + return NULL; + } + + interface_metric_cache =3D g_hash_table_new_full(g_str_hash, g_str_equ= al, + g_free, NULL); + adptr_addrs =3D guest_get_adapters_addresses(&local_err); + if (local_err) { + error_free(local_err); + adptr_addrs =3D NULL; + } + + for (i =3D 0; i < pIpForwardTable2->NumEntries; i++) { + row =3D &pIpForwardTable2->Table[i]; + + if (row->DestinationPrefix.Prefix.si_family =3D=3D AF_INET) { + route =3D g_new0(GuestNetworkRoute, 1); + fill_ipv4_route_info(route, row); + } else if (row->DestinationPrefix.Prefix.si_family =3D=3D AF_INET6= ) { + route =3D g_new0(GuestNetworkRoute, 1); + fill_ipv6_route_info(route, row); + } else { + continue; + } + + route->iface =3D get_interface_name(row, adptr_addrs); + + /* + * Get interface metric for combined route metric calculation. + * Windows calculates effective route metric as route + interface = metric. + * This matches the values displayed by Windows 'route print' comm= and. + * See: + * https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns= -netioapi-mib_ipforward_row2 + */ + gchar *luid_key =3D g_strdup_printf("%" G_GUINT64_FORMAT, + row->InterfaceLuid.Value); + gpointer cached_metric =3D g_hash_table_lookup(interface_metric_ca= che, + luid_key); + + if (cached_metric) { + route->metric =3D (int)row->Metric + GPOINTER_TO_INT(cached_me= tric); + g_free(luid_key); + } else { + memset(&ipifrow, 0, sizeof(ipifrow)); + InitializeIpInterfaceEntry(&ipifrow); + ipifrow.InterfaceLuid =3D row->InterfaceLuid; + ipifrow.Family =3D row->DestinationPrefix.Prefix.si_family; + if (GetIpInterfaceEntry(&ipifrow) =3D=3D NO_ERROR) { + g_hash_table_insert(interface_metric_cache, luid_key, + GINT_TO_POINTER(ipifrow.Metric)); + route->metric =3D (int)row->Metric + (int)ipifrow.Metric; + } else { + route->metric =3D (int)row->Metric; + g_free(luid_key); + } + } + + memset(&ifrow2, 0, sizeof(ifrow2)); + ifrow2.InterfaceLuid =3D row->InterfaceLuid; + if (GetIfEntry2(&ifrow2) =3D=3D NO_ERROR) { + route->has_mtu =3D true; + route->mtu =3D (int)ifrow2.Mtu; + } + + QAPI_LIST_APPEND(tail, route); + route =3D NULL; + } + + FreeMibTable(pIpForwardTable2); + g_free(adptr_addrs); + g_hash_table_destroy(interface_metric_cache); + return head; +} diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 8162d888bb..6d5c0630e8 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -1879,7 +1879,8 @@ ## # @GuestNetworkRoute: # -# Route information, currently, only linux supported. +# Route information. Supported on Linux (since 9.1) and Windows +# (since 11.0). # # @iface: The destination network or host's egress network interface in th= e routing table # @@ -1913,8 +1914,7 @@ # # @version: IP version (4 or 6) # -# Since: 9.1 - +# Since: 9.1 (Linux only); 11.0 (Windows) ## { 'struct': 'GuestNetworkRoute', 'data': {'iface': 'str', @@ -1934,7 +1934,7 @@ '*nexthop': 'str', 'version': 'int' }, - 'if': 'CONFIG_LINUX' } + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } } ## # @guest-network-get-route: @@ -1943,9 +1943,9 @@ # # Returns: List of route info of guest. # -# Since: 9.1 +# Since: 9.1 (Linux only); 11.0 (Windows) ## { 'command': 'guest-network-get-route', 'returns': ['GuestNetworkRoute'], - 'if': 'CONFIG_LINUX' + 'if': { 'any': ['CONFIG_LINUX', 'CONFIG_WIN32'] } } -- 2.52.0 From nobody Sun Apr 12 05:51:24 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=1771237868; cv=none; d=zohomail.com; s=zohoarc; b=J/rbVRP4k6D++UmH84tngaj6uiOsW5DXg15a7Ryp0rsybUhi+NhY1V1QD2xeIklolS3ubj9pGYNPkb7CE05COsuJpvG/tLwhJ2EREwU3/3I6A+F7WbupQ7cXLY6u5Sq8DrojyqGfL0JEYtXUgMM6mn6SP8FEbBu8TypmtSskS6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771237868; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=rrHCY5KX91VDIK/7DELWtkdibSPQHxJxeU1/Q0fsMT0=; b=h3UYmqV639ZGM8gtj9GwP9W4HowgXbIz+CeE0EM5FLhEqcu5uHGW/EIiUqlvBp2KmCDzeoIgjFt0oUQ8QxArx0ztiNbvvsBlinQbvyGeVyf12L1fxKVRIiOoULw/+ZcDNFepBdpAWMCyml5VZWcIHsVCssxlr2U/4zOlotPVjDc= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771237868495607.5983514502775; Mon, 16 Feb 2026 02:31:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vrvrt-0005xZ-3l; Mon, 16 Feb 2026 05:30:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vrvrp-0005wz-D5 for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:14 -0500 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 1vrvrj-0006tK-7N for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:09 -0500 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-503-0eOSy0isOOeg5D-Nk9onkQ-1; Mon, 16 Feb 2026 05:30:03 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 53DFC1955D7A; Mon, 16 Feb 2026 10:30:02 +0000 (UTC) Received: from srv1.redhat.com (unknown [10.44.32.156]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2009F1800465; Mon, 16 Feb 2026 10:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771237805; 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=rrHCY5KX91VDIK/7DELWtkdibSPQHxJxeU1/Q0fsMT0=; b=Cr7pj1VmvsJPAc9VWxbeW6sB1oNexqUBddcqqEX8/5y7ne2lOHySpb1XEJr6+Ab+rTVROB pSRl3ja8roHJDABZ+7NBZRnwCB3m3LvKrWbFEFBalsV8m6KEQfV6ArB+Hm84l5AmRe7BVf pxiN+hzrWzLO3izchRuJSSpYoSmEzBg= X-MC-Unique: 0eOSy0isOOeg5D-Nk9onkQ-1 X-Mimecast-MFC-AGG-ID: 0eOSy0isOOeg5D-Nk9onkQ_1771237802 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 4/5] qga: Move CoInitialize/CoInitializeSecurity to main process thread Date: Mon, 16 Feb 2026 12:29:50 +0200 Message-ID: <20260216102951.150381-5-kkostiuk@redhat.com> In-Reply-To: <20260216102951.150381-1-kkostiuk@redhat.com> References: <20260216102951.150381-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1771237871699154100 Content-Type: text/plain; charset="utf-8" From: Elizabeth Ashurov Problem: Two issues with COM initialization: Issue #1: Incorrect call order - requester_init() called CoInitializeSecurity first - Per Microsoft documentation, CoInitialize() must be called BEFORE CoInitializeSecurity() Issue #2: Incorrect call location - CoInitializeSecurity was called from dll instead of the main process - Per Microsoft documentation, CoInitializeSecurity() must be called exactl= y once per process from the main executable, not from a DLL Reference: https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseap= i-coinitializesecurity https://learn.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coin= itialize This caused incorrect COM initialization, preventing VSS Writers from calling back via IVssWriterCallback (hr =3D 0x80070005, Access denied, Event ID 8194). Fix: - Initialize COM in main.c for both service and CLI modes - Call CoInitialize() followed by CoInitializeSecurity() in correct order in the main thread before any VSS operations - Add proper CoUninitialize() cleanup Result: VSS Writers can now successfully call back to the agent. Event ID 8194 error is resolved. Signed-off-by: Elizabeth Ashurov Reviewed-by: Kostiantyn Kostiuk Tested-by: Dehan Meng Link: https://lore.kernel.org/qemu-devel/20260211101744.757548-1-eashurov@r= edhat.com Signed-off-by: Kostiantyn Kostiuk --- qga/main.c | 42 +++++++++++++++++++++++++++++++++++++ qga/vss-win32/requester.cpp | 13 ------------ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/qga/main.c b/qga/main.c index dd1c216f9a..fd19c7037d 100644 --- a/qga/main.c +++ b/qga/main.c @@ -32,6 +32,8 @@ #include "qemu/systemd.h" #include "qemu-version.h" #ifdef _WIN32 +#include +#include #include #include #include "qga/service-win32.h" @@ -830,6 +832,29 @@ DWORD WINAPI service_ctrl_handler(DWORD ctrl, DWORD ty= pe, LPVOID data, return ret; } =20 +/* Initialize COM for VSS operations */ +static HRESULT init_com(void) +{ + HRESULT hr; + + hr =3D CoInitialize(NULL); + if (FAILED(hr)) { + return hr; + } + + hr =3D CoInitializeSecurity( + NULL, -1, NULL, NULL, + RPC_C_AUTHN_LEVEL_PKT_PRIVACY, + RPC_C_IMP_LEVEL_IDENTIFY, + NULL, EOAC_NONE, NULL); + if (FAILED(hr)) { + CoUninitialize(); + return hr; + } + + return S_OK; +} + VOID WINAPI service_main(DWORD argc, TCHAR *argv[]) { GAService *service =3D &ga_state->service; @@ -842,6 +867,13 @@ VOID WINAPI service_main(DWORD argc, TCHAR *argv[]) return; } =20 + /* Initialize COM for VSS operations in the service thread */ + HRESULT hr_com =3D init_com(); + if (FAILED(hr_com)) { + g_critical("Failed to initialize COM in service thread: 0x%lx", hr= _com); + return; + } + service->status.dwServiceType =3D SERVICE_WIN32; service->status.dwCurrentState =3D SERVICE_RUNNING; service->status.dwControlsAccepted =3D SERVICE_ACCEPT_STOP | SERVICE_A= CCEPT_SHUTDOWN; @@ -866,6 +898,8 @@ VOID WINAPI service_main(DWORD argc, TCHAR *argv[]) =20 run_agent(ga_state); =20 + CoUninitialize(); + UnregisterDeviceNotification(service->device_notification_handle); service->status.dwCurrentState =3D SERVICE_STOPPED; SetServiceStatus(service->status_handle, &service->status); @@ -1719,7 +1753,15 @@ int main(int argc, char **argv) StartServiceCtrlDispatcher(service_table); ret =3D EXIT_SUCCESS; } else { + HRESULT hr_com =3D init_com(); + if (FAILED(hr_com)) { + g_critical("Failed to initialize COM: 0x%lx", hr_com); + ret =3D EXIT_FAILURE; + goto end; + } + ret =3D run_agent(s); + CoUninitialize(); } #else ret =3D run_agent(s); diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp index 5615955b6f..2ebfabf45d 100644 --- a/qga/vss-win32/requester.cpp +++ b/qga/vss-win32/requester.cpp @@ -60,15 +60,6 @@ STDAPI requester_init(void) { qga_debug_begin; =20 - COMInitializer initializer; /* to call CoInitializeSecurity */ - HRESULT hr =3D CoInitializeSecurity( - NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, - RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL); - if (FAILED(hr)) { - qga_debug("failed to CoInitializeSecurity (error %lx)", hr); - return hr; - } - hLib =3D LoadLibraryA("VSSAPI.DLL"); if (!hLib) { qga_debug("failed to load VSSAPI.DLL"); @@ -320,8 +311,6 @@ void requester_freeze(int *num_vols, void *mountpoints,= ErrorSet *errset) return; } =20 - CoInitialize(NULL); - /* Allow unrestricted access to events */ InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE); @@ -560,7 +549,6 @@ out: =20 out1: requester_cleanup(); - CoUninitialize(); =20 qga_debug_end; } @@ -641,7 +629,6 @@ void requester_thaw(int *num_vols, void *mountpints, Er= rorSet *errset) *num_vols =3D vss_ctx.cFrozenVols; requester_cleanup(); =20 - CoUninitialize(); StopService(); =20 qga_debug_end; --=20 2.52.0 From nobody Sun Apr 12 05:51:24 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=1771237864; cv=none; d=zohomail.com; s=zohoarc; b=T85naPGMbG3ENefOpRATKNVafL0YRq38UATPq0ENXZnss+fZIiuALjGTyZcYV1q8Nf3IlkttjBWwEA68GxkJydIp+gXVFnliSMY6t08jfZum0GwX5GEpTzXNIrxdl2YHMLjVWSNG4DnYU0pQue8rjqA6zfWAJIUcqt3nMNSnb/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771237864; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=HqDwu0T0oJAOwK1ffJHuITlC5Gc0NgpKr7ZD1XAqwTQ=; b=dPsIAH2Cgk7zq372kORe/5MsmQxJ1HdF7sEHXYpJwqvcOOWufda+sSZyjd1m8P3laiU2T4a7Wt9ACFyrqHWODvPr5jY+yNVmcKyIXhigpBOQToEY9gW7sIVb2biic8J7ZZQr+uYX8YxNbd06b67K5wQtXfSDnq3R6thxuzLtsrA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771237864789981.9978086939536; Mon, 16 Feb 2026 02:31:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vrvrt-0005xa-D2; Mon, 16 Feb 2026 05:30:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vrvrr-0005x4-6a for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:15 -0500 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 1vrvrn-0006tq-4w for qemu-devel@nongnu.org; Mon, 16 Feb 2026 05:30:14 -0500 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-325-Jmq0_FyzNuOXfdKFLkPw4g-1; Mon, 16 Feb 2026 05:30:05 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 278EB1955BC1; Mon, 16 Feb 2026 10:30:04 +0000 (UTC) Received: from srv1.redhat.com (unknown [10.44.32.156]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E28E9180066B; Mon, 16 Feb 2026 10:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771237809; 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=HqDwu0T0oJAOwK1ffJHuITlC5Gc0NgpKr7ZD1XAqwTQ=; b=Y1ox5DaxSzaYpj3FRuAKK+eI0EXL2PxPrggr/sm0tGhR6NdQK54qag1T09zqcr1A9BkgSO fvvd1kJQR789tr1KfeZ3awb2QV/Ii5ApscIPchvoH2xp0J3Vxv2QFdDtJoHsIwaWoxFwsM wOqckg084Gio821LVP1Kzn7R5gXmg6Y= X-MC-Unique: Jmq0_FyzNuOXfdKFLkPw4g-1 X-Mimecast-MFC-AGG-ID: Jmq0_FyzNuOXfdKFLkPw4g_1771237804 From: Kostiantyn Kostiuk To: qemu-devel@nongnu.org, Peter Maydell , Richard Henderson Subject: [PULL 5/5] qga: Fix VSS provider GetSnapshotProperties return value Date: Mon, 16 Feb 2026 12:29:51 +0200 Message-ID: <20260216102951.150381-6-kkostiuk@redhat.com> In-Reply-To: <20260216102951.150381-1-kkostiuk@redhat.com> References: <20260216102951.150381-1-kkostiuk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1771237867522154100 Content-Type: text/plain; charset="utf-8" From: Elizabeth Ashurov GetSnapshotProperties() returned VSS_E_OBJECT_NOT_FOUND causing "Snapshot id not found" errors during VSS operations. Any error in this function causes a similar error in Windows VSS, so we must return S_OK there. Signed-off-by: Elizabeth Ashurov Reviewed-by: Kostiantyn Kostiuk Link: https://lore.kernel.org/qemu-devel/20260211101744.757548-2-eashurov@r= edhat.com Signed-off-by: Kostiantyn Kostiuk --- qga/vss-win32/provider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/vss-win32/provider.cpp b/qga/vss-win32/provider.cpp index a102a23fbf..2b5c6f8e8e 100644 --- a/qga/vss-win32/provider.cpp +++ b/qga/vss-win32/provider.cpp @@ -263,7 +263,7 @@ STDMETHODIMP CQGAVssProvider::SetContext(LONG lContext) STDMETHODIMP CQGAVssProvider::GetSnapshotProperties( VSS_ID SnapshotId, VSS_SNAPSHOT_PROP *pProp) { - return VSS_E_OBJECT_NOT_FOUND; + return S_OK; } =20 STDMETHODIMP CQGAVssProvider::Query( --=20 2.52.0