From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641822523; cv=none; d=zohomail.com; s=zohoarc; b=kZ3Dm2/Vk6SzSDjkMwInCLAdrGo8qpfN6wLdfFhWLCWuU1GSRCiMI45qdonsdvNthzWN7v/mlHMwujhUBWNt/GepKdLwdBp3qTvgQVtPcoLgulgvZi4bCVzfM2ckllCKVIp7iDGRptFIHr5Uv3N92d5fWldJLedqJscq46lbSrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641822523; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eMZAiN+6XqFNsTzoorsBAPybo4OMP1BOM7hvyCtTKcY=; b=Vu0hj5Dj5KOJ1Q2/xTUOoJs77wAJzUilkXxmK0RyG7lAxjhPO6umyeUd0LomndhxdVd4ujug1CzSjQ4tNQB4aZG6NfF4TF+AWQNLfLGqLtBhfyBF5I0I6e5413ZZf3OMn9LbaG58yZS4UZf6e1YfQBSJD0wDolqNklMP1Hvb5u0= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641822523360665.355819481704; Mon, 10 Jan 2022 05:48:43 -0800 (PST) Received: from localhost ([::1]:50154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6v2Q-0004Yv-0L for importer@patchew.org; Mon, 10 Jan 2022 08:48:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0j-0001us-SN for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0h-0006zs-5F for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-98-13qm_InhMpayQPlKfoCdww-1; Mon, 10 Jan 2022 08:46:49 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EED0F760C8; Mon, 10 Jan 2022 13:46:48 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 144DE7BB41; Mon, 10 Jan 2022 13:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822414; 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=eMZAiN+6XqFNsTzoorsBAPybo4OMP1BOM7hvyCtTKcY=; b=KaCWjuFTUC8Kx1m2LCGbDX1iOopDPKJgk/yvKQ0bDVwfhiLDB2UZFB8L9d3lJ7lBRLtRWq oouUnd62MIWB9HKTzW91azyLbSw3o89vbKKd+9VcyG5GzGW4FXrSEXSorhpKp82a0B7Jom inHyGQejAxG0xeYgMRdvDb6TwTVMJ9E= X-MC-Unique: 13qm_InhMpayQPlKfoCdww-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 1/9] MAINTAINERS: Add entry for QEMU Guest Agent Windows components Date: Mon, 10 Jan 2022 15:46:36 +0200 Message-Id: <20220110134644.107375-2-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641822524765100001 Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael Roth --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c98a61caee..391904bc60 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2737,6 +2737,14 @@ F: scripts/qemu-guest-agent/ F: tests/unit/test-qga.c T: git https://github.com/mdroth/qemu.git qga +QEMU Guest Agent Win32 +M: Kostiantyn Kostiuk +S: Maintained +F: qga/*win32* +F: qga/vss-win32/ +F: qga/installer/ +T: git https://github.com/kostyanf14/qemu.git qga-win32 + QOM M: Paolo Bonzini R: Daniel P. Berrange -- 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641822692; cv=none; d=zohomail.com; s=zohoarc; b=EFaA9Q/SaGZfly3bhL/+D2CCaFpj8wyOxygbCLs5bch78tnd4p4CYBTGf4o9Km26OGcLgbtB6y6Guliut1f6hQSy/QKC+rZNXPS0pVYUWWRbxPxWaiPaTypI/HtfqZWgh6fvQ0nXBvk/C/Lk1dJOiQp5gxivhKoPwL8Vhzuj+tk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641822692; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=81iP8Bmqh4r4uCT5+wWiTidyJFfp5wCSuLR5w8j5nss=; b=WokLOpr4NcP8n4ryQvd5WvJqotHR/F6NjhpkdbBs8Z0WtOA8aAnBx/QKTb6DtR2+MDrzR6XHFbK7pWl/E0xE04gQpQH/JpjzTu00/WcD/TYufDVOnTuN8jP1zgMy8xtkcLE+nDcvjG44DMBZ00BNucDvftRrN5NG/YE7Y3yIT8k= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164182269232269.55127510491116; Mon, 10 Jan 2022 05:51:32 -0800 (PST) Received: from localhost ([::1]:54980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6v59-0008AG-5V for importer@patchew.org; Mon, 10 Jan 2022 08:51:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0i-0001os-7s for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21276) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0f-0006zI-4U for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:54 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-Fbmg1grcMo6MAZyWQeXilA-1; Mon, 10 Jan 2022 08:46:51 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 582ED83DD20; Mon, 10 Jan 2022 13:46:50 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 727AA7BB4C; Mon, 10 Jan 2022 13:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822412; 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=81iP8Bmqh4r4uCT5+wWiTidyJFfp5wCSuLR5w8j5nss=; b=FIdAKMsvVcHVq1eyD0eLgVvU1OJTh4fdwl4X71E8IOs2U1bvysr+HekZwyU3XwTvjaoj4L xC3FMgR79EN4nwDCdq6WY8K67WiN5ubGXd7vH6VIltTD5cEAUMEowz+IuiHIof1nPvVwqO bd+3zpHHRZxp+UsNlGv5wB7kvr3I7EM= X-MC-Unique: Fbmg1grcMo6MAZyWQeXilA-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 2/9] gqa-win: get_pci_info: Clean dev_info if handle is valid Date: Mon, 10 Jan 2022 15:46:37 +0200 Message-Id: <20220110134644.107375-3-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641822693681100001 From: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 4e84afd83b..3dd74fe225 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -514,7 +514,7 @@ DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, static GuestPCIAddress *get_pci_info(int number, Error **errp) { - HDEVINFO dev_info; + HDEVINFO dev_info =3D INVALID_HANDLE_VALUE; SP_DEVINFO_DATA dev_info_data; SP_DEVICE_INTERFACE_DATA dev_iface_data; HANDLE dev_file; @@ -749,7 +749,9 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } free_dev_info: - SetupDiDestroyDeviceInfoList(dev_info); + if (dev_info !=3D INVALID_HANDLE_VALUE) { + SetupDiDestroyDeviceInfoList(dev_info); + } out: return pci; } -- 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641822905; cv=none; d=zohomail.com; s=zohoarc; b=QinSuqTvb3GPMuehpcHx1XKoKpi/AM+u4wB/HJWoCtXpGFSZD9LelZYCNFMYd2psW1ay6G314oUURgkBFW2hAbPl6QIO6aaSlZbdtpyokx5DEoe2SQX7zMwZaj97fmJ1oRmoN95mW+YrWzq5yOGwTgcjxRlNTDAeLIRUzDZXv7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641822905; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MLzXieUcRi2i7lUAR3KwYD9jCWQ4DcFrEKZJCFAUqcs=; b=WznCLOVjJgOp4ztgfagCEzQ13cJMJhtOME23epw4QU/AYYyJExrcm4R8N5Z3XXMmS+G3PKcqd3XIGGibinc8W6KrfMs9CzxnzHVDk2zKErwBJVqUagZy/cHzYobKoj0UYs31pPvW7FzMZy8crxjNZ8iS23GP+I6GHQD01tOVtxY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641822905327246.39183301267394; Mon, 10 Jan 2022 05:55:05 -0800 (PST) Received: from localhost ([::1]:32814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6v8a-0004Ga-A7 for importer@patchew.org; Mon, 10 Jan 2022 08:55:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0l-00023z-Bu for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40349) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0i-00070c-4t for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-286-LioVMVLkMbWqwaQ64LGopA-1; Mon, 10 Jan 2022 08:46:52 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AABED760C6; Mon, 10 Jan 2022 13:46:51 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C043D7BB41; Mon, 10 Jan 2022 13:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822415; 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=MLzXieUcRi2i7lUAR3KwYD9jCWQ4DcFrEKZJCFAUqcs=; b=G/9havb4v4FdK93D0QTQf72jN4InDHNSXBJqERi5WzUcAFMTBVNceFJlWh2nJEkovjX+D8 wYJsrci+NJ3kRs/5dgzLnC+BZ1hHNx1QGEnWf0fKFHfWMfSrz+4HpnJDMFdq+xnU+VF/s0 Cuf3dutbRHAutZslfwe5fgnd6jFb/mA= X-MC-Unique: LioVMVLkMbWqwaQ64LGopA-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 3/9] gqa-win: get_pci_info: Use common 'end' label Date: Mon, 10 Jan 2022 15:46:38 +0200 Message-Id: <20220110134644.107375-4-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641822907720100003 From: Kostiantyn Kostiuk To prevent memory leaks, always try to free initialized variables. Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 3dd74fe225..93c5375132 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -532,7 +532,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (dev_info =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to get devices tree= "); - goto out; + goto end; } g_debug("enumerating devices"); @@ -562,7 +562,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } else { error_setg_win32(errp, GetLastError(), "failed to get device interfaces"); - goto free_dev_info; + goto end; } } @@ -576,7 +576,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) CloseHandle(dev_file); error_setg_win32(errp, GetLastError(), "failed to get device slot number"); - goto free_dev_info; + goto end; } CloseHandle(dev_file); @@ -586,7 +586,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } else { error_setg_win32(errp, GetLastError(), "failed to get device interfaces"); - goto free_dev_info; + goto end; } g_debug("found device slot %d. Getting storage controller", number= ); @@ -603,7 +603,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) } else { error_setg_win32(errp, GetLastError(), "failed to get device instance ID"); - goto out; + goto end; } } @@ -617,14 +617,14 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) g_error("CM_Locate_DevInst failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get device instance"); - goto out; + goto end; } cr =3D CM_Get_Parent(&parent_dev_inst, dev_inst, 0); if (cr !=3D CR_SUCCESS) { g_error("CM_Get_Parent failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get parent device instance"); - goto out; + goto end; } cr =3D CM_Get_Device_ID_Size(&dev_id_size, parent_dev_inst, 0); @@ -632,7 +632,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) g_error("CM_Get_Device_ID_Size failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get parent device ID length"); - goto out; + goto end; } ++dev_id_size; @@ -647,7 +647,7 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) g_error("CM_Get_Device_ID failed with code %lx", cr); error_setg_win32(errp, GetLastError(), "failed to get parent device ID"); - goto out; + goto end; } } @@ -661,14 +661,14 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) if (parent_dev_info =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to get parent device"); - goto out; + goto end; } parent_dev_info_data.cbSize =3D sizeof(SP_DEVINFO_DATA); if (!SetupDiEnumDeviceInfo(parent_dev_info, 0, &parent_dev_info_da= ta)) { error_setg_win32(errp, GetLastError(), "failed to get parent device data"); - goto out; + goto end; } for (j =3D 0; @@ -748,11 +748,10 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) break; } -free_dev_info: +end: if (dev_info !=3D INVALID_HANDLE_VALUE) { SetupDiDestroyDeviceInfoList(dev_info); } -out: return pci; } -- 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641823310; cv=none; d=zohomail.com; s=zohoarc; b=PGD3JaCk7DpiczohchL7gy9JvhWEdfw4j7t4OXixLUu5m+YjMGaMhkeFH3MrRDRwxTMdBfmG2kyGfFnKzdD3/bdy3AGnDvkqZPjHHQ/oFWsgU/QtArx5MT1trjwpoDUJLkIzwkwZUOOWp1n6JK47W6vMVFsCUj3h8+JWr0LTPCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641823310; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GHnS0hrIvnNAbWoQsQXH9Sq+Km55TVnQvEU2Ul/Fv1Q=; b=eATU2ndLDeMo7oXA2RbHwPwyaLflb1NqTOK2NoNxrQ9rPlRQt9AodzvVlhRggzKdu2w+zTpCy1od0czqoa2axYgPLBQbJKreW/Vg33hitHdzuyLIMRTB2BvYhohIMdJepGJ5FMfS2tQmsoCHgNp7/sjvct9enscJEUH1/a0Viys= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641823309924660.8191218091663; Mon, 10 Jan 2022 06:01:49 -0800 (PST) Received: from localhost ([::1]:43040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6vF6-000392-SF for importer@patchew.org; Mon, 10 Jan 2022 09:01:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0l-00022r-6J for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26088) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0j-00070I-II for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:46:58 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-BFIfsbIEPymc-moESxLE-w-1; Mon, 10 Jan 2022 08:46:53 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 038D71083F61; Mon, 10 Jan 2022 13:46:53 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C6677BB41; Mon, 10 Jan 2022 13:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822414; 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=GHnS0hrIvnNAbWoQsQXH9Sq+Km55TVnQvEU2Ul/Fv1Q=; b=DSADdPcRdrCHVG2tN+3YPCQ4GlKl3zihq9lI9qJTdYlzebLp9BhH/f5Rz9gczBua/pDDWa YpnAWvzrGSF6jJ2HqFtov50nniHjq2kHA6lmrDeOWzfCA73O2w440ijcrgs6697zJe8vKB lnBHVOEUmNfeOGP/2r+ebj/J9hfOzqc= X-MC-Unique: BFIfsbIEPymc-moESxLE-w-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 4/9] gqa-win: get_pci_info: Free parent_dev_info properly Date: Mon, 10 Jan 2022 15:46:39 +0200 Message-Id: <20220110134644.107375-5-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641823315438100001 From: Kostiantyn Kostiuk In case when the function fails to get parent device data, the parent_dev_info variable will be initialized, but not freed. Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 93c5375132..f6de9e2676 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -515,6 +515,8 @@ DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, static GuestPCIAddress *get_pci_info(int number, Error **errp) { HDEVINFO dev_info =3D INVALID_HANDLE_VALUE; + HDEVINFO parent_dev_info =3D INVALID_HANDLE_VALUE; + SP_DEVINFO_DATA dev_info_data; SP_DEVICE_INTERFACE_DATA dev_iface_data; HANDLE dev_file; @@ -542,7 +544,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data =3D NULL; STORAGE_DEVICE_NUMBER sdn; char *parent_dev_id =3D NULL; - HDEVINFO parent_dev_info; SP_DEVINFO_DATA parent_dev_info_data; DWORD j; DWORD size =3D 0; @@ -744,11 +745,13 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) break; } } - SetupDiDestroyDeviceInfoList(parent_dev_info); break; } =20 end: + if (parent_dev_info !=3D INVALID_HANDLE_VALUE) { + SetupDiDestroyDeviceInfoList(parent_dev_info); + } if (dev_info !=3D INVALID_HANDLE_VALUE) { SetupDiDestroyDeviceInfoList(dev_info); } --=20 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641823553; cv=none; d=zohomail.com; s=zohoarc; b=PhPpGmecHtCADbfQkWHo1NM3HNok8pkc9NSghGOmahswQBYnadO6yDFSIlMJS38Vi1bB9uDoCJx68DrNCWOWDgjRIQimOAQUfuhp8Je4nG1oxuiUBMRLIWuYUICnt/FTGILFM8t1iKZ0FeNOnHj7y5E1bRxxjqwe93TGkqpUUf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641823553; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kE9QTO0QrbN3FbKC9QgtZf3QAJc0flztkO6IMgwqh2o=; b=OMI4ablCfU05t06EmJQxItDghyyHN0Vo+UTsZX4T0AxuDtvVHE5A6bjuFXrom0+QfUVKg1eskXa4fl81h+6hd6icsVDqnnaR+GLOWqKo1GmfOv8nWQJfwZVIX7UG+Ldn08HgzLsaEEISFpeeOwR1ftXRUDEqQoNr57dEkLP0H14= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641823553737833.7796918360337; Mon, 10 Jan 2022 06:05:53 -0800 (PST) Received: from localhost ([::1]:47842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6vJ0-0006gN-UU for importer@patchew.org; Mon, 10 Jan 2022 09:05:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0m-0002EC-VG for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0k-000722-RC for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:00 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-572-_ZsksWMTPNem5ip-dZ2NJw-1; Mon, 10 Jan 2022 08:46:55 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 524681006AA4; Mon, 10 Jan 2022 13:46:54 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C49D7BB53; Mon, 10 Jan 2022 13:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822418; 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=kE9QTO0QrbN3FbKC9QgtZf3QAJc0flztkO6IMgwqh2o=; b=hAOa/S746lSkI4F/Nge/k46SK2Trf/dy7pLTjvad6bcnMjyVOaJZM2WR+DSRe438seyQ0U QOGujRU4Xaw139+rDtuTq3SLchrjCtK16JgXSYVInEzHLbGRjQsNV/n3msXtjs54j+66Ze uOPSBnI8JebdhF3EX+E0+p2tl7/69mI= X-MC-Unique: _ZsksWMTPNem5ip-dZ2NJw-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 5/9] gqa-win: get_pci_info: Split logic to separate functions Date: Mon, 10 Jan 2022 15:46:40 +0200 Message-Id: <20220110134644.107375-6-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641823556334100001 From: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 161 +++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 74 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index f6de9e2676..8588fa8633 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -512,6 +512,92 @@ DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, 0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); =20 +static void get_pci_address_for_device(GuestPCIAddress *pci, + HDEVINFO dev_info) +{ + SP_DEVINFO_DATA dev_info_data; + DWORD j; + DWORD size; + bool partial_pci =3D false; + + dev_info_data.cbSize =3D sizeof(SP_DEVINFO_DATA); + + for (j =3D 0; + SetupDiEnumDeviceInfo(dev_info, j, &dev_info_data); + j++) { + DWORD addr, bus, ui_slot, type; + int func, slot; + size =3D sizeof(DWORD); + + /* + * There is no need to allocate buffer in the next functions. The + * size is known and ULONG according to + * https://msdn.microsoft.com/en-us/library/windows/hardware/ff5430= 95(v=3Dvs.85).aspx + */ + if (!SetupDiGetDeviceRegistryProperty( + dev_info, &dev_info_data, SPDRP_BUSNUMBER, + &type, (PBYTE)&bus, size, NULL)) { + debug_error("failed to get PCI bus"); + bus =3D -1; + partial_pci =3D true; + } + + /* + * The function retrieves the device's address. This value will be + * transformed into device function and number + */ + if (!SetupDiGetDeviceRegistryProperty( + dev_info, &dev_info_data, SPDRP_ADDRESS, + &type, (PBYTE)&addr, size, NULL)) { + debug_error("failed to get PCI address"); + addr =3D -1; + partial_pci =3D true; + } + + /* + * This call returns UINumber of DEVICE_CAPABILITIES structure. + * This number is typically a user-perceived slot number. + */ + if (!SetupDiGetDeviceRegistryProperty( + dev_info, &dev_info_data, SPDRP_UI_NUMBER, + &type, (PBYTE)&ui_slot, size, NULL)) { + debug_error("failed to get PCI slot"); + ui_slot =3D -1; + partial_pci =3D true; + } + + /* + * SetupApi gives us the same information as driver with + * IoGetDeviceProperty. According to Microsoft: + * + * FunctionNumber =3D (USHORT)((propertyAddress) & 0x0000FFFF) + * DeviceNumber =3D (USHORT)(((propertyAddress) >> 16) & 0x0000FF= FF) + * SPDRP_ADDRESS is propertyAddress, so we do the same. + * + * https://docs.microsoft.com/en-us/windows/desktop/api/setupapi/nf= -setupapi-setupdigetdeviceregistrypropertya + */ + if (partial_pci) { + pci->domain =3D -1; + pci->slot =3D -1; + pci->function =3D -1; + pci->bus =3D -1; + continue; + } else { + func =3D ((int)addr =3D=3D -1) ? -1 : addr & 0x0000FFFF; + slot =3D ((int)addr =3D=3D -1) ? -1 : (addr >> 16) & 0x0000FFF= F; + if ((int)ui_slot !=3D slot) { + g_debug("mismatch with reported slot values: %d vs %d", + (int)ui_slot, slot); + } + pci->domain =3D 0; + pci->slot =3D (int)ui_slot; + pci->function =3D func; + pci->bus =3D (int)bus; + return; + } + } +} + static GuestPCIAddress *get_pci_info(int number, Error **errp) { HDEVINFO dev_info =3D INVALID_HANDLE_VALUE; @@ -522,7 +608,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) HANDLE dev_file; int i; GuestPCIAddress *pci =3D NULL; - bool partial_pci =3D false; =20 pci =3D g_malloc0(sizeof(*pci)); pci->domain =3D -1; @@ -545,7 +630,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) STORAGE_DEVICE_NUMBER sdn; char *parent_dev_id =3D NULL; SP_DEVINFO_DATA parent_dev_info_data; - DWORD j; DWORD size =3D 0; =20 g_debug("getting device path"); @@ -672,79 +756,8 @@ static GuestPCIAddress *get_pci_info(int number, Error= **errp) goto end; } =20 - for (j =3D 0; - SetupDiEnumDeviceInfo(parent_dev_info, j, &parent_dev_info_da= ta); - j++) { - DWORD addr, bus, ui_slot, type; - int func, slot; + get_pci_address_for_device(pci, parent_dev_info); =20 - /* - * There is no need to allocate buffer in the next functions. = The - * size is known and ULONG according to - * https://msdn.microsoft.com/en-us/library/windows/hardware/f= f543095(v=3Dvs.85).aspx - */ - if (!SetupDiGetDeviceRegistryProperty( - parent_dev_info, &parent_dev_info_data, SPDRP_BUSNUMBER, - &type, (PBYTE)&bus, size, NULL)) { - debug_error("failed to get PCI bus"); - bus =3D -1; - partial_pci =3D true; - } - - /* - * The function retrieves the device's address. This value wil= l be - * transformed into device function and number - */ - if (!SetupDiGetDeviceRegistryProperty( - parent_dev_info, &parent_dev_info_data, SPDRP_ADDRESS, - &type, (PBYTE)&addr, size, NULL)) { - debug_error("failed to get PCI address"); - addr =3D -1; - partial_pci =3D true; - } - - /* - * This call returns UINumber of DEVICE_CAPABILITIES structure. - * This number is typically a user-perceived slot number. - */ - if (!SetupDiGetDeviceRegistryProperty( - parent_dev_info, &parent_dev_info_data, SPDRP_UI_NUMBE= R, - &type, (PBYTE)&ui_slot, size, NULL)) { - debug_error("failed to get PCI slot"); - ui_slot =3D -1; - partial_pci =3D true; - } - - /* - * SetupApi gives us the same information as driver with - * IoGetDeviceProperty. According to Microsoft: - * - * FunctionNumber =3D (USHORT)((propertyAddress) & 0x0000FFF= F) - * DeviceNumber =3D (USHORT)(((propertyAddress) >> 16) & 0x0= 000FFFF) - * SPDRP_ADDRESS is propertyAddress, so we do the same. - * - * https://docs.microsoft.com/en-us/windows/desktop/api/setupa= pi/nf-setupapi-setupdigetdeviceregistrypropertya - */ - if (partial_pci) { - pci->domain =3D -1; - pci->slot =3D -1; - pci->function =3D -1; - pci->bus =3D -1; - continue; - } else { - func =3D ((int)addr =3D=3D -1) ? -1 : addr & 0x0000FFFF; - slot =3D ((int)addr =3D=3D -1) ? -1 : (addr >> 16) & 0x000= 0FFFF; - if ((int)ui_slot !=3D slot) { - g_debug("mismatch with reported slot values: %d vs %d", - (int)ui_slot, slot); - } - pci->domain =3D 0; - pci->slot =3D (int)ui_slot; - pci->function =3D func; - pci->bus =3D (int)bus; - break; - } - } break; } =20 --=20 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641822757; cv=none; d=zohomail.com; s=zohoarc; b=b3EhORIIA8HeBtXA6wS5XWf6NFL+I8PAG9bcG9Lri9jDrK7kXLcFPweWFQKxgvBwSdipxTLL1s+ZATOrxpOa3ikgZXk8wRXPvQu4+dchU8uJYbqWthULs6K8m7Ul3fRnPgOtm5VjUHSZ5vD2ZyV5DdsiS3xNeUKp0FX4vYdAaHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641822757; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=INkPE+Nwn2YIyU4WMhuqG3ay4pwb6QMnPEdGJng4ARs=; b=T3BzyagDHke8Aoz6e6PMXKjSub2VThu++pHyNZBXjB9+fMVWDRxLKUUpX5b8EHWtSJ3iP6W0Q3aspDKE1+VTvn8U3QSeRLHgrl7iFfBkijhvvjqorkx8Pjzbb4z/BoCsBPS26U6FRIub72ezM8plwgnNUBMJN+EIoU+MEYsNCFw= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641822757923199.2634184442129; Mon, 10 Jan 2022 05:52:37 -0800 (PST) Received: from localhost ([::1]:56238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6v6C-0000q9-Qk for importer@patchew.org; Mon, 10 Jan 2022 08:52:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0m-0002Ao-D1 for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0k-00071a-0c for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:00 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-G48DzG6-Ncu6l0mFUu-DUw-1; Mon, 10 Jan 2022 08:46:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FE6C81CCBD; Mon, 10 Jan 2022 13:46:55 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9D427BB5B; Mon, 10 Jan 2022 13:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822417; 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=INkPE+Nwn2YIyU4WMhuqG3ay4pwb6QMnPEdGJng4ARs=; b=NIEc3FUmMT8pIthTxlfTDc0+3/XKMwLOdSD/SXWs8hmmhoq+SWgNR6sBTw+lJX3z+IhAwB BjLOTSl7gp+nRO0GoMcTGImyua/o1dTZ6knUO5Dc1Xp185PMyJ4i5mRtEVNNeCi8pwJj9N 8F36MYhH4Do8r7tJOQTG4O67i7iOKzg= X-MC-Unique: G48DzG6-Ncu6l0mFUu-DUw-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 6/9] gqa-win: get_pci_info: Add g_autofree for few variables Date: Mon, 10 Jan 2022 15:46:41 +0200 Message-Id: <20220110134644.107375-7-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641822759316100001 From: Kostiantyn Kostiuk Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 8588fa8633..3092566313 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -626,9 +626,9 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) dev_info_data.cbSize =3D sizeof(SP_DEVINFO_DATA); dev_iface_data.cbSize =3D sizeof(SP_DEVICE_INTERFACE_DATA); for (i =3D 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++)= { - PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data =3D NULL; + g_autofree PSP_DEVICE_INTERFACE_DETAIL_DATA pdev_iface_detail_data= =3D NULL; STORAGE_DEVICE_NUMBER sdn; - char *parent_dev_id =3D NULL; + g_autofree char *parent_dev_id =3D NULL; SP_DEVINFO_DATA parent_dev_info_data; DWORD size =3D 0; =20 @@ -654,7 +654,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) dev_file =3D CreateFile(pdev_iface_detail_data->DevicePath, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - g_free(pdev_iface_detail_data); =20 if (!DeviceIoControl(dev_file, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn), &size, NULL))= { @@ -741,7 +740,6 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) parent_dev_info =3D SetupDiGetClassDevs(&GUID_DEVINTERFACE_STORAGEPORT, parent_dev= _id, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFAC= E); - g_free(parent_dev_id); =20 if (parent_dev_info =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), --=20 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641823119; cv=none; d=zohomail.com; s=zohoarc; b=DGHG6OsFdBULKMvUBaQoVEgYGLaOzTBwGxSGhfMpBwNWK4Fx1FfoCsuKROpE9YzQQPZ7Nbw0a3oUyeMWpNxx9+7EHLuoP+1hFf2wvjYewkWEV/IYw9XlRCZDPQxcHKFEHv7qHYic5kDd+qNUtoq6JcfDiqq/fnVSQUurafXxSY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641823119; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gxyTMSHPbovkP19pWuJszzL337mGlIXOIGMkFvAaUvM=; b=ejqn5XzcxPGbP0Om0WuoNF60ryt75l2t4IAdvJBi2RwZgFBcz6tqtWZroivd2BHk1Z/M9HLqKNh+BcwuWU3eEtSM2qVb9TvWO251ffB9C0kzghpGk4wq/AnAcIiwWcfe8wrNpXL8aMK3XwMdAS2CGxPI6xNPFeIvzCQ0cA086lQ= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641823119647882.7781545452449; Mon, 10 Jan 2022 05:58:39 -0800 (PST) Received: from localhost ([::1]:37686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6vC2-0007tX-Hq for importer@patchew.org; Mon, 10 Jan 2022 08:58:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0n-0002HF-FJ for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0l-00072O-Ju for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-h5MxguDGMPCcBUX592PuCw-1; Mon, 10 Jan 2022 08:46:57 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D98F18B613F; Mon, 10 Jan 2022 13:46:57 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1366D7BB41; Mon, 10 Jan 2022 13:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822418; 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=gxyTMSHPbovkP19pWuJszzL337mGlIXOIGMkFvAaUvM=; b=SynTiL66s8Y547LQ8q4qeWevIH7PDh5z66/sXc1iInD/JuZxzdE2dl826K2gnHqU3JXp6a A0ey9oyHdHbMjMUz9zpSew7VI3vHnqpoIOCNUwiTPqx8UZ/QyhTez3xflqy+F066/QM+sa FiSkOXcyIn6XqZ3bhOiqzqF3DDlrvmg= X-MC-Unique: h5MxguDGMPCcBUX592PuCw-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 7/9] gqa-win: get_pci_info: Replace 'while' with 2 calls of the function Date: Mon, 10 Jan 2022 15:46:42 +0200 Message-Id: <20220110134644.107375-8-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641823122095100005 From: Kostiantyn Kostiuk Microsoft suggests this solution in the documentation: https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-set= updigetdeviceinterfacedetaila Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 3092566313..892082504f 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -636,10 +636,10 @@ static GuestPCIAddress *get_pci_info(int number, Erro= r **errp) if (SetupDiEnumDeviceInterfaces(dev_info, &dev_info_data, &GUID_DEVINTERFACE_DISK, 0, &dev_iface_data)) { - while (!SetupDiGetDeviceInterfaceDetail(dev_info, &dev_iface_d= ata, - pdev_iface_detail_data, - size, &size, - &dev_info_data)) { + if (!SetupDiGetDeviceInterfaceDetail(dev_info, &dev_iface_data, + pdev_iface_detail_data, + size, &size, + &dev_info_data)) { if (GetLastError() =3D=3D ERROR_INSUFFICIENT_BUFFER) { pdev_iface_detail_data =3D g_malloc(size); pdev_iface_detail_data->cbSize =3D @@ -651,6 +651,16 @@ static GuestPCIAddress *get_pci_info(int number, Error= **errp) } } =20 + if (!SetupDiGetDeviceInterfaceDetail(dev_info, &dev_iface_data, + pdev_iface_detail_data, + size, &size, + &dev_info_data)) { + // pdev_iface_detail_data already is allocated + error_setg_win32(errp, GetLastError(), + "failed to get device interfaces"); + goto end; + } + dev_file =3D CreateFile(pdev_iface_detail_data->DevicePath, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); @@ -680,8 +690,8 @@ static GuestPCIAddress *get_pci_info(int number, Error = **errp) ULONG dev_id_size =3D 0; =20 size =3D 0; - while (!SetupDiGetDeviceInstanceId(dev_info, &dev_info_data, - parent_dev_id, size, &size)= ) { + if (!SetupDiGetDeviceInstanceId(dev_info, &dev_info_data, + parent_dev_id, size, &size)) { if (GetLastError() =3D=3D ERROR_INSUFFICIENT_BUFFER) { parent_dev_id =3D g_malloc(size); } else { @@ -691,6 +701,14 @@ static GuestPCIAddress *get_pci_info(int number, Error= **errp) } } =20 + if (!SetupDiGetDeviceInstanceId(dev_info, &dev_info_data, + parent_dev_id, size, &size)) { + // parent_dev_id already is allocated + error_setg_win32(errp, GetLastError(), + "failed to get device instance ID"); + goto end; + } + /* * CM API used here as opposed to * SetupDiGetDeviceProperty(..., DEVPKEY_Device_Parent, ...) --=20 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641823311; cv=none; d=zohomail.com; s=zohoarc; b=TMaO4d4Z9PLpRNF/C7zSUVdu09jrFVPLV8JiLnnBgPnTBGIZg04HF9B0C28Bhyj3K15tf5hKSaGPSt2KWafdZUqUgOM/HpRttoZH7LtPAIH9Mj15567O8brGTwY9hf+3cDFHfk5YjWNPiFsBsXwdxuBuD7HPhZoH7cs+sm64GTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641823311; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B/PuiaiPTEsCHacu0SBkdgDPgiVpur/KjjkCy3lBTeA=; b=m2x756UUazo02MXbIzEUsuVJ2IVXFWQ90tL3yjO0OLFAXrxWp02mekkia433QUxRmOGFEVpZsSbQAApvl12ClSeb+6ml6zVgXIH3R7cyB5oyneafT0uvO/oBcvS3A+HsBP+9ubJTyp4QzMOQGiGS2LXtWW7yrlDjriT8avIie00= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641823311217423.2081896063527; Mon, 10 Jan 2022 06:01:51 -0800 (PST) Received: from localhost ([::1]:43240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6vF8-0003Kr-4J for importer@patchew.org; Mon, 10 Jan 2022 09:01:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0o-0002MV-Fl for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0m-00073E-Mx for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:02 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-ZdBV6euUObihQaRL8Wl7RQ-1; Mon, 10 Jan 2022 08:46:59 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4660681CCB7; Mon, 10 Jan 2022 13:46:58 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 609487BB41; Mon, 10 Jan 2022 13:46:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822420; 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=B/PuiaiPTEsCHacu0SBkdgDPgiVpur/KjjkCy3lBTeA=; b=e8K+ZWTT8VuRYUxg8FuTXx/r3FWC5oATBd7/e/d6xPiwTFndWm8N9rqbJnFIQmyI/f5RNH N5JCKGa4XDZZurteUobBFkzxGERIgWyE/Q8XeLrURBA7SCZiO+u8thglQPO0RXTmBUm+9u aq3u8Ctq5tm5dN3p9Goohvf7/IUOUFs= X-MC-Unique: ZdBV6euUObihQaRL8Wl7RQ-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 8/9] qga-win: Detect OS based on Windows 10 by first build number Date: Mon, 10 Jan 2022 15:46:43 +0200 Message-Id: <20220110134644.107375-9-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641823316612100005 From: Kostiantyn Kostiuk Windows Server 2016, 2019, 2022 are based on Windows 10 and have the same major and minor versions. So, the only way to detect the proper version is to use the build number. Before this commit, the guest agent use the last build number for each OS, but it causes problems when new OS releases. There are few preview versions before release, and we can't update this list. After this commit, the guest agent will use the first build number. For each new preview version or release version, Microsoft increases the build number, so we can add the number of the first preview build and this will work until the new OS release. Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 892082504f..3f60419419 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -2195,7 +2195,7 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2]= [8] =3D { }; =20 typedef struct _ga_win_10_0_server_t { - int final_build; + int first_build; char const *version; char const *version_id; } ga_win_10_0_server_t; @@ -2235,18 +2235,22 @@ static char *ga_get_win_name(OSVERSIONINFOEXW const= *os_version, bool id) int tbl_idx =3D (os_version->wProductType !=3D VER_NT_WORKSTATION); ga_matrix_lookup_t const *table =3D WIN_VERSION_MATRIX[tbl_idx]; ga_win_10_0_server_t const *win_10_0_table =3D WIN_10_0_SERVER_VERSION= _MATRIX; + ga_win_10_0_server_t const *win_10_0_version =3D NULL; while (table->version !=3D NULL) { if (major =3D=3D 10 && minor =3D=3D 0 && tbl_idx) { while (win_10_0_table->version !=3D NULL) { - if (build <=3D win_10_0_table->final_build) { - if (id) { - return g_strdup(win_10_0_table->version_id); - } else { - return g_strdup(win_10_0_table->version); - } + if (build >=3D win_10_0_table->first_build) { + win_10_0_version =3D win_10_0_table; } win_10_0_table++; } + if (win_10_0_table) { + if (id) { + return g_strdup(win_10_0_version->version_id); + } else { + return g_strdup(win_10_0_version->version); + } + } } else if (major =3D=3D table->major && minor =3D=3D table->minor)= { if (id) { return g_strdup(table->version_id); --=20 2.25.1 From nobody Mon Apr 29 23:52:17 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641823552; cv=none; d=zohomail.com; s=zohoarc; b=NS553G2W+xJSEa2y//ut0Rzu/2nDubZKXRJ+zSXBKMlxNrxjuUgyC3P2IhuC3XT5CkNj/S43zFVrS5oJ5ehT2zAdwQAqaccFC/S055zEFLzemTstGxlg7670Vhm2vjUxUa9srftC2T453dhkT788uC7VQQp6Liz3Q6IL4Bk+Xt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641823552; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IcTXArrUysVq5WZf7Ot3TfG9SgPurVupPsFDLKdzNZ8=; b=PXZfp2wjG7rYabCcfA0R3/4tJuyEUOiYvuT7lwUuTMC8AzeTXu/tfzkWi/Zw+4UrgC6dDTy/x4JO3eacuISLo7cxR6oU7477pPlGUigLVZRXCc45unrjYlTUzNwqPFGTUBBoCSK3lZ7NqyrD9BxL5x5vxnrroukxs2sfshbd7Nw= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164182355288862.49154160712965; Mon, 10 Jan 2022 06:05:52 -0800 (PST) Received: from localhost ([::1]:47836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6vJ0-0006gC-DP for importer@patchew.org; Mon, 10 Jan 2022 09:05:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0q-0002VO-33 for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6v0o-000751-9I for qemu-devel@nongnu.org; Mon, 10 Jan 2022 08:47:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-512-OGRqbuqsMi2HEtfiEmMBWA-1; Mon, 10 Jan 2022 08:47:00 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9417583DD21; Mon, 10 Jan 2022 13:46:59 +0000 (UTC) Received: from kostyanf14nb.Dlink (unknown [10.40.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE3D57BB41; Mon, 10 Jan 2022 13:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641822421; 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=IcTXArrUysVq5WZf7Ot3TfG9SgPurVupPsFDLKdzNZ8=; b=SgPJ3QdonmDfKgYua/Lp8Xkps70bvVkI1PEc+Wxt/4JFhpylHkEeCPCIqHSURjw1PPEjKo RUB4uKrL5CzNy89udvzryQSn7rR74fnKl6W1XbcnDS2SbJPzKlbJdupqqUKED01OTE5qKu cXs4ft83KuJ+N2LCkKdgo5yqOIA8zN8= X-MC-Unique: OGRqbuqsMi2HEtfiEmMBWA-1 From: Konstantin Kostiuk To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 9/9] qga-win: Detect Windows 11 by build number Date: Mon, 10 Jan 2022 15:46:44 +0200 Message-Id: <20220110134644.107375-10-kkostiuk@redhat.com> In-Reply-To: <20220110134644.107375-1-kkostiuk@redhat.com> References: <20220110134644.107375-1-kkostiuk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kkostiuk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=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: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.597, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641823554073100001 From: Kostiantyn Kostiuk Windows 10 and 11 have the same major and minor versions. So, the only way to determine the correct version is to use the build number. After this commit, the guest agent will return the proper "version" and "version-id" for Windows 11. The "pretty-name" is read from the registry and will be incorrect until the MS updates the registry. We only can create some workaround and replace 10 to 11. Signed-off-by: Kostiantyn Kostiuk Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Kostiantyn Kostiuk --- qga/commands-win32.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 3f60419419..484cb1c6bd 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -2170,7 +2170,7 @@ typedef struct _ga_matrix_lookup_t { char const *version_id; } ga_matrix_lookup_t; =20 -static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][8] =3D { +static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][7] =3D { { /* Desktop editions */ { 5, 0, "Microsoft Windows 2000", "2000"}, @@ -2179,7 +2179,6 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2]= [8] =3D { { 6, 1, "Microsoft Windows 7" "7"}, { 6, 2, "Microsoft Windows 8", "8"}, { 6, 3, "Microsoft Windows 8.1", "8.1"}, - {10, 0, "Microsoft Windows 10", "10"}, { 0, 0, 0} },{ /* Server editions */ @@ -2189,24 +2188,29 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[= 2][8] =3D { { 6, 2, "Microsoft Windows Server 2012", "2012"}, { 6, 3, "Microsoft Windows Server 2012 R2", "2012r2"}, { 0, 0, 0}, - { 0, 0, 0}, { 0, 0, 0} } }; =20 -typedef struct _ga_win_10_0_server_t { +typedef struct _ga_win_10_0_t { int first_build; char const *version; char const *version_id; -} ga_win_10_0_server_t; +} ga_win_10_0_t; =20 -static ga_win_10_0_server_t const WIN_10_0_SERVER_VERSION_MATRIX[4] =3D { +static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[4] =3D { {14393, "Microsoft Windows Server 2016", "2016"}, {17763, "Microsoft Windows Server 2019", "2019"}, {20344, "Microsoft Windows Server 2022", "2022"}, {0, 0} }; =20 +static ga_win_10_0_t const WIN_10_0_CLIENT_VERSION_MATRIX[3] =3D { + {10240, "Microsoft Windows 10", "10"}, + {22000, "Microsoft Windows 11", "11"}, + {0, 0} +}; + static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp) { typedef NTSTATUS(WINAPI *rtl_get_version_t)( @@ -2234,10 +2238,11 @@ static char *ga_get_win_name(OSVERSIONINFOEXW const= *os_version, bool id) DWORD build =3D os_version->dwBuildNumber; int tbl_idx =3D (os_version->wProductType !=3D VER_NT_WORKSTATION); ga_matrix_lookup_t const *table =3D WIN_VERSION_MATRIX[tbl_idx]; - ga_win_10_0_server_t const *win_10_0_table =3D WIN_10_0_SERVER_VERSION= _MATRIX; - ga_win_10_0_server_t const *win_10_0_version =3D NULL; + ga_win_10_0_t const *win_10_0_table =3D tbl_idx ? + WIN_10_0_SERVER_VERSION_MATRIX : WIN_10_0_CLIENT_VERSION_MATRIX; + ga_win_10_0_t const *win_10_0_version =3D NULL; while (table->version !=3D NULL) { - if (major =3D=3D 10 && minor =3D=3D 0 && tbl_idx) { + if (major =3D=3D 10 && minor =3D=3D 0) { while (win_10_0_table->version !=3D NULL) { if (build >=3D win_10_0_table->first_build) { win_10_0_version =3D win_10_0_table; --=20 2.25.1