From nobody Thu Nov 6 12:13:06 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 1540911030604150.61482800155363; Tue, 30 Oct 2018 07:50:30 -0700 (PDT) Received: from localhost ([::1]:53667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVLh-0003AB-4F for importer@patchew.org; Tue, 30 Oct 2018 10:50:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHVG9-0007Vc-6f 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-00009V-LS for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:45 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:36241) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHVG7-0008TW-AN for qemu-devel@nongnu.org; Tue, 30 Oct 2018 10:44:43 -0400 Received: by mail-qt1-x829.google.com with SMTP id u34-v6so13726271qth.3 for ; Tue, 30 Oct 2018 07:44:39 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id a4-v6sm17559999qkb.62.2018.10.30.07.44.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Oct 2018 07:44:36 -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=NVXUYNeDrhjdeO57CII9mlPqqLk8udmn1Njwjh+9JQY=; b=mGyXbSaOiteF8B8DtVng9Zcyp4A+yiwPYdZywl3XrRHDP1jUIuM+mms0/WzHSujlmy j+OVdL1aV0TE8g75DBExotdbInG8xQclV94THvvALkJCOzmGl8OGRS9hmxjKCkDzoQDc RPg0Jkm9pGF7E6KZjvCG/4HD9XuJGwpEzoZp/DaA9Ow6/u+8KhgY31aXxQYVEFauJ6Wu ZiG8L9Gdrvh9eXO2dnbncx0TCX4Le2pfzIFL0JAyo0NCTy1oCxviW3FW0WUggyMJpT3G rb7X+wTcw7sAppQ35JJLXnRm0AUGLt+i5dgeB/2uVU5oAOR01B5CGvvqqHuEAe+K/szG CkfQ== 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=NVXUYNeDrhjdeO57CII9mlPqqLk8udmn1Njwjh+9JQY=; b=XN7MPhfEsN9k+kbgvvcb9L4PLL8wuZi4iK6Qow5qb6Zwecki4ppVJlz98kRaj1B/an PiNEDCg/698oPq5xtDFlIYfPJzh5nkrylV95IMB8Sw+fWQvKxvZHttFdAWy0TB9vasPs 7U7RPSspNVKM3ZopojDGKat6VdjvlMy5n5ZZdDyvbEHS0RelGdbfp1E6gJhVhxiCutqN Jh3YrjOhj2ibJ3IOrRO0HEMhI45SaaZGtnhgFWD42pI6SvBfJinhDKjexE3waf/VF4Jx nRJ/lv/+JjVmE5jNJfQXj65h/ZxbG0CXx9ueSo8QSZlQDARBOeQPJ7P2evOUDS/I3apI ZTTQ== X-Gm-Message-State: AGRZ1gKXA6JwFn8h6HjqSB5LrEenp/9J+vgHNmGfa+RXJG31Aa5A25Ov HGMXKAFNoOM0Cbyk2BSeC8PNPWh1 X-Google-Smtp-Source: AJdET5c+YFg06D6SRol81cxb5l8SJ2A3Z1gNPquGuDj+Adis5AEatscPJr7EoyVvPZNLGrymA/wZHw== X-Received: by 2002:a0c:8a54:: with SMTP id 20mr16850813qvu.94.1540910677416; Tue, 30 Oct 2018 07:44:37 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 30 Oct 2018 09:43:47 -0500 Message-Id: <20181030144358.23144-14-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::829 Subject: [Qemu-devel] [PULL 13/24] 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: 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 building of disk info into a function that builds the list and a function that returns infor for single disk. This will be used in future commit that will handle multi-disk volumes. Signed-off-by: Tom=C3=A1=C5=A1 Golembiovsk=C3=BD Signed-off-by: Michael Roth --- qga/commands-win32.c | 52 +++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 2d7b56d538..21a88d31e1 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -667,20 +667,15 @@ out_free: return; } =20 -/* VSS provider works with volumes, thus there is no difference if - * the volume consist of spanned disks. Info about the first disk in the - * volume is returned for the spanned disk group (LVM) */ -static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **err= p) +static void get_single_disk_info(char *name, GuestDiskAddress *disk, + Error **errp) { - GuestDiskAddressList *list =3D NULL; - GuestDiskAddress *disk; SCSI_ADDRESS addr, *scsi_ad; DWORD len; HANDLE vol_h; Error *local_err =3D NULL; =20 scsi_ad =3D &addr; - char *name =3D g_strndup(guid, strlen(guid)-1); =20 g_debug("getting disk info for: %s", name); vol_h =3D CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, @@ -690,7 +685,6 @@ static GuestDiskAddressList *build_guest_disk_info(char= *guid, Error **errp) goto err; } =20 - disk =3D g_malloc0(sizeof(*disk)); get_disk_properties(vol_h, disk, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -730,20 +724,44 @@ static GuestDiskAddressList *build_guest_disk_info(ch= ar *guid, Error **errp) * information about volume. */ } =20 - list =3D g_malloc0(sizeof(*list)); - list->value =3D disk; - list->next =3D NULL; - CloseHandle(vol_h); - g_free(name); - return list; - err_close: - g_free(disk); CloseHandle(vol_h); err: + return; +} + +/* VSS provider works with volumes, thus there is no difference if + * the volume consist of spanned disks. Info about the first disk in the + * volume is returned for the spanned disk group (LVM) */ +static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **err= p) +{ + Error *local_err =3D NULL; + GuestDiskAddressList *list =3D NULL, *cur_item =3D NULL; + GuestDiskAddress *disk =3D NULL; + + /* strip final backslash */ + char *name =3D g_strdup(guid); + if (g_str_has_suffix(name, "\\")) { + name[strlen(name) - 1] =3D 0; + } + + disk =3D g_malloc0(sizeof(GuestDiskAddress)); + get_single_disk_info(name, disk, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto out; + } + + cur_item =3D g_malloc0(sizeof(*list)); + cur_item->value =3D disk; + disk =3D NULL; + list =3D cur_item; + +out: + qapi_free_GuestDiskAddress(disk); g_free(name); =20 - return NULL; + return list; } =20 #else --=20 2.17.1