From nobody Thu Nov 6 12:13:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540911023815220.21192284204608; Tue, 30 Oct 2018 07:50:23 -0700 (PDT) Received: from localhost ([::1]:53666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVLa-00038b-7F for importer@patchew.org; Tue, 30 Oct 2018 10:50:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVG9-0007Ve-GT for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHVG7-00009b-QK for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:45 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:39215) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHVG7-0008Lr-DR for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:43 -0400 Received: by mail-qt1-x831.google.com with SMTP id g10-v6so13718785qtq.6 for ; Tue, 30 Oct 2018 07:44:32 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id n39-v6sm18063573qtn.36.2018.10.30.07.44.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 07:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RPJEUP7diCJbHKDeII8UxiVI5VxahZogKC/CIYD6XH8=; b=ttZ8ThvGqil9qW1NvUN8bJFBb21GfI1CLe6pcMIIGi2lMPzOZfWV9NZAYspl9m6XHG ZVTw8bAT5oqA9ZSLW7Vb5kl0r6qlIIgxH/mgZ6viwHMhSdmpVBhGDb2fZger1lGk7O8V hNpIuoDoKdRUdE+NVpHEGud6jUW8GOlB4vKdxM1QdQMTT7UuWozFyFvR6V90SH4gT5ih 1Xc7DMGU5K0CqXj4d2xYja4RC15P8rvi2weeP0coygjA8g/b0FU+SQmEzD6hFPmDTMLB l7dmKK/GH4nDVYhcq1DEgijERN+KFEOgcdoROrE6wUb59r+Z+PBn8o5/+lbcRFrVvt4w W6VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RPJEUP7diCJbHKDeII8UxiVI5VxahZogKC/CIYD6XH8=; b=iIlwsDkY0fNQJYhJIDWkmKbsddzSGFFE+ZjJPFsTh1UN4VRsHfORDSfYDB/5HTcyAq VZzFCC/MGB9x6gpG2Lavmg3EtKIorJYgaZFneMg0OgH0NASwBhpDawgjISX0XBpQtjmz hBkgDpVhBtRzIA8bQjYAjay3xyzRnbuV1vNVZYJUOqPzGHKT9RurvDqDqFuGL8SDlE1V TA0rxROeYKRN390jx7UfhfF7A8JOlh1Baah/tBOASZoTlbuIhYNnQVyGmmKwOw0peC/k SGACMI55H5DLkKYG8ovt0dbH0+LAuYiXn/+O1YAq+DlXX5Ra7qzZGXTY0W862NjEsQqv i0FA== X-Gm-Message-State: AGRZ1gIj8ezgbSjEPzb0V/gE/MLPYvEQTiIK9i6odM6YlWvPxROX7nlK 1Th4ydj4+8NN0fEZq5aHlE9C4RG4 X-Google-Smtp-Source: AJdET5edD7Drb8eiEvcnKfdzUdzkgaUT+KFdUgH624IRTjNFytyXc2QCg1AD5+GYaR9I1bf//x+c0Q== X-Received: by 2002:ac8:4787:: with SMTP id k7-v6mr2478519qtq.191.1540910671660; Tue, 30 Oct 2018 07:44:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 09:43:45 -0500 Message-Id: <20181030144358.23144-12-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181030144358.23144-1-mdroth@linux.vnet.ibm.com> References: <20181030144358.23144-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::831 Subject: [Qemu-devel] [PULL 11/24] 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: peter.maydell@linaro.org, =?UTF-8?q?Tom=C3=A1=C5=A1=20Golembiovsk=C3=BD?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD 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 Signed-off-by: Michael Roth --- qga/commands-win32.c | 45 ++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 1a21aac5ad..1e91aa2343 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -613,25 +613,28 @@ 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); =20 - return dev_desc->BusType; + return; } =20 /* VSS provider works with volumes, thus there is no difference if @@ -643,7 +646,6 @@ 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 @@ -655,17 +657,16 @@ 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); /* always set pci_controller as required by schema. get_pci_info() sho= uld * report -1 values for non-PCI buses rather than fail. fail the comma= nd @@ -675,12 +676,14 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) disk->pci_controller =3D get_pci_info(name, &local_err); if (local_err) { error_propagate(errp, local_err); - goto out_close; + goto err_close; } - 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 @@ -700,11 +703,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.17.1