From nobody Mon Nov 3 18:06:08 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529844433748117.38995792293076; Sun, 24 Jun 2018 05:47:13 -0700 (PDT) Received: from localhost ([::1]:41790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fX4Q5-0004u0-09 for importer@patchew.org; Sun, 24 Jun 2018 08:47:05 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 op= tion 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=3D1594113 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 =20 #include "qga/guest-agent-core.h" #include "qga/vss-win32.h" @@ -852,6 +853,11 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Er= ror **errp) HANDLE handle; WCHAR guid[MAX_PATH] =3D L""; =20 + if (!IsWindows8OrGreater()) { + error_setg(errp, "fstrim is only supported for Win8+"); + return NULL; + } + handle =3D FindFirstVolumeW(guid, ARRAYSIZE(guid)); if (handle =3D=3D INVALID_HANDLE_VALUE) { error_setg_win32(errp, GetLastError(), "failed to find any volume"= ); --=20 2.13.6