From nobody Sun Feb 8 17:21:29 2026 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 15409970254199.427193076048866; Wed, 31 Oct 2018 07:43:45 -0700 (PDT) Received: from localhost ([::1]:60001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHrii-00005U-2g for importer@patchew.org; Wed, 31 Oct 2018 10:43:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHrNM-0001U2-UB for qemu-devel@nongnu.org; Wed, 31 Oct 2018 10:21:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHrNF-0007Yv-OW for qemu-devel@nongnu.org; Wed, 31 Oct 2018 10:21:40 -0400 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]:44769) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHrND-0007Tg-9L for qemu-devel@nongnu.org; Wed, 31 Oct 2018 10:21:31 -0400 Received: by mail-ot1-x330.google.com with SMTP id p23so14663960otf.11 for ; Wed, 31 Oct 2018 07:21:20 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id o189-v6sm7391722oih.15.2018.10.31.07.21.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 07:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jqJy8O/Q/q3DF/vRTGPc19Bl200H+tWJBLN5cD9F4O8=; b=NddRb8ca1Spd7L8C4nr8hkNwYu+RHyWTJXiCjzCorIWql/E19ZQ+JLlxAnUUmsSNvy asS7n0f+MXXq8C0PU6vtzmfGn1C+47X4i3+V6Hn7ExWIUxgSPO3dV2/C/j7oSrDN9ASQ j0+gGODAJCOSRIiDUZVWbtJrjjJMR2MVQGKLllGhWa085aBKTlWm3wwyGHqetR6mjGWN EGFN8SG41irKzXDm2pva6horjhRqVcsEsWPCGEpjCXPj3nI8vhbhznYkEg0Z9q0kRyFl uCMCi5FUAcSg4lhgo5J6Cu+SK7VQzxe1isZcAVtNH4GRbQSFk3lI2pJvTqbxLq7ze2Tw 03Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jqJy8O/Q/q3DF/vRTGPc19Bl200H+tWJBLN5cD9F4O8=; b=EUFhX7SfWIntym9FHhDzFvTxwpSvKYrzY2KrJ3XAZE6/wgP6053h021Aov5jMxTybW ehREGtPJ4zn1G6CCdVd0MalehG1Seex2YRbC5S9x8qyOENeWNq7aW05imF6yb12mixoQ LXJhxEdn6R1cdDLUY8K0WVoS4ptXlFRBoxW+QxojOqa/48yRGN6PLGZHMxJbFjTwZu7b 714nJQ20IkPYb6Cy1pSFqnkIx5NO74p48xoK4GIG9puKEMAMDzJzixbVEM/LHrbscc+R uyDiJeTcrgjyP3jgYmiUZRKDy2VRAFiikqQVBZNSAoeefXgny5GkvaifBJmWY7KgobXK H3RQ== X-Gm-Message-State: AGRZ1gIeyNE0iXVL7Hi2nQcQRj0IToXcrVGF5QDSYWsZqOgHX0e4zYkd RTf1YyNvSxYPFCq5Us6U4UqPLb1Y X-Google-Smtp-Source: AJdET5f+E8dzEAWnYuSeKb+Ko5XGkrgevGe0vOIyDGEfPvUwh8mEywiAegqKER0QSSic8UqBDrTuBA== X-Received: by 2002:a9d:2ff1:: with SMTP id b46mr1857603otd.69.1540995679013; Wed, 31 Oct 2018 07:21:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2018 09:19:09 -0500 Message-Id: <20181031141925.30026-9-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031141925.30026-1-mdroth@linux.vnet.ibm.com> References: <20181031141925.30026-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::330 Subject: [Qemu-devel] [PULL v3 08/24] 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: Sameeh Jubran , peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD *squash in fix for when get_pci_info() returns NULL pci_controller field *fix handling for error_set() cases in get_pci_info(), not just NULL return *force all -1 PCI addr fields if any single one of them isn't found Signed-off-by: Michael Roth --- qga/commands-win32.c | 46 +++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index f0e6f6128b..4fe1517778 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -499,6 +499,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) char *buffer =3D NULL; GuestPCIAddress *pci =3D NULL; char *name =3D g_strdup(&guid[4]); + bool partial_pci =3D false; pci =3D g_malloc0(sizeof(*pci)); pci->domain =3D -1; pci->slot =3D -1; @@ -519,7 +520,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, @@ -549,21 +551,24 @@ 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; + partial_pci =3D true; } =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; + partial_pci =3D true; } =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; + partial_pci =3D true; } =20 /* SetupApi gives us the same information as driver with @@ -573,12 +578,19 @@ 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; - pci->domain =3D dev; - pci->slot =3D slot; - pci->function =3D func; - pci->bus =3D bus; + if (partial_pci) { + pci->domain =3D -1; + pci->slot =3D -1; + pci->function =3D -1; + pci->bus =3D -1; + } else { + func =3D ((int) addr =3D=3D -1) ? -1 : addr & 0x0000FFFF; + dev =3D ((int) addr =3D=3D -1) ? -1 : (addr >> 16) & 0x0000FFF= F; + pci->domain =3D dev; + pci->slot =3D (int) slot; + pci->function =3D func; + pci->bus =3D (int) bus; + } break; } =20 @@ -622,6 +634,7 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) DWORD len; int bus; HANDLE vol_h; + Error *local_err =3D NULL; =20 scsi_ad =3D &addr; char *name =3D g_strndup(guid, strlen(guid)-1); @@ -640,6 +653,16 @@ static GuestDiskAddressList *build_guest_disk_info(cha= r *guid, Error **errp) =20 disk =3D g_malloc0(sizeof(*disk)); disk->bus_type =3D find_bus_type(bus); + /* always set pci_controller as required by schema. get_pci_info() sho= uld + * report -1 values for non-PCI buses rather than fail. fail the comma= nd + * if that doesn't hold since that suggests some other unexpected + * breakage + */ + disk->pci_controller =3D get_pci_info(name, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto out_close; + } if (bus =3D=3D BusTypeScsi || bus =3D=3D BusTypeAta || bus =3D=3D BusT= ypeRAID #if (_WIN32_WINNT >=3D 0x0600) /* This bus type is not supported before Windows Server 2003 S= P1 */ @@ -654,12 +677,9 @@ static GuestDiskAddressList *build_guest_disk_info(cha= r *guid, Error **errp) disk->unit =3D addr.Lun; disk->target =3D addr.TargetId; disk->bus =3D addr.PathId; - disk->pci_controller =3D get_pci_info(name, errp); } /* We do not set error in this case, because we still have enough * information about volume. */ - } else { - disk->pci_controller =3D NULL; } =20 list =3D g_malloc0(sizeof(*list)); --=20 2.17.1