From nobody Sat Feb 7 16:26:52 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; 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 1538653733578378.11644239953534; Thu, 4 Oct 2018 04:48:53 -0700 (PDT) Received: from localhost ([::1]:55197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g827g-0000jJ-7A for importer@patchew.org; Thu, 04 Oct 2018 07:48:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tH-000411-2Z for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iM-0003Sb-Oe for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:46 -0400 Received: from mail-wm1-f51.google.com ([209.85.128.51]:38518) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iM-0003SI-I0 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:42 -0400 Received: by mail-wm1-f51.google.com with SMTP id 193-v6so8597921wme.3 for ; Thu, 04 Oct 2018 04:22: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 k7-v6sm5191789wmf.41.2018.10.04.04.22.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22: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=1oV/fLH1dgFfJzaAWTXDHel71TPwWcODZkc6QORnjI0=; b=Q1gSWCYqSodnyx3GqWcFa+fOZ9TZgiQn/UMzmD2kTsVPk13eSCM4/74aQk07etSMBb q+xxLuz/Bzu+KM/nsU7IOOxJCqbkN5tjsKBkm4b/IJJcZQE1EVYNh4YmalLGqZHd3Uq0 7j50FLHHK/MQqZljHVCf5mrrrgPu08w/p3rNqVo2iDmA/FTMjho8//E+nCbhs9c1fGtk 4wYlZLcHbLMeRreYUAwzituM7GsVmK3NKPdbDNjRNEO3X3mQP9lNCGhdkF4Y+etdFJuS z/V7XGaqP8ZcInfgD1Zsxmz75LNV5XKU+YpoXy2SK5OVrE9G3E8NBCGnIqECnZNk9NhG ekTQ== X-Gm-Message-State: ABuFfojM07ojngiVselQ+2QceXGlcvrztJpNwImqLGiYatuuO5k7xime ARVffmG0KW+C/X80yOgJu7uZuuqBVh0= X-Google-Smtp-Source: ACcGV62jhJWYKHhuAKqWXQy5J6dXI5zevS6Y0RaGVuetW3joNWxgMnarl1c8s7Ey0v62ggsssP5Pyw== X-Received: by 2002:a1c:7dd5:: with SMTP id y204-v6mr4614218wmc.63.1538652161220; Thu, 04 Oct 2018 04:22:41 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:28 +0200 Message-Id: <0ad2a56e767a04f8fd2c8cb32ed6c1bc0f1c2497.1538652143.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.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.128.51 Subject: [Qemu-devel] [PATCH v4 01/11] qga-win: 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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 leads to a crash 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 98d9735389..9c959122d9 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -633,15 +633,32 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) * https://technet.microsoft.com/en-us/library/ee851589(v=3Dws.10)= .aspx */ 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) { + g_debug("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.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653265773260.89268829362743; Thu, 4 Oct 2018 04:41:05 -0700 (PDT) Received: from localhost ([::1]:55147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8208-0001ic-Fg for importer@patchew.org; Thu, 04 Oct 2018 07:41:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81st-000411-H4 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iO-0003Sw-5m for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:48 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39952) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iN-0003Sl-VE for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:44 -0400 Received: by mail-wr1-f67.google.com with SMTP id d2-v6so5058522wro.7 for ; Thu, 04 Oct 2018 04:22: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 k7-v6sm5191789wmf.41.2018.10.04.04.22.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22: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=9TgnOkRe56uCIfYJy4HqUUQRlSYhp0EwqdJ05l2ODI4=; b=nGmBKypQQ8vETlXcauvo22VemB1cPOOhD43qvbEHuaw+N40fITzTLxlB49eFI9oiAe vIxo2ekL90kBizVyaqbRmMh2EepXokYIrJCSzPtOe5VL2cJfMh1LOGGNIPh/pz2M8/eG 8udO1Rtxv7t8waWX2af5bBEcobDow2Y2G0BAShLk6p3FOJUr+ug3Ss9MaM665c5h2uk9 kK/AdSULcJoH5nLnSRztJXn/oqyoGydLLRAeCfAqw9rXV1F3R0ecgJDXT+Icj+nvm562 wA60E4vwYKaAyC5teEk4vXqHK4Mv7NblYhyZAKWggkLPwlPEwhL/NfbrnRXBxwD7GITO 56SA== X-Gm-Message-State: ABuFfognVqiY6QujiKfyGKC6dEzK/xCeRlphWUzrcdiIGAg/gLdl3KYm CwcqdeK6visVh8D1QzOMD64SDf0tuWM= X-Google-Smtp-Source: ACcGV60/jkL3A9rJrT3J1ZAkaQ0Yv6jHXvNAPZ2/9rYQVtXdNx/TL1dOqiWn2LTrLzCbYUiXu7dPnw== X-Received: by 2002:adf:f90b:: with SMTP id b11-v6mr4530667wrr.307.1538652162569; Thu, 04 Oct 2018 04:22:42 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:29 +0200 Message-Id: X-Mailer: git-send-email 2.19.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 v4 02/11] qga-win: handle NULL values 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Handle returned NULLs properly to: - avoid crashes in serialization. - properly report errors to the caller Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-win32.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 9c959122d9..49fc747298 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -735,6 +735,12 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *g= uid, Error **errp) } fs->type =3D g_strdup(fs_name); fs->disk =3D build_guest_disk_info(guid, errp); + if (fs->disk =3D=3D NULL) { + g_free(fs); + fs =3D NULL; + goto free; + } + free: g_free(mnt_point); return fs; @@ -755,7 +761,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **e= rrp) do { GuestFilesystemInfo *info =3D build_guest_fsinfo(guid, errp); if (info =3D=3D NULL) { - continue; + goto out; } new =3D g_malloc(sizeof(*ret)); new->value =3D info; @@ -767,6 +773,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **e= rrp) error_setg_win32(errp, GetLastError(), "failed to find next volume= "); } =20 +out: FindVolumeClose(vol_h); return ret; } --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653339979105.20061833112209; Thu, 4 Oct 2018 04:42:19 -0700 (PDT) Received: from localhost ([::1]:55159 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g821K-0002dp-MU for importer@patchew.org; Thu, 04 Oct 2018 07:42:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tH-000415-0g for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iP-0003Ua-Ar for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:49 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41243) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iP-0003TH-3x for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:45 -0400 Received: by mail-wr1-f65.google.com with SMTP id x12-v6so9483158wru.8 for ; Thu, 04 Oct 2018 04:22: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 k7-v6sm5191789wmf.41.2018.10.04.04.22.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22: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=O5rTliceuplIm0QyCVn/E3p4RYeddSvMfeyt1TNcB+8=; b=aISn6I3T1j1n5nfgHLW2+lIABIOfJdosg9nfvDjBBV1gerfwNDgyXdxaijEBEMA0mJ 4sje62o4snSm61sDiHdw5CxdHHL/PUORdXGI5y7zLgNybyMCwHc+iEuCICArnQSSnuk5 fudK2EeOT/QGaXNfRc/MzIaSthUh3lN6BgB3NFwQMSVfQtp/KIsBB650lFNRxD/YLw1V OJpui9E82T6XVd0zeb45hX1quS6VgeN7O5kjxgb/JXkR+2wIeyt1QKbGh/VSFUwjdmYW ZihyKMrbzdbGTeirklt9Ybk8HGezwnt8EIOxudhFeNx5yvcK+ZKmDLtdXLpyqalepWK7 eHAQ== X-Gm-Message-State: ABuFfoi43FyxgkJFysrsn4p+uSDnHRhsVG4JemMNNrfbDkFB4ordU+LD bTapaMSSQVEM/2a80oB9RKPL6YLc0YQ= X-Google-Smtp-Source: ACcGV612/NFYXeTyTmH8IkLDn8/IKiW3GM9BQT9pejUAW941Gq1gJJmxMUVleBJdBkb52NiTOpQO8A== X-Received: by 2002:a5d:6309:: with SMTP id i9-v6mr4323334wru.163.1538652163877; Thu, 04 Oct 2018 04:22:43 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:30 +0200 Message-Id: <73a25549dfd4206b53f5fd8e98f789b20ac861a4.1538652143.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.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.65 Subject: [Qemu-devel] [PATCH v4 03/11] 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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 Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Sameeh Jubran --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 58862d2ae8..0f168607e8 100755 --- a/configure +++ b/configure @@ -6201,7 +6201,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.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653402594980.2035124347166; Thu, 4 Oct 2018 04:43:22 -0700 (PDT) Received: from localhost ([::1]:55163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g822L-00043E-Gm for importer@patchew.org; Thu, 04 Oct 2018 07:43:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tC-0004Dx-5R for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:33:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iQ-0003Vv-M4 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:50 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:35805) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iQ-0003Ux-Eu for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:46 -0400 Received: by mail-wr1-f42.google.com with SMTP id w5-v6so9501521wrt.2 for ; Thu, 04 Oct 2018 04:22: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 k7-v6sm5191789wmf.41.2018.10.04.04.22.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22: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=zhInFiEpHmkZ2840Yk5OGiBlWEMkdXOli4evpvokdL0=; b=ZyUu9MH+jY3oiekoRmGSBTEE0UU9dc1CDzRIur3/APaUfSAeEpeg3FZ1ht5QQbJj5N BToKV/szvQDJjX1WqyRY54bkfRLYFJoKETE1Nx6YiD5gUDDzQBAjXaMvBCz+tAPAQKTs betWlQ23dlB0oAMFHXodwTJHBj9SbxwVMfIudq3Xp4EO3dd/oC7WhwYI3pxdd5X2w5Lt uTJ5WCc6Gq+nIIUvVvgM9jP88ASBNlcUtbp/EnAevDlhicvVhdDFVwICQGB/NbdSiIs6 FP+JbBb5lbSSg23CNR7pCdxCzG5Gq9TDJ9WbQHqf3hVUtjqKyZIb/FFJpO7ei0z+FxMe G0Tg== X-Gm-Message-State: ABuFfoi3nMCzlXe1vW5VLKpbg6WXSyMnwhiXuWSA3NMxN2TUZpCTXxga MUoPhyKMNZdXAbt7nN0Bgn7gHQ5nYlE= X-Google-Smtp-Source: ACcGV60u+KYNe65yQnC7Pu9F2a23wuT4T3iawfJSkhbVXCpQDVJTpUvoN5cMS2nzDCdkgLfQ24kw8g== X-Received: by 2002:adf:ad65:: with SMTP id p92-v6mr4685937wrc.7.1538652165144; Thu, 04 Oct 2018 04:22:45 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:31 +0200 Message-Id: X-Mailer: git-send-email 2.19.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 v4 04/11] qga-win: 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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 Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/commands-win32.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 49fc747298..2a7a3af614 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -89,6 +89,12 @@ static OpenFlags guest_file_open_modes[] =3D { {"a+b", FILE_GENERIC_APPEND|GENERIC_READ, OPEN_ALWAYS } }; =20 +#define debug_error(msg) do { \ + char *suffix =3D g_win32_error_message(GetLastError()); \ + g_debug("%s: %s", (msg), suffix); \ + g_free(suffix); \ +} while (0) + static OpenFlags *find_open_flag(const char *mode_str) { int mode; @@ -498,6 +504,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 +529,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 +538,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) { + debug_error("failed to get bus"); break; } =20 @@ -537,6 +546,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)) { + debug_error("failed to get address"); break; } =20 @@ -544,6 +554,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)) { + debug_error("failed to get slot"); break; } =20 @@ -608,6 +619,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 +627,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 +635,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 +645,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)) { Error *local_err =3D NULL; --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538652939813598.1223389590411; Thu, 4 Oct 2018 04:35:39 -0700 (PDT) Received: from localhost ([::1]:55107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81us-00053F-65 for importer@patchew.org; Thu, 04 Oct 2018 07:35:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81sl-0003yj-7Q for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:33:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iS-0003Wn-07 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:52 -0400 Received: from mail-wm1-f46.google.com ([209.85.128.46]:40652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iR-0003WH-Nf for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:47 -0400 Received: by mail-wm1-f46.google.com with SMTP id z204-v6so7812069wmc.5 for ; Thu, 04 Oct 2018 04:22:47 -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 k7-v6sm5191789wmf.41.2018.10.04.04.22.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22:45 -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=isq93APmjvuIkF019JP1rgCocjhxVznUygWH+BBLQsw=; b=CV1Uh0fqW5lLU+mgZCy7VhsYg/o79J6oK2+XCRdDpSGr/WYwXhJlmgNaJ8LF9De4P+ DeXco1loyp4CyRkfE+3fZOepBrZvE0eVDV/VhHnQOglMWQOtkG92u7hieQLp8aNsQeH4 DVK4I/nKtydHVLG4b6HELykZTRGzqSvajtOaAaUMbo+rgU0AGMdjOb/jHZ5D0FhONgs2 aR89YlnFYPQrGW27ImQyR5jMbbC7/2gTIBSPWm92c6FqaZR2AH61JhZhauUZ/Nf3iU00 Rsz7SWBp0s/+94W/921c2iqLbS8BAne+XOjdrxT4Ykfv5/6eDiWFnSl5Dh/63xINNtP3 Eq6A== X-Gm-Message-State: ABuFfoj2WjItLTThF09zwVlDF7WZ7S105mbeXTG4Yj7yKawlJN0meJqN LnK8NFZR+0INIWarBHJRfno/H7nxL2E= X-Google-Smtp-Source: ACcGV63DPcqznB3lHZ7Sa3pXHBHedRMo3Jw17KazwfUX9NUBzMFz+oy5R/NualfpMUlOYt5XEDkDsg== X-Received: by 2002:a1c:3e48:: with SMTP id l69-v6mr4247242wma.143.1538652166362; Thu, 04 Oct 2018 04:22:46 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:32 +0200 Message-Id: X-Mailer: git-send-email 2.19.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.128.46 Subject: [Qemu-devel] [PATCH v4 05/11] qga-win: refactor disk properties (bus) 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Refactor code that queries bus type to be more generic. The function get_disk_bus_type() has been renamed to build_guest_disk_info(). Following commit(s) will extend this function. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-win32.c | 46 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 2a7a3af614..d7864fc65a 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -583,25 +583,29 @@ 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); + g_free(dev_desc); =20 - return dev_desc->BusType; + return; } =20 /* VSS provider works with volumes, thus there is no difference if @@ -613,8 +617,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); @@ -624,22 +628,22 @@ 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)); + 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 @@ -679,11 +683,17 @@ 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 --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653364983490.96780502388594; Thu, 4 Oct 2018 04:42:44 -0700 (PDT) Received: from localhost ([::1]:55161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g821j-0002y0-FL for importer@patchew.org; Thu, 04 Oct 2018 07:42:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tG-0004Dx-UO for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iU-0003Y1-NN for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:54 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:40718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iU-0003X4-FE for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:50 -0400 Received: by mail-wr1-f52.google.com with SMTP id d2-v6so5058801wro.7 for ; Thu, 04 Oct 2018 04:22:50 -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 k7-v6sm5191789wmf.41.2018.10.04.04.22.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22:46 -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=M72CmDnOs2t74mvkB61g3UAEOROo2UAHNMxhjCumw84=; b=kXf8CRotb2DPU/8e/cRL3USyJQCsxSEZ2r9XG/qVOJAxrwhEn5V4J7XWM4sZ7W1eqz QFuqqr6X424cTcQ9MaV3WVzxvR4r5e8GKJcBLnbfielJyQa7ZtJ1945xdHCj1hVEV/G+ KK9sNcHOqWUxW4caK2QrFjyBWoOpYkiVQqSwD+NBOwJRRod0gggaojrXDlA4ydyaG3i7 m2u4nDil9I4Y2UWB92JUmKzr2iD5kabfLkpwN0RQHNzL0VdYaxk/DbsmRAfM1Duu7lk9 niZQX8C9acSSfgtmSTURiu9vmL8ePZI6D4vQHe/bGO2V/MOTDwWmT9fmrSEDN4KC4oAD HWPA== X-Gm-Message-State: ABuFfogD+6Qzr3eBcZmKJWKT6feYAWw456ihV3n1q5Gs4lFiaTq0yoTS JDGlulM/eL0ma6WELqZ9ZZ4CUtuzHHI= X-Google-Smtp-Source: ACcGV61TSdwwMNvHZLeOiXbQ+qoyzc6pbigHlesDMi6dMRDmH0h/iYJx+oE8DE4BjdMfQJ18eCcISg== X-Received: by 2002:a5d:438e:: with SMTP id i14-v6mr4821043wrq.156.1538652167701; Thu, 04 Oct 2018 04:22:47 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:33 +0200 Message-Id: <2510f7c260bd2cbdf1b6089c2a021e6434cb0d38.1538652143.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.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.52 Subject: [Qemu-devel] [PATCH v4 06/11] configure: add test for libudev 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Reviewed-by: Marc-Andr=C3=A9 Lureau --- configure | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/configure b/configure index 0f168607e8..ac24cb3975 100755 --- a/configure +++ b/configure @@ -477,6 +477,7 @@ libxml2=3D"" docker=3D"no" debug_mutex=3D"no" libpmem=3D"" +libudev=3D"no" =20 # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64=3D"aarch64-linux-gnu-gcc" @@ -873,6 +874,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" + libudev=3D"yes" ;; esac =20 @@ -5676,6 +5678,20 @@ if test "$libnfs" !=3D "no" ; then fi fi =20 +########################################## +# Do we have libudev +if test "$libudev" !=3D "no" ; then + if $pkg_config libudev; then + libudev=3D"yes" + libudev_libs=3D$($pkg_config --libs libudev) + else + if test "$libudev" =3D "yes" ; then + feature_not_found "libudev" "Install systemd development files" + fi + libudev=3D"no" + fi +fi + # Now we've finished running tests it's OK to add -Werror to the compiler = flags if test "$werror" =3D "yes"; then QEMU_CFLAGS=3D"-Werror $QEMU_CFLAGS" @@ -6100,6 +6116,7 @@ echo "VxHS block device $vxhs" echo "capstone $capstone" echo "docker $docker" echo "libpmem support $libpmem" +echo "libudev $libudev" =20 if test "$sdl_too_old" =3D "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -6944,6 +6961,11 @@ if test "$docker" !=3D "no"; then echo "HAVE_USER_DOCKER=3Dy" >> $config_host_mak fi =20 +if test "$libudev" !=3D "no"; then + echo "CONFIG_LIBUDEV=3Dy" >> $config_host_mak + echo "LIBUDEV_LIBS=3D$libudev_libs" >> $config_host_mak +fi + # use included Linux headers if test "$linux" =3D "yes" ; then mkdir -p linux-headers --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538652948639954.8335456765992; Thu, 4 Oct 2018 04:35:48 -0700 (PDT) Received: from localhost ([::1]:55112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81v1-0005Cj-7j for importer@patchew.org; Thu, 04 Oct 2018 07:35:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81ss-00040d-Im for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:33:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iU-0003Xp-Gn for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:54 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:34569) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iU-0003XU-A2 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:50 -0400 Received: by mail-wr1-f47.google.com with SMTP id z4-v6so9494304wrb.1 for ; Thu, 04 Oct 2018 04:22:50 -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 k7-v6sm5191789wmf.41.2018.10.04.04.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22:48 -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=M4yuVoO3GFIGu6gJwnJT1Ygm3YJ614FqON2WvFD/AFo=; b=YRTVudr9ExU3gwnr79/ywNzS8R4KuZ/nvJ2Hp0ABIhCNchvb/NPQ1gY+Ms8LtNaRw2 DWtKZrsHfQ4tRhvLUKPnCTBsNWsZLok8bRPuL0PU9+9gCscFHdaZRvKgtlmdhRzWc6pR QFhk76zwWTiyDW+V+qLAgAQXa2qBoRbNYq/3PuvdDwv8CJfR/ofvD50LCKoAUcbONxSH 7wOxaEaM/06G2oPocG1vkqB5O73WxTLa+plWQojjTsb5Rkr9YihMDlfEJoObIKB1zfcq gnj/nRN7J/ozcEjxi/xiQdFzAOLSH6TmM4WCOb8o8ctcoEcJLw+VfxRxZO6H/eWIL9O7 Icjg== X-Gm-Message-State: ABuFfojuIS6JLOLGHxZxYZIhTeZzAyatH8N3QpZ1HyX9rS7pSHdMU/KM lMQ7im+jg7iUDwpb3XZUTCu6P9ib+iU= X-Google-Smtp-Source: ACcGV60mfZuqtF3YUMVas7VUoLEHJQnp0CTakLq+tXPecglNpKfljLD3RAxC76o7uXi9n+v2CGE8dQ== X-Received: by 2002:adf:a352:: with SMTP id d18-v6mr4428282wrb.31.1538652168917; Thu, 04 Oct 2018 04:22:48 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:34 +0200 Message-Id: <54f53859b73142e6264c948ff8a8e70616baf268.1538652143.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.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.47 Subject: [Qemu-devel] [PATCH v4 07/11] qga: report disk serial number 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 The feature is implemented for Windows and Linux. Reporting of serial number on Linux depends on libudev. Example from Linux: { "name": "dm-2", "mountpoint": "/", ... "disk": [ { "serial": "SAMSUNG_MZ7LN512HCHP-000L1_S1ZKNXAG822493", ... } ], } Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/Makefile.objs | 1 + qga/commands-posix.c | 27 +++++++++++++++++++++++++++ qga/commands-win32.c | 24 ++++++++++++++++++++++++ qga/qapi-schema.json | 4 +++- 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/qga/Makefile.objs b/qga/Makefile.objs index ed08c5917c..80e6bb3c2e 100644 --- a/qga/Makefile.objs +++ b/qga/Makefile.objs @@ -1,3 +1,4 @@ +commands-posix.o-libs :=3D $(LIBUDEV_LIBS) qga-obj-y =3D commands.o guest-agent-command-state.o main.o qga-obj-$(CONFIG_POSIX) +=3D commands-posix.o channel-posix.o qga-obj-$(CONFIG_WIN32) +=3D commands-win32.o channel-win32.o service-win3= 2.o diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 37e8a2d791..4d324178f2 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -48,6 +48,10 @@ extern char **environ; #include #include =20 +#ifdef CONFIG_LIBUDEV +#include +#endif + #ifdef FIFREEZE #define CONFIG_FSFREEZE #endif @@ -872,6 +876,10 @@ static void build_guest_fsinfo_for_real_device(char co= nst *syspath, GuestDiskAddressList *list =3D NULL; bool has_ata =3D false, has_host =3D false, has_tgt =3D false; char *p, *q, *driver =3D NULL; +#ifdef CONFIG_LIBUDEV + struct udev *udev =3D NULL; + struct udev_device *udevice =3D NULL; +#endif =20 p =3D strstr(syspath, "/devices/pci"); if (!p || sscanf(p + 12, "%*x:%*x/%x:%x:%x.%x%n", @@ -936,6 +944,21 @@ static void build_guest_fsinfo_for_real_device(char co= nst *syspath, list =3D g_malloc0(sizeof(*list)); list->value =3D disk; =20 +#ifdef CONFIG_LIBUDEV + 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 *serial; + 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; + } + } +#endif + if (strcmp(driver, "ata_piix") =3D=3D 0) { /* a host per ide bus, target*:0::0 */ if (!has_host || !has_tgt) { @@ -1003,6 +1026,10 @@ cleanup: qapi_free_GuestDiskAddressList(list); } g_free(driver); +#ifdef CONFIG_LIBUDEV + udev_unref(udev); + udev_device_unref(udevice); +#endif } =20 static void build_guest_fsinfo_for_device(char const *devpath, diff --git a/qga/commands-win32.c b/qga/commands-win32.c index d7864fc65a..376ca1e288 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -603,6 +603,30 @@ static void get_disk_properties(HANDLE vol_h, GuestDis= kAddress *disk, } 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->SerialNumberOf= fset; + 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; diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index dfbc4a5e32..3bcda6257e 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: 3.1) # # 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'} } =20 ## # @GuestFilesystemInfo: --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653656996552.6832648462299; Thu, 4 Oct 2018 04:47:36 -0700 (PDT) Received: from localhost ([::1]:55190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g826R-0007X2-Vi for importer@patchew.org; Thu, 04 Oct 2018 07:47:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tG-0003yo-Tn for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iV-0003YN-HH for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:55 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]:39886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iV-0003Xw-8L for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:51 -0400 Received: by mail-wm1-f48.google.com with SMTP id q8-v6so8615341wmq.4 for ; Thu, 04 Oct 2018 04:22:51 -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 k7-v6sm5191789wmf.41.2018.10.04.04.22.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22:49 -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=oYTYFhU+gFcW4LRMcsYRu7kvC7H/VNDOoZY32j8XEvw=; b=YoSnLd4auawd2jPJz2J4RBQGRfkz2InanJv3RbVUh5uqgEa7kpv1qlXnBonJY0F1w2 NggnF+VzD6ltdgZKucQWwE+Dcst4Fd311/k/GM2ryllZIDQwHWrNMC0ebpgz4lBncoPf xoiSLyKRMmywZn61JynRjBALl99mTHVVvigrS7DzyZQg7hD/16SNLianMwlbgO7klF0h RIfM4t+LQ6bqUWE2XRYm1erg2uCz9T+eZR/qFJlaqu2dzWLmhdGowYnPqYyE4r8C78ai i9dXg+B7Rr95+WyJPELk1BUDAfYt58DKxTH+mS4bRIri73UFXi4O61xcbiC88WuBHwoK b2hw== X-Gm-Message-State: ABuFfoiodbJnfPudx3/iKZ0UJ6u32Iv+jHoNr0fm4WP3/n6pDcj+YQFv vB0EjwH6Aoi+qV8sFIvHfyF8ZXmHgsg= X-Google-Smtp-Source: ACcGV61i+twjxBxrGWZjc8jz1X9cSYHMwfaLCRRlolpzbSQQap4qB7xPwOs3WJyqiFHDlWWf5FCz9Q== X-Received: by 2002:a1c:1783:: with SMTP id 125-v6mr4492908wmx.75.1538652169964; Thu, 04 Oct 2018 04:22:49 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:35 +0200 Message-Id: X-Mailer: git-send-email 2.19.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.128.48 Subject: [Qemu-devel] [PATCH v4 08/11] qga-win: refactor disk 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Refactor building of disk info into a function that builds the list and a function that returns infor for single disk. This will be used in future commit that will handle multi-disk volumes. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-win32.c | 54 +++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 376ca1e288..1e64642b8a 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -632,20 +632,15 @@ out_free: return; } =20 -/* VSS provider works with volumes, thus there is no difference if - * the volume consist of spanned disks. Info about the first disk in the - * volume is returned for the spanned disk group (LVM) */ -static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **err= p) +static void get_single_disk_info(char *name, GuestDiskAddress *disk, + Error **errp) { - GuestDiskAddressList *list =3D NULL; - GuestDiskAddress *disk; SCSI_ADDRESS addr, *scsi_ad; DWORD len; HANDLE vol_h; Error *local_err =3D NULL; =20 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, @@ -655,7 +650,6 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) goto err; } =20 - disk =3D g_malloc0(sizeof(*disk)); get_disk_properties(vol_h, disk, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -676,7 +670,6 @@ static GuestDiskAddressList *build_guest_disk_info(char= *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; @@ -688,6 +681,7 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) g_debug("failed to get PCI controller info: %s", error_get_pretty(local_err)); error_free(local_err); + local_err =3D NULL; } 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, @@ -704,20 +698,44 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) disk->pci_controller =3D g_malloc0(sizeof(GuestPCIAddress)); } =20 - list =3D g_malloc0(sizeof(*list)); - list->value =3D disk; - list->next =3D NULL; - CloseHandle(vol_h); - g_free(name); - return list; - err_close: - g_free(disk); CloseHandle(vol_h); err: + return; +} + +/* VSS provider works with volumes, thus there is no difference if + * the volume consist of spanned disks. Info about the first disk in the + * volume is returned for the spanned disk group (LVM) */ +static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **err= p) +{ + Error *local_err =3D NULL; + GuestDiskAddressList *list =3D NULL, *cur_item =3D NULL; + GuestDiskAddress *disk =3D NULL; + + /* strip final backslash */ + char *name =3D g_strdup(guid); + if (g_str_has_suffix(name, "\\") =3D=3D TRUE) { + name[strlen(name) - 1] =3D 0; + } + + disk =3D g_malloc0(sizeof(GuestDiskAddress)); + get_single_disk_info(name, disk, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto out; + } + + cur_item =3D g_malloc0(sizeof(*list)); + cur_item->value =3D disk; + disk =3D NULL; + list =3D cur_item; + +out: + g_free(disk); g_free(name); =20 - return NULL; + return list; } =20 #else --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653524798925.0984135699058; Thu, 4 Oct 2018 04:45:24 -0700 (PDT) Received: from localhost ([::1]:55175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g824B-0005em-Ry for importer@patchew.org; Thu, 04 Oct 2018 07:45:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tG-0003ym-U1 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:34:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iW-0003aX-QT for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:56 -0400 Received: from mail-wm1-f43.google.com ([209.85.128.43]:51118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iW-0003Zl-K1 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:52 -0400 Received: by mail-wm1-f43.google.com with SMTP id s12-v6so8676706wmc.0 for ; Thu, 04 Oct 2018 04:22:52 -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 k7-v6sm5191789wmf.41.2018.10.04.04.22.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22:50 -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=oJv9BstmDlVkehEy0ySFqXk3YJMLikIowKYENfECsO4=; b=L53evVLON9TUSzvJi6f923KDe2R6S6tek5l2khQ+qrQx/e46bd+llyxG4ihzenFCSu Y77mD3a6IDP8OP426n3AQir1iKXE8OJXNU8Tifzkn5KE3GwttObpi/NfLSVzUEWcJ/9f 7T0DLC1MpVH2GDi6lz4bE6vnCXVZQXBeSA61HekPPIldymOJ1wUQBPUY0TGNmeLBLTtR 1NXmWds74PDrL86EXcroXNs9Pws1m2q0PCK6iAPzdWl8ot4eYbhK7tNPmud9Cn9JQfyq nZbBj/Bsn5owfTk7j1/g+kDT2UFqFkZHD/u5ltQHKbxfxUUKm02mxIAckVZoOVEdlqbV ReHg== X-Gm-Message-State: ABuFfogqeNz0IQO+GNerqnjqIhkBM3tS7D2faJ+VCFxbAC/UNO55oj6g JUl2UOw7Q2Ew1/lOkFM7CCavD6kOydQ= X-Google-Smtp-Source: ACcGV61PaodjvbiWJKxDwWdL5xYhsGPsjO4DCCf5xid2narPtHZijEnzQhuQlxcUk7+NuXGvCIBYaQ== X-Received: by 2002:a1c:ee15:: with SMTP id m21-v6mr4375463wmh.124.1538652171267; Thu, 04 Oct 2018 04:22:51 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:36 +0200 Message-Id: X-Mailer: git-send-email 2.19.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.128.43 Subject: [Qemu-devel] [PATCH v4 09/11] qga-win: handle multi-disk volumes 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Probe the volume for disk extents and return list of all disks. Originally only first disk of composite volume was returned. Note that the patch changes get_pci_info() from one state of brokenness into a different state of brokenness. In other words it still does not do what it's supposed to do (see comment in code). If anyone knows how to fix it, please step in. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-win32.c | 126 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 108 insertions(+), 18 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 1e64642b8a..a591d8221d 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -477,9 +477,26 @@ static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE= bus) return win2qemu[(int)bus]; } =20 +/* XXX: The following function is BROKEN! + * + * It does not work and probably has never worked. When we query for list = of + * disks we get cryptic names like "\Device\0000001d" instead of + * "\PhysicalDriveX" or "\HarddiskX". Whether the names can be translated = one + * way or the other for comparison is an open question. + * + * When we query volume names (the original version) we are able to match = those + * but then the property queries report error "Invalid function". (duh!) + */ + +/* DEFINE_GUID(GUID_DEVINTERFACE_VOLUME, 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); +*/ +DEFINE_GUID(GUID_DEVINTERFACE_DISK, + 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, + 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + =20 static GuestPCIAddress *get_pci_info(char *guid, Error **errp) { @@ -497,7 +514,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error = **errp) goto out; } =20 - dev_info =3D SetupDiGetClassDevs(&GUID_DEVINTERFACE_VOLUME, 0, 0, + dev_info =3D SetupDiGetClassDevs(&GUID_DEVINTERFACE_DISK, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (dev_info =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to get devices tree= "); @@ -637,20 +654,20 @@ static void get_single_disk_info(char *name, GuestDis= kAddress *disk, { SCSI_ADDRESS addr, *scsi_ad; DWORD len; - HANDLE vol_h; + HANDLE disk_h; Error *local_err =3D NULL; =20 scsi_ad =3D &addr; =20 g_debug("getting disk info for: %s", name); - vol_h =3D CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, + disk_h =3D CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if (vol_h =3D=3D INVALID_HANDLE_VALUE) { - error_setg_win32(errp, GetLastError(), "failed to open volume"); - goto err; + if (disk_h =3D=3D INVALID_HANDLE_VALUE) { + error_setg_win32(errp, GetLastError(), "failed to open disk"); + return; } =20 - get_disk_properties(vol_h, disk, &local_err); + get_disk_properties(disk_h, disk, &local_err); if (local_err) { error_propagate(errp, local_err); goto err_close; @@ -668,7 +685,7 @@ static void get_single_disk_info(char *name, GuestDiskA= ddress *disk, * 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, + if (DeviceIoControl(disk_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_= ad, sizeof(SCSI_ADDRESS), &len, NULL)) { disk->unit =3D addr.Lun; disk->target =3D addr.TargetId; @@ -699,8 +716,7 @@ static void get_single_disk_info(char *name, GuestDiskA= ddress *disk, } =20 err_close: - CloseHandle(vol_h); -err: + CloseHandle(disk_h); return; } =20 @@ -712,6 +728,10 @@ static GuestDiskAddressList *build_guest_disk_info(cha= r *guid, Error **errp) Error *local_err =3D NULL; GuestDiskAddressList *list =3D NULL, *cur_item =3D NULL; GuestDiskAddress *disk =3D NULL; + int i; + HANDLE vol_h; + DWORD size; + PVOLUME_DISK_EXTENTS extents =3D NULL; =20 /* strip final backslash */ char *name =3D g_strdup(guid); @@ -719,19 +739,89 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) name[strlen(name) - 1] =3D 0; } =20 - disk =3D g_malloc0(sizeof(GuestDiskAddress)); - get_single_disk_info(name, disk, &local_err); - if (local_err) { - error_propagate(errp, local_err); + g_debug("opening %s", name); + vol_h =3D CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, + 0, NULL); + if (vol_h =3D=3D INVALID_HANDLE_VALUE) { + error_setg_win32(errp, GetLastError(), "failed to open volume"); goto out; } =20 - cur_item =3D g_malloc0(sizeof(*list)); - cur_item->value =3D disk; - disk =3D NULL; - list =3D cur_item; + /* Get list of extents */ + g_debug("getting disk extents"); + size =3D sizeof(VOLUME_DISK_EXTENTS); + extents =3D g_malloc0(size); + if (!DeviceIoControl(vol_h, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, + 0, extents, size, NULL, NULL)) { + DWORD last_err =3D GetLastError(); + if (last_err =3D=3D ERROR_MORE_DATA) { + /* Try once more with big enough buffer */ + size =3D sizeof(VOLUME_DISK_EXTENTS) + + extents->NumberOfDiskExtents*sizeof(DISK_EXTENT); + g_free(extents); + extents =3D g_malloc0(size); + if (!DeviceIoControl( + vol_h, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, + 0, extents, size, NULL, NULL)) { + error_setg_win32(errp, GetLastError(), + "failed to get disk extents"); + return NULL; + } + } else if (last_err =3D=3D ERROR_INVALID_FUNCTION) { + /* Possibly CD-ROM or a shared drive. Try to pass the volume */ + g_debug("volume not on disk"); + disk =3D g_malloc0(sizeof(GuestDiskAddress)); + get_single_disk_info(name, disk, &local_err); + if (local_err) { + g_debug("failed to get disk info, ignoring error: %s", + error_get_pretty(local_err)); + error_free(local_err); + goto out; + } + list =3D g_malloc0(sizeof(*list)); + list->value =3D disk; + disk =3D NULL; + list->next =3D NULL; + goto out; + } else { + error_setg_win32(errp, GetLastError(), + "failed to get disk extents"); + goto out; + } + } + g_debug("Number of extents: %lu", extents->NumberOfDiskExtents); + + /* Go through each extent */ + for (i =3D 0; i < extents->NumberOfDiskExtents; i++) { + char *disk_name =3D NULL; + disk =3D g_malloc0(sizeof(GuestDiskAddress)); + + /* Disk numbers directly correspond to numbers used in UNCs + * + * See documentation for DISK_EXTENT: + * https://docs.microsoft.com/en-us/windows/desktop/api/winioctl/n= s-winioctl-_disk_extent + * + * See also Naming Files, Paths and Namespaces: + * https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-= a-file#win32-device-namespaces + */ + disk_name =3D g_strdup_printf("\\\\.\\PhysicalDrive%lu", + extents->Extents[i].DiskNumber); + get_single_disk_info(disk_name, disk, &local_err); + g_free(disk_name); + if (local_err) { + error_propagate(errp, local_err); + goto out; + } + cur_item =3D g_malloc0(sizeof(*list)); + cur_item->value =3D disk; + disk =3D NULL; + cur_item->next =3D list; + list =3D cur_item; + } + =20 out: + g_free(extents); g_free(disk); g_free(name); =20 --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653206293805.5016543990753; Thu, 4 Oct 2018 04:40:06 -0700 (PDT) Received: from localhost ([::1]:55140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81z3-0000qr-AM for importer@patchew.org; Thu, 04 Oct 2018 07:39:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tF-0004Be-R0 for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:34:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iY-0003cH-Fr for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:58 -0400 Received: from mail-wm1-f50.google.com ([209.85.128.50]:38541) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iY-0003bZ-8j for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:54 -0400 Received: by mail-wm1-f50.google.com with SMTP id 193-v6so8598547wme.3 for ; Thu, 04 Oct 2018 04:22:54 -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 k7-v6sm5191789wmf.41.2018.10.04.04.22.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22:52 -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=qS2f2v1zI9HNWeLvPN3uviTMmWFxvdf6H2VDxP5hhrE=; b=qoaKAexk1bWrhdg1zk4sRK3MT69bdSIoCLTdL+nuB6JQjOq0LujENPf4bsqivinANQ xK7yQ6uqu+ZiUKd7sUlxpQJTaq4K7Om3GoWgXQzr2SVQhF6AlYT6YUJsif5RKOCiNtK5 0354jrIYlnAZCYvdth8AOzpSslIVsj4RqQUBlWhANayPjIdkf/7DN/VcUX+mbLxdGgb7 CSYSWOtDKdgXUN8Sxc2Y4r4q2Z3rwWSyEa20OeEAdTo0a41B80cuvJJjIN9bZPb91ckC s2GRfJ1vXGU6W31tYgcNB7PzHNZmOUmKbsRZq/H6X17EeR+OJY3e78Jmr6wWC5jHEcjH TlrQ== X-Gm-Message-State: ABuFfogMspyhcIfTDtYEeKCmfycheOJgTFGdk9TcdiVLIUSG3uxqisOb bOvT2KWwR2ml5V9zI1n324LuMo/piaE= X-Google-Smtp-Source: ACcGV619ii7pKuCVt/C0F2no3Jwx9jBO+3EVXrLGRIvD4aW0nEVpVLDrWvpjML70TbdVrFu7IEBxqA== X-Received: by 2002:a1c:87ca:: with SMTP id j193-v6mr3991972wmd.99.1538652172823; Thu, 04 Oct 2018 04:22:52 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:37 +0200 Message-Id: X-Mailer: git-send-email 2.19.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.128.50 Subject: [Qemu-devel] [PATCH v4 10/11] qga: return disk device in guest-get-fsinfo 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Report device node of the disk. It is implemented for Linux (needs libudev) and Windows. The node is reported e.g. as "/dev/sda2" on Linux and as "\\.\PhysicalDriveX" on Windows. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD --- qga/commands-posix.c | 7 ++++++- qga/commands-win32.c | 21 +++++++++++---------- qga/qapi-schema.json | 3 ++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 4d324178f2..31952b07f4 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -950,7 +950,12 @@ static void build_guest_fsinfo_for_real_device(char co= nst *syspath, if (udev =3D=3D NULL || udevice =3D=3D NULL) { g_debug("failed to query udev"); } else { - const char *serial; + 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); diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a591d8221d..d0d969d0ce 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -649,8 +649,7 @@ out_free: return; } =20 -static void get_single_disk_info(char *name, GuestDiskAddress *disk, - Error **errp) +static void get_single_disk_info(GuestDiskAddress *disk, Error **errp) { SCSI_ADDRESS addr, *scsi_ad; DWORD len; @@ -659,8 +658,8 @@ static void get_single_disk_info(char *name, GuestDiskA= ddress *disk, =20 scsi_ad =3D &addr; =20 - g_debug("getting disk info for: %s", name); - disk_h =3D CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, + g_debug("getting disk info for: %s", disk->dev); + disk_h =3D CreateFile(disk->dev, 0, FILE_SHARE_READ, NULL, OPEN_EXISTI= NG, 0, NULL); if (disk_h =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to open disk"); @@ -692,7 +691,7 @@ static void get_single_disk_info(char *name, GuestDiskA= ddress *disk, disk->bus =3D addr.PathId; 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); + disk->pci_controller =3D get_pci_info(disk->dev, &local_err); =20 if (local_err) { g_debug("failed to get PCI controller info: %s", @@ -771,7 +770,9 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) /* Possibly CD-ROM or a shared drive. Try to pass the volume */ g_debug("volume not on disk"); disk =3D g_malloc0(sizeof(GuestDiskAddress)); - get_single_disk_info(name, disk, &local_err); + disk->has_dev =3D true; + disk->dev =3D g_strdup(name); + get_single_disk_info(disk, &local_err); if (local_err) { g_debug("failed to get disk info, ignoring error: %s", error_get_pretty(local_err)); @@ -793,7 +794,6 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) =20 /* Go through each extent */ for (i =3D 0; i < extents->NumberOfDiskExtents; i++) { - char *disk_name =3D NULL; disk =3D g_malloc0(sizeof(GuestDiskAddress)); =20 /* Disk numbers directly correspond to numbers used in UNCs @@ -804,10 +804,11 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) * See also Naming Files, Paths and Namespaces: * https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-= a-file#win32-device-namespaces */ - disk_name =3D g_strdup_printf("\\\\.\\PhysicalDrive%lu", + disk->has_dev =3D true; + disk->dev =3D g_strdup_printf("\\\\.\\PhysicalDrive%lu", extents->Extents[i].DiskNumber); - get_single_disk_info(disk_name, disk, &local_err); - g_free(disk_name); + + get_single_disk_info(disk, &local_err); if (local_err) { error_propagate(errp, local_err); goto out; diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json index 3bcda6257e..c6725b3ec8 100644 --- a/qga/qapi-schema.json +++ b/qga/qapi-schema.json @@ -835,6 +835,7 @@ # @target: target id # @unit: unit id # @serial: serial number (since: 3.1) +# @dev: device node (POSIX) or device UNC (Windows) (since: 3.1) # # Since: 2.2 ## @@ -842,7 +843,7 @@ 'data': {'pci-controller': 'GuestPCIAddress', 'bus-type': 'GuestDiskBusType', 'bus': 'int', 'target': 'int', 'unit': 'int', - '*serial': 'str'} } + '*serial': 'str', '*dev': 'str'} } =20 ## # @GuestFilesystemInfo: --=20 2.19.0 From nobody Sat Feb 7 16:26:52 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; 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 1538653233931561.7805963491701; Thu, 4 Oct 2018 04:40:33 -0700 (PDT) Received: from localhost ([::1]:55141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81zT-00019V-MJ for importer@patchew.org; Thu, 04 Oct 2018 07:40:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g81tF-0003yi-Oc for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:34:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g81iZ-0003d3-NT for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:59 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:33690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g81iZ-0003cT-GJ for qemu-devel@nongnu.org; Thu, 04 Oct 2018 07:22:55 -0400 Received: by mail-wr1-f53.google.com with SMTP id e4-v6so9519811wrs.0 for ; Thu, 04 Oct 2018 04:22:55 -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 k7-v6sm5191789wmf.41.2018.10.04.04.22.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Oct 2018 04:22:53 -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=ypMQ6lfWirY+rezQpG8/CfV0Gf4Exyk2pmQoLAKZGsY=; b=bYa3/h/FIJOenDf0Kp0mBx6D29hj6TyLv2vHF30HOhG2Gc+ppUvJTNOjUztcOM7uIq dLoAKRNGVAXTK0yxJuHuQn04uy8g92EhcsjGZLYXsbXpXkKjupdcspuZAEFmpWOPxlKN ZDOO26KLtt5EjNQ+f/iasgyJo8JopMy+akRcJnp96PFJC2cNrp6yOu2xaJ0V66P5b2TE ZCcLCWsWsf3OMVwFQZuz7wSXvtvp970LW9ktMHuvy0xj/MK1EVGp28j93agALKjnJ1B5 Or7xbDlCMqlxvrqjue0fmjsihr1YXK967jy3mJrD7IrpGANlBj6oNEoZeuBQMaNTJOzE Qyww== X-Gm-Message-State: ABuFfohLNSWd2MBdR0GSsKFF5BVOW4SZBaZBh2PobF6uCSnCeWzRyXC7 lYyxwQVre64Iw7VaDJxUpzD4WUHeXgk= X-Google-Smtp-Source: ACcGV628TAj0QNku+OS27X4zC+0ezWcmpupK9yKLCupJnvpjCgfvnd+ViahLSQV/80Ny9LZfd18l0g== X-Received: by 2002:adf:a40b:: with SMTP id d11-v6mr4362900wra.121.1538652174274; Thu, 04 Oct 2018 04:22:54 -0700 (PDT) From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2018 13:22:38 +0200 Message-Id: X-Mailer: git-send-email 2.19.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.53 Subject: [Qemu-devel] [PATCH v4 11/11] qga-win: demystify namespace striping 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: Michael Roth , Olga Krishtal , =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= , Sameeh Jubran , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 It was not obvious what exactly the cryptic string copying does to the GUID. This change makes the intent clearer. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Reviewed-by: Marc-Andr=C3=A9 Lureau --- qga/commands-win32.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index d0d969d0ce..82881aa749 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -507,7 +507,14 @@ static GuestPCIAddress *get_pci_info(char *guid, Error= **errp) char dev_name[MAX_PATH]; char *buffer =3D NULL; GuestPCIAddress *pci =3D NULL; - char *name =3D g_strdup(&guid[4]); + char *name =3D NULL; + + if ((g_str_has_prefix(guid, "\\\\.\\") =3D=3D TRUE) || + (g_str_has_prefix(guid, "\\\\?\\") =3D=3D TRUE)) { + name =3D g_strdup(&guid[4]); + } else { + name =3D g_strdup(guid); + } =20 if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) { error_setg_win32(errp, GetLastError(), "failed to get dos device n= ame"); --=20 2.19.0