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 1533639076601183.6844196385108; Tue, 7 Aug 2018 03:51:16 -0700 (PDT) Received: from localhost ([::1]:38331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmza7-0001HD-DG for importer@patchew.org; Tue, 07 Aug 2018 06:51:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzYN-00087H-VY for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzYJ-00034n-3E for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:28 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:33725) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzYI-00034W-TL for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:23 -0400 Received: by mail-wm0-f42.google.com with SMTP id r24-v6so14004997wmh.0 for ; Tue, 07 Aug 2018 03:49:22 -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 i125-v6sm2308141wmd.23.2018.08.07.03.49.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:49:20 -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=AxJc4ApLmLkOlzmyHGt8DUsCvNrmUFCae5W4smRTKdgRGS5TbUPzIuMPjVXYNprSEY tJ3cAmax+5IxPauOzibBELa4k+IhiPnbOppGSJ/5xcet4ttTVlefqYKzdu6VXSFTjsSK DEaB6uUJHgNLv7b1scMu3iRlJ/RiHe6OhVOGDv0OHF0c9rdyvRtATPG9g1ACYH0GuHU4 4QgTYjIX64J9m8uoZqgFtW2C64oGYAqxcOSQQ78V3LFc0mLonQrp0OEk9H++0KU4eWWu QlXo6tC3oVTEDWIMgPPkdZL4g2fuYhcVYmfYjCEk9t47Ovh0pYOmrESTozHusTLVaQiM +i0g== X-Gm-Message-State: AOUpUlH+Sco2aJ6hLyh3BYpqyl7YMmkvfqcDabFC4dFoAmvfXUVZpk0b RjxGSlfsB8UIKOCs/hVxjdixxNdG40Q= X-Google-Smtp-Source: AA+uWPzECqVZqPfi9heqmd6O/qY298HkMKfpXaJ8DI+uIlYRuskcND8nZ+MUEDWWhy3Gvl1+3GuTMA== X-Received: by 2002:a1c:55c8:: with SMTP id j191-v6mr1302836wmb.67.1533638961665; Tue, 07 Aug 2018 03:49:21 -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:49:15 +0200 Message-Id: <65e1a15b5c2bb532a26a4fe908c67f4c9ea5f138.1533638952.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: 74.125.82.42 Subject: [Qemu-devel] [PATCH 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 1533639086864111.18117588633868; Tue, 7 Aug 2018 03:51:26 -0700 (PDT) Received: from localhost ([::1]:38332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmza9-0001LM-P0 for importer@patchew.org; Tue, 07 Aug 2018 06:51:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzYP-00089e-FW for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzYK-000358-If for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:29 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:54209) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzYK-00034v-Ad for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:24 -0400 Received: by mail-wm0-f45.google.com with SMTP id s9-v6so16926164wmh.3 for ; Tue, 07 Aug 2018 03:49:24 -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 i125-v6sm2308141wmd.23.2018.08.07.03.49.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:49:22 -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=LGJg5K6AamHchimFulgwvM2XDz6EgmWkeGw/wd/gkWrUOXid5HT0JHnywWrBmuHROL DATX4buO2qSBbeds02mZ5a3/ZkAe2U9E0Ki34ynNVRGXwmDClmld/PcZM6OdMc1VRbEK Nu1J7n1kCOwS9kc91Lyu1i/QFcZ3H7K/eeJpg6A8M+7wsC48IW4oTpkJRljKnEFEqoJk 63h7ShOiqEeO4XJzmnLcCQnrXwP170IEYxnuRYyIieJBCwRSmmwy0KIK8DJCWT9vTnN7 +y3WCTB373GXIjsQE9/9Cyty6xRZWcQ4zM7JPb8jiG86kRsWGpMiY3/1pQocbPK9geqs W/Hg== X-Gm-Message-State: AOUpUlFH05ceRP4J6KjJFkQKVBO07omqOExy3W5iLesAhRAcxxhoMi2y nnkygBGe544ORrHTprrqZPrrkR05Jjs= X-Google-Smtp-Source: AA+uWPzZCAB+KTgaHsqGymDyVy+mkF2rRq1vq+AB/+CxsvPfN/WnZ80aYN0WzSob2uuUKPIrdFa2Jg== X-Received: by 2002:a1c:b286:: with SMTP id b128-v6mr1229203wmf.121.1533638963056; Tue, 07 Aug 2018 03:49:23 -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:49:16 +0200 Message-Id: <9fcdb4fc0d467b1e0f0a4b2e299305e05a62e7eb.1533638952.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: 74.125.82.45 Subject: [Qemu-devel] [PATCH 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 15336392427244.447290459596729; Tue, 7 Aug 2018 03:54:02 -0700 (PDT) Received: from localhost ([::1]:38345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzcn-0003NF-N3 for importer@patchew.org; Tue, 07 Aug 2018 06:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzYQ-0008AQ-He for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzYL-00035Z-LD for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:30 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzYL-00035D-ED for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:25 -0400 Received: by mail-wr1-f67.google.com with SMTP id g1-v6so11831412wru.2 for ; Tue, 07 Aug 2018 03:49:25 -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 i125-v6sm2308141wmd.23.2018.08.07.03.49.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:49:23 -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=ZBnRT/QlgAJfpFuldftiQKudm57JsSHIEP86VSIKU8nNsRN9cDTx7jbrWiyaVUjI23 Wb1uTGsq/5arROOReHILe/W7loCHqjmtIqH5DZfNhORk0sgTHmxAhlxvjHfu42DiyCqD BGKGOQN0jxbDXkcnEw6zu+1r2GYgIyUolgzQrGau6xWhzwwpUkKClGgYWeEtbgV7Ptd7 SIoPgun+xvmoKTQDxpMoW0dj9GnQqLHiVQLDB1KUSpQACTmlxZ1P53giS9MuhEAajW9R gu0Sx8dqBh+veS0aRA3oSTyNeIhR708AbBgxQXNzWC+np+6unCeY+PvVBhl2KWm2nWsE Zvkg== X-Gm-Message-State: AOUpUlGc8aG5lyLfSn+/LrbEC25TNHBLQQPTVLjKZ7DD7BJdHgrxWgCL qw37j3jRDrpWdbBhMNaw3AZjHIf83rw= X-Google-Smtp-Source: AAOMgpcx9kah8Ax66jAzmYbdFZZeViToNTLOCREwnlr5stMRLfgD39T43Eln4J+y35ejConN7WM+mg== X-Received: by 2002:adf:dc8e:: with SMTP id r14-v6mr12283262wrj.166.1533638964201; Tue, 07 Aug 2018 03:49:24 -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:49:17 +0200 Message-Id: <951d1c8265e9ef6b36d61358fd01f267a9b83ca7.1533638952.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 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 1533639255101411.46870584703083; Tue, 7 Aug 2018 03:54:15 -0700 (PDT) Received: from localhost ([::1]:38346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzcx-0003VX-EU for importer@patchew.org; Tue, 07 Aug 2018 06:54:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmzYS-0008CB-At for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmzYN-000368-C9 for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:32 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55388) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmzYN-00035i-1u for qemu-devel@nongnu.org; Tue, 07 Aug 2018 06:49:27 -0400 Received: by mail-wm0-f66.google.com with SMTP id f21-v6so16909299wmc.5 for ; Tue, 07 Aug 2018 03:49:26 -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 i125-v6sm2308141wmd.23.2018.08.07.03.49.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 03:49:24 -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=X+zmz8qFjzeRubuNcdynWOR9Z4/2mZXANAv02+jDCkUIhIM3qkfDCDM80zdcbMmkTJ 3nlogZaqWVW0BCTTIX1p7+9ua76540AoRABW+LomSEo/gKLAIWHeJSPnHaT+UbNAORMC JnOtj2b+U95LBfwI8zbyZa27Yec7gYzKm8iq8i2FKSVW0Gj+v8K5+CYFvNOiLxpyawVx kKKQajIhdfg7+c4SJKOM2tRWEMSydHlnwejJTwAHu/gb0cLQJrGfBqLIvBuFmkPTmVsa xe1MnQl7dXi6zi5U1ku4KYk/1VeJqISRNJHgi2CvRAhnZ42TeA7ZZsHcXuSIZHRZKEUL l6dw== X-Gm-Message-State: AOUpUlE7d/90HJhlpFn6aPeh4K2juM45DU0DJoNclWrq1JZ+NPkGkAAs vTd97fDJke/UyQAMl9mxsUwWZp2xAiU= X-Google-Smtp-Source: AA+uWPyJD3FYG6B0WrsGy1lCM3nylbiiMNnYK6gUdU24+tkb6HxVnBF3tKxKXDlO44UlCxcjqtXA5A== X-Received: by 2002:a1c:6f44:: with SMTP id k65-v6mr1271519wmc.19.1533638965684; Tue, 07 Aug 2018 03:49:25 -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:49:18 +0200 Message-Id: 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: 74.125.82.66 Subject: [Qemu-devel] [PATCH 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