From 11ae7a0a56776a21ef917e93fc2e057dd193fd45 Mon Sep 17 00:00:00 2001 From: Andrea Spadaccini <spadaccio@google.com> Date: Mon, 15 Aug 2011 13:21:57 +0100 Subject: [PATCH] Fixed potential unreferenced variable usage I noticed a path in the code that would use spice_ip_version even if it was not initialized. This patch fixes it. Signed-off-by: Andrea Spadaccini <spadaccio@google.com> Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/hypervisor/hv_kvm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 579e563de..10718a54f 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -721,6 +721,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): kvm_cmd.extend(["-serial", "none"]) spice_bind = hvp[constants.HV_KVM_SPICE_BIND] + spice_ip_version = None if spice_bind: if netutils.IsValidInterface(spice_bind): # The user specified a network interface, we have to figure out the IP @@ -756,11 +757,10 @@ class KVMHypervisor(hv_base.BaseHypervisor): # ValidateParameters checked it. spice_address = spice_bind - spice_arg = "addr=%s,ipv%s,port=%s" % (spice_address, - spice_ip_version, - instance.network_port) - - spice_arg = "%s,disable-ticketing" % spice_arg + spice_arg = "addr=%s,port=%s,disable-ticketing" % (spice_address, + instance.network_port) + if spice_ip_version: + spice_arg = "%s,ipv%s" % (spice_arg, spice_ip_version) logging.info("KVM: SPICE will listen on port %s", instance.network_port) kvm_cmd.extend(["-spice", spice_arg]) -- GitLab