From nobody Wed Nov 5 11:06:32 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; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540293950779374.5193301590732; Tue, 23 Oct 2018 04:25:50 -0700 (PDT) Received: from localhost ([::1]:40278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuoi-00030I-Gz for importer@patchew.org; Tue, 23 Oct 2018 07:25:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumi-0001qW-3l for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumg-0007i0-1w for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:39 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36631) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumc-0007c8-UQ for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:36 -0400 Received: by mail-wr1-f65.google.com with SMTP id y16so1273737wrw.3 for ; Tue, 23 Oct 2018 04:23:33 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:31 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=gqgs3CiWI32X5dBjLd2AqB9RFIURkIv0v+aWB/iqlEY=; b=hoOjrSOFvYkMEI//ddvFlW9WHx+IwBJj2cz/ZWDvP+vojCmhCFmbKQD9Y0m3mP6jv2 i6OpiJdHVUQtmS1DjR7L2cUqDQHcUEfaQbbuO6Hpsm8JtQVhSfoQdZCunLGZ1ng/dsrX 84YoCKpR+gt46SsFPO3admjNCGdyZn+vmeBQSJHNpndoyY0kGVqiSy3oLUdquIqGTNMX B/icuqhFBHY4TxCoWydU27Ga+o1Ikbu20DzH9n4Qa29dpnOB1f3dJwvF3UXFAm5/F3Oj tKyP5qcsNbsmkxGjU9NgVF7c7nzLhdhaPPmqdlH3duxwt6xdhNAXUrB8R1hXejcf344H NZqg== X-Gm-Message-State: ABuFfohy5RyT/l336uGO/KPrDWBZQcCySTwLB5a/WKHqL1+KHl9uQWvv 9l1HbyaHFw8hmWFEYNheoGYJX4MEMJM= X-Google-Smtp-Source: ACcGV631yUNcqsdrqLfVPhHCkbbjkfmncFSjuWJkZX+7pgak/41WF9mvprYrWeRs96/w/o/sfDwxBA== X-Received: by 2002:a5d:5342:: with SMTP id t2-v6mr48454964wrv.257.1540293812073; Tue, 23 Oct 2018 04:23:32 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:14 +0200 Message-Id: <424c3de694d06531e3b21e5d965b4b7f7d7be190.1540293795.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.65 Subject: [Qemu-devel] [PATCH v5 05/14] 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 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 Signed-off-by: Michael Roth (cherry picked from commit d42f51de2d10b318d396f4f439f7a3995fdc0f65) Signed-off-by: Michael Roth Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- 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 8289e7d6ea..a8967abf06 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.19.0