qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sameeh Jubran <sameeh@daynix.com>
To: qemu-devel@nongnu.org
Cc: Yan Vugenfirer <yan@daynix.com>,
	Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH] qga-win: Handle fstrim for OSes lower than Win8
Date: Sun, 24 Jun 2018 15:45:40 +0300	[thread overview]
Message-ID: <20180624124540.6659-1-sameeh@daynix.com> (raw)

From: Sameeh Jubran <sjubran@redhat.com>

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 <sjubran@redhat.com>
---
 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 <lm.h>
 #include <wtsapi32.h>
 #include <wininet.h>
+#include <versionhelpers.h>
 
 #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

             reply	other threads:[~2018-06-24 12:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-24 12:45 Sameeh Jubran [this message]
2018-07-16 11:43 ` [Qemu-devel] [PATCH] qga-win: Handle fstrim for OSes lower than Win8 Sameeh Jubran
2018-07-16 20:10 ` Michael Roth
2018-07-17  5:46   ` Sameeh Jubran
2018-07-24  0:06     ` Michael Roth
2018-07-17  9:34   ` Daniel P. Berrangé
2018-07-17 16:03     ` Michael Roth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180624124540.6659-1-sameeh@daynix.com \
    --to=sameeh@daynix.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yan@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).