From nobody Thu Nov 6 12:13:08 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 1540911383671625.0756811457819; Tue, 30 Oct 2018 07:56:23 -0700 (PDT) Received: from localhost ([::1]:53704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVRN-0001ox-Os for importer@patchew.org; Tue, 30 Oct 2018 10:56:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVHR-0000CY-V2 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:46:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVHL-0001zt-Lq for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:46:05 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:44766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHVHJ-0001Jq-Mw for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:45:58 -0400 Received: by mail-qk1-x735.google.com with SMTP id n12so7367654qkh.11 for ; Tue, 30 Oct 2018 07:45:33 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id o41-v6sm19531297qto.38.2018.10.30.07.45.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 07:45:31 -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=GKoH4ZZB9tVMSVkp1P+gh/ekSJnTNYHTpPWOfDhvCxrpuLC1PKk9fREtGIepFFQ8+u BHlK+hUWwUkc8iA9866scYvIVA0Sder+AuFhISSfurmXcUBHyBBS9GD7RVi4d0ObT2ij lj+pkCu3KwMWwqiN+j2926hSAqKB8ZwT5sP3ZNpgCiizzOmDwxdls7SGyePTq3V7mV00 7o5WtprmFVgQ+xHXGDXORVdMFhNmFPksnjoNwav/VD19+EFVVuntRpvtH029eDrptiyc 2km6YQ+adyjRnw0bhLZ3R8CF7Y6RGujyS7sWuyE1m9WP4lZpiZ3fYuC9ClXOfvcU6Upo /VBQ== 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=d8KzIOgvNdvpogBJivjJCYR+7M2zvkEbzYqT1bvgdzRMNQBfJcbjqKJffvxxnZ1GfH 2BKwqmWC4W/3NYynu5398xn1XSHIccCDCrgdM8MxyXegbMlgynkeErBjtLyFPMvCrn/w 7kZYtCCv2CyZfEMUN8H6A6sYqT+hrrUGEmyS3a+KDMVEgnbYMv29zw9L9xoNVSBA0364 II+NwniURPrMErEj4hfhwb4qxDDmlMPhYLiuf7qrJMv9q3QyVrSDYaFSKGzJuJqBPKMk tKg3d2Nde6/6IIJHbMJKoQNQZjhPPu4f8yS8DZ2J0sjsFG5bNHI/W852ICJ7wYSHvIit IwRw== X-Gm-Message-State: AGRZ1gL5aASKa/vd7vJMPCKki6k7ZWBeqBtLJmJZ9Khv5bauEJW2pq3j K/HVvSHknxriqJW0DanfetYmLtPx X-Google-Smtp-Source: AJdET5c/QWeDuc4MemPn9uZTmOY0dY5E9h3mR+y9/t4WUQQHp78vols+JUJJocrgpUArSOPmLm3DaQ== X-Received: by 2002:a37:a315:: with SMTP id m21mr15862294qke.152.1540910732469; Tue, 30 Oct 2018 07:45:32 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 09:43:42 -0500 Message-Id: <20181030144358.23144-9-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181030144358.23144-1-mdroth@linux.vnet.ibm.com> References: <20181030144358.23144-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::735 Subject: [Qemu-devel] [PULL 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