All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virt.kvm: Handle migrate errors using QMP monitor properly
@ 2012-08-21 15:02 Lucas Meneghel Rodrigues
  2012-08-22 14:19 ` Luiz Capitulino
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Meneghel Rodrigues @ 2012-08-21 15:02 UTC (permalink / raw)
  To: autotest-kernel
  Cc: kvm, Lucas Meneghel Rodrigues, Qingtang Zhou, Gerd Hoffmann

When using QMP monitor as the sole monitor on KVM autotest
(something that we sadly did not exercise on our test farms),
starting qemu with -S and then issuing 'cont' will cause
errors, since the error treatment with QMP monitors is more
strict [1]. Take advantage of the fact that error treatment
with the QMP json structures is much easier, and handle
failures during migration accordingly.

With this patch, migration works properly using only QMP
monitors.

[1] This means we probably should be more rigorous treating
Human Monitor errors, but that's going to be handled later.

CC: Qingtang Zhou <qzhou@redhat.com>
CC: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/virt/kvm_monitor.py |  8 +++++++-
 client/virt/kvm_vm.py      | 10 +++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/client/virt/kvm_monitor.py b/client/virt/kvm_monitor.py
index 8b5e251..9d8ed87 100644
--- a/client/virt/kvm_monitor.py
+++ b/client/virt/kvm_monitor.py
@@ -1152,7 +1152,13 @@ class QMPMonitor(Monitor):
         args = {"uri": uri,
                 "blk": full_copy,
                 "inc": incremental_copy}
-        return self.cmd("migrate", args)
+        try:
+            return self.cmd("migrate", args)
+        except QMPCmdError, e:
+            if e.data['class'] == 'SockConnectInprogress':
+                logging.debug("Migrate socket connection still initializing...")
+            else:
+                raise e
 
 
     def migrate_set_speed(self, value):
diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index 871b824..19d018d 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -1743,7 +1743,15 @@ class VM(virt_vm.BaseVM):
                     output_params=(outfile,))
 
             # start guest
-            self.monitor.cmd("cont")
+            if self.monitor.verify_status("paused"):
+                try:
+                    self.monitor.cmd("cont")
+                except kvm_monitor.QMPCmdError, e:
+                    if ((e.data['class'] == "MigrationExpected") and
+                        (migration_mode is not None)):
+                        logging.debug("Migration did not start yet...")
+                    else:
+                        raise e
 
         finally:
             fcntl.lockf(lockfile, fcntl.LOCK_UN)
-- 
1.7.11.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] virt.kvm: Handle migrate errors using QMP monitor properly
  2012-08-21 15:02 [PATCH] virt.kvm: Handle migrate errors using QMP monitor properly Lucas Meneghel Rodrigues
@ 2012-08-22 14:19 ` Luiz Capitulino
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Capitulino @ 2012-08-22 14:19 UTC (permalink / raw)
  To: Lucas Meneghel Rodrigues
  Cc: autotest-kernel, kvm, Qingtang Zhou, Gerd Hoffmann

On Tue, 21 Aug 2012 12:02:11 -0300
Lucas Meneghel Rodrigues <lmr@redhat.com> wrote:

> When using QMP monitor as the sole monitor on KVM autotest
> (something that we sadly did not exercise on our test farms),
> starting qemu with -S and then issuing 'cont' will cause
> errors, since the error treatment with QMP monitors is more
> strict [1]. Take advantage of the fact that error treatment
> with the QMP json structures is much easier, and handle
> failures during migration accordingly.
> 
> With this patch, migration works properly using only QMP
> monitors.
> 
> [1] This means we probably should be more rigorous treating
> Human Monitor errors, but that's going to be handled later.
> 
> CC: Qingtang Zhou <qzhou@redhat.com>
> CC: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
> ---
>  client/virt/kvm_monitor.py |  8 +++++++-
>  client/virt/kvm_vm.py      | 10 +++++++++-
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/client/virt/kvm_monitor.py b/client/virt/kvm_monitor.py
> index 8b5e251..9d8ed87 100644
> --- a/client/virt/kvm_monitor.py
> +++ b/client/virt/kvm_monitor.py
> @@ -1152,7 +1152,13 @@ class QMPMonitor(Monitor):
>          args = {"uri": uri,
>                  "blk": full_copy,
>                  "inc": incremental_copy}
> -        return self.cmd("migrate", args)
> +        try:
> +            return self.cmd("migrate", args)
> +        except QMPCmdError, e:
> +            if e.data['class'] == 'SockConnectInprogress':

We've refactored our errors in QMP and most errors are going away (the one
above included). The only errors that are staying for compatibility are:
CommandNotFound, DeviceEncrypted, DeviceNotActive, DeviceNotFound, KVMMissingCap,
MigrationExpected. All other errors are going to be simply GenericError.

> +                logging.debug("Migrate socket connection still initializing...")
> +            else:
> +                raise e
>  
>  
>      def migrate_set_speed(self, value):
> diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
> index 871b824..19d018d 100644
> --- a/client/virt/kvm_vm.py
> +++ b/client/virt/kvm_vm.py
> @@ -1743,7 +1743,15 @@ class VM(virt_vm.BaseVM):
>                      output_params=(outfile,))
>  
>              # start guest
> -            self.monitor.cmd("cont")
> +            if self.monitor.verify_status("paused"):
> +                try:
> +                    self.monitor.cmd("cont")
> +                except kvm_monitor.QMPCmdError, e:
> +                    if ((e.data['class'] == "MigrationExpected") and
> +                        (migration_mode is not None)):
> +                        logging.debug("Migration did not start yet...")
> +                    else:
> +                        raise e
>  
>          finally:
>              fcntl.lockf(lockfile, fcntl.LOCK_UN)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-22 14:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21 15:02 [PATCH] virt.kvm: Handle migrate errors using QMP monitor properly Lucas Meneghel Rodrigues
2012-08-22 14:19 ` Luiz Capitulino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.