From patchwork Thu Oct 18 09:14:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 192246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7DBBA2C0082 for ; Thu, 18 Oct 2012 20:14:52 +1100 (EST) Received: from localhost ([::1]:35486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOmBm-0001aO-6s for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 05:14:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOmBa-0001aF-UO for qemu-devel@nongnu.org; Thu, 18 Oct 2012 05:14:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOmBV-0006P4-5A for qemu-devel@nongnu.org; Thu, 18 Oct 2012 05:14:38 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:54274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOmBU-0006Oy-V6 for qemu-devel@nongnu.org; Thu, 18 Oct 2012 05:14:33 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so8182494pad.4 for ; Thu, 18 Oct 2012 02:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=8GmhgD99IftTlkuzmYEBxFemhulKg77r5XjjlDozP7Y=; b=UqDQDLcWlhvTV6HMmEooPBLDDB9zyTwGhBq7JoT8AYPX5lielM5KvCDDaNPdvFHG8W 0whkodTgcKG+QkoaBuQc0Ud97WglGKlizzatcHyobl3G/xj3HNUZ/VVIcQxZXNS8n3Ak Z+erMOMyP0ySMmzNmb+t+0efmVwak48y/vvQZm14iUmGYsfo61QQPfHwbqCYi4jTNpks wHR5c1EydUbElwHnKvUCheayFITHHfcQ54c1o7RHg17a3WRWU38O+tIpYYgMyb/AJwgW AEaEHGBdcKInSe8DWNRTefuT28+k/7Ts/cQpAuNQYpFMCXYrnx+GNLVnPhl2ez707Dtp qqQw== Received: by 10.68.230.66 with SMTP id sw2mr64411329pbc.119.1350551672253; Thu, 18 Oct 2012 02:14:32 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id iu8sm13942005pbc.71.2012.10.18.02.14.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 18 Oct 2012 02:14:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2012 11:14:22 +0200 Message-Id: <1350551662-18408-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.45 Cc: lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] qmp: handle stop/cont in INMIGRATE state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Right now, stop followed by an incoming migration will let the virtual machine start. cont before an incoming migration instead will fail. This is bad because the actual behavior is not predictable; it is racy with respect to the start of the incoming migration. That's because incoming migration is blocking, and thus will delay the processing of stop/cont until the end of the migration. In addition, there's nothing that really prevents the user from typing the block device's passwords before incoming migration is done, so we may as well allow that. Both things can be fixed by just toggling the autostart variable when stop/cont are called in INMIGRATE state. Signed-off-by: Paolo Bonzini --- qmp.c | 17 +++++++++++------ 1 file modificato, 11 inserzioni(+), 6 rimozioni(-) diff --git a/qmp.c b/qmp.c index 36c54c5..2c8d559 100644 --- a/qmp.c +++ b/qmp.c @@ -85,7 +85,11 @@ void qmp_quit(Error **err) void qmp_stop(Error **errp) { - vm_stop(RUN_STATE_PAUSED); + if (runstate_check(RUN_STATE_INMIGRATE)) { + autostart = 0; + } else { + vm_stop(RUN_STATE_PAUSED); + } } void qmp_system_reset(Error **errp) @@ -144,10 +148,7 @@ void qmp_cont(Error **errp) { Error *local_err = NULL; - if (runstate_check(RUN_STATE_INMIGRATE)) { - error_set(errp, QERR_MIGRATION_EXPECTED); - return; - } else if (runstate_check(RUN_STATE_INTERNAL_ERROR) || + if (runstate_check(RUN_STATE_INTERNAL_ERROR) || runstate_check(RUN_STATE_SHUTDOWN)) { error_set(errp, QERR_RESET_REQUIRED); return; @@ -162,7 +163,11 @@ void qmp_cont(Error **errp) return; } - vm_start(); + if (runstate_check(RUN_STATE_INMIGRATE)) { + autostart = 1; + } else { + vm_start(); + } } void qmp_system_wakeup(Error **errp)