From patchwork Tue Oct 23 11:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWMP5FrBz9sN9 for ; Tue, 23 Oct 2018 22:27:29 +1100 (AEDT) Received: from localhost ([::1]:40292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuqN-0004Jb-Ab for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:27:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001qn-J4 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumf-0007go-Hv for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumb-0007Wv-Ss for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:34 -0400 Received: by mail-wr1-f67.google.com with SMTP id i4-v6so1241464wrr.13 for ; Tue, 23 Oct 2018 04:23:28 -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=v9SSjOz0Aei/EO+w4Nvr1ksZM1zbZHXZW64je/z4YG0=; b=NE0GhRPVDN06rlWHHEpLXg2PYkNl6Bu5KOq9Ehxo3VqL8YlyEQmYMdSxf9VpUVR9/F UZzdq2cTAabvVXejXxxlCHFx+nclCEsfdy0BKtsuEFB4BWjIY97W6rbaM3BCERiU1ROb 6HsEKRRnj1N2ayCHsRHr2CMK8ngqAJnS4NnVGYV9nbgyR6JslUlEXxVF4X5WQ7Syh/js 1YbqTs7BnO5oIgEfG/mMoJjW/AWavnNZD+YR2FDKodJhmH6dx1htB/n0gVOn7NhIygZi FsH2oHQMS+h+LUZJs2S6hJFf1bHQapG8sw5M886V0y04Xq3M4ctDsbRtS1E4VHBQglMf PZCg== X-Gm-Message-State: ABuFfoj5KSP4gkEMi9TAOa/C7s6/5wsE0tI8v0Nu4qRQamdwARY4HsoD ZFlpeRNrsfMZgJKPiGf6JXLG7uUe348= X-Google-Smtp-Source: ACcGV60weL7PYFjON+YURIB7SSVesMUrbFha9OvXYE+KRqGLj4XLWYobiXR0M9bZlCP9/vznU37VTg== X-Received: by 2002:adf:b743:: with SMTP id n3-v6mr50779088wre.274.1540293806755; Tue, 23 Oct 2018 04:23:26 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:25 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:10 +0200 Message-Id: <381564979b0059cf0acd44eeefe92e0ec3061a50.1540293795.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 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 v5 01/14] 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Tomáš Golembiovský Reviewed-by: Marc-André Lureau --- configure | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/configure b/configure index c3da1a2587..26e8605bbc 100755 --- a/configure +++ b/configure @@ -477,6 +477,7 @@ libxml2="" docker="no" debug_mutex="no" libpmem="" +libudev="no" # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64="aarch64-linux-gnu-gcc" @@ -873,6 +874,7 @@ Linux) vhost_vsock="yes" QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES" supported_os="yes" + libudev="yes" ;; esac @@ -5665,6 +5667,20 @@ if test "$libnfs" != "no" ; then fi fi +########################################## +# Do we have libudev +if test "$libudev" != "no" ; then + if $pkg_config libudev; then + libudev="yes" + libudev_libs=$($pkg_config --libs libudev) + else + if test "$libudev" = "yes" ; then + feature_not_found "libudev" "Install systemd development files" + fi + libudev="no" + fi +fi + # Now we've finished running tests it's OK to add -Werror to the compiler flags if test "$werror" = "yes"; then QEMU_CFLAGS="-Werror $QEMU_CFLAGS" @@ -6092,6 +6108,7 @@ echo "VxHS block device $vxhs" echo "capstone $capstone" echo "docker $docker" echo "libpmem support $libpmem" +echo "libudev $libudev" if test "$sdl_too_old" = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -6936,6 +6953,11 @@ if test "$docker" != "no"; then echo "HAVE_USER_DOCKER=y" >> $config_host_mak fi +if test "$libudev" != "no"; then + echo "CONFIG_LIBUDEV=y" >> $config_host_mak + echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak +fi + # use included Linux headers if test "$linux" = "yes" ; then mkdir -p linux-headers From patchwork Tue Oct 23 11:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWML16XNz9sN9 for ; Tue, 23 Oct 2018 22:27:26 +1100 (AEDT) Received: from localhost ([::1]:40288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuqJ-0004FN-Md for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:27:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumi-0001qX-48 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumc-0007ef-Vd for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:39 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEuma-0007YH-LR for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:33 -0400 Received: by mail-wr1-f66.google.com with SMTP id y16so1273521wrw.3 for ; Tue, 23 Oct 2018 04:23:29 -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=Jb1BKdBPDzdhlSdNyzWNIqF6KCjVYDbKtYetSmm9xNA=; b=c8Tih87vELh5MuSV02s11wY4xiZ2YB3dumG5i9/q7KkVbAk5oEUGn/SE8lSQFcwTff 9E27fa87zrtMlCqn3h66oYWVS+GkxRs4JhAQjrDHqeS7NPvMz+pNjx1R55/eqYWbkOGe 8e20iUZJCvqngJZpqOPDwD9rIW8g9pz8BN8PYvIFtUwzHGBpChUbK21UIOZ4gxC2XhAR PRYhcEWNAVfU7rjzUpypwJuC6ygDIkX5dZKlUTzbhCi2k+JpQJAb0eefR0hb2GoHa6UY ns9ikpkuKt41VKq5SXBnqRNZ1CDUAuk4RflrNrvS0m4cGaJPocwLwdezyJP6EM8lWiLo atQg== X-Gm-Message-State: ABuFfoi1jgAE/OGvrqXj/pMtb2MheOsYhKEOcn3pL8gLO/lSDzotUW02 VubvomIehvLkTbNKr4Is7FhzkiNx/44= X-Google-Smtp-Source: ACcGV62ThMpdKCIDtfXO4jFFYu0pGkXlqk4gOYQOGhWUGX7u5yY+kexen5VipRE+Ol978QXL6AZDPg== X-Received: by 2002:a5d:48cc:: with SMTP id p12-v6mr37403278wrs.122.1540293807928; Tue, 23 Oct 2018 04:23:27 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:27 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:11 +0200 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.66 Subject: [Qemu-devel] [PATCH v5 02/14] qga: linux: 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add reporting of disk serial number on Linux guests. The feature depends on libudev. Example: { "name": "dm-2", "mountpoint": "/", ... "disk": [ { "serial": "SAMSUNG_MZ7LN512HCHP-000L1_S1ZKNXAG822493", ... } ], } Signed-off-by: Tomáš Golembiovský --- qga/Makefile.objs | 1 + qga/commands-posix.c | 32 ++++++++++++++++++++++++++++++-- qga/qapi-schema.json | 4 +++- 3 files changed, 34 insertions(+), 3 deletions(-) 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 := $(LIBUDEV_LIBS) qga-obj-y = commands.o guest-agent-command-state.o main.o qga-obj-$(CONFIG_POSIX) += commands-posix.o channel-posix.o qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 37e8a2d791..d08719ba68 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -48,6 +48,10 @@ extern char **environ; #include #include +#ifdef CONFIG_LIBUDEV +#include +#endif + #ifdef FIFREEZE #define CONFIG_FSFREEZE #endif @@ -872,6 +876,10 @@ static void build_guest_fsinfo_for_real_device(char const *syspath, GuestDiskAddressList *list = NULL; bool has_ata = false, has_host = false, has_tgt = false; char *p, *q, *driver = NULL; +#ifdef CONFIG_LIBUDEV + struct udev *udev = NULL; + struct udev_device *udevice = NULL; +#endif p = 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 const *syspath, list = g_malloc0(sizeof(*list)); list->value = disk; +#ifdef CONFIG_LIBUDEV + udev = udev_new(); + udevice = udev_device_new_from_syspath(udev, syspath); + if (udev == NULL || udevice == NULL) { + g_debug("failed to query udev"); + } else { + const char *serial; + serial = udev_device_get_property_value(udevice, "ID_SERIAL"); + if (serial != NULL && *serial != 0) { + disk->serial = g_strdup(serial); + disk->has_serial = true; + } + } +#endif + if (strcmp(driver, "ata_piix") == 0) { /* a host per ide bus, target*:0::0 */ if (!has_host || !has_tgt) { @@ -995,14 +1018,19 @@ static void build_guest_fsinfo_for_real_device(char const *syspath, list->next = fs->disk; fs->disk = list; - g_free(driver); - return; + goto out; cleanup: if (list) { qapi_free_GuestDiskAddressList(list); } +out: g_free(driver); +#ifdef CONFIG_LIBUDEV + udev_unref(udev); + udev_device_unref(udevice); +#endif + return; } static void build_guest_fsinfo_for_device(char const *devpath, 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'} } ## # @GuestFilesystemInfo: From patchwork Tue Oct 23 11:23:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWQ63fQbz9sN9 for ; Tue, 23 Oct 2018 22:29:50 +1100 (AEDT) Received: from localhost ([::1]:40302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuse-00079o-1f for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:29:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001qp-JH for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumf-0007gt-I2 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumb-0007Yz-St for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:34 -0400 Received: by mail-wr1-f68.google.com with SMTP id d10-v6so1269440wrs.5 for ; Tue, 23 Oct 2018 04:23:30 -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=27B1fSel9gcyUfpSuvMQ+m8avd7XZlhqKZV94M3d3lM=; b=Nr8ijcvyvxCjbg/gk6nfnTOWFS45WX6QTGOfCVzzd+6JsiUhh2VxXW0zhAbqdsee1E DE23JNULUl+/jGVSyh38yPIhgifp6nZRfOZNHb7iSt5uADSGZ0JQxSM1JAfsfvC7aiJq 7oNMvQ1CTdGyIgRhyDT10AD8niI1GpYMV1VNOVBxiuTF5V0GFFeRFgJJaBOLiwugWTja YY4L4uW0S5dDDBtyOUpGC16fwHrJOcgpbm9vAmpeIQqjKSKpgdQeNjt5SMaj7MzQ9BTF sIHttl1s2bcCPyIdZuLSg4fSKE0uB5vzx9qHZ1q57cQJSxPoxmomxW1NmTHi7tCDgbG+ ODTA== X-Gm-Message-State: ABuFfogbBzUmqsmqnmMJsow8vBTBQBdilGI6t2cSoU11SxMIDIcP9xKH xOX2ybxsOcqFQdCirhEQTqTYruVmnfc= X-Google-Smtp-Source: ACcGV62CFVjm5mdOOQeTGgXDU3zX6YOfWg9Alsz5mzya6q2rjSvd2+oaPupOrFqtDLiZcDWkMTDfAw== X-Received: by 2002:adf:8425:: with SMTP id 34-v6mr46338360wrf.153.1540293809254; Tue, 23 Oct 2018 04:23:29 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:28 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:12 +0200 Message-Id: <0c23b5d49b0f355197b94eaf8685ccca2b46eb06.1540293795.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.68 Subject: [Qemu-devel] [PATCH v5 03/14] qga: linux: 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Report device node of the disk on Linux (e.g. "/dev/sda2"). Requirs libudev. Signed-off-by: Tomáš Golembiovský --- qga/commands-posix.c | 7 ++++++- qga/qapi-schema.json | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index d08719ba68..0c04937a13 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -950,7 +950,12 @@ static void build_guest_fsinfo_for_real_device(char const *syspath, if (udev == NULL || udevice == NULL) { g_debug("failed to query udev"); } else { - const char *serial; + const char *devnode, *serial; + devnode = udev_device_get_devnode(udevice); + if (devnode != NULL) { + disk->dev = g_strdup(devnode); + disk->has_dev = true; + } serial = udev_device_get_property_value(udevice, "ID_SERIAL"); if (serial != NULL && *serial != 0) { disk->serial = g_strdup(serial); 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'} } ## # @GuestFilesystemInfo: From patchwork Tue Oct 23 11:23:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWHw2F00z9sN9 for ; Tue, 23 Oct 2018 22:24:28 +1100 (AEDT) Received: from localhost ([::1]:40272 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEunR-0001sp-Of for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:24:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001qq-JO for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumf-0007hn-WC for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42306) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumc-0007ah-8E for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:36 -0400 Received: by mail-wr1-f67.google.com with SMTP id a9so1256765wrx.9 for ; Tue, 23 Oct 2018 04:23:32 -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=MZIg3TKh4tJfdWpxQEZBiPE59Bfdfyf9BbMYucvibcg=; b=D3kaHkr4dYJ3A5dWS4nWHdy89cnJh2oq6oCWX8BNboxqDVX4pgJFbGBz9iLERY+R7K dcdld3j0JOJbXp4k4tb0U1WxqoO2KX6GHAqt270vvkaQ33Pif7jP6Sa6xSEd7o/USKst xrjPtYgVtueH7Y9SUQjOgQMHNMEsrvwHWaRMVcfHK6BL7TS5RMtpDV2mdAX3qlswLCBG MFluZMwfOwwnn7KWTBLilXGSfvhBZRcV8j/Suura6Z4/QADX+sXN5T1/PXrBiHok6Gz5 CkO0uaAs/qnv3ycKE8y8kZJ/QJPCURQukHqmlZl6uPSE+EaoQqW4XWEEeilZeX8TOjcM B9LA== X-Gm-Message-State: ABuFfogRkfB0ZXrauBMc+h0Kj+6G2TOAd7ZeCU7CV3KHlA+p1kycUV2s c5VkXInJd/L+Qp4AlK0rvbUonvdjCoY= X-Google-Smtp-Source: ACcGV63+XUqLvL//r2Uy+/V/2q5MlHW9t1WRF+H7vWP8lOjTg8I3k0lUZ+FOeCuIyl0lZcg/vOxmYg== X-Received: by 2002:adf:8347:: with SMTP id 65-v6mr49713823wrd.264.1540293810947; Tue, 23 Oct 2018 04:23:30 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:30 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:13 +0200 Message-Id: <0480ec44dcd79afecf5903a1c0f5ac2092732d9a.1540293795.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 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 v5 04/14] qga-win: prevent crash when executing fsinfo command 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Sameeh Jubran The fsinfo command is currently implemented for Windows only and it's disk parameter can be enabled by adding the define "CONFIG_QGA_NTDDSCSI" to the qga code. When enabled and executed the qemu-ga crashed with the following message: ------------------------------------------------ File qapi/qapi-visit-core.c, Line 49 Expression: !(v->type & VISITOR_OUTPUT) || *obj) ------------------------------------------------ After some digging, turns out that the GuestPCIAddress is null and the qapi visitor doesn't like that, so we can always allocate it instead and initiate all it's members to -1. Signed-off-by: Sameeh Jubran Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Michael Roth (cherry picked from commit ecb8293d90eafde5b0423ef90aacfeff718ed913) Signed-off-by: Michael Roth Signed-off-by: Tomáš Golembiovský --- qga/commands-win32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 98d9735389..8289e7d6ea 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -485,6 +485,11 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) char *buffer = NULL; GuestPCIAddress *pci = NULL; char *name = g_strdup(&guid[4]); + pci = g_malloc0(sizeof(*pci)); + pci->domain = -1; + pci->slot = -1; + pci->function = -1; + pci->bus = -1; if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) { error_setg_win32(errp, GetLastError(), "failed to get dos device name"); @@ -556,7 +561,6 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) func = addr & 0x0000FFFF; dev = (addr >> 16) & 0x0000FFFF; - pci = g_malloc0(sizeof(*pci)); pci->domain = dev; pci->slot = slot; pci->function = func; From patchwork Tue Oct 23 11:23:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWHr6JBgz9sN9 for ; Tue, 23 Oct 2018 22:24:24 +1100 (AEDT) Received: from localhost ([::1]:40271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEunO-0001qt-Cq for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:24:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumi-0001qW-3l for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumg-0007i0-1w for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:39 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36631) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumc-0007c8-UQ for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:36 -0400 Received: by mail-wr1-f65.google.com with SMTP id y16so1273737wrw.3 for ; Tue, 23 Oct 2018 04:23:33 -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=gqgs3CiWI32X5dBjLd2AqB9RFIURkIv0v+aWB/iqlEY=; b=hoOjrSOFvYkMEI//ddvFlW9WHx+IwBJj2cz/ZWDvP+vojCmhCFmbKQD9Y0m3mP6jv2 i6OpiJdHVUQtmS1DjR7L2cUqDQHcUEfaQbbuO6Hpsm8JtQVhSfoQdZCunLGZ1ng/dsrX 84YoCKpR+gt46SsFPO3admjNCGdyZn+vmeBQSJHNpndoyY0kGVqiSy3oLUdquIqGTNMX B/icuqhFBHY4TxCoWydU27Ga+o1Ikbu20DzH9n4Qa29dpnOB1f3dJwvF3UXFAm5/F3Oj tKyP5qcsNbsmkxGjU9NgVF7c7nzLhdhaPPmqdlH3duxwt6xdhNAXUrB8R1hXejcf344H NZqg== X-Gm-Message-State: ABuFfohy5RyT/l336uGO/KPrDWBZQcCySTwLB5a/WKHqL1+KHl9uQWvv 9l1HbyaHFw8hmWFEYNheoGYJX4MEMJM= X-Google-Smtp-Source: ACcGV631yUNcqsdrqLfVPhHCkbbjkfmncFSjuWJkZX+7pgak/41WF9mvprYrWeRs96/w/o/sfDwxBA== X-Received: by 2002:a5d:5342:: with SMTP id t2-v6mr48454964wrv.257.1540293812073; Tue, 23 Oct 2018 04:23:32 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:31 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:14 +0200 Message-Id: <424c3de694d06531e3b21e5d965b4b7f7d7be190.1540293795.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 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 v5 05/14] qga-win: fsinfo: pci-info: allow partial info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , Olga Krishtal , =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Sameeh Jubran The call to SetupDiGetDeviceRegistryProperty might fail because the value doesn't exist in the registry, in this case we shouldn't exit from the loop but instead continue to look for other available values in the registry and set this value as unavailable (-1). Signed-off-by: Sameeh Jubran Signed-off-by: Michael Roth (cherry picked from commit d42f51de2d10b318d396f4f439f7a3995fdc0f65) Signed-off-by: Michael Roth Signed-off-by: Tomáš Golembiovský --- qga/commands-win32.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 8289e7d6ea..a8967abf06 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -505,7 +505,8 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA); for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) { - DWORD addr, bus, slot, func, dev, data, size2; + DWORD addr, bus, slot, data, size2; + int func, dev; while (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_PHYSICAL_DEVICE_OBJECT_NAME, &data, (PBYTE)buffer, size, @@ -535,21 +536,21 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) { - break; + bus = -1; } /* The function retrieves the device's address. This value will be * transformed into device function and number */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_ADDRESS, &data, (PBYTE)&addr, size, NULL)) { - break; + addr = -1; } /* This call returns UINumber of DEVICE_CAPABILITIES structure. * This number is typically a user-perceived slot number. */ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data, SPDRP_UI_NUMBER, &data, (PBYTE)&slot, size, NULL)) { - break; + slot = -1; } /* SetupApi gives us the same information as driver with @@ -559,12 +560,12 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) * DeviceNumber = (USHORT)(((propertyAddress) >> 16) & 0x0000FFFF); * SPDRP_ADDRESS is propertyAddress, so we do the same.*/ - func = addr & 0x0000FFFF; - dev = (addr >> 16) & 0x0000FFFF; + func = ((int) addr == -1) ? -1 : addr & 0x0000FFFF; + dev = ((int) addr == -1) ? -1 : (addr >> 16) & 0x0000FFFF; pci->domain = dev; - pci->slot = slot; + pci->slot = (int) slot; pci->function = func; - pci->bus = bus; + pci->bus = (int) bus; break; } From patchwork Tue Oct 23 11:23:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWMS2Tj7z9sN9 for ; Tue, 23 Oct 2018 22:27:32 +1100 (AEDT) Received: from localhost ([::1]:40293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuqP-0004L7-W7 for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:27:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001qo-JF for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumg-0007iP-6W for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36636) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumf-0007dP-HL for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:38 -0400 Received: by mail-wr1-f68.google.com with SMTP id y16so1273816wrw.3 for ; Tue, 23 Oct 2018 04:23:34 -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=QIRqdDEDCjzpcTJi3DEmJq4V6AN/2TLbW5wfi/ynF0U=; b=K0Ef9aW514++Y9f+XTN8Fo+EYGNoQPUhBApjqLqkiY9dTsVoimQ0SsjYv204UPxM6C FEC/nNcXs0qVJYPisKUvpzsJEO0ShuglguyyElLR96ZvI1f0jloJGuTlfZ0w7malsIrs e3HbyHuBtK24yxkqUhoiku+bWwMJnqIgdGiVr/GBKOJ4RDOhrHkM9/wFcEzo/ogy2f/W T6KFIAe7DyYukKlz+vA1ZP3IfE7xcOXfcwpE1S/vXpj1+wb9mK3ocWOZiebv+uel/k9J Oee4ejk/tu494KrQkw0121ONJa3qiV0YQp5wkUFM0my/w8Pht1ZaxkEYUA5+Mf5fU2MQ fu7w== X-Gm-Message-State: ABuFfojKJpxJtyFmWikBtSVOL/Qjc+WNeKRxY4MDLNyCCDJAil5VHsqz QhisohrhnDZF43NHFoG8VDMwVu2ZgsU= X-Google-Smtp-Source: ACcGV62/tga+NdoT8Fh+MHPxO4Kxu7JIDtAoqH8fmfwHmK/uFxUOqEfnUi8xxTFFHvpiEIhg8pNGsA== X-Received: by 2002:a5d:48cc:: with SMTP id p12-v6mr37403654wrs.122.1540293813500; Tue, 23 Oct 2018 04:23:33 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:32 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:15 +0200 Message-Id: <549ee1b2bd426c958e09aff0cec73443880c1348.1540293795.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.68 Subject: [Qemu-devel] [PATCH v5 06/14] *additonal fixup for NULL pci_controller field 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Michael Roth (cherry picked from commit 51fe925a7b473c76e06b60ddb8a862c91901b290) Signed-off-by: Michael Roth Signed-off-by: Tomáš Golembiovský --- qga/commands-win32.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a8967abf06..44b6b1ce88 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -627,6 +627,10 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) disk = g_malloc0(sizeof(*disk)); disk->bus_type = find_bus_type(bus); + /* always set pci_controller as required by schema. get_pci_info() should + * report -1 values for non-PCI buses rather than fail. + */ + disk->pci_controller = get_pci_info(name, errp); if (bus == BusTypeScsi || bus == BusTypeAta || bus == BusTypeRAID #if (_WIN32_WINNT >= 0x0600) /* This bus type is not supported before Windows Server 2003 SP1 */ @@ -641,12 +645,9 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) disk->unit = addr.Lun; disk->target = addr.TargetId; disk->bus = addr.PathId; - disk->pci_controller = get_pci_info(name, errp); } /* We do not set error in this case, because we still have enough * information about volume. */ - } else { - disk->pci_controller = NULL; } list = g_malloc0(sizeof(*list)); From patchwork Tue Oct 23 11:23:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWQ56kRGz9sNd for ; Tue, 23 Oct 2018 22:29:49 +1100 (AEDT) Received: from localhost ([::1]:40301 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEusd-00078U-Gh for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:29:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001qm-IB for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumi-0007jz-1x for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39132) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumg-0007ex-1Q for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:38 -0400 Received: by mail-wr1-f68.google.com with SMTP id r10-v6so363036wrv.6 for ; Tue, 23 Oct 2018 04:23:35 -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=s2YgaCnLP12cyII7rhvQCvotFBtfpUv1EX4w2HDrZb0=; b=MzRTeAs0bPZZgJtXsON6Ur0hFfh/+YNkYxMsOJmo8Io3KNDUgVkD0VFGLAN40gQ9oa C97LvbhGhQm8k3dTN0IHXLS0OdL9BDfC5XJuV7N5VkJO9TSs9QqsAPJfHIkGOjvqw8ue Kx1PFTUSmtFOJ2EcqsgY+Tz+UWhu7Sw/9vZtKM8DQXb7S54rycwrZNGuFVS7bL8+8ypH MbNx1a/7gwN2WeASC4f6zGCP4rKgyBI5ZwZtSpnonlaWf6KvkpnzwBlNnotmHcEExL/8 UH5wtfjYuMz5U7Xrh2oZBnHINTnstfQMTVAtlowUWWoG4BYs89ksTE+SdWtGRwBHGtSB UplA== X-Gm-Message-State: AGRZ1gKxQcJPVn9f/VWgY//mXGq++85SGfZq8oqVikkxEdxdrX1uSm/q kYad5OzjM+RAsNiW0SGfGoXBn5MeNpo= X-Google-Smtp-Source: AJdET5erShF2yNwOCNhzj1SgME+afOg+QE8sNqEnoxok0My2I4qTsiMzzKhb9+TtNVkuLUJG12Sz0w== X-Received: by 2002:a5d:4406:: with SMTP id z6-v6mr8765028wrq.308.1540293814731; Tue, 23 Oct 2018 04:23:34 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:33 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:16 +0200 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.68 Subject: [Qemu-devel] [PATCH v5 07/14] 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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áš Golembiovský Reviewed-by: Marc-André Lureau Reviewed-by: Sameeh Jubran --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 26e8605bbc..491e6e85c4 100755 --- a/configure +++ b/configure @@ -6204,7 +6204,7 @@ if test "$mingw32" = "yes" ; then echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak fi if test "$guest_agent_ntddscsi" = "yes" ; then - echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak + echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak fi if test "$guest_agent_msi" = "yes"; then echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak From patchwork Tue Oct 23 11:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWTV0tNDz9sNN for ; Tue, 23 Oct 2018 22:32:46 +1100 (AEDT) Received: from localhost ([::1]:40319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuvT-0000ii-Lk for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:32:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001qr-JL for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumi-0007kG-4y for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumg-0007g5-48 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:39 -0400 Received: by mail-wr1-f67.google.com with SMTP id t10-v6so1248729wrn.10 for ; Tue, 23 Oct 2018 04:23:37 -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=OIgNfiCRVar7f5mchA+lbc36v3cwZ4vJmRTbZZ83cSc=; b=fQShxB8LyRmjaPboeegZ41UrbOzsyz+0OBoasf+73cFsjQ6uj+IAk1e+EJBLC6Obus aAbNCfM0BY+ev4pU28zh643G/w6uC2uMPDOXo4Nc+bxmhRGAoZo8OcXOkLAKOLtjilXY u9KePZ61Rq5ZeaRtyQQX6JHQ9OdIXg+HuMGoXHPJ3uQu55MY2k8h3U5XWhuwxoiJCIWl 8eE/T72t4BFmyubkspLAG3zJ1alSiQBCvdMuNOeMf/1y6Mf747D6Nll9tc6y+H17CYiC OFya9yOwmkXU623e4NMgiQQGY9iCOMkKP0TD+qK51dzg0wxOWFM6gP1HjVFl5MeKEDYy Lbpg== X-Gm-Message-State: AGRZ1gJ39bMUd+cofDb7J6gyYT8jjLYdBfvOFU9cvAYk0aLwUQW8p4S3 +bI1xtIJVAJjO7/tHsoZQCLPJ+kPwvY= X-Google-Smtp-Source: AJdET5fmigp+1RmPJN9q4QeeMvkkLdYTLnJlh7csY3jpXJP4HYE8Fv/kGQ4fhEwx+hPE2BgMZx8lJg== X-Received: by 2002:a5d:558b:: with SMTP id i11-v6mr5860379wrv.38.1540293815884; Tue, 23 Oct 2018 04:23:35 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:35 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:17 +0200 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 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 v5 08/14] 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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áš Golembiovský Reviewed-by: Marc-André Lureau --- dtc | 2 +- qga/commands-win32.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dtc b/dtc index 88f18909db..e54388015a 160000 --- a/dtc +++ b/dtc @@ -1 +1 @@ -Subproject commit 88f18909db731a627456f26d779445f84e449536 +Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42 diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 44b6b1ce88..a3d28d06b3 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -89,6 +89,12 @@ static OpenFlags guest_file_open_modes[] = { {"a+b", FILE_GENERIC_APPEND|GENERIC_READ, OPEN_ALWAYS } }; +#define debug_error(msg) do { \ + char *suffix = 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; @@ -503,6 +509,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) goto out; } + g_debug("enumerating devices"); dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA); for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) { DWORD addr, bus, slot, data, size2; @@ -528,6 +535,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) if (g_strcmp0(buffer, dev_name)) { continue; } + g_debug("found device %s", dev_name); /* There is no need to allocate buffer in the next functions. The size * is known and ULONG according to @@ -536,6 +544,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"); bus = -1; } @@ -543,6 +552,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"); addr = -1; } @@ -550,6 +560,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"); slot = -1; } @@ -613,6 +624,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) scsi_ad = &addr; char *name = g_strndup(guid, strlen(guid)-1); + g_debug("getting disk info for: %s", name); vol_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (vol_h == INVALID_HANDLE_VALUE) { @@ -620,6 +632,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) goto out_free; } + g_debug("getting bus type"); bus = get_disk_bus_type(vol_h, errp); if (bus < 0) { goto out_close; @@ -627,6 +640,7 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) disk = g_malloc0(sizeof(*disk)); disk->bus_type = find_bus_type(bus); + g_debug("bus type %d", disk->bus_type); /* always set pci_controller as required by schema. get_pci_info() should * report -1 values for non-PCI buses rather than fail. */ @@ -640,6 +654,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=ws.10).aspx */ + g_debug("getting pci-controller info"); if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_ad, sizeof(SCSI_ADDRESS), &len, NULL)) { disk->unit = addr.Lun; From patchwork Tue Oct 23 11:23:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWHy0l6Jz9sN9 for ; Tue, 23 Oct 2018 22:24:30 +1100 (AEDT) Received: from localhost ([::1]:40274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEunT-0001u2-Hm for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:24:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001qs-Ji for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumi-0007l6-Fg for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumi-0007h8-86 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:40 -0400 Received: by mail-wr1-f68.google.com with SMTP id d10-v6so1269909wrs.5 for ; Tue, 23 Oct 2018 04:23:38 -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=s29R5/FRXevPoLX8I6gNciHnAQejaKibg9gsiOhCzVk=; b=ZSzc/y8c7oLG5dstCtO5Mp/lv9nXfZR8/sHlNk/D21zwPujpaiRgnhVdJDEdCYhgFE 4rEXwWCWKjr+/CqKtnclNfbWqYa9D5c4eCi+foivUIVSL0Xmv7jpU1NNFgvPUuKbck+T Xp/BhioKl9oyBDqPM4tnZ9IhetRDRzXrLZCCxS0jPJcub8ot4x1LuQw9b02awoOVxZKi ORFkmwLFINEoZhEA1jr+nUXQu5pAbNnD6FX8IIt9BIH3QMsse7W2KlOzQfBDGX2z9TUQ QzVMNuBazhNfFEKin0CNDaFB5YFXq3YJsZ7LXVgg67YJ3NA/dLRRJKhgMc5S383oWbh4 oC+A== X-Gm-Message-State: ABuFfogR1vT8HoV2Wm8S13j8aq9dER16wfz5QoTRv8gE3QHAbKEu6CzB jP5ORH+g3pb4zVTLVebgdXDjLiNFrLo= X-Google-Smtp-Source: ACcGV61fIvfFMiS//R5xFQ4ggAEhbvCP+85L1BpFkFzQz3Nfx/AGCjJzYj3Xxcm/K+7bGcXsMVJZ+g== X-Received: by 2002:a5d:5342:: with SMTP id t2-v6mr48455275wrv.257.1540293816944; Tue, 23 Oct 2018 04:23:36 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:36 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:18 +0200 Message-Id: <4a25866e48d9e3bb5c0b35547b723d1f4806b3c8.1540293796.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.68 Subject: [Qemu-devel] [PATCH v5 09/14] 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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áš Golembiovský --- qga/commands-win32.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index a3d28d06b3..5ebacd241f 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -588,25 +588,28 @@ out: return pci; } -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 = sizeof(buf); dev_desc = &buf; - dev_desc->Size = sizeof(buf); query.PropertyId = StorageDeviceProperty; query.QueryType = PropertyStandardQuery; 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 = find_bus_type(dev_desc->BusType); + g_debug("bus type %d", disk->bus_type); - return dev_desc->BusType; + return; } /* VSS provider works with volumes, thus there is no difference if @@ -618,8 +621,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 = NULL; scsi_ad = &addr; char *name = g_strndup(guid, strlen(guid)-1); @@ -629,26 +632,27 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) 0, NULL); if (vol_h == INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to open volume"); - goto out_free; + goto err; } - g_debug("getting bus type"); - bus = get_disk_bus_type(vol_h, errp); - if (bus < 0) { - goto out_close; + disk = g_malloc0(sizeof(*disk)); + get_disk_properties(vol_h, disk, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto err_close; } - disk = g_malloc0(sizeof(*disk)); - disk->bus_type = find_bus_type(bus); g_debug("bus type %d", disk->bus_type); /* always set pci_controller as required by schema. get_pci_info() should * report -1 values for non-PCI buses rather than fail. */ disk->pci_controller = get_pci_info(name, errp); - if (bus == BusTypeScsi || bus == BusTypeAta || bus == BusTypeRAID + if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI + || disk->bus_type == GUEST_DISK_BUS_TYPE_IDE + || disk->bus_type == GUEST_DISK_BUS_TYPE_RAID #if (_WIN32_WINNT >= 0x0600) /* This bus type is not supported before Windows Server 2003 SP1 */ - || bus == BusTypeSas + || disk->bus_type == GUEST_DISK_BUS_TYPE_SAS #endif ) { /* We are able to use the same ioctls for different bus types @@ -668,11 +672,17 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) list = g_malloc0(sizeof(*list)); list->value = disk; list->next = 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; } #else From patchwork Tue Oct 23 11:23:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988156 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWQ840HVz9sN9 for ; Tue, 23 Oct 2018 22:29:52 +1100 (AEDT) Received: from localhost ([::1]:40303 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEusg-0007BA-3R for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:29:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumk-0001ql-5d for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumi-0007kw-Co for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumi-0007in-44 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:40 -0400 Received: by mail-wr1-f65.google.com with SMTP id y16so1274076wrw.3 for ; Tue, 23 Oct 2018 04:23:39 -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=skZVrF37u6HGTAuOR7vryDJKJh6bnk3oKTcQQkTu3O8=; b=o6sLMy5jm5IJPHpcd+EBinbY5ZxkQV0D9AJ3Wx5zPh8b62tAgNmoflFKKqWCyo7MIs twncWyeNt8GzwjFpG2Te2ro+ZxhFVj+rQMSoiWC4EjKph0V5sxIPMQlMPuGBfCYVsFY5 3gWxiDeX/Y+ppK5r8rqQ3QB5h8l7cLw0EhHdmtOKvxpXhLhcb1xr47r/4e000yQP2o5o OGnkjrtu/DPs0D9byPXREVuBUuSwVKYSTYDL6iWd/VAp9K6ddxz6co0VPNVnUq3nQVTm 7SBf4m6G8gJriGtacVvybPPAOppW2/K5YJNarSIQjEzRl1iHXSQybSlCChg1qAuzYhkZ P7bQ== X-Gm-Message-State: AGRZ1gKPFWqzJaNmt+mPMJMGTiQiSUz4SzJmnmFaMUncHCeMveZrIVqi TJzX+P8KbhOi8afJ/UQ2sJb6jzQ9ktI= X-Google-Smtp-Source: AJdET5f8x1qqZ1AqKYYdibz6Um2Dpbw9C1rngpskwipV08jzapqozOaZqJ8w0oopLYkrkeF08f13ng== X-Received: by 2002:adf:e485:: with SMTP id i5-v6mr10299882wrm.145.1540293818041; Tue, 23 Oct 2018 04:23:38 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:37 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:19 +0200 Message-Id: <39758553c13a033021bd981d1cbaf1a170c453fd.1540293796.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 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 v5 10/14] qga-win: 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Tomáš Golembiovský --- qga/commands-win32.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 5ebacd241f..e7d9cdea62 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -609,6 +609,31 @@ static void get_disk_properties(HANDLE vol_h, GuestDiskAddress *disk, disk->bus_type = find_bus_type(dev_desc->BusType); g_debug("bus type %d", disk->bus_type); + /* Query once more. Now with long enough buffer. */ + size = dev_desc->Size; + dev_desc = 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 number"); + goto out_free; + } + if (dev_desc->SerialNumberOffset > 0) { + if (dev_desc->SerialNumberOffset >= received) { + error_setg(errp, "offset outside the buffer"); + goto out_free; + } + const char *serial = (char *)dev_desc + dev_desc->SerialNumberOffset; + size_t len = received - dev_desc->SerialNumberOffset; + if (*serial != 0) { + disk->serial = g_strndup(serial, len); + disk->has_serial = true; + g_debug("serial number %s", disk->serial); + } + } +out_free: + g_free(dev_desc); + return; } From patchwork Tue Oct 23 11:23:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988164 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWTX1DRgz9sNN for ; Tue, 23 Oct 2018 22:32:48 +1100 (AEDT) Received: from localhost ([::1]:40320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuvV-0000kb-OH for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:32:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuml-0001rP-61 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumj-0007lt-5i for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42320) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumi-0007l0-Ur for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:41 -0400 Received: by mail-wr1-f66.google.com with SMTP id a9so1257166wrx.9 for ; Tue, 23 Oct 2018 04:23: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=d491FpMiPyLN4soVzPHVurluyjfPPmTjI5R5mydFo7E=; b=SlcWuQvp9C1eKnrGj44LG/otFnDxw4XoxbwXeOwhGXdQ5q2tlkjSEHyAaHUnMlabdX Bo5YmJSrmldJ5lgxRqT9w1TIolSaHILKrIatUrKi++IhN+Wn8L/3fI50jbBv28DWxpgx cqfqmUzIf/IOHMSk1qGtYIshcKPBD3v3IxeO9ql/qXs2gXW8BFA/sCfgsPdcUiIzQEk4 xxHDF682S+LmpZ3CthBdE1kIDg+CYMT87Uw8zXHGneeKWUc26I4JhVw8+WgeUtTMgtsm MvBHvnsE3ofhR1AP+dskjkbmYtSOf3OQnmAqTUKTubI/D5hSIgkAIPhC6kKXYyLcczAf GnLw== X-Gm-Message-State: ABuFfoheqB4QFNa5vq+GlKgwN2CpgjRnOJzl+njcUqhKZZL3z0odJMpX /GEZvP69JMpmBYVfjHcR7KfJEyZYwkY= X-Google-Smtp-Source: ACcGV61Jvo2eKvoR9e5j+O31HFG9ItSn2nEzHwSlo/abu+PEtNZfyWJZSCwEeYLdM1kYagvB17lN0g== X-Received: by 2002:adf:ecc9:: with SMTP id s9-v6mr47109743wro.142.1540293819619; Tue, 23 Oct 2018 04:23:39 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:38 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:20 +0200 Message-Id: <9a5ef741f75e87ef47f2f36b4075d55789b30870.1540293796.git.tgolembi@redhat.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.221.66 Subject: [Qemu-devel] [PATCH v5 11/14] 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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áš Golembiovský --- qga/commands-win32.c | 58 ++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index e7d9cdea62..bb9bf0218a 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -637,20 +637,15 @@ out_free: 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 **errp) +static void get_single_disk_info(char *name, GuestDiskAddress *disk, + Error **errp) { - GuestDiskAddressList *list = NULL; - GuestDiskAddress *disk; SCSI_ADDRESS addr, *scsi_ad; DWORD len; HANDLE vol_h; Error *local_err = NULL; scsi_ad = &addr; - char *name = g_strndup(guid, strlen(guid)-1); g_debug("getting disk info for: %s", name); vol_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, @@ -660,7 +655,6 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) goto err; } - disk = g_malloc0(sizeof(*disk)); get_disk_properties(vol_h, disk, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -671,7 +665,11 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) /* always set pci_controller as required by schema. get_pci_info() should * report -1 values for non-PCI buses rather than fail. */ - disk->pci_controller = get_pci_info(name, errp); + disk->pci_controller = get_pci_info(name, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto err_close; + } if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI || disk->bus_type == GUEST_DISK_BUS_TYPE_IDE || disk->bus_type == GUEST_DISK_BUS_TYPE_RAID @@ -694,20 +692,44 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) * information about volume. */ } - list = g_malloc0(sizeof(*list)); - list->value = disk; - list->next = 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 **errp) +{ + Error *local_err = NULL; + GuestDiskAddressList *list = NULL, *cur_item = NULL; + GuestDiskAddress *disk = NULL; + + /* strip final backslash */ + char *name = g_strdup(guid); + if (g_str_has_suffix(name, "\\")) { + name[strlen(name) - 1] = 0; + } + + disk = g_malloc0(sizeof(GuestDiskAddress)); + get_single_disk_info(name, disk, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto out; + } + + cur_item = g_malloc0(sizeof(*list)); + cur_item->value = disk; + disk = NULL; + list = cur_item; + +out: + qapi_free_GuestDiskAddress(disk); g_free(name); - return NULL; + return list; } #else From patchwork Tue Oct 23 11:23:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWTV3G8Pz9sNf for ; Tue, 23 Oct 2018 22:32:46 +1100 (AEDT) Received: from localhost ([::1]:40318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuvU-0000iM-1I for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:32:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumm-0001sf-Aw for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumk-0007n9-II for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:44 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumk-0007mL-59 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:42 -0400 Received: by mail-wr1-f65.google.com with SMTP id r10-v6so363317wrv.6 for ; Tue, 23 Oct 2018 04:23:42 -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=KBurd7FjpCNqDHlBiPtRGCj5ouiHBlXtV4c/pDRqQ7w=; b=NDPe2n1xsPv6NuywxB5NVM3CcfjqGzCgc4Rdp6Yge72WyZ9DmGzCVfjdQO1lzJxBKP kQT7bqW9shNB6yJM2UTZrmaoQgOxh5lejBnAfUjQ1y6WWs4FRB4HhKjF/wc+BAqfPJPI kORtAC4H1NIWJP3Tj+X7NWQpQpNceMTLvCfDwPTp6hg9eVvLEfY4i9xWYckbGGWVldYu qXqBX2jUbMQaa6lmI1Sreqohz8Vxqya7Vu6Cvw+39wDriN7e/38Ej7cZICswqDr/az09 w5L2tBq18zmDPXbO7rX1rwI5nGJZGx12leCGeo7Kl/gS5nKihKXi324P2zrC+TSWxF6H WN6Q== X-Gm-Message-State: AGRZ1gISDzDTJ0H7GwK7HALT9Q52T8VBn+RO0yy+EmA5TkDWNKe4aIxa h9qBwB6+J5mNPzPDUbdOGQXsO5ppfWs= X-Google-Smtp-Source: AJdET5dvFBVxf5AtyFb+18d/vUxJuTWRFfo1KCZuzlxRRTzFYh3psN6Hv7yB0HY/Sw3e3W+sfDv9Bw== X-Received: by 2002:a5d:558b:: with SMTP id i11-v6mr5860683wrv.38.1540293820825; Tue, 23 Oct 2018 04:23:40 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:40 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:21 +0200 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 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 v5 12/14] 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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áš Golembiovský --- 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 bb9bf0218a..09566b3f47 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]; } +/* 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); + static GuestPCIAddress *get_pci_info(char *guid, Error **errp) { @@ -502,7 +519,7 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) goto out; } - dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_VOLUME, 0, 0, + dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DISK, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (dev_info == INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to get devices tree"); @@ -642,20 +659,20 @@ static void get_single_disk_info(char *name, GuestDiskAddress *disk, { SCSI_ADDRESS addr, *scsi_ad; DWORD len; - HANDLE vol_h; + HANDLE disk_h; Error *local_err = NULL; scsi_ad = &addr; g_debug("getting disk info for: %s", name); - vol_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, + disk_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if (vol_h == INVALID_HANDLE_VALUE) { - error_setg_win32(errp, GetLastError(), "failed to open volume"); - goto err; + if (disk_h == INVALID_HANDLE_VALUE) { + error_setg_win32(errp, GetLastError(), "failed to open disk"); + return; } - 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; @@ -682,7 +699,7 @@ static void get_single_disk_info(char *name, GuestDiskAddress *disk, * according to Microsoft docs * https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx */ g_debug("getting pci-controller info"); - if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_ad, + if (DeviceIoControl(disk_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_ad, sizeof(SCSI_ADDRESS), &len, NULL)) { disk->unit = addr.Lun; disk->target = addr.TargetId; @@ -693,8 +710,7 @@ static void get_single_disk_info(char *name, GuestDiskAddress *disk, } err_close: - CloseHandle(vol_h); -err: + CloseHandle(disk_h); return; } @@ -706,6 +722,10 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) Error *local_err = NULL; GuestDiskAddressList *list = NULL, *cur_item = NULL; GuestDiskAddress *disk = NULL; + int i; + HANDLE vol_h; + DWORD size; + PVOLUME_DISK_EXTENTS extents = NULL; /* strip final backslash */ char *name = g_strdup(guid); @@ -713,20 +733,90 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) name[strlen(name) - 1] = 0; } - disk = 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 = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, + 0, NULL); + if (vol_h == INVALID_HANDLE_VALUE) { + error_setg_win32(errp, GetLastError(), "failed to open volume"); goto out; } - cur_item = g_malloc0(sizeof(*list)); - cur_item->value = disk; - disk = NULL; - list = cur_item; + /* Get list of extents */ + g_debug("getting disk extents"); + size = sizeof(VOLUME_DISK_EXTENTS); + extents = g_malloc0(size); + if (!DeviceIoControl(vol_h, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, + 0, extents, size, NULL, NULL)) { + DWORD last_err = GetLastError(); + if (last_err == ERROR_MORE_DATA) { + /* Try once more with big enough buffer */ + size = sizeof(VOLUME_DISK_EXTENTS) + + extents->NumberOfDiskExtents*sizeof(DISK_EXTENT); + g_free(extents); + extents = 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 == ERROR_INVALID_FUNCTION) { + /* Possibly CD-ROM or a shared drive. Try to pass the volume */ + g_debug("volume not on disk"); + disk = 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 = g_malloc0(sizeof(*list)); + list->value = disk; + disk = NULL; + list->next = 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 = 0; i < extents->NumberOfDiskExtents; i++) { + char *disk_name = NULL; + disk = 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/ns-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 = 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 = g_malloc0(sizeof(*list)); + cur_item->value = disk; + disk = NULL; + cur_item->next = list; + list = cur_item; + } + out: qapi_free_GuestDiskAddress(disk); + g_free(extents); g_free(name); return list; From patchwork Tue Oct 23 11:23:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWXs5T5bz9sDC for ; Tue, 23 Oct 2018 22:35:40 +1100 (AEDT) Received: from localhost ([::1]:40332 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuyI-0002r6-7o for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:35:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumq-0001x2-FS for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEuml-0007pC-G5 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:48 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35529) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEuml-0007nD-8H for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:43 -0400 Received: by mail-wm1-f65.google.com with SMTP id w186-v6so1379144wmf.0 for ; Tue, 23 Oct 2018 04:23: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=YqYMldWxKOLj2KwTq553fOjb1H+/pMo5u05sjxiX0sk=; b=YOyxdAOOJMBMrWWug6cdqDIgsC3NJE7CdiGb7bIYa+2eA2VVfoQ2QoW6UJfqO/V04I VEQ+MLNqsqHqhx1GMcvEiPrd7i2fUjSG3fU+yP5Pq/juadh6cNSTgD72WThBR7sEbXij aDFnQAMaaxoeF6f6Myqa+AeuERRs6vDBr8O587Fph3j6kNFgItmEzddWPTNbeJkqVXuG luh+uYXRorCAsdib4GZp2k/QmtT+nbMCEnP3Kzc8PCf9HogDnJRO5eLMGWh00l7KMLBn l9J3sdFTeyZifdXRuvhmpaGuptcCJynmoWgniGhcPmHW5puZvoMB75D779Zxz3tyWSvs dlOw== X-Gm-Message-State: ABuFfojb89MB07tpUo8vm5vIE6R9k5q4rL2GYn1A9+jN7pDgYa/OMPR6 xDG6QXyoLJRnjEc4Tpb3J8wMtjYLlt8= X-Google-Smtp-Source: ACcGV60iM3xWyM08VQCAeh1XuDv43E2U4R0EUa4GEM5KPlpNKZA9zOAdchY3s+bDrxiT6xdBsFqwhA== X-Received: by 2002:a1c:c187:: with SMTP id r129-v6mr19559888wmf.20.1540293821852; Tue, 23 Oct 2018 04:23:41 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:41 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:22 +0200 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.65 Subject: [Qemu-devel] [PATCH v5 13/14] qga-win: 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Report device UNC of the disk. It is reported as "\\.\PhysicalDriveX". Signed-off-by: Tomáš Golembiovský --- qga/commands-win32.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 09566b3f47..12aba8cc50 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -654,8 +654,7 @@ out_free: return; } -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; @@ -664,8 +663,8 @@ static void get_single_disk_info(char *name, GuestDiskAddress *disk, scsi_ad = &addr; - g_debug("getting disk info for: %s", name); - disk_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, + g_debug("getting disk info for: %s", disk->dev); + disk_h = CreateFile(disk->dev, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (disk_h == INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to open disk"); @@ -682,7 +681,7 @@ static void get_single_disk_info(char *name, GuestDiskAddress *disk, /* always set pci_controller as required by schema. get_pci_info() should * report -1 values for non-PCI buses rather than fail. */ - disk->pci_controller = get_pci_info(name, &local_err); + disk->pci_controller = get_pci_info(disk->dev, &local_err); if (local_err) { error_propagate(errp, local_err); goto err_close; @@ -765,7 +764,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 = g_malloc0(sizeof(GuestDiskAddress)); - get_single_disk_info(name, disk, &local_err); + disk->has_dev = true; + disk->dev = 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)); @@ -787,7 +788,6 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp) /* Go through each extent */ for (i = 0; i < extents->NumberOfDiskExtents; i++) { - char *disk_name = NULL; disk = g_malloc0(sizeof(GuestDiskAddress)); /* Disk numbers directly correspond to numbers used in UNCs @@ -798,10 +798,11 @@ static GuestDiskAddressList *build_guest_disk_info(char *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 = g_strdup_printf("\\\\.\\PhysicalDrive%lu", + disk->has_dev = true; + disk->dev = 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; From patchwork Tue Oct 23 11:23:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= X-Patchwork-Id: 988168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42fWXt37L8z9sN9 for ; Tue, 23 Oct 2018 22:35:42 +1100 (AEDT) Received: from localhost ([::1]:40342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEuyJ-0002tM-Ux for incoming@patchwork.ozlabs.org; Tue, 23 Oct 2018 07:35:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEumr-0001yi-RQ for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEumm-0007qN-TY for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:49 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37850) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEumm-0007pO-M4 for qemu-devel@nongnu.org; Tue, 23 Oct 2018 07:23:44 -0400 Received: by mail-wm1-f68.google.com with SMTP id x19-v6so1365265wmc.2 for ; Tue, 23 Oct 2018 04:23: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=AGf2jCn6NBp1indlMDqYY918CooL347mtnpSMsGHL5M=; b=fQVbhXXUrDr4AnHqxRFBz8F8dWWAQwGFGAiJMfDr7tcik/ZyBaJJ6CzSnmh8hzU48g BQ3LwXHP3lxTFPNvt7PQJ3m+IehXht8o3Im91pDtrpcfeBo8uzfWw5o46QUKbEzAfXO8 U3Vaor84G3o5+OCQkrR+MG/zk0gMxhPsXJ48inJDnzd0/Uj0WHE8TBD2NRFCxIKXTRgc HSjem7TDnIp0n4IQK+f0KNO0/NO3zsbS9wA5EA9ZE1YUtp3/f4pDr7y1WF33JNijItAe hdmMRnK5aUbTZagKDUXIwgLOKwKZf075SvuxICHmUpuKSHjAso+zqH2iGPkigq3kuTbf olVg== X-Gm-Message-State: ABuFfohz1i+vvrd/Wc2fYEKgaYIYG/GoSCAyTCPlaN4SURUO7jo6C8Cu LUwVSRFnWQEu/0kh9+r+K79pozE+Ce0= X-Google-Smtp-Source: ACcGV63TeoLLWW8sWchahxE6fI/YzO7s0aYTV0Q1ZLsdAb8xYLjmKn9j3JZQ7i0bLTpFWU7TZrvrDw== X-Received: by 2002:a1c:c708:: with SMTP id x8-v6mr19748616wmf.116.1540293823277; Tue, 23 Oct 2018 04:23:43 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id g8-v6sm1498990wmf.45.2018.10.23.04.23.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 04:23:42 -0700 (PDT) From: =?utf-8?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:23:23 +0200 Message-Id: X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.68 Subject: [Qemu-devel] [PATCH v5 14/14] qga-win: demystify namespace stripping 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?b?VG9tw6HFoSBHb2xlbWJpb3Zza8O9?= , Sameeh Jubran , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It was not obvious what exactly the cryptic string copying does to the GUID. This change makes the intent clearer. Signed-off-by: Tomáš Golembiovský --- qga/commands-win32.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 12aba8cc50..779c8ce1fa 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -507,13 +507,21 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp) char dev_name[MAX_PATH]; char *buffer = NULL; GuestPCIAddress *pci = NULL; - char *name = g_strdup(&guid[4]); + char *name = NULL; + pci = g_malloc0(sizeof(*pci)); pci->domain = -1; pci->slot = -1; pci->function = -1; pci->bus = -1; + if (g_str_has_prefix(guid, "\\\\.\\") || + g_str_has_prefix(guid, "\\\\?\\")) { + name = g_strdup(guid + 4); + } else { + name = g_strdup(guid); + } + if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) { error_setg_win32(errp, GetLastError(), "failed to get dos device name"); goto out;