[Qemu-devel] [PATCH v8 12/13] qemu.py: launch vm only if it's not running

Amador Pahim posted 13 patches 8 years, 2 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v8 12/13] qemu.py: launch vm only if it's not running
Posted by Amador Pahim 8 years, 2 months ago
A new call to launch() with a running VM will fall in exception and
consequently call shutdown().

This patch makes launch() to raise an exception when it's called with VM
already running.

Signed-off-by: Amador Pahim <apahim@redhat.com>
---
 scripts/qemu.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/qemu.py b/scripts/qemu.py
index 03e4cc34b7..363f649a7e 100644
--- a/scripts/qemu.py
+++ b/scripts/qemu.py
@@ -165,6 +165,9 @@ class QEMUMachine(object):
         Try to launch the VM and make sure we cleanup and expose the
         command line/output in case of exception.
         '''
+        if self.is_running():
+            raise QEMUMachineError('VM already running')
+
         self._iolog = None
         self._qemu_full_args = None
         try:
-- 
2.13.5


Re: [Qemu-devel] [PATCH v8 12/13] qemu.py: launch vm only if it's not running
Posted by Fam Zheng 8 years, 2 months ago
On Fri, 09/01 13:28, Amador Pahim wrote:
> A new call to launch() with a running VM will fall in exception and
> consequently call shutdown().
> 
> This patch makes launch() to raise an exception when it's called with VM
> already running.
> 
> Signed-off-by: Amador Pahim <apahim@redhat.com>
> ---
>  scripts/qemu.py | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/scripts/qemu.py b/scripts/qemu.py
> index 03e4cc34b7..363f649a7e 100644
> --- a/scripts/qemu.py
> +++ b/scripts/qemu.py
> @@ -165,6 +165,9 @@ class QEMUMachine(object):
>          Try to launch the VM and make sure we cleanup and expose the
>          command line/output in case of exception.
>          '''
> +        if self.is_running():
> +            raise QEMUMachineError('VM already running')
> +
>          self._iolog = None
>          self._qemu_full_args = None
>          try:
> -- 
> 2.13.5
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>