From nobody Thu Nov 6 12:14:36 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 1540950152670130.17307848343364; Tue, 30 Oct 2018 18:42:32 -0700 (PDT) Received: from localhost ([::1]:56590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHfWZ-0001U4-T6 for importer@patchew.org; Tue, 30 Oct 2018 21:42:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHfUc-0000JK-5N for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:40:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHfUY-00024V-AZ for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:40:22 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:37016) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHfUY-0001vC-28 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 21:40:18 -0400 Received: by mail-qt1-x82b.google.com with SMTP id d14-v6so15999371qto.4 for ; Tue, 30 Oct 2018 18:40:09 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id h49-v6sm19498217qth.32.2018.10.30.18.40.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 18:40:06 -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=hp3qt9IkDOcpKi589Sh7ImPk1oCZ109zYp31HNhpfEZN8jXga4DVJoURtaFmH3vI34 h1jNECGqQAYS7NGeRXt+TOaoKwEpWSYZQNMFv9tGwWLFv82XmzR3sHAhdwLFQM/Ambj9 h+gvIjt1wiKQcHR7nxSJQnibDrX1zo4MJxUK390Hlvmdj3YPJMlTb5OqF3+laLmmT8GB Np+7PW6w3+orm6yfylXD8qBRPs821Npp6UI2SltDy9Y/PaiwbBPSNFBOwSyvF9rhkAX4 Sfk8vairhSXB73TRMDyLjs+OnXEdVe19z3ObrOTA54pTopb8isptrZZxv9w3HzNADxbb UXhw== 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=mj8c7wL71dgqLTbgLjR2JW35s333hGcivegG5G1zAq9N65iWwJ3woiZetiTm2Y3yi9 gbAt3MQeEQZA8wguizXpSc/rUsVxGHU3WOfhPZmdvitd1RPl6wZ8ERpywmUKJZdDyZPG LiOMhCZk7oBCLgy0TBf2m7Y9gd3YCmeb+qvCaLYuW5n0E82WkrxfCISKyAYRz8eP6pJx AinBdniNFCEfy5zoioLDCJyy8nT2pfr6Jbg44P+bfwvte4fCVINPkZ8s8EtNIcP8eLxp SUlKt6qzIRoMDkpjHHKjO84KHzrW29/rPRuIFxaaFpL0kW2S0MC1ODS95fdUjTV4m2+L dD9A== X-Gm-Message-State: AGRZ1gK0yqud5WttqBLOBs6zTo/EOpFI9LR2EkKKJswWoqRJ8x9aeK2H bV4tHlfeB2YrNGLOPtcvmySDhEaz X-Google-Smtp-Source: AJdET5dQ40HT/pw/oJy96XL2B8ZT//i5rKUZpOWLQOr1YRbj+6JfLUeX3Kb+TzHULXhJlGmuGCOAHg== X-Received: by 2002:a0c:acaf:: with SMTP id m44mr972780qvc.142.1540950008068; Tue, 30 Oct 2018 18:40:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 20:38:08 -0500 Message-Id: <20181031013821.24023-12-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031013821.24023-1-mdroth@linux.vnet.ibm.com> References: <20181031013821.24023-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::82b Subject: [Qemu-devel] [PULL v2 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