From nobody Wed Nov 5 05:21:15 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 1532390967783367.5565850336143; Mon, 23 Jul 2018 17:09:27 -0700 (PDT) Received: from localhost ([::1]:37391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhktB-0003YR-0V for importer@patchew.org; Mon, 23 Jul 2018 20:09:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhkr7-0002RM-UL for qemu-devel@nongnu.org; Mon, 23 Jul 2018 20:07:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhkr4-0005B5-Pf for qemu-devel@nongnu.org; Mon, 23 Jul 2018 20:07:09 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:44349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhkr4-0005Ar-KD for qemu-devel@nongnu.org; Mon, 23 Jul 2018 20:07:06 -0400 Received: by mail-oi0-x244.google.com with SMTP id s198-v6so4378267oih.11 for ; Mon, 23 Jul 2018 17:07:06 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m62-v6sm27426197oik.30.2018.07.23.17.07.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 17:07:04 -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; bh=WL82KUHwurTq5cKzoN01viEOk8ThxEts57LsixCspiY=; b=gDLOpCwL5zUndz6eAWcfqd6eyQrN7Y8UfyKG7bNiANnJWeEfE5mOOOTZF6YR4rHVUB uyo6gon/IAzzrGsKMIn20L7xUkYtgHqZQ8VZbW+7rJw70d9xiWab08BaOZqlhuWgZiyC IDdU4Aib3ObX6m7uSzHetf/Wolv39oPKjgT/+//T284fpWYjbM8RvjJ9YlF9ATCIKxon NEFvtaEfJykjgS6S0R7dbQVCwjRM9rBKiuciryfh/AVQLMDe9cEDV9/KDhz6ZOZoeG52 paIKITeBiYyDHCR+GJsRblQLUzeRLOk8iTi3g+GjysV0FAeSk3Ev2scgeE9nvepbrY7x ePpg== 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; bh=WL82KUHwurTq5cKzoN01viEOk8ThxEts57LsixCspiY=; b=mdABjsR793ilGYFB/IveAnuQBhpjV/He1bQ5WgjPqv8HE04v4/noF0nLvGKKSDbAs3 HzNGbit4U9NvNHks/fPsSj+6gWR0twgY3Nh2dxi7mWme1v4skGEPDx00fqTLM2IMwWTn 8Hb/cSvvYlQvewgv7m4tPz2k+cGN8A5jo+Zs5ttymZbA1N7NQA0m4agzOtoVDuA4rFWA iMTSupAchy+fGAXPc9QEheezz+rUQ3XYcX27paD6q8oDDlmeqgYEr3yXLjja7yusXVAM LqysSNiqM8pVBOlnFz8HVlnV+b32v5Ob2amkgHEvMRlvWcPMjo9JpNCMfE/EowTmirkk GUWw== X-Gm-Message-State: AOUpUlH5Hgw0EY9WkOg6UQjgcnwpK/G2K8G9ZBhzcKDdSODux6WJIxPU juW89YU/IqpSrCT//czGRW4P+OlJnlnO+w== X-Google-Smtp-Source: AAOMgpdZKLha8885JVKCGnbsPPjZYxcPS9Vvip1W5ZDo/B/9vZZn2EZq66pWcC96gBYok/6TzZRNfQ== X-Received: by 2002:aca:698c:: with SMTP id e134-v6mr1060508oic.302.1532390825539; Mon, 23 Jul 2018 17:07:05 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 19:01:25 -0500 Message-Id: <20180724000126.21787-2-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180724000126.21787-1-mdroth@linux.vnet.ibm.com> References: <20180724000126.21787-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PULL for-3.0 1/2] 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: Sameeh Jubran , peter.maydell@linaro.org 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 * use alternative version query code proposed by Sameeh * fix up version check logic * avoid CamelCase variable names when possible Signed-off-by: Michael Roth --- qga/commands-win32.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 318d760a74..98d9735389 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -865,6 +865,19 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Er= ror **errp) GuestFilesystemTrimResponse *resp; HANDLE handle; WCHAR guid[MAX_PATH] =3D L""; + OSVERSIONINFO osvi; + BOOL win8_or_later; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize =3D sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + win8_or_later =3D (osvi.dwMajorVersion > 6 || + ((osvi.dwMajorVersion =3D=3D 6) && + (osvi.dwMinorVersion >=3D 2))); + if (!win8_or_later) { + error_setg(errp, "fstrim is only supported for Win8+"); + return NULL; + } =20 handle =3D FindFirstVolumeW(guid, ARRAYSIZE(guid)); if (handle =3D=3D INVALID_HANDLE_VALUE) { --=20 2.17.1