From: Michael Hanselmann Date: Mon, 17 Dec 2012 16:06:24 +0000 (+0100) Subject: hv_kvm: List of SPICE parameters should be module-global X-Git-Tag: v2.7.0beta1~301 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/07788a0bd71fa15ba9c56114777fdd94e7fc15d1 hv_kvm: List of SPICE parameters should be module-global This list is static at runtime and doesn't need to be recreated every time. Signed-off-by: Michael Hanselmann Reviewed-by: Guido Trotter --- diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 13e0ec4..a388ec2 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -68,6 +68,17 @@ IFF_TAP = 0x0002 IFF_NO_PI = 0x1000 IFF_VNET_HDR = 0x4000 +#: SPICE parameters which depend on L{constants.HV_KVM_SPICE_BIND} +_SPICE_ADDITIONAL_PARAMS = frozenset([ + constants.HV_KVM_SPICE_IP_VERSION, + constants.HV_KVM_SPICE_PASSWORD_FILE, + constants.HV_KVM_SPICE_LOSSLESS_IMG_COMPR, + constants.HV_KVM_SPICE_JPEG_IMG_COMPR, + constants.HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR, + constants.HV_KVM_SPICE_STREAMING_VIDEO_DETECTION, + constants.HV_KVM_SPICE_USE_TLS, + ]) + def _ProbeTapVnetHdr(fd): """Check whether to enable the IFF_VNET_HDR flag. @@ -1957,16 +1968,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): else: # All the other SPICE parameters depend on spice_bind being set. Raise an # error if any of them is set without it. - spice_additional_params = frozenset([ - constants.HV_KVM_SPICE_IP_VERSION, - constants.HV_KVM_SPICE_PASSWORD_FILE, - constants.HV_KVM_SPICE_LOSSLESS_IMG_COMPR, - constants.HV_KVM_SPICE_JPEG_IMG_COMPR, - constants.HV_KVM_SPICE_ZLIB_GLZ_IMG_COMPR, - constants.HV_KVM_SPICE_STREAMING_VIDEO_DETECTION, - constants.HV_KVM_SPICE_USE_TLS, - ]) - for param in spice_additional_params: + for param in _SPICE_ADDITIONAL_PARAMS: if hvparams[param]: raise errors.HypervisorError("spice: %s requires %s to be set" % (param, constants.HV_KVM_SPICE_BIND))