From nobody Wed Nov 5 07:39:42 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 1533639478379542.6407649442037; Tue, 7 Aug 2018 03:57:58 -0700 (PDT) Received: from localhost ([::1]:38365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzgb-0006dL-1j for importer@patchew.org; Tue, 07 Aug 2018 06:57:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzad-00023Z-JO for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzaY-0004Gj-OA for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:47 -0400 Received: from mail-wr1-f49.google.com ([209.85.221.49]:39546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzaY-0004G2-Iu for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:42 -0400 Received: by mail-wr1-f49.google.com with SMTP id h10-v6so15309257wre.6 for ; Tue, 07 Aug 2018 03:51:42 -0700 (PDT) Received: from fiorina.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id j9-v6sm1287794wrv.5.2018.08.07.03.51.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:51:40 -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=j+owlrYxus4FuhJWiHPRyw/nCqprMjPOzt0YF0TS8R0=; b=rCunyWEy7EvR9iNWFvVfM+UWiS4MuVc6RtyFC4WSChJpUqnGWHbqsB7ioaBfFkc0al M6L9ZPsU9BGKVFV86MlOuUNV33x9Hcf91tmqmxr8bokZk92NmRDSRNd9uXjKPEmfmv+h Ym5bEhuIJ3PDGuohTWEuhDgE01DE0ulfLsBODGvsJMTyr/akfqBJvSFRyYuISOyhK39n ZyQi1SITpEZoph1opJPt+DEPDozKa0NL6FjMgYvc1yejXTYqBUP3LhkUeusaShRI0tBI MXudypk1aONMHGdF97+ZPG/RNY1IShrBgTHdabOb+GxD3kT5rdiheSIP/urBpPHnCEb5 p9zg== X-Gm-Message-State: AOUpUlFyrGzqmy+3uB893o/UtSIG9WbXUZcDoQyeWkXIQnQVdMoLPwRe Tpqb7b4LQVUk8e6YdPVGvDllCt24x8M= X-Google-Smtp-Source: AAOMgpfU8E1YNa7bbuIHMuAM+B59WkMcubdhHlnm8goyBfXnzBH+UQaG54QxwI/hECgUat+St2Hkfg== X-Received: by 2002:adf:fd12:: with SMTP id e18-v6mr11751862wrr.280.1533639101376; Tue, 07 Aug 2018 03:51:41 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2018 12:51:35 +0200 Message-Id: <65e1a15b5c2bb532a26a4fe908c67f4c9ea5f138.1533639095.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.18.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.49 Subject: [Qemu-devel] [PATCH v2 1/4] build: rename CONFIG_QGA_NTDDDISK to CONFIG_QGA_NTDDSCSI 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 There was inconsistency between commits: 50cbebb9a3 configure: add configure check for ntdddisk.h a3ef3b2272 qga: added bus type and disk location path The first commit added #define CONFIG_QGA_NTDDDISK but the second commit expected the name to be CONFIG_QGA_NTDDSCSI. As a result the code in second patch was never used. Renaming the option to CONFIG_QGA_NTDDSCSI to match the name of header file that is being checked for. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 2a7796ea80..b31f37ed50 100755 --- a/configure +++ b/configure @@ -6111,7 +6111,7 @@ if test "$mingw32" =3D "yes" ; then echo "WIN_SDK=3D\"$win_sdk\"" >> $config_host_mak fi if test "$guest_agent_ntddscsi" =3D "yes" ; then - echo "CONFIG_QGA_NTDDDISK=3Dy" >> $config_host_mak + echo "CONFIG_QGA_NTDDSCSI=3Dy" >> $config_host_mak fi if test "$guest_agent_msi" =3D "yes"; then echo "QEMU_GA_MSI_ENABLED=3Dyes" >> $config_host_mak --=20 2.18.0 From nobody Wed Nov 5 07:39:42 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 15336395905521010.8366163453916; Tue, 7 Aug 2018 03:59:50 -0700 (PDT) Received: from localhost ([::1]:38427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmziP-0000Gw-Jj for importer@patchew.org; Tue, 07 Aug 2018 06:59:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzae-00024r-Nq for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzaZ-0004IK-TP for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:48 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:33942) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzaZ-0004HS-My for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:43 -0400 Received: by mail-wr1-f42.google.com with SMTP id c13-v6so15332298wrt.1 for ; Tue, 07 Aug 2018 03:51:43 -0700 (PDT) Received: from fiorina.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id j9-v6sm1287794wrv.5.2018.08.07.03.51.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:51:41 -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=rCCBQLCvoxUj/rJHYqFIRwOfG/RwdLkaEfJuGDN4GzU=; b=EXUCMsxkfCLC/s41mkSqd6s3l53ULEpOzogrgQU/CEV3fW0l31Mjxkn0P/bpfaljNz dHNxvYPCzLlSirm26zfm1wlIhWPLjIJHmzObgZnTyfNU8omDOOiHyIQp8iyqPMPgBNvW obvbCRrPnVKQxK22NonjSQBpwV//RJCgiT2G7vd79WY47RqI1Am88vuqEbO674k5jnWj lz++JjY3sEfsYgdCJEw/Wn0XONR18m15hcGgeOPKAW6oyv5EJjQ5AXzKV2m0rRoU9gpn TzzhlX+VfMvSu2l8Y4YMrFmtrNlEVJSpLaNnbPAiW2Z1r/Ajt6/SzqOgAjQjMWJjyD+X WK9Q== X-Gm-Message-State: AOUpUlFZ30VSR7GOqL7VxBi2eNiWSD32uHYxyhxxbiaUnl5fh99UwRIA rC9daDFw8WoGbWKrAI3wXAgsBn71GoA= X-Google-Smtp-Source: AAOMgpdsIbh/4bfbCnmUSXIyFSI1+PUy1cwarVCLdPX04nEY7ApFKWy9AsuAdQaQpbGJ6Non8SkYEA== X-Received: by 2002:adf:8385:: with SMTP id 5-v6mr12350317wre.13.1533639102522; Tue, 07 Aug 2018 03:51:42 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2018 12:51:36 +0200 Message-Id: <9fcdb4fc0d467b1e0f0a4b2e299305e05a62e7eb.1533639095.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.18.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.42 Subject: [Qemu-devel] [PATCH v2 2/4] qga: win32: add debugging information 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 The windows code generaly lacks debug information (compared to posix code). This patch adds some related to HW info in guest-get-fsinfo command. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-win32.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 318d760a74..36d76c22c0 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -498,6 +498,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) goto out; } =20 + g_debug("enumerating devices"); 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; @@ -522,6 +523,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) if (g_strcmp0(buffer, dev_name)) { continue; } + g_debug("found device %s", dev_name); =20 /* There is no need to allocate buffer in the next functions. The = size * is known and ULONG according to @@ -530,6 +532,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) { + g_debug("failed to get bus"); break; } =20 @@ -537,6 +540,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) * transformed into device function and number */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_ADDRESS, &data, (PBYTE)&addr, size, NULL)) { + g_debug("failed to get address"); break; } =20 @@ -544,6 +548,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) * This number is typically a user-perceived slot number. */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_UI_NUMBER, &data, (PBYTE)&slot, size, NULL)) { + g_debug("failed to get slot"); break; } =20 @@ -608,6 +613,7 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) scsi_ad =3D &addr; char *name =3D g_strndup(guid, strlen(guid)-1); =20 + g_debug("getting disk info for: %s", name); vol_h =3D CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (vol_h =3D=3D INVALID_HANDLE_VALUE) { @@ -615,6 +621,7 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) goto out_free; } =20 + g_debug("getting bus type"); bus =3D get_disk_bus_type(vol_h, errp); if (bus < 0) { goto out_close; @@ -622,6 +629,7 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) =20 disk =3D g_malloc0(sizeof(*disk)); disk->bus_type =3D find_bus_type(bus); + g_debug("bus type %d", disk->bus_type); 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 */ @@ -631,6 +639,7 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) /* We are able to use the same ioctls for different bus types * according to Microsoft docs * https://technet.microsoft.com/en-us/library/ee851589(v=3Dws.10)= .aspx */ + g_debug("getting pci-controller info"); if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_a= d, sizeof(SCSI_ADDRESS), &len, NULL)) { disk->unit =3D addr.Lun; --=20 2.18.0 From nobody Wed Nov 5 07:39:42 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 153363931162238.48753432358376; Tue, 7 Aug 2018 03:55:11 -0700 (PDT) Received: from localhost ([::1]:38347 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzdu-0004Fs-HH for importer@patchew.org; Tue, 07 Aug 2018 06:55:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzag-00026U-8M for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzab-0004Iq-Ct for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39252) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzab-0004IT-5m for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:45 -0400 Received: by mail-wr1-f66.google.com with SMTP id h10-v6so15309382wre.6 for ; Tue, 07 Aug 2018 03:51:45 -0700 (PDT) Received: from fiorina.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id j9-v6sm1287794wrv.5.2018.08.07.03.51.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:51:43 -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=X5LepDNieYkbdKjEhwiYO8WZOnC/U4KooY5hzpI0S2k=; b=hMISbUiwx6gG+zURkLE+pgssrw+a09N4llnDIYoXMlm52sp64S2UejetdSnA5bcSrB /awcxTC+235db0euUEdskZfi/nIUw6tRyXU7OaxtG4T/IRyzbOltpUqqQIbR+tflVqBj M8z2gUQ8QVXj6UXi3K0AaykgL0lLdkLq4cdqlyWssexhg/fmP+iWYsDmQ5cGYoM5qu3y EysE3gC0xeQJXhPkD1g8imAgqTgk8Q9rJ8pKENBOninRhbujyBb3jvHleMOfh8qazVKy CXOZ8FoAbyAk0ENNFdgyJLThD3bsPGp2JYnb3JhrHB0+/6nQsCFtDsDdoN6Dt6Pi/8QZ jXQg== X-Gm-Message-State: AOUpUlFtRBJq6+TmOtWwUzGniij2KxsjSCv+IvpZiprfgZjz3259WOOG WnXD/iAeoWQN3zE0pmWR22szIuEtWLo= X-Google-Smtp-Source: AAOMgpcluze3YJfbhR84Zd7unnk8AJ1wNWFFjtu5+MeCYBvvAalBGDUYlv1d1tM4i7GuuZLqhVCEdw== X-Received: by 2002:a5d:6748:: with SMTP id l8-v6mr12473273wrw.197.1533639103950; Tue, 07 Aug 2018 03:51:43 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2018 12:51:37 +0200 Message-Id: <951d1c8265e9ef6b36d61358fd01f267a9b83ca7.1533639095.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.18.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.66 Subject: [Qemu-devel] [PATCH v2 3/4] qga: win32: fix crashes when PCI info cannot be retrived 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 The guest-get-fsinfo command collects also information about PCI controller where the disk is attached. When this fails for some reasons it tries to return just the partial information. However in certain cases the pointer to the structure was not initialized and was set to NULL. This breaks the serializer and lead to crasehs of the guest agent. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-win32.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 36d76c22c0..995f62c2e4 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -642,15 +642,32 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) g_debug("getting pci-controller info"); if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_a= d, sizeof(SCSI_ADDRESS), &len, NULL)) { + Error *local_err =3D NULL; disk->unit =3D addr.Lun; disk->target =3D addr.TargetId; disk->bus =3D addr.PathId; - disk->pci_controller =3D get_pci_info(name, errp); + g_debug("unit=3D%lld target=3D%lld bus=3D%lld", + disk->unit, disk->target, disk->bus); + disk->pci_controller =3D get_pci_info(name, &local_err); + + if (local_err) { + slog("failed to get PCI controller info: %s", + error_get_pretty(local_err)); + error_free(local_err); + } else if (disk->pci_controller !=3D NULL) { + g_debug("pci: domain=3D%lld bus=3D%lld slot=3D%lld functio= n=3D%lld", + disk->pci_controller->domain, + disk->pci_controller->bus, + disk->pci_controller->slot, + disk->pci_controller->function); + } } - /* We do not set error in this case, because we still have enough - * information about volume. */ - } else { - disk->pci_controller =3D NULL; + } + /* We do not set error in case pci_controller is NULL, because we still + * have enough information about volume. */ + if (disk->pci_controller =3D=3D NULL) { + g_debug("no PCI controller info"); + disk->pci_controller =3D g_malloc0(sizeof(GuestPCIAddress)); } =20 list =3D g_malloc0(sizeof(*list)); --=20 2.18.0 From nobody Wed Nov 5 07:39:42 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 1533639377801157.97099307152018; Tue, 7 Aug 2018 03:56:17 -0700 (PDT) Received: from localhost ([::1]:38359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzey-0005Xw-K5 for importer@patchew.org; Tue, 07 Aug 2018 06:56:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzai-000281-0W for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzac-0004K2-Vp for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:52 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzac-0004JK-L6 for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:51:46 -0400 Received: by mail-wr1-f67.google.com with SMTP id f12-v6so15292950wrv.12 for ; Tue, 07 Aug 2018 03:51:46 -0700 (PDT) Received: from fiorina.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id j9-v6sm1287794wrv.5.2018.08.07.03.51.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:51:44 -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=ncbHHdNjWOh29l6qvmnp+qScohb0zB/pAKVYS/AJygw=; b=YYbuJy3uDeuW+B64aHhB4QZGETYXmwoblH4R4TG0VGdzmvy9HcfAy6oAs6juSy9Fm6 BUXs1tZEQKC2P1zfThJASB86ZQiPbcGCGRlmFqL4LUb8qdekw+UwhM+2RnbmFauBP9JX 2S/AqBa0DKZHoV5kruZ/Lzk3Ty6DVK3dYs6NmvUebfk+YrEmYoioLFNiSsv91cS74/Vr 4VG9Pk2S19tEt35k/HBHAH6+DwucUKkPRh5oNMgsxRQp+X5igHKCaN4FBCJBYqPw3GWz 0SKduLleqlmFE2RyIKzbQ211e0HnEdqtmWSCoeljVevs8+aOEZooe24UQ4ycnOo2xLOs jb1g== X-Gm-Message-State: AOUpUlHatGlfTIbiJJ9y4uDq8xqvbZWAetkgIZu04BFJTFlTysar18Yp JQm6V9VlFJ17n9vmjYBi+BgUZKj+3oE= X-Google-Smtp-Source: AAOMgpfEw4W+ib4IoZaJhKWKAFdAgrJYOwpXF+nPoHudBqqH+RBcBE9H03ekufwYgI4BIc73YeLtxQ== X-Received: by 2002:adf:dc8e:: with SMTP id r14-v6mr12288849wrj.166.1533639105384; Tue, 07 Aug 2018 03:51:45 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Tue, 7 Aug 2018 12:51:38 +0200 Message-Id: <23ca1636f8e238b2ffaded962519d2be1e3b5d3a.1533639095.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.18.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.67 Subject: [Qemu-devel] [PATCH v2 4/4] qga: report serial ID and device node 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Michael Roth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 On Linux the functionality depends on libudev. Example from Linux: { "name": "dm-2", "mountpoint": "/", ... "disk": [ { "serial": "SAMSUNG_MZ7LN512HCHP-000L1_S1ZKNXAG822493", "dev": "/dev/sda2", ... } ], } Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- configure | 1 + qga/commands-posix.c | 23 ++++++++++++++ qga/commands-win32.c | 73 ++++++++++++++++++++++++++++++++------------ qga/qapi-schema.json | 4 ++- 4 files changed, 81 insertions(+), 20 deletions(-) diff --git a/configure b/configure index b31f37ed50..d73d929b6c 100755 --- a/configure +++ b/configure @@ -871,6 +871,7 @@ Linux) vhost_vsock=3D"yes" QEMU_INCLUDES=3D"-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QE= MU_INCLUDES" supported_os=3D"yes" + libs_qga=3D"$($pkg_config --libs libudev) $libs_qga" ;; esac =20 diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 233f78a406..4270f85aae 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -47,6 +47,7 @@ extern char **environ; #include #include #include +#include =20 #ifdef FIFREEZE #define CONFIG_FSFREEZE @@ -872,6 +873,8 @@ static void build_guest_fsinfo_for_real_device(char con= st *syspath, GuestDiskAddressList *list =3D NULL; bool has_ata =3D false, has_host =3D false, has_tgt =3D false; char *p, *q, *driver =3D NULL; + struct udev *udev =3D NULL; + struct udev_device *udevice =3D NULL; =20 p =3D strstr(syspath, "/devices/pci"); if (!p || sscanf(p + 12, "%*x:%*x/%x:%x:%x.%x%n", @@ -935,6 +938,24 @@ static void build_guest_fsinfo_for_real_device(char co= nst *syspath, list =3D g_malloc0(sizeof(*list)); list->value =3D disk; =20 + udev =3D udev_new(); + udevice =3D udev_device_new_from_syspath(udev, syspath); + if (udev =3D=3D NULL || udevice =3D=3D NULL) { + g_debug("failed to query udev"); + } else { + const char *devnode, *serial; + devnode =3D udev_device_get_devnode(udevice); + if (devnode !=3D NULL) { + disk->dev =3D g_strdup(devnode); + disk->has_dev =3D true; + } + serial =3D udev_device_get_property_value(udevice, "ID_SERIAL"); + if (serial !=3D NULL && *serial !=3D 0) { + disk->serial =3D g_strdup(serial); + disk->has_serial =3D true; + } + } + if (strcmp(driver, "ata_piix") =3D=3D 0) { /* a host per ide bus, target*:0::0 */ if (!has_host || !has_tgt) { @@ -1002,6 +1023,8 @@ cleanup: qapi_free_GuestDiskAddressList(list); } g_free(driver); + udev_unref(udev); + udev_device_unref(udevice); } =20 static void build_guest_fsinfo_for_device(char const *devpath, diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 995f62c2e4..666443dec2 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -577,25 +577,53 @@ out: return pci; } =20 -static int get_disk_bus_type(HANDLE vol_h, Error **errp) +static void get_disk_properties(HANDLE vol_h, GuestDiskAddress *disk, + Error **errp) { STORAGE_PROPERTY_QUERY query; STORAGE_DEVICE_DESCRIPTOR *dev_desc, buf; DWORD received; + ULONG size =3D sizeof(buf); =20 dev_desc =3D &buf; - dev_desc->Size =3D sizeof(buf); query.PropertyId =3D StorageDeviceProperty; query.QueryType =3D PropertyStandardQuery; =20 if (!DeviceIoControl(vol_h, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(STORAGE_PROPERTY_QUERY), dev_desc, - dev_desc->Size, &received, NULL)) { + size, &received, NULL)) { error_setg_win32(errp, GetLastError(), "failed to get bus type"); - return -1; + return; + } + disk->bus_type =3D find_bus_type(dev_desc->BusType); + g_debug("bus type %d", disk->bus_type); + + /* Query once more. Now with long enough buffer. */ + size =3D dev_desc->Size; + dev_desc =3D g_malloc0(size); + if (!DeviceIoControl(vol_h, IOCTL_STORAGE_QUERY_PROPERTY, &query, + sizeof(STORAGE_PROPERTY_QUERY), dev_desc, + size, &received, NULL)) { + error_setg_win32(errp, GetLastError(), "failed to get serial numbe= r"); + goto out_free; + } + if (dev_desc->SerialNumberOffset > 0) { + if (dev_desc->SerialNumberOffset >=3D received) { + error_setg(errp, "offset outside the buffer"); + goto out_free; + } + const char *serial =3D (char*)dev_desc + dev_desc->SerialNumberOff= set; + size_t len =3D received - dev_desc->SerialNumberOffset; + if (*serial !=3D 0) { + disk->serial =3D g_strndup(serial, len); + disk->has_serial =3D true; + g_debug("serial number %s", disk->serial); + } } +out_free: + g_free(dev_desc); =20 - return dev_desc->BusType; + return; } =20 /* VSS provider works with volumes, thus there is no difference if @@ -607,8 +635,8 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) GuestDiskAddress *disk; SCSI_ADDRESS addr, *scsi_ad; 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); @@ -618,22 +646,24 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) 0, NULL); if (vol_h =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to open volume"); - goto out_free; + goto err; } =20 - g_debug("getting bus type"); - bus =3D get_disk_bus_type(vol_h, errp); - if (bus < 0) { - goto out_close; + disk =3D g_malloc0(sizeof(*disk)); + disk->dev =3D name; + disk->has_dev =3D true; + get_disk_properties(vol_h, disk, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto err_close; } =20 - disk =3D g_malloc0(sizeof(*disk)); - disk->bus_type =3D find_bus_type(bus); - g_debug("bus type %d", disk->bus_type); - if (bus =3D=3D BusTypeScsi || bus =3D=3D BusTypeAta || bus =3D=3D BusT= ypeRAID + if (disk->bus_type =3D=3D GUEST_DISK_BUS_TYPE_SCSI + || disk->bus_type =3D=3D GUEST_DISK_BUS_TYPE_IDE + || disk->bus_type =3D=3D GUEST_DISK_BUS_TYPE_RAID #if (_WIN32_WINNT >=3D 0x0600) /* This bus type is not supported before Windows Server 2003 S= P1 */ - || bus =3D=3D BusTypeSas + || disk->bus_type =3D=3D GUEST_DISK_BUS_TYPE_SAS #endif ) { /* We are able to use the same ioctls for different bus types @@ -673,11 +703,16 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) list =3D g_malloc0(sizeof(*list)); list->value =3D disk; list->next =3D NULL; -out_close: CloseHandle(vol_h); -out_free: - g_free(name); return list; + +err_close: + g_free(disk); + CloseHandle(vol_h); +err: + g_free(name); + + return NULL; } =20 #else diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index dfbc4a5e32..dea995181e 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -834,13 +834,15 @@ # @bus: bus id # @target: target id # @unit: unit id +# @serial: serial number # # Since: 2.2 ## { 'struct': 'GuestDiskAddress', 'data': {'pci-controller': 'GuestPCIAddress', 'bus-type': 'GuestDiskBusType', - 'bus': 'int', 'target': 'int', 'unit': 'int'} } + 'bus': 'int', 'target': 'int', 'unit': 'int', + '*serial': 'str', '*dev': 'str'} } =20 ## # @GuestFilesystemInfo: --=20 2.18.0