From nobody Tue May 7 09:57:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685663120; cv=none; d=zohomail.com; s=zohoarc; b=Txk0cCgnF3/Q6t2MWzsL9MXS100pZW4nESh8uhDNc6UMYG3lakLmhgHMaTaO5/qFGdFsfD4qMwnuorj6J/e2zNqYp3CgYTinloVO7wyJdgV0kMV1XNwJtJteWATapIdMKb4gHOddrYNUtEo6y7axZsEKI35XR9ZR4l/KlEqGGiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685663120; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1HIuK2JuDsuMAWMzDLOmEGJIdWcuvp6JGlclttbw8+Y=; b=MDsAagIR5kvInypcoWYRYcZVsNWoEcUH6oYKH1gZA5kxPnKqpA67Md9Xj9CpH37jXXH4a/+WJ4GR2edqKfVduFl3Ww7LI4zcloVtxS030ktzDRW/S0+Obc/LLPibDhQL3F5eK2nCx1xpsHXkczXbUwriFVr5EKpyAkbF6B4soLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685663120195140.8680637073694; Thu, 1 Jun 2023 16:45:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4ryB-0005wy-H9; Thu, 01 Jun 2023 19:44:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ry7-0005wL-Vx for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ry6-0000vu-74 for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:35 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-347-bw1nyl0eNhar2gDwFO1FGw-1; Thu, 01 Jun 2023 19:44:30 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2FA583C00086; Thu, 1 Jun 2023 23:44:30 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id E38F9492B00; Thu, 1 Jun 2023 23:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685663073; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1HIuK2JuDsuMAWMzDLOmEGJIdWcuvp6JGlclttbw8+Y=; b=fTsNJzKP3Mrs2Vx+KHipvqavo+80R7DjjUAaHlcbeO4BE6C/vqg/U9caLeN6t2yCpLO9if icHwzsek86TIBPFepZlu5JTg3koJ6mPFqrr9rYBCa1MNRbdzRe2qykkBukDpiSMc+3W2SZ IO+0ZXjaf+SRlG8CpGvimMiZ8FMFOVo= X-MC-Unique: bw1nyl0eNhar2gDwFO1FGw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Vladimir Sementsov-Ogievskiy Subject: [PULL 1/6] runstate: add runstate_get() Date: Fri, 2 Jun 2023 01:44:21 +0200 Message-Id: <20230601234426.29984-2-quintela@redhat.com> In-Reply-To: <20230601234426.29984-1-quintela@redhat.com> References: <20230601234426.29984-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685663122187100003 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy It's necessary to restore the state after failed/cancelled migration in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-2-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- include/sysemu/runstate.h | 1 + softmmu/runstate.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index f3ed52548e..85f5d9a419 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -6,6 +6,7 @@ =20 bool runstate_check(RunState state); void runstate_set(RunState new_state); +RunState runstate_get(void); bool runstate_is_running(void); bool runstate_needs_reset(void); bool runstate_store(char *str, size_t size); diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 2f2396c819..1e6f0bcecc 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -221,6 +221,11 @@ void runstate_set(RunState new_state) current_run_state =3D new_state; } =20 +RunState runstate_get(void) +{ + return current_run_state; +} + bool runstate_is_running(void) { return runstate_check(RUN_STATE_RUNNING); --=20 2.40.1 From nobody Tue May 7 09:57:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685663159; cv=none; d=zohomail.com; s=zohoarc; b=SH/BX+v+KOCeVniOGkDhULwYcqS/LOigwQWhhkwe6LoeJDFA5t+pK2g10fQt7fz0Md4Wzzo241F3A1KzJF2WyJLQkOqaVvg2d2ngVCowipqKybgFxC7dNocP7/1KmYi26f1VvtwnCmdZxAUmdawIEhAGK+Rghex8KwlGQyodE9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685663159; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TF/SpRsVU0zyYX4JBUn+J3w91fUBxDQQEjMTghPFV0M=; b=cUWcoyK9Lk3rpk3cWeYLuc4SNL9PKsknVMYn+ccgZp0v5x8/PcmdUJ5UTlrArxk8UbxbYomnj6Wq/wzRZTI+on3s6Tc7xkQrWZhjnPIUVhhPDtipboP9b6MrsepIUwP2/hEE7K1hT6VnJGjx3VGqetYK7A75fkNlzjW8stQFGYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685663159045296.7513642476732; Thu, 1 Jun 2023 16:45:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4ryN-0006Fl-Ae; Thu, 01 Jun 2023 19:44:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryL-0006Eg-3z for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryH-0000xe-3x for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:47 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-jp9jFAVsM9enegM95dbyLA-1; Thu, 01 Jun 2023 19:44:31 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 92D338015D8; Thu, 1 Jun 2023 23:44:31 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 701F0492B00; Thu, 1 Jun 2023 23:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685663083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TF/SpRsVU0zyYX4JBUn+J3w91fUBxDQQEjMTghPFV0M=; b=JBJWG0E+FqLL0ypVC12XF3Ku2wBOdjRim05dmsF+24p529ZyCgm5gtDQaKL5zi8JP9mUvn lnTXZ0xjtgI+IebsBJ6Wrw+AVcNo9d4Z0gfc8b9pUeFysxSBSobzMTsJYXqn2KwRIr/JOA CjEoB04OBN2azKFWp9Bdd18c5xBLMPY= X-MC-Unique: jp9jFAVsM9enegM95dbyLA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Vladimir Sementsov-Ogievskiy Subject: [PULL 2/6] migration: never fail in global_state_store() Date: Fri, 2 Jun 2023 01:44:22 +0200 Message-Id: <20230601234426.29984-3-quintela@redhat.com> In-Reply-To: <20230601234426.29984-1-quintela@redhat.com> References: <20230601234426.29984-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685663161116100003 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Actually global_state_store() can never fail. Let's get rid of extra error paths. To make things clear, use new runstate_get() and use same approach for global_state_store() and global_state_store_running(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-3-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- include/migration/global_state.h | 2 +- migration/global_state.c | 29 +++++++++++----------- migration/migration.c | 41 +++++++++++++++----------------- migration/savevm.c | 6 +---- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/include/migration/global_state.h b/include/migration/global_st= ate.h index 945eb35d5b..d7c2cd3216 100644 --- a/include/migration/global_state.h +++ b/include/migration/global_state.h @@ -16,7 +16,7 @@ #include "qapi/qapi-types-run-state.h" =20 void register_global_state(void); -int global_state_store(void); +void global_state_store(void); void global_state_store_running(void); bool global_state_received(void); RunState global_state_get_runstate(void); diff --git a/migration/global_state.c b/migration/global_state.c index a33947ca32..4e2a9d8ec0 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -29,23 +29,22 @@ typedef struct { =20 static GlobalState global_state; =20 -int global_state_store(void) +static void global_state_do_store(RunState state) { - if (!runstate_store((char *)global_state.runstate, - sizeof(global_state.runstate))) { - error_report("runstate name too big: %s", global_state.runstate); - trace_migrate_state_too_big(); - return -EINVAL; - } - return 0; -} - -void global_state_store_running(void) -{ - const char *state =3D RunState_str(RUN_STATE_RUNNING); - assert(strlen(state) < sizeof(global_state.runstate)); + const char *state_str =3D RunState_str(state); + assert(strlen(state_str) < sizeof(global_state.runstate)); strpadcpy((char *)global_state.runstate, sizeof(global_state.runstate), - state, '\0'); + state_str, '\0'); +} + +void global_state_store(void) +{ + global_state_do_store(runstate_get()); +} + +void global_state_store_running(void) +{ + global_state_do_store(RUN_STATE_RUNNING); } =20 bool global_state_received(void) diff --git a/migration/migration.c b/migration/migration.c index 5de7f734b9..c75d5aa479 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2288,27 +2288,26 @@ static void migration_completion(MigrationState *s) s->downtime_start =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); s->vm_was_running =3D runstate_is_running(); - ret =3D global_state_store(); + global_state_store(); =20 - if (!ret) { - ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); - trace_migration_completion_vm_stop(ret); - if (ret >=3D 0) { - ret =3D migration_maybe_pause(s, ¤t_active_state, - MIGRATION_STATUS_DEVICE); - } - if (ret >=3D 0) { - /* - * Inactivate disks except in COLO, and track that we - * have done so in order to remember to reactivate - * them if migration fails or is cancelled. - */ - s->block_inactive =3D !migrate_colo(); - migration_rate_set(RATE_LIMIT_DISABLED); - ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file,= false, - s->block_inactive= ); - } + ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); + trace_migration_completion_vm_stop(ret); + if (ret >=3D 0) { + ret =3D migration_maybe_pause(s, ¤t_active_state, + MIGRATION_STATUS_DEVICE); } + if (ret >=3D 0) { + /* + * Inactivate disks except in COLO, and track that we + * have done so in order to remember to reactivate + * them if migration fails or is cancelled. + */ + s->block_inactive =3D !migrate_colo(); + migration_rate_set(RATE_LIMIT_DISABLED); + ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file, fal= se, + s->block_inactive); + } + qemu_mutex_unlock_iothread(); =20 if (ret < 0) { @@ -3088,9 +3087,7 @@ static void *bg_migration_thread(void *opaque) qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); s->vm_was_running =3D runstate_is_running(); =20 - if (global_state_store()) { - goto fail; - } + global_state_store(); /* Forcibly stop VM before saving state of vCPUs and devices */ if (vm_stop_force_state(RUN_STATE_PAUSED)) { goto fail; diff --git a/migration/savevm.c b/migration/savevm.c index 03795ce8dc..bc284087f9 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2919,11 +2919,7 @@ bool save_snapshot(const char *name, bool overwrite,= const char *vmstate, =20 saved_vm_running =3D runstate_is_running(); =20 - ret =3D global_state_store(); - if (ret) { - error_setg(errp, "Error saving global state"); - return false; - } + global_state_store(); vm_stop(RUN_STATE_SAVE_VM); =20 bdrv_drain_all_begin(); --=20 2.40.1 From nobody Tue May 7 09:57:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685663107; cv=none; d=zohomail.com; s=zohoarc; b=BaAQssfH+zhBl64RsJSMVvG67l0nTaNKKLmt7xl+GkJBLF7piuFT35LWQXSM7W9QGSBsvV/2IyiU0gmLOi3I+1yk2HnBX7qFMxiUeG/CXmRFvoEFShHtSdnaScPRFdRhi9iYt27GFHQ8o/wzswypvsA7ThoSwmbpKVvEcWUTkG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685663107; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NGtkd/VOEqR1Ouq/Wg8DwRbxBOulP2LrMmjMkxNN4GY=; b=Zkfxt4T2dVuDrwXA+UjehSqhnlpxXtmkxHlNbFOaCDhsfYoqhaeEc5MHJADgLTXS6ENK9RbX/YeVvWA5Ysr1nWay4kjdxvOK+rYHAQ5mInphgVqAO8y8TaooHMquGJSoAxDUHr4JvTUDVaPUXJzPSoK/4gaaXq1IBRXgJyz9eXs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685663107205272.1710012651664; Thu, 1 Jun 2023 16:45:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4ryE-00067s-Ss; Thu, 01 Jun 2023 19:44:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryC-0005xT-NM for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ry9-0000wN-Mk for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:38 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-wwpCj7dcMzWxf7Id36ktOQ-1; Thu, 01 Jun 2023 19:44:34 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D3DD085A5AA; Thu, 1 Jun 2023 23:44:32 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2571492B00; Thu, 1 Jun 2023 23:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685663077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NGtkd/VOEqR1Ouq/Wg8DwRbxBOulP2LrMmjMkxNN4GY=; b=U4R4x2Y0gz8tDQkFurU6L/AoiuTEhFLJFHtMFjG1Z0qz6gk/tnGjX13T032WBuHnsw0kp3 U502Oj4cNToXpU0ljkIZ8O40CyiltOG/u4E/TGOzLTb5KKsPIGz6d78ygi8NHXm0ubA5mm vfHcL1huTs52avP/fd+MGoPsh3DjcEU= X-MC-Unique: wwpCj7dcMzWxf7Id36ktOQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Vladimir Sementsov-Ogievskiy Subject: [PULL 3/6] runstate: drop unused runstate_store() Date: Fri, 2 Jun 2023 01:44:23 +0200 Message-Id: <20230601234426.29984-4-quintela@redhat.com> In-Reply-To: <20230601234426.29984-1-quintela@redhat.com> References: <20230601234426.29984-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685663108492100003 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy The function is unused since previous commit. Drop it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-4-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- include/sysemu/runstate.h | 1 - softmmu/runstate.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 85f5d9a419..7beb29c2e2 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -9,7 +9,6 @@ void runstate_set(RunState new_state); RunState runstate_get(void); bool runstate_is_running(void); bool runstate_needs_reset(void); -bool runstate_store(char *str, size_t size); =20 typedef void VMChangeStateHandler(void *opaque, bool running, RunState sta= te); =20 diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 1e6f0bcecc..0370230a5e 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -175,18 +175,6 @@ bool runstate_check(RunState state) return current_run_state =3D=3D state; } =20 -bool runstate_store(char *str, size_t size) -{ - const char *state =3D RunState_str(current_run_state); - size_t len =3D strlen(state) + 1; - - if (len > size) { - return false; - } - memcpy(str, state, len); - return true; -} - static void runstate_init(void) { const RunStateTransition *p; --=20 2.40.1 From nobody Tue May 7 09:57:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685663128; cv=none; d=zohomail.com; s=zohoarc; b=YHK8a/Rn7ZucUXcptk/l+c/8OKPmowwriEVdWh0JXWEpHkSFas61MFe7jh85WQSN8usygmGDJ2XWyjLvRYYtRjwfqnkLNzJ7TOxbi9lOndzY0nuOBcGo1gayEbb/S0nBF9SXJglE41c0iHIwNgQiE4H+NeBAUKWIDK6UAxmzbzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685663128; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tj0cQwuOH13SAeW28WyCSad0nngr0wzVxNpQRkS9oRA=; b=WwEfm2tTymySCWx8zOkySaTC3x10wxpZ0LqCqaGYCK7OkZ8mpv2K9MCHJbLknTFIU1l6+W1HrmsFdzwlv9xs9CiGZ7vZ7fNAFnBiBHE4//emmTGRzI8GxlBYnEAvIEMN7Q5msdmQhzOrZEATgytWhvIKzciDkgZUeo3mBBnLZ/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685663128759893.6534060786283; Thu, 1 Jun 2023 16:45:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4ryF-000692-Mc; Thu, 01 Jun 2023 19:44:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryD-00062u-Ie for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryA-0000wR-7M for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:40 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-567-hRcXudGWPAOnrzmucjQnQA-1; Thu, 01 Jun 2023 19:44:34 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 223E2101A52C; Thu, 1 Jun 2023 23:44:34 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FF96492B00; Thu, 1 Jun 2023 23:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685663077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tj0cQwuOH13SAeW28WyCSad0nngr0wzVxNpQRkS9oRA=; b=T8pCtNp3sft/BufodunEcfOvrO5oAsRtyAdF1kqiQqYI0l1tlcaiotlyEcOl/5PNycT8WS iDLM3uDEMLjmRvQd82m7eXHQRk7VU9Sk0Us4A717JyvxLnaIBd8lu2+Wjes2HICJFyCmol yEM6uST8/lnQGZfIHIQT+WW5QkqnIj8= X-MC-Unique: hRcXudGWPAOnrzmucjQnQA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Vladimir Sementsov-Ogievskiy Subject: [PULL 4/6] migration: switch from .vm_was_running to .vm_old_state Date: Fri, 2 Jun 2023 01:44:24 +0200 Message-Id: <20230601234426.29984-5-quintela@redhat.com> In-Reply-To: <20230601234426.29984-1-quintela@redhat.com> References: <20230601234426.29984-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685663130921100007 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy No logic change here, only refactoring. That's a preparation for next commit where we finally restore the stopped vm state on migration failure or cancellation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-5-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- migration/migration.h | 9 ++++++--- migration/migration.c | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 48a46123a0..30c3e97635 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -25,6 +25,7 @@ #include "net/announce.h" #include "qom/object.h" #include "postcopy-ram.h" +#include "sysemu/runstate.h" =20 struct PostcopyBlocktimeContext; =20 @@ -317,12 +318,14 @@ struct MigrationState { int64_t expected_downtime; bool capabilities[MIGRATION_CAPABILITY__MAX]; int64_t setup_time; + /* - * Whether guest was running when we enter the completion stage. + * State before stopping the vm by vm_stop_force_state(). * If migration is interrupted by any reason, we need to continue - * running the guest on source. + * running the guest on source if it was running or restore its stopped + * state. */ - bool vm_was_running; + RunState vm_old_state; =20 /* Flag set once the migration has been asked to enter postcopy */ bool start_postcopy; diff --git a/migration/migration.c b/migration/migration.c index c75d5aa479..033162cda0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1402,7 +1402,7 @@ void migrate_init(MigrationState *s) =20 s->start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); s->total_time =3D 0; - s->vm_was_running =3D false; + s->vm_old_state =3D -1; s->iteration_initial_bytes =3D 0; s->threshold_size =3D 0; } @@ -2287,7 +2287,8 @@ static void migration_completion(MigrationState *s) qemu_mutex_lock_iothread(); s->downtime_start =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); - s->vm_was_running =3D runstate_is_running(); + + s->vm_old_state =3D runstate_get(); global_state_store(); =20 ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); @@ -2760,12 +2761,12 @@ static void migration_iteration_finish(MigrationSta= te *s) case MIGRATION_STATUS_COLO: assert(migrate_colo()); migrate_start_colo_process(s); - s->vm_was_running =3D true; + s->vm_old_state =3D RUN_STATE_RUNNING; /* Fallthrough */ case MIGRATION_STATUS_FAILED: case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_CANCELLING: - if (s->vm_was_running) { + if (s->vm_old_state =3D=3D RUN_STATE_RUNNING) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { vm_start(); } @@ -3085,7 +3086,7 @@ static void *bg_migration_thread(void *opaque) * transition in vm_stop_force_state() we need to wakeup it up. */ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); - s->vm_was_running =3D runstate_is_running(); + s->vm_old_state =3D runstate_get(); =20 global_state_store(); /* Forcibly stop VM before saving state of vCPUs and devices */ --=20 2.40.1 From nobody Tue May 7 09:57:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685663155; cv=none; d=zohomail.com; s=zohoarc; b=jbrwFxnl+X7sy2Xsub9auaZNLYPp2MA3Sb9TPM+HLvI30RTg2WSLlXfPziNKhqVJ+grQo3bMlVkAJt3kl3LXGxuDNzoQtHb3mV+2L2upH2J+dyhAJ5G2CzH1NpuYfD75O3QXDbwDz99EXVWGaxtQR2PEZ7m461/i/xb1XU+yXMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685663155; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I4gJ60Ealycyn+5Tv6j+hmZj9B87IXvu+mOtep4AFto=; b=YPGOUcHLgYtRly1vU6pXe06RRcMaE9QLQ+KI50O0t5BkL97LtzUh7Fu43kTTVBc4J+HiT/BsxS6L65XnaylBtybNYirX2zAE8EBcKpnHZhDk9Dzfp8imt+CS4wfUBOGkbWIT1BHbFgeMOnS45bck6n8Ky5WIKBnYnG6fXV9BJ9w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685663155341338.7928758382774; Thu, 1 Jun 2023 16:45:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4ryI-00069c-Pq; Thu, 01 Jun 2023 19:44:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryF-00068e-F4 for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryB-0000ws-GI for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:42 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-80-3MFlIKD3MuybpL27u8QnSg-1; Thu, 01 Jun 2023 19:44:35 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 639D11C08DA7; Thu, 1 Jun 2023 23:44:35 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 623A6492B00; Thu, 1 Jun 2023 23:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685663078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I4gJ60Ealycyn+5Tv6j+hmZj9B87IXvu+mOtep4AFto=; b=ZBHqECPz+y8HFBVfasty6it0H9wkQ44qgsyYBMUmRpLBIG+Kk52rgDVcC+f0qcCuQIEh1t tFs9u3s7nDm3i1Zu/JPK92uJbu54gk9nHXksBl9RaPM7FpSbyOlXylH/pi22dcCEsLC5y/ FbvYTgeyhlyL8drTg+kXE3a5/ii8pMo= X-MC-Unique: 3MFlIKD3MuybpL27u8QnSg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Vladimir Sementsov-Ogievskiy Subject: [PULL 5/6] migration: restore vmstate on migration failure Date: Fri, 2 Jun 2023 01:44:25 +0200 Message-Id: <20230601234426.29984-6-quintela@redhat.com> In-Reply-To: <20230601234426.29984-1-quintela@redhat.com> References: <20230601234426.29984-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685663157093100003 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 1. Otherwise failed migration just drops guest-panicked state, which is not good for management software. 2. We do keep different paused states like guest-panicked during migration with help of global_state state. 3. We do restore running state on source when migration is cancelled or failed. 4. "postmigrate" state is documented as "guest is paused following a successful 'migrate'", so originally it's only for successful path and we never documented current behavior. Let's restore paused states like guest-panicked in case of cancel or fail too. Allow same transitions like for inmigrate state. This commit changes the behavior that was introduced by commit 42da5550d6 "migration: set state to post-migrate on failure" and provides a bit different fix on related https://bugzilla.redhat.com/show_bug.cgi?id=3D1355683 Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-6-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- migration/migration.c | 2 +- softmmu/runstate.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 033162cda0..7c3425c6fe 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2772,7 +2772,7 @@ static void migration_iteration_finish(MigrationState= *s) } } else { if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { - runstate_set(RUN_STATE_POSTMIGRATE); + runstate_set(s->vm_old_state); } } break; diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 0370230a5e..1957caf73f 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -121,7 +121,13 @@ static const RunStateTransition runstate_transitions_d= ef[] =3D { { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PAUSED }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PRELAUNCH }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_COLO}, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_COLO }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_INTERNAL_ERROR }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_IO_ERROR }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_SHUTDOWN }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_SUSPENDED }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_WATCHDOG }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_GUEST_PANICKED }, =20 { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, --=20 2.40.1 From nobody Tue May 7 09:57:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685663129; cv=none; d=zohomail.com; s=zohoarc; b=I2G1WpJWKpqyzdoYj3hllXcIp7RuKDyMad5HHdScizuIrEGfdkkFYhId3cOyxAlO3DNCN6Sv+bHgASutwx+4XJPx9CyxdjEacMGM6grwj9d9I1Ru0CaKCaybuLItJKLhFEsWG/ffgs5fJiZUIFXVfWjjl4y5FriuUglT6dx840g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685663129; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=91p2ckiGRqO94BU5adKr4Xtfpf3nukraIVriIitpigg=; b=P6WtR1dFdZd3eszLtDkUkYBfEOOR6Ph+6/f7/NomcqUTCIG6ncYU1ncdeTP/gYqD113nCFV/JBX/mm93bGBxnCJVQ2Oxua1wNiYOBt/WXxOexlenCF+JHHfFlQFLhuJ5OcRWJ1rj57TiZD6WzY/volSWqwfki0xNnVTJqsbgxbs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685663129499778.1898085509051; Thu, 1 Jun 2023 16:45:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4ryJ-0006A6-2G; Thu, 01 Jun 2023 19:44:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryH-00069T-Bb for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4ryA-0000wi-Us for qemu-devel@nongnu.org; Thu, 01 Jun 2023 19:44:43 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-92-Dr3206cbOju2cLHNovYPbQ-1; Thu, 01 Jun 2023 19:44:37 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED04E1C08DB0; Thu, 1 Jun 2023 23:44:36 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4575492B00; Thu, 1 Jun 2023 23:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685663078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=91p2ckiGRqO94BU5adKr4Xtfpf3nukraIVriIitpigg=; b=HdKmt4HbVGgY2bzkp0Qs6iJMGgW+P5czzINBue9JDU7M4vdhHD/9yPHPqX+sVqEccY8hHg zRCIUeWhcbuBWIM4WsYz+NkQRFwtzBfmwnm+It9F5QFGnp3pbnHVFMP/csJJ11EweDRgpA BPb6xZ6gRN0O9HejEvzwOOwA9fZL7Q4= X-MC-Unique: Dr3206cbOju2cLHNovYPbQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras , Paolo Bonzini , Fiona Ebner Subject: [PULL 6/6] migration: stop tracking ram writes when cancelling background migration Date: Fri, 2 Jun 2023 01:44:26 +0200 Message-Id: <20230601234426.29984-7-quintela@redhat.com> In-Reply-To: <20230601234426.29984-1-quintela@redhat.com> References: <20230601234426.29984-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685663130179100001 Content-Type: text/plain; charset="utf-8" From: Fiona Ebner Currently, it is only done when the iteration finishes successfully. Not cleaning up the userfaultfd write protection can lead to symptoms/issues such as the process hanging in memmove or GDB not being able to attach. Signed-off-by: Fiona Ebner Message-Id: <20230526115908.196171-1-f.ebner@proxmox.com> Signed-off-by: Juan Quintela --- migration/migration.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 7c3425c6fe..dc05c6f6ea 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2400,13 +2400,6 @@ static void bg_migration_completion(MigrationState *= s) { int current_active_state =3D s->state; =20 - /* - * Stop tracking RAM writes - un-protect memory, un-register UFFD - * memory ranges, flush kernel wait queues and wake up threads - * waiting for write fault to be resolved. - */ - ram_write_tracking_stop(); - if (s->state =3D=3D MIGRATION_STATUS_ACTIVE) { /* * By this moment we have RAM content saved into the migration str= eam. @@ -2788,6 +2781,13 @@ static void migration_iteration_finish(MigrationStat= e *s) =20 static void bg_migration_iteration_finish(MigrationState *s) { + /* + * Stop tracking RAM writes - un-protect memory, un-register UFFD + * memory ranges, flush kernel wait queues and wake up threads + * waiting for write fault to be resolved. + */ + ram_write_tracking_stop(); + qemu_mutex_lock_iothread(); switch (s->state) { case MIGRATION_STATUS_COMPLETED: --=20 2.40.1