From 41e794f68b1d7f1136f19ba0bf575e47f3b314b8 Mon Sep 17 00:00:00 2001 From: Apollon Oikonomopoulos Date: Mon, 28 Feb 2011 13:51:14 +0200 Subject: [PATCH] KVM: use cache=none for shared disk templates Disable host cache for externally mirrored disks to avoid cache incoherency. Without this, migrations between the same two nodes may end up in disk corruption. This is a runtime override of cluster defaults, mostly a workaround. Unfortunately, we cannot use cmdlib._CheckHVParams, as we want to check the hypervisor parameters *in conjunction* with the disk template, which is part of the instance definition. Signed-off-by: Apollon Oikonomopoulos Signed-off-by: Iustin Pop Reviewed-by: Iustin Pop --- lib/hypervisor/hv_kvm.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 3e9e0250b..aef5fe1e8 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -1,7 +1,7 @@ # # -# Copyright (C) 2008, 2009, 2010 Google Inc. +# Copyright (C) 2008, 2009, 2010, 2011 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -534,7 +534,14 @@ class KVMHypervisor(hv_base.BaseHypervisor): if_val = ',if=%s' % disk_type # Cache mode disk_cache = hvp[constants.HV_DISK_CACHE] - if disk_cache != constants.HT_CACHE_DEFAULT: + if instance.disk_template in constants.DTS_EXT_MIRROR: + if disk_cache != "none": + # TODO: make this a hard error, instead of a silent overwrite + logging.warning("KVM: overriding disk_cache setting '%s' with 'none'" + " to prevent shared storage corruption on migration", + disk_cache) + cache_val = ",cache=none" + elif disk_cache != constants.HT_CACHE_DEFAULT: cache_val = ",cache=%s" % disk_cache else: cache_val = "" -- GitLab