From nobody Thu Nov 6 12:14:37 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 1540951206148445.01006490165787; Tue, 30 Oct 2018 19:00:06 -0700 (PDT) Received: from localhost ([::1]:56685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHfng-0003ty-ST for importer@patchew.org; Tue, 30 Oct 2018 22:00:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHfVQ-000103-UL for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:41:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHfVP-0002fz-Mx for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:41:12 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:33436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHfVP-0002fd-Gm for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:41:11 -0400 Received: by mail-qt1-x82b.google.com with SMTP id i15-v6so16014497qtr.0 for ; Tue, 30 Oct 2018 18:41:11 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 34-v6sm9722204qty.58.2018.10.30.18.41.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 18:41:08 -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=D2S7rorGFIvmAm5vm1nLGI4s34uuERT8pMeZCy1zfdfPu/yY2U+rNWiOaSe2ccq+yU rG+eOv7yujaseThbkXUIrPU0kPCxkCrZazGRhGHHAJ5cL50qlslYR0ETl4Qexa1LlHqU DE9DWyZpl4+txb7DNuuO+N8J0njLwuJjBijQy3BO2rs6s6hVpoPLRXsDOdxx1cyuwTO+ wLohv1QTXsoi9W/hRkJoaA9w+vDZvFwxRR9HFzf2gVYtMQuZFNG17xBVa8Z+SnvXQwmz ERnPBaoiCrwL3PNwrJXSjhZFKgA9tklNrtXC/dkSGUD+r3ieYgXUv6a8oQks/v/vwLFe Otyg== 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=gVshutOY/TJL9PsVlZFDjKfxKDhqorFk2GtgHaQ18rDyxyyQMdtzcxeNXmdcrsg02f twHrWrq9izzrynNx+iRODBhCeViiiTLz+iMj+h2Pi0ASrzOKXL9bhPer3v2HLPzCuscZ 5eV1/TDB920zi3xbbXuAKzwzpALuZTkK5kzh07jF2VYQRUrlmeQdF44wOCeNYtqYMVeA ilMCCLVlUibQuq8Z87VOiFUDcJ7gk2zO0dRONDHvWqplJytA8v6PihIBvdK1Kh8icC3L fM1WytZg/ZuxPmnIJmD2hbrrip99XKmw/CZQYfh0EvPN8fZJbAkmpPUevpPvzNZztOmV turg== X-Gm-Message-State: AGRZ1gKOSFn24u795dyH0UEr9hQ4GNYR8rqU0BfgINZrlPob0Sq5Nqud Mdpnw4sc6EM5b+4IXKl5qRzxHSB0 X-Google-Smtp-Source: AJdET5d2ZIAwVNZODnlrnw5IojAltCd67kJ7tQtUw7d9KYJ0Qbm9H87hlk+X4NIJn9W/KTwuSBdHgg== X-Received: by 2002:ac8:22ed:: with SMTP id g42-v6mr994854qta.105.1540950069892; Tue, 30 Oct 2018 18:41:09 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 20:38:05 -0500 Message-Id: <20181031013821.24023-9-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031013821.24023-1-mdroth@linux.vnet.ibm.com> References: <20181031013821.24023-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::82b Subject: [Qemu-devel] [PULL v2 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