From nobody Tue Nov 4 10:51:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530025943601333.8758286281345; Tue, 26 Jun 2018 08:12:23 -0700 (PDT) Received: from localhost ([::1]:53256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXpdm-0004an-Kz for importer@patchew.org; Tue, 26 Jun 2018 11:12:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXpcK-0003lP-71 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXpcI-00089h-0N for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:52 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:34899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXpcH-00089U-Pg for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:49 -0400 Received: by mail-wm0-x242.google.com with SMTP id z137-v6so2266299wmc.0 for ; Tue, 26 Jun 2018 08:10:49 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id w15-v6sm2503195wrn.25.2018.06.26.08.10.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references:list-id; bh=ZVaOzqfyhhX8JKzKWx9VG/TC/Y2N7teO00dnPfYCNkQ=; b=iKOk4swN4yiJbbECYXyg5RBKDckjTZ56T3dWr0H3WM3XBmRGcOPlXHJ24H3JKcx1b5 qrOKzKovP1/8Y1PTKvlNhZnVanRQuoUbu93OeeY/X/J18Ahj1+GRPyUcNhKmL9fTPohA FhvF4R9k+f7KEiGkxByPfhstTcAAGZHHTr4BNwuOCRqf65jZTglLEiUClaN1rQ6lnKnI iCnAWMNbuYV9hjqRYN8vKxcmBzibMuaXtMwmrC03Fh1eJgjK8/32cwpr0yrQoDjxw4S6 /BpwPvVrMIutGeWt1wY51fuq1GY8e3NHxly6iPs5ZJA9xlmt4oHPtR2Imrnlka7DD3qO wSJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:list-id; bh=ZVaOzqfyhhX8JKzKWx9VG/TC/Y2N7teO00dnPfYCNkQ=; b=ffR6sALGpFhZkOXAyvjhnuDlhU6pBTir7VpwNG8DtwWAiNOXabVY94hzJzcUvyUY0E 7DTAgq/w8yr0DIvxyv+XF5JzRKf0IOkgPvuO72IzwdDAw/1jr74JoQYxMmFXec+6RvTy kIhdYPBsUVI5zxUJZPxmszj63N81xteuw+UvZcHDl9Pam6h0bbIMaerHBDi/TVhfy0aY NgQEI9sUcEaA2snITL2hXWx2GjRwWxR1xX2qOGClgrZFYMKjhrlk6Gd4x2rdFD4uvWtS dxVOYoRf0u1rIxGB6RnaXbfRSi4TwZ0KJ/ZJPMZVsOXl/9WByDD6vraZ/9Lhxj0XJNX3 BFBQ== X-Gm-Message-State: APt69E1kcNdbbeRDHTP9WBpNLveBb6CZ0gXPJnJqAR+6CzcR1ayHASXL 56CPpkTlCIiGPxr88jbRlsiCNvF6 X-Google-Smtp-Source: AAOMgpcsNEY1su1ngOpp4KdyG01HbZFfm9E8/8Vs+NXStxYCnIKSV2K/0rKygeOejBYchKejmCrBBA== X-Received: by 2002:a1c:d287:: with SMTP id j129-v6mr1869944wmg.106.1530025848732; Tue, 26 Jun 2018 08:10:48 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 18:10:37 +0300 Message-Id: <20180626151038.24771-2-sameeh@daynix.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180626151038.24771-1-sameeh@daynix.com> References: <20180626151038.24771-1-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PATCH 1/2] qga-win: prevent crash when executing fsinfo command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sameeh Jubran The fsinfo command is currently implemented for Windows only and it's disk parameter can be enabled by adding the define "CONFIG_QGA_NTDDSCSI" to the = qga code. When enabled and executed the qemu-ga crashed with the following mess= age: Reviewed-by: Philippe Mathieu-Daud=C3=A9 ------------------------------------------------ File qapi/qapi-visit-core.c, Line 49 Expression: !(v->type & VISITOR_OUTPUT) || *obj) ------------------------------------------------ After some digging, turns out that the GuestPCIAddress is null and the qapi visitor doesn't like that, so we can always allocate it instead and initiate all it's members to -1. Signed-off-by: Sameeh Jubran --- qga/commands-win32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 2d48394748..c5f1c884e1 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -485,6 +485,11 @@ static GuestPCIAddress *get_pci_info(char *guid, Error= **errp) char *buffer =3D NULL; GuestPCIAddress *pci =3D NULL; char *name =3D g_strdup(&guid[4]); + pci =3D g_malloc0(sizeof(*pci)); + pci->domain =3D -1; + pci->slot =3D -1; + pci->function =3D -1; + pci->bus =3D -1; =20 if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) { error_setg_win32(errp, GetLastError(), "failed to get dos device n= ame"); @@ -556,7 +561,6 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) =20 func =3D addr & 0x0000FFFF; dev =3D (addr >> 16) & 0x0000FFFF; - pci =3D g_malloc0(sizeof(*pci)); pci->domain =3D dev; pci->slot =3D slot; pci->function =3D func; --=20 2.13.6 From nobody Tue Nov 4 10:51:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530026036139539.0103478972859; Tue, 26 Jun 2018 08:13:56 -0700 (PDT) Received: from localhost ([::1]:53273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXpfH-0005ud-G5 for importer@patchew.org; Tue, 26 Jun 2018 11:13:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXpcK-0003lO-6t for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXpcJ-0008A9-A6 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:52 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:54820) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXpcJ-00089r-3U for qemu-devel@nongnu.org; Tue, 26 Jun 2018 11:10:51 -0400 Received: by mail-wm0-x244.google.com with SMTP id i139-v6so2365573wmf.4 for ; Tue, 26 Jun 2018 08:10:51 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id w15-v6sm2503195wrn.25.2018.06.26.08.10.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 08:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references:list-id; bh=/O4gma0E9dqpQ1h1/RSYqN4OIOlPX6c9jt2SLCqU6Vw=; b=MEWBdFYa3WqSC1KCwDVl+6YD7xr0O9QyvgzcY/STi1KOTM7Zh+2MszGYrPKDzYsy7d D4O1Ts1VM51ISzWR7Lccnpeyum/g0qGrN0mISxeaJMAQFHPvVKAcLEmhXXchTxmNhU69 0hFCKZTmwRNBEAnkDSz28q0hUWtYk5fHn52w6Bm8MGrro+c1c+n3Oip2EIjKT+2oovQo EYSRyGTULVBKHY+0KqA/H2RbF5751IyK6CLaH9t7D7C6xPqszKzLhEABnZpH4zak0IVZ 0/9W7ZWL8mLtpAa5SolETHJ3yXSOc2NVKJrNoy9AUjpuG2Qff5yopWbqc3ca/Ro+SEq6 8C4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:list-id; bh=/O4gma0E9dqpQ1h1/RSYqN4OIOlPX6c9jt2SLCqU6Vw=; b=ZkaxhZwF9YZ9Mifnr9FwxJ9zlkapCeiEZt5P/Y0YXIK1u5PZsm5dA6rhcIhR8vflgP VyKSlYNrNoBkZNvd1+L8EqrRqJBSR9MSpjuW6SyhpZJYJBuddGLtdVtJ54uBD/3CxzOw FOqfuJNSMlA6Mq4nOe2ivISdytwwzSoR+3Kn0zTh23VMDqn4VdxexuvsaQOPz0as4Lvz X7zqjejiblcgx8WWoLcZ0ZLKskao57T86YLtte4asb6ghywhSfsCkwkWBYIwlqs4e+m4 lu1f06OoPCgeryIyhwVc0+VJt9W6EdtHWH/NpQi4JOiKp78FG13yjlbJ+RUXdW3PQ3oe olQg== X-Gm-Message-State: APt69E3F2em1Ayyrz2ojVKHT2g4AJV8I8cgZNtqyDjMYDbX8MG0vKgoo bJjYNpD94G+gKwmYW4pbN5a1xMRl X-Google-Smtp-Source: AAOMgpdthXbKDLeqZWde+o53DW3xotUiSfKiD6LWviaIocef/uFpOql52Rx0YXrfxw15w8SMXyhuvw== X-Received: by 2002:a1c:1695:: with SMTP id 143-v6mr1941343wmw.12.1530025849975; Tue, 26 Jun 2018 08:10:49 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org Date: Tue, 26 Jun 2018 18:10:38 +0300 Message-Id: <20180626151038.24771-3-sameeh@daynix.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180626151038.24771-1-sameeh@daynix.com> References: <20180626151038.24771-1-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH 2/2] qga-win: fsinfo: pci-info: allow partial info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sameeh Jubran The call to SetupDiGetDeviceRegistryProperty might fail because the value doesn't exist in the registry, in this case we shouldn't exit from the loop but instead continue to look for other available values in the registry and set this value as unavailable (-1). Signed-off-by: Sameeh Jubran --- qga/commands-win32.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index c5f1c884e1..55e460dee3 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -505,7 +505,8 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) =20 dev_info_data.cbSize =3D sizeof(SP_DEVINFO_DATA); for (i =3D 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++)= { - DWORD addr, bus, slot, func, dev, data, size2; + DWORD addr, bus, slot, data, size2; + int func, dev; while (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_PHYSICAL_DEVICE_OBJECT_N= AME, &data, (PBYTE)buffer, size, @@ -535,21 +536,21 @@ static GuestPCIAddress *get_pci_info(char *guid, Erro= r **errp) */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) { - break; + bus =3D -1; } =20 /* 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, &data, (PBYTE)&addr, size, NULL)) { - break; + addr =3D -1; } =20 /* 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, &data, (PBYTE)&slot, size, NULL)) { - break; + slot =3D -1; } =20 /* SetupApi gives us the same information as driver with @@ -559,12 +560,12 @@ static GuestPCIAddress *get_pci_info(char *guid, Erro= r **errp) * DeviceNumber =3D (USHORT)(((propertyAddress) >> 16) & 0x0000FFF= F); * SPDRP_ADDRESS is propertyAddress, so we do the same.*/ =20 - func =3D addr & 0x0000FFFF; - dev =3D (addr >> 16) & 0x0000FFFF; + func =3D ((int) addr =3D=3D -1) ? -1 : addr & 0x0000FFFF; + dev =3D ((int) addr =3D=3D -1) ? -1 : (addr >> 16) & 0x0000FFFF; pci->domain =3D dev; - pci->slot =3D slot; + pci->slot =3D (int) slot; pci->function =3D func; - pci->bus =3D bus; + pci->bus =3D (int) bus; break; } =20 --=20 2.13.6