diff mbox

[4/9] KVM test: Redirect the serial to the unix domain socket

Message ID 20100426100354.26268.97488.stgit@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Jason Wang April 26, 2010, 10:03 a.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 6bc7987..8f4753f 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -116,17 +116,20 @@  class VM:
         self.address_cache = address_cache
         self.pci_assignable = None
 
-        # Find available monitor filename
+        # Find available filenames for monitor and guest serial redirection
         while True:
-            # The monitor filename should be unique
+            # The filenames should be unique
             self.instance = (time.strftime("%Y%m%d-%H%M%S-") +
                              kvm_utils.generate_random_string(4))
-            self.monitor_file_name = os.path.join("/tmp",
-                                                  "monitor-" + self.instance)
-            if not os.path.exists(self.monitor_file_name):
-                break
-
 
+            names = [os.path.join("/tmp", type + self.instance) for type in
+                     "monitor-", "serial-"]
+            if True in [os.path.exists(file) for file in names]:
+                continue
+            else:
+                [self.monitor_file_name, self.serial_file_name] = names
+                break
+                                                         
     def clone(self, name=None, params=None, root_dir=None, address_cache=None):
         """
         Return a clone of the VM object with optionally modified parameters.
@@ -316,6 +319,8 @@  class VM:
             for pci_id in self.pa_pci_ids:
                 qemu_cmd += " -pcidevice host=%s" % pci_id
 
+        qemu_cmd += " -serial unix:%s,server,nowait" % self.serial_file_name
+
         return qemu_cmd