From patchwork Sun Jun 24 12:45:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sameeh Jubran X-Patchwork-Id: 10484149 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 407CB601C3 for ; Sun, 24 Jun 2018 12:46:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F44B2888B for ; Sun, 24 Jun 2018 12:46:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 238CE28994; Sun, 24 Jun 2018 12:46:48 +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 8E9F42888B for ; Sun, 24 Jun 2018 12:46:47 +0000 (UTC) Received: from localhost ([::1]:41790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fX4Pm-0004u0-TF for patchwork-qemu-devel@patchwork.kernel.org; Sun, 24 Jun 2018 08:46:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fX4Ov-0004cv-AN for qemu-devel@nongnu.org; Sun, 24 Jun 2018 08:45:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fX4Oq-0003JU-FB for qemu-devel@nongnu.org; Sun, 24 Jun 2018 08:45:53 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:46630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fX4Oq-0003JL-77 for qemu-devel@nongnu.org; Sun, 24 Jun 2018 08:45:48 -0400 Received: by mail-wr0-x241.google.com with SMTP id l14-v6so5820286wrq.13 for ; Sun, 24 Jun 2018 05:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:list-id; bh=X9YNwOu5bxDjjrWdxSXvXh5Xe2i8LYrT7q+fagns2h4=; b=HDt3RfU5gxrdX6Y5ZYo1ERgMO3iV8WnYEccC2X5Zdq2QrcWt3iv7GdYQhfPXNLPTEG nT3XXEUa+DnDL/NTb1mzLRu2c54fIlyJF/Jk0qSVW5UmIGcdeJbgwIDN1TOsY+pgf03M QYZCWeC/GO+AW43Y2/EmnrM26qVn/LmwLLoyg2FFc0T99la8lWUqtiRTv4FFavk1+kVU Cjo9cddnotF1N5j7oAWbuoIQpJZt4oMWWmvpmKj1H555RsnuPNJisK8C5qhcujqCjjWT P38vCqIt+IYqb8SJczElr+m3cMjyVtvPwQ7Z8AiQTUOn8H8f7DB7yyquw8tHFyf8113w v3hA== 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:list-id; bh=X9YNwOu5bxDjjrWdxSXvXh5Xe2i8LYrT7q+fagns2h4=; b=TNIObsGH2FDVbpQYm4k2P9ympTb4w6gjcJ0tUC2g3P4JeNYcC16e7/VayQ46XGYzOl uGhKPnFLf9nJyrjVKKT7HSo3t44qBaHvSmBYNt/GSFLyhTq4ANykL0ayt/vEJ00o/dXb Z4WgZXUoCifk8dRZahaXlFFmS0OJivTMfOtUsE8zKj3ylFCX1SV1IrujS6hrfkm6taaI 0ECMPEnW5ZjtgaHcxSr/gWpS909GyNfI3bx6u+oxhbJX1PyI+HNW9GFc68Q9e1tuOOEw AFpUOJvdq8ZXdH9OycjP+jz3OutwPuphs+d9aqNgbMX8X51tTKTzoxR7YoL3p5bhyae9 CUxA== X-Gm-Message-State: APt69E1uSpAS8yW9O3+ceLbyNNg/c1EYuwLCFoAJFTFybNL840M9XGMP gRHyhp7JwTaFbjN4v5qaP+9ouh1b X-Google-Smtp-Source: AAOMgpdMHF3OHs26itOCkxIUhpba21QVqJapGIFms4/8nMBSySXhUxU2kjXllJk1XIBoItpFZbKJPA== X-Received: by 2002:adf:fb43:: with SMTP id c3-v6mr7492279wrs.32.1529844346386; Sun, 24 Jun 2018 05:45:46 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id e63-v6sm8963404wma.46.2018.06.24.05.45.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Jun 2018 05:45:45 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org Date: Sun, 24 Jun 2018 15:45:40 +0300 Message-Id: <20180624124540.6659-1-sameeh@daynix.com> X-Mailer: git-send-email 2.13.6 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [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 , Michael Roth Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 #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");