From patchwork Tue Jul 17 05:46:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 10528135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 29F0A60247 for ; Tue, 17 Jul 2018 05:47:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1061C28B41 for ; Tue, 17 Jul 2018 05:47:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 008BD28B4A; Tue, 17 Jul 2018 05:47:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 53D6B28B3C for ; Tue, 17 Jul 2018 05:47:26 +0000 (UTC) Received: from localhost ([::1]:57194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffIpZ-0004KI-6p for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Jul 2018 01:47:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffIoj-00040V-Cb for qemu-devel@nongnu.org; Tue, 17 Jul 2018 01:46:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffIof-0001qj-BE for qemu-devel@nongnu.org; Tue, 17 Jul 2018 01:46:33 -0400 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]:46317) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffIoe-0001q5-Sm for qemu-devel@nongnu.org; Tue, 17 Jul 2018 01:46:29 -0400 Received: by mail-ed1-x542.google.com with SMTP id o8-v6so138854edt.13 for ; Mon, 16 Jul 2018 22:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=xfsD0/db/83bQPVZgAcu8ciNReQGhFTRZAuk3/PcT6s=; b=IZMDTTKkJPv1B9m+uu8CC7X2/Ha8vHAkTRec3lTjgYQh0nxIsy2Tt6s1RL93XyD0Rr UhUqjfmUq0TloFDpRcpCLEn+UmX9c6aWF8nwPDT/c1Z9uSb/NnAq3E9flnImuc7goMjW 3cvWEZu1oq7ftKTOKnWUc81rDa6lHShGOWd1QTneDUN4L0c1GVMLYE9Zin2IRW53zy5b dGQOjZCGY+ZIZAWh9C7TVF0TEptpfFq+VxYP5VT06gDCw07dvYQM/GSCMCZ2S6+lnEgn g7cewF9l5rRKVfdtmkhMsNW+yTeCJZG0BFl4QxImsoXWRlN7uhhHtXTQXZX9LcqgoIID PPrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=xfsD0/db/83bQPVZgAcu8ciNReQGhFTRZAuk3/PcT6s=; b=R7mqYb1Yu2cSTfL+x7HKInuL3FDeCs7RVOAcAiAXw2GLMXOKmvjspFwN51UfOtXoLh cqcDYimyFEXCjYP0xdlSjSD2n1jC3AjEDb/vqXzjb4CoWUQlQRES8q8Yd299etFW0oOg gz+QzgbLBWz3BBPn2+MyKOmI0QEnMozonZ3WLzn4YpA2P7FFnbfZfxJNi34KTbEXlskF MzRDIfGcy0oN9lJQxyms9MfO9Bs5HY1AgtKJ/sBVRpeJ0pGgg32b7MBr+MDQsM6f9lnj /abhtUNCISc+JaM+jYVUDKtJsCZ6Bt9KzECFLUuP2cFX7IFOHFksllAgUC37R/YqtorN p0wA== X-Gm-Message-State: AOUpUlELlbUlk/bDE9mua1zCZs9gpSsJ5mVlfbjQ0TtP3UpKSKJnKghw F/4X+v5IsXzmOr6edwYcnEuekyt8rUotktFI9Oglkw== X-Google-Smtp-Source: AAOMgpeOwqIrR33uhG4nvyN77jH9YdDTUnab/Sj2d/lZmt11DqjqaMRxI1yfUBlbHQUK5as7Zkq74BDr9JOizkfGWig= X-Received: by 2002:a50:f78a:: with SMTP id h10-v6mr739205edn.37.1531806387636; Mon, 16 Jul 2018 22:46:27 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:baca:0:0:0:0:0 with HTTP; Mon, 16 Jul 2018 22:46:27 -0700 (PDT) X-Originating-IP: [89.139.16.241] In-Reply-To: <153177183866.7766.1789433991037567183@sif> References: <20180624124540.6659-1-sameeh@daynix.com> <153177183866.7766.1789433991037567183@sif> From: Sameeh Jubran Date: Tue, 17 Jul 2018 08:46:27 +0300 Message-ID: To: Michael Roth X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::542 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [Qemu-devel] [PATCH] qga-win: Handle fstrim for OSes lower than Win8 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: Yan Vugenfirer , QEMU Developers Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP I'v successfully compiled the previous patch on Fedora 27, but it seems to be failing on RHEL, You can apply this patch instead which avoids using the versionhelpers header: --- qga/commands-win32.c | 11 +++++++++++ 1 file changed, 11 insertions(+) handle = FindFirstVolumeW(guid, ARRAYSIZE(guid)); if (handle == INVALID_HANDLE_VALUE) { -- 2.8.1.185.gdc0db2c On Mon, Jul 16, 2018 at 11:10 PM, Michael Roth wrote: > Quoting Sameeh Jubran (2018-06-24 07:45:40) > > From: Sameeh Jubran > > > > The defrag.exe tool which is used for executing the fstrim command > > on Windows doesn't support retrim for OSes lower than Win8. This > > commit handles this case and returns a suitable error. > > > > Output of fstrim before this commit: > > {"execute":"guest-fstrim"} > > {"return": {"paths": [{"path": "C:\\", "error": "An invalid command line > option > > was specified. (0x89000008)"}, {"path": "F:\\", "error": "An invalid > command > > line option was specified. (0x89000008)"}, {"path": "S:\\", "error": "An > > invalid command line option was specified. (0x89000008)"}]}} > > > > Reported on: > > https://bugzilla.redhat.com/show_bug.cgi?id=1594113 > > > > Signed-off-by: Sameeh Jubran > > --- > > qga/commands-win32.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/qga/commands-win32.c b/qga/commands-win32.c > > index d79974f212..0bdcd9dd38 100644 > > --- a/qga/commands-win32.c > > +++ b/qga/commands-win32.c > > @@ -30,6 +30,7 @@ > > #include > > #include > > #include > > +#include > > I have this queued locally but the mingw64 build environment I've been > using (fc20) doesn't support this header and I'm running into some odd > null pointer / 0xc0000005 / access violation issues with the binary > generated in newer tool chains. I'll send a pull for this next week when > I can get it tested. > > What build envionment are you using? > > > > > #include "qga/guest-agent-core.h" > > #include "qga/vss-win32.h" > > @@ -852,6 +853,11 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, > Error **errp) > > HANDLE handle; > > WCHAR guid[MAX_PATH] = L""; > > > > + if (!IsWindows8OrGreater()) { > > + error_setg(errp, "fstrim is only supported for Win8+"); > > + return NULL; > > + } > > + > > handle = FindFirstVolumeW(guid, ARRAYSIZE(guid)); > > if (handle == INVALID_HANDLE_VALUE) { > > error_setg_win32(errp, GetLastError(), "failed to find any > volume"); > > -- > > 2.13.6 > > > diff --git a/qga/commands-win32.c b/qga/commands-win32.c index fb91f5d..e688e71 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -846,6 +846,17 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp) GuestFilesystemTrimResponse *resp; HANDLE handle; WCHAR guid[MAX_PATH] = L""; + OSVERSIONINFO osvi; + BOOL bIsWindows8orLater; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + bIsWindows8orLater = ((osvi.dwMajorVersion == 6) && (osvi.dwMinorVersion >= 2)); + if (!bIsWindows8orLater) { + error_setg(errp, "fstrim is only supported for Win8+"); + return NULL; + }