]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qcow2: Allow 'cache-clean-interval' in Linux only
authorAlberto Garcia <berto@igalia.com>
Fri, 25 Nov 2016 11:27:44 +0000 (13:27 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 25 Nov 2016 12:51:30 +0000 (13:51 +0100)
The cache-clean-interval option of qcow2 only works on Linux. However
we allow setting it in other systems regardless of whether it works or
not.

In those systems this option is not simply a no-op: it actually
invalidates perfectly valid cache tables for no good reason without
freeing their memory.

This patch forbids using that option in non-Linux systems.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c

index 7cfcd8412c5a3e6a17246a19ef36c07a130993e0..ed9e0f31d60bd620e174066189883df4fd4713e5 100644 (file)
@@ -668,6 +668,14 @@ static int qcow2_update_options_prepare(BlockDriverState *bs,
     r->cache_clean_interval =
         qemu_opt_get_number(opts, QCOW2_OPT_CACHE_CLEAN_INTERVAL,
                             s->cache_clean_interval);
+#ifndef CONFIG_LINUX
+    if (r->cache_clean_interval != 0) {
+        error_setg(errp, QCOW2_OPT_CACHE_CLEAN_INTERVAL
+                   " not supported on this host");
+        ret = -EINVAL;
+        goto fail;
+    }
+#endif
     if (r->cache_clean_interval > UINT_MAX) {
         error_setg(errp, "Cache clean interval too big");
         ret = -EINVAL;