From patchwork Tue Aug 21 15:02:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 1355481 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A81A6DFB34 for ; Tue, 21 Aug 2012 15:07:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751636Ab2HUPCY (ORCPT ); Tue, 21 Aug 2012 11:02:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61419 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751399Ab2HUPCW (ORCPT ); Tue, 21 Aug 2012 11:02:22 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7LF2LCR002791 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Aug 2012 11:02:21 -0400 Received: from freedom.redhat.com (vpn-11-36.rdu.redhat.com [10.11.11.36]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7LF2Dm7031368; Tue, 21 Aug 2012 11:02:14 -0400 From: Lucas Meneghel Rodrigues To: autotest-kernel@redhat.com Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues , Qingtang Zhou , Gerd Hoffmann Subject: [PATCH] virt.kvm: Handle migrate errors using QMP monitor properly Date: Tue, 21 Aug 2012 12:02:11 -0300 Message-Id: <1345561331-16019-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 CC: Gerd Hoffmann Signed-off-by: Lucas Meneghel Rodrigues --- 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)