From nobody Mon Feb 9 10:38:40 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