From 14aa53cbf83ea1fce32142fa44cf9c63bc2a1b9b Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Tue, 16 Dec 2008 16:24:08 +0000 Subject: [PATCH] KVM: improve socat interface Call socat with a full path specified at configure time, rather than just by its name, and check for the binary to exist at hypervisor verify. Reviewed-by: iustinp --- Makefile.am | 1 + configure.ac | 10 ++++++++++ lib/constants.py | 1 + lib/hypervisor/hv_kvm.py | 6 +++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 85a114bed..ac2fdc6d0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -294,6 +294,7 @@ lib/_autoconf.py: Makefile stamp-directories echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \ echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \ echo "KVM_PATH = '$(KVM_PATH)'"; \ + echo "SOCAT_PATH = '$(SOCAT_PATH)'"; \ } > $@ $(REPLACE_VARS_SED): Makefile stamp-directories diff --git a/configure.ac b/configure.ac index 9c0a2846c..28c194068 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,16 @@ AC_ARG_WITH([kvm-path], [kvm_path="/usr/bin/kvm"]) AC_SUBST(KVM_PATH, $kvm_path) +# --with-socat-path=... +AC_ARG_WITH([socat-path], + [AS_HELP_STRING([--with-socat-path=PATH], + [absolute path to the socat binary] + [ (default is /usr/bin/socat)] + )], + [socat_path="$withval"], + [socat_path="/usr/bin/socat"]) +AC_SUBST(SOCAT_PATH, $socat_path) + # Check common programs AC_PROG_INSTALL AC_PROG_LN_S diff --git a/lib/constants.py b/lib/constants.py index ca0c38f10..a5748c900 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -131,6 +131,7 @@ XEN_KERNEL = _autoconf.XEN_KERNEL XEN_INITRD = _autoconf.XEN_INITRD KVM_PATH = _autoconf.KVM_PATH +SOCAT_PATH = _autoconf.SOCAT_PATH VALUE_DEFAULT = "default" VALUE_AUTO = "auto" diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 86890d870..f3f5b4eca 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -256,6 +256,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): """Stop an instance. """ + socat_bin = constants.SOCAT_PATH pid_file = self._PIDS_DIR + "/%s" % instance.name pid = utils.ReadPidFile(pid_file) if pid > 0 and utils.IsProcessAlive(pid): @@ -264,7 +265,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): else: # This only works if the instance os has acpi support monitor_socket = '%s/%s.monitor' % (self._CTRL_DIR, instance.name) - socat = 'socat -u STDIN UNIX-CONNECT:%s' % monitor_socket + socat = '%s -u STDIN UNIX-CONNECT:%s' % (socat_bin, monitor_socket) command = "echo 'system_powerdown' | %s" % socat result = utils.RunCmd(command) if result.failed: @@ -352,6 +353,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): """ if not os.path.exists(constants.KVM_PATH): return "The kvm binary ('%s') does not exist." % constants.KVM_PATH + if not os.path.exists(constants.SOCAT_PATH): + return "The socat binary ('%s') does not exist." % constants.SOCAT_PATH + @classmethod def CheckParameterSyntax(cls, hvparams): -- GitLab