diff mbox

Add UUID option into kvm command line

Message ID 1247843861-3976-1-git-send-email-yzhou@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yolkfull Chow July 17, 2009, 3:17 p.m. UTC
Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

Comments

Lucas Meneghel Rodrigues July 20, 2009, 12:43 p.m. UTC | #1
On Fri, 2009-07-17 at 23:17 +0800, Yolkfull Chow wrote:
> Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
> ---
>  client/tests/kvm/kvm_vm.py |   24 ++++++++++++++++++++++++
>  1 files changed, 24 insertions(+), 0 deletions(-)

Ok, I've followed the discussion around this patch, thanks Yolkfull and
Michael. Applied.

> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 503f636..48f2916 100644
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -107,6 +107,7 @@ class VM:
>          @param iso_dir: The directory where ISOs reside
>          """
>          self.pid = None
> +        self.uuid = None
>  
>          self.name = name
>          self.params = params
> @@ -287,6 +288,11 @@ class VM:
>          elif params.get("display") == "nographic":
>              qemu_cmd += " -nographic"
>  
> +        if params.get("uuid") == "random":
> +            qemu_cmd += " -uuid %s" % self.uuid
> +        elif params.get("uuid"):
> +            qemu_cmd += " -uuid %s" % params.get("uuid")
> +
>          return qemu_cmd
>  
> 
> @@ -371,6 +377,12 @@ class VM:
>              if params.get("display") == "vnc":
>                  self.vnc_port = kvm_utils.find_free_port(5900, 6000)
>  
> +            # Find random UUID if specified 'uuid = random' in config file
> +            if params.get("uuid") == "random":
> +                f = open("/proc/sys/kernel/random/uuid")
> +                self.uuid = f.read().strip()
> +                f.close()
> +
>              # Make qemu command
>              qemu_command = self.make_qemu_command()
>  
> @@ -732,3 +744,15 @@ class VM:
>                  self.send_key("shift-%s" % char.lower())
>              else:
>                  self.send_key(char)
> +
> +    
> +    def get_uuid(self):
> +        """
> +        Catch UUID of the VM.
> +
> +        @return: None,if not specified in config file
> +        """
> +        if self.params.get("uuid") == "random":
> +            return self.uuid
> +        else:
> +            return self.params.get("uuid", None)

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 503f636..48f2916 100644
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -107,6 +107,7 @@  class VM:
         @param iso_dir: The directory where ISOs reside
         """
         self.pid = None
+        self.uuid = None
 
         self.name = name
         self.params = params
@@ -287,6 +288,11 @@  class VM:
         elif params.get("display") == "nographic":
             qemu_cmd += " -nographic"
 
+        if params.get("uuid") == "random":
+            qemu_cmd += " -uuid %s" % self.uuid
+        elif params.get("uuid"):
+            qemu_cmd += " -uuid %s" % params.get("uuid")
+
         return qemu_cmd
 
 
@@ -371,6 +377,12 @@  class VM:
             if params.get("display") == "vnc":
                 self.vnc_port = kvm_utils.find_free_port(5900, 6000)
 
+            # Find random UUID if specified 'uuid = random' in config file
+            if params.get("uuid") == "random":
+                f = open("/proc/sys/kernel/random/uuid")
+                self.uuid = f.read().strip()
+                f.close()
+
             # Make qemu command
             qemu_command = self.make_qemu_command()
 
@@ -732,3 +744,15 @@  class VM:
                 self.send_key("shift-%s" % char.lower())
             else:
                 self.send_key(char)
+
+    
+    def get_uuid(self):
+        """
+        Catch UUID of the VM.
+
+        @return: None,if not specified in config file
+        """
+        if self.params.get("uuid") == "random":
+            return self.uuid
+        else:
+            return self.params.get("uuid", None)