Commit 14aa53cb authored by Guido Trotter's avatar Guido Trotter

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
parent dd71f05b
......@@ -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
......
......@@ -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
......
......@@ -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"
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment