From patchwork Tue Jun 26 15:10:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 10489347 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25F7260386 for ; Tue, 26 Jun 2018 15:13:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14A6B25F3E for ; Tue, 26 Jun 2018 15:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 097E226D05; Tue, 26 Jun 2018 15:13:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 982812625B for ; Tue, 26 Jun 2018 15:13:43 +0000 (UTC) Received: from localhost ([::1]:53273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXpf4-0005ud-TH for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Jun 2018 11:13:42 -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) 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) 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) 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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) dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA); for (i = 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_NAME, &data, (PBYTE)buffer, size, @@ -535,21 +536,21 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) { - break; + bus = -1; } /* 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 = -1; } /* 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 = -1; } /* SetupApi gives us the same information as driver with @@ -559,12 +560,12 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) * DeviceNumber = (USHORT)(((propertyAddress) >> 16) & 0x0000FFFF); * SPDRP_ADDRESS is propertyAddress, so we do the same.*/ - func = addr & 0x0000FFFF; - dev = (addr >> 16) & 0x0000FFFF; + func = ((int) addr == -1) ? -1 : addr & 0x0000FFFF; + dev = ((int) addr == -1) ? -1 : (addr >> 16) & 0x0000FFFF; pci->domain = dev; - pci->slot = slot; + pci->slot = (int) slot; pci->function = func; - pci->bus = bus; + pci->bus = (int) bus; break; }