KVM: improve socat interface
authorGuido Trotter <ultrotter@google.com>
Tue, 16 Dec 2008 16:24:08 +0000 (16:24 +0000)
committerGuido Trotter <ultrotter@google.com>
Tue, 16 Dec 2008 16:24:08 +0000 (16:24 +0000)
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
configure.ac
lib/constants.py
lib/hypervisor/hv_kvm.py

index 85a114b..ac2fdc6 100644 (file)
@@ -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
index 9c0a284..28c1940 100644 (file)
@@ -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
index ca0c38f..a5748c9 100644 (file)
@@ -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"
index 86890d8..f3f5b4e 100644 (file)
@@ -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):