From nobody Thu May 2 06:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630004426357406.3294139061845; Thu, 26 Aug 2021 12:00:26 -0700 (PDT) Received: from localhost ([::1]:58308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJKbv-0004pp-3u for importer@patchew.org; Thu, 26 Aug 2021 15:00:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJKZy-0002od-Rw for qemu-devel@nongnu.org; Thu, 26 Aug 2021 14:58:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJKZw-00018M-Ox for qemu-devel@nongnu.org; Thu, 26 Aug 2021 14:58:22 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-191-EkAYYaUvNDeeiXLd8dNMvw-1; Thu, 26 Aug 2021 14:58:19 -0400 Received: by mail-qt1-f198.google.com with SMTP id o22-20020ac872d60000b029029817302575so2384840qtp.10 for ; Thu, 26 Aug 2021 11:58:18 -0700 (PDT) Received: from t490s.phub.net.cable.rogers.com ([2607:fea8:56a3:500::d413]) by smtp.gmail.com with ESMTPSA id t8sm2328195qtn.37.2021.08.26.11.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 11:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630004299; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5c869mJqUNKr64ls6+3RLF7ISrAtPh0abNoLZorTZv4=; b=GQSBhxsqVx/LJKjHlTQDdtiCgA9XozVJveNhlisQ53lZibul04jOeoNRag1ZfooJVjc0dZ x7R1nDkyTL4bRbLjlrAkZlHHqTgbT5xDionDoXCNdvI6f8HV6Lv1pKVsS084RRkiCAkhDu U351sR5KUT8AOci2IMBG5GNwchXghck= X-MC-Unique: EkAYYaUvNDeeiXLd8dNMvw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5c869mJqUNKr64ls6+3RLF7ISrAtPh0abNoLZorTZv4=; b=bDynABBugWeobtQsDioFS211fKNcLEpb4O59Ty0xq8+YljKEmDepmEAMifD7Y37+sA MQYwU5sXFm7OKU7r0dn8OOLJVgiPkIGctF0VpQYZ4IK7Qkv2w+o2WZDha4125S1tVLVl 3mO3XTNYlWkccByQpN2kqPB8BkrsXb+WLE6uTHj8pBEDMfSNQBJBiuf/RFSaKKnJWpcP HwR4QidO/PN5OdvwxQ5modeFr3XCc9IEDwyo+rfDQF/VfJSEbwBHWp9yK9xmE4KX+HXM V0stcD3r+zAaytkhlmTABc/xwp9UcxBcj9avtsOSpcCdpJ6ZyPZvUapV36ZuWAHXEm8L xGbQ== X-Gm-Message-State: AOAM5336ehqZwqE6NCPkw749bRU71lMOo+hacA8t7Wr0TlBxcRfXjTNJ ZhWpXUPE/efFyQa0AK6NNTkSv5tpbvs93Kztc1AhYEFdSxVwtwPiygtq9e+9YrKIluKYWtvNC1B dCL/xgg/Agd184CAgZhFsNDjhcGe76fXZIytDsqqPCTarnd3kvViFeMB9zJ3p37QN X-Received: by 2002:ac8:7ca3:: with SMTP id z3mr4801421qtv.109.1630004298097; Thu, 26 Aug 2021 11:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0NBs0yoXCVDhxxyvIoSuVZI46Ki2za1WCud6R7Fwc1JTJ8N/NQyxN0YL5fi6eZQo9sQmd/w== X-Received: by 2002:ac8:7ca3:: with SMTP id z3mr4801391qtv.109.1630004297827; Thu, 26 Aug 2021 11:58:17 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v2 1/3] migration: Make migration blocker work for snapshots too Date: Thu, 26 Aug 2021 14:58:11 -0400 Message-Id: <20210826185813.248441-2-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826185813.248441-1-peterx@redhat.com> References: <20210826185813.248441-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster , Leonardo Bras Soares Passos , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630004427522100001 Content-Type: text/plain; charset="utf-8" save_snapshot() checks migration blocker, which looks sane. At the meantim= e we should also teach the blocker add helper to fail if during a snapshot, just like for migrations. Signed-off-by: Peter Xu Reviewed-by: Marc-Andr=C3=A9 Lureau --- migration/migration.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 041b8451a6..f476e2101e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2062,15 +2062,16 @@ int migrate_add_blocker(Error *reason, Error **errp) return -EACCES; } =20 - if (migration_is_idle()) { - migration_blockers =3D g_slist_prepend(migration_blockers, reason); - return 0; + /* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM too= . */ + if (runstate_check(RUN_STATE_SAVE_VM) || !migration_is_idle()) { + error_propagate_prepend(errp, error_copy(reason), + "disallowing migration blocker " + "(migration/snapshot in progress) for: "); + return -EBUSY; } =20 - error_propagate_prepend(errp, error_copy(reason), - "disallowing migration blocker " - "(migration in progress) for: "); - return -EBUSY; + migration_blockers =3D g_slist_prepend(migration_blockers, reason); + return 0; } =20 void migrate_del_blocker(Error *reason) --=20 2.31.1 From nobody Thu May 2 06:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630004426484752.7112027004536; Thu, 26 Aug 2021 12:00:26 -0700 (PDT) Received: from localhost ([::1]:58326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJKbv-0004qt-Sg for importer@patchew.org; Thu, 26 Aug 2021 15:00:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJKZz-0002ov-IL for qemu-devel@nongnu.org; Thu, 26 Aug 2021 14:58:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJKZy-00019r-58 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 14:58:23 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-579-fntFecaxNRKd9fOs-WBdRg-1; Thu, 26 Aug 2021 14:58:20 -0400 Received: by mail-qv1-f69.google.com with SMTP id ib9-20020a0562141c8900b003671c3a1243so1086859qvb.21 for ; Thu, 26 Aug 2021 11:58:20 -0700 (PDT) Received: from t490s.phub.net.cable.rogers.com ([2607:fea8:56a3:500::d413]) by smtp.gmail.com with ESMTPSA id t8sm2328195qtn.37.2021.08.26.11.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 11:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630004301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nu2lN1o02zB4SS5XpgBl+iZRy4+/xMk8bEFWb+JPULI=; b=O0gGSZMzB/Fa95AQS4DEkJ8CJ6CdFYOYXI6MvJgY1mOBOzokDxaaZf8o6jg2R/hpBmftMW 0SPN5WQAZFApmfHfTzBY6WlddXCx6Uxwpizf5NUez0ie9/Zc9yv/3Mj8YZNscNdNYOY9oj vknM3caVaHYmFmvxkjsqFeTPvSpeMfA= X-MC-Unique: fntFecaxNRKd9fOs-WBdRg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nu2lN1o02zB4SS5XpgBl+iZRy4+/xMk8bEFWb+JPULI=; b=mtaMrrbc1fqEOmDWNUjYSyIUsMEY+mvgp05TY6lQW0NrsH3fEfU0+OLsqLg7yXHaF0 a4+yd/YOGicpUINy05phZalSvtHBJH6stYEaXqFzFR4d1ZDkUxaWBS/Ct8Of16nwXGHO 4215k7v+0ZcoYPdb6cpfV2xCpYFpKhHeH6Ysnb/zx79l32NHzFkHEjJFqF8TE8hKUAEZ RkBfTme78qsXLv0ojJXomqvF9m8qWS3qeyxorqslsZF9vfW1ONv1UE9W33Gz24YWhMI+ 1JHUTaHC3boi0FhUIYYiG8PuMlcObjU7WEHfVe4nYkXVYy+hNF2SqVk9PFTF/xMHDJ0b FJjA== X-Gm-Message-State: AOAM531AAWr/jbnhy6GF90FHtahzcepRsKmn0BtgJlSWxTNsuEfEqrpd gZtW6aOO+oCf8iGC9K/fawvY3OYMgMgT3/oOf+7Xvv+k1xPJMdNIBl45xfC9gjp6M0qcpvXbTIb sBs+I5j0V5fm7o23uJxzX6irzoPIkZvmZEMVzvu7zFoXLWukp3205sAaX8zUJf+9e X-Received: by 2002:a05:622a:c1:: with SMTP id p1mr4774570qtw.365.1630004299705; Thu, 26 Aug 2021 11:58:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0eQkpR0PpH5rq2Zewl/FmICoiN2mgu43xwE4zMJT7Zp6lFl18qzH7oO+VcXt11VxlffI1IQ== X-Received: by 2002:a05:622a:c1:: with SMTP id p1mr4774544qtw.365.1630004299425; Thu, 26 Aug 2021 11:58:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v2 2/3] migration: Add migrate_add_blocker_internal() Date: Thu, 26 Aug 2021 14:58:12 -0400 Message-Id: <20210826185813.248441-3-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826185813.248441-1-peterx@redhat.com> References: <20210826185813.248441-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster , Leonardo Bras Soares Passos , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630004427539100003 An internal version that removes -only-migratable implications. It can be = used for temporary migration blockers like dump-guest-memory. Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela Signed-off-by: Peter Xu --- include/migration/blocker.h | 16 ++++++++++++++++ migration/migration.c | 21 +++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/migration/blocker.h b/include/migration/blocker.h index acd27018e9..9cebe2ba06 100644 --- a/include/migration/blocker.h +++ b/include/migration/blocker.h @@ -25,6 +25,22 @@ */ int migrate_add_blocker(Error *reason, Error **errp); =20 +/** + * @migrate_add_blocker_internal - prevent migration from proceeding witho= ut + * only-migrate implications + * + * @reason - an error to be returned whenever migration is attempted + * + * @errp - [out] The reason (if any) we cannot block migration right now. + * + * @returns - 0 on success, -EBUSY on failure, with errp set. + * + * Some of the migration blockers can be temporary (e.g., for a few second= s), + * so it shouldn't need to conflict with "-only-migratable". For those ca= ses, + * we can call this function rather than @migrate_add_blocker(). + */ +int migrate_add_blocker_internal(Error *reason, Error **errp); + /** * @migrate_del_blocker - remove a blocking error from migration * diff --git a/migration/migration.c b/migration/migration.c index f476e2101e..2aaf2fd449 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2053,15 +2053,8 @@ void migrate_init(MigrationState *s) s->threshold_size =3D 0; } =20 -int migrate_add_blocker(Error *reason, Error **errp) +int migrate_add_blocker_internal(Error *reason, Error **errp) { - if (only_migratable) { - error_propagate_prepend(errp, error_copy(reason), - "disallowing migration blocker " - "(--only-migratable) for: "); - return -EACCES; - } - /* Snapshots are similar to migrations, so check RUN_STATE_SAVE_VM too= . */ if (runstate_check(RUN_STATE_SAVE_VM) || !migration_is_idle()) { error_propagate_prepend(errp, error_copy(reason), @@ -2074,6 +2067,18 @@ int migrate_add_blocker(Error *reason, Error **errp) return 0; } =20 +int migrate_add_blocker(Error *reason, Error **errp) +{ + if (only_migratable) { + error_propagate_prepend(errp, error_copy(reason), + "disallowing migration blocker " + "(--only-migratable) for: "); + return -EACCES; + } + + return migrate_add_blocker_internal(reason, errp); +} + void migrate_del_blocker(Error *reason) { migration_blockers =3D g_slist_remove(migration_blockers, reason); --=20 2.31.1 From nobody Thu May 2 06:58:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630004590632996.5197179752282; Thu, 26 Aug 2021 12:03:10 -0700 (PDT) Received: from localhost ([::1]:35330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJKeb-0008TT-LQ for importer@patchew.org; Thu, 26 Aug 2021 15:03:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJKa2-0002tC-7A for qemu-devel@nongnu.org; Thu, 26 Aug 2021 14:58:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45979) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJKa0-0001BM-Fi for qemu-devel@nongnu.org; Thu, 26 Aug 2021 14:58:25 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-121-VjYWJA4FOzKGvxQmgkVmcg-1; Thu, 26 Aug 2021 14:58:22 -0400 Received: by mail-qv1-f70.google.com with SMTP id u11-20020a0562141c0b00b0036201580785so459187qvc.11 for ; Thu, 26 Aug 2021 11:58:22 -0700 (PDT) Received: from t490s.phub.net.cable.rogers.com ([2607:fea8:56a3:500::d413]) by smtp.gmail.com with ESMTPSA id t8sm2328195qtn.37.2021.08.26.11.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 11:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630004303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=62MuU3H3NB0I9MePyooMeyPJWMxyy9cKmJ9raN3w+eQ=; b=UxmNMzx4MP8yPF1ccK883A97THsHD3GdLRelfJQWMR1QuWMG0hjXNhu08/IkQUcABKdnKE VES2fd0dIalnKrWos6mglnC+kUU3yFyBvHFd9EzmusDbcj/rDjWaKauscQz8f84XuS3eim glxrqy5/SCrTGBwTFvzm0/818QayujI= X-MC-Unique: VjYWJA4FOzKGvxQmgkVmcg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=62MuU3H3NB0I9MePyooMeyPJWMxyy9cKmJ9raN3w+eQ=; b=pLdbimQkrA1N1FxiHnzwiZICLt1ChIc35554RF2PvVgPTmF/xnYc8e9IUaVO4jEAOC 94VWLvTnVLXrZGoU465FGDDh4AknecQyKQQgcIDPCW1SVmm2ekbXHQfQaOOFHgkFFmyM M0IdmqbzFdQelj9WhvLcXiZMfe6y7u6TdNq+i8qLjzWpb3eFUUaqrg6/Aa+DrqitLu5P HUlI1WsodqEbXgqUNLxZBgRDvsFKKFjqMN0/2S1w8BTJX8gGdseCesQh760pzcrTPNx0 zJRbuLd4uNGIfVH+v5/I5vjDgqjqlBp+GhXgfDTlKwe/j/apN1468nYsYZsRaMcyIWgj zIfw== X-Gm-Message-State: AOAM532Tlfjl8clEOaEHAqGLxuaDazxnkylvEdMLTeMp9HMUS5D6DAW0 5BxYwByvlszyWw0FsWcNDAvqE1Zzw+xLtWAt58iRk1ZwJ7MgauEYRTga0Cnj16a6kH/OZJki/0i Po0Hrg8SLAHjhQ8tOnclRAju8islVPOKe0DTHvyk0JF+EeTN6dyRP9CyRAs49fr3B X-Received: by 2002:ac8:47d7:: with SMTP id d23mr4797681qtr.73.1630004301611; Thu, 26 Aug 2021 11:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylBYg0Rob+9iYme7i9LL+c2D+hE186/hyvCegT5FMcbfuqUq6IqNh1wFdHxK1Eai2cJ/4PiQ== X-Received: by 2002:ac8:47d7:: with SMTP id d23mr4797648qtr.73.1630004301332; Thu, 26 Aug 2021 11:58:21 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v2 3/3] dump-guest-memory: Block live migration Date: Thu, 26 Aug 2021 14:58:13 -0400 Message-Id: <20210826185813.248441-4-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826185813.248441-1-peterx@redhat.com> References: <20210826185813.248441-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jones , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Markus Armbruster , Leonardo Bras Soares Passos , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630004591274100001 Content-Type: text/plain; charset="utf-8" Both dump-guest-memory and live migration caches vm state at the beginning. Either of them entering the other one will cause race on the vm state, and = even more severe on that (please refer to the crash report in the bug link). Let's block live migration in dump-guest-memory, and that'll also block dump-guest-memory if it detected that we're during a live migration. Side note: migrate_del_blocker() can be called even if the blocker is not inserted yet, so it's safe to unconditionally delete that blocker in dump_cleanup (g_slist_remove allows no-entry-found case). Suggested-by: Dr. David Alan Gilbert Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=3D1996609 Signed-off-by: Peter Xu --- dump/dump.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index ab625909f3..9c1c1fb738 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -29,6 +29,7 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "hw/misc/vmcoreinfo.h" +#include "migration/blocker.h" =20 #ifdef TARGET_X86_64 #include "win_dump.h" @@ -47,6 +48,8 @@ =20 #define MAX_GUEST_NOTE_SIZE (1 << 20) /* 1MB should be enough */ =20 +static Error *dump_migration_blocker; + #define ELF_NOTE_SIZE(hdr_size, name_size, desc_size) \ ((DIV_ROUND_UP((hdr_size), 4) + \ DIV_ROUND_UP((name_size), 4) + \ @@ -101,6 +104,7 @@ static int dump_cleanup(DumpState *s) qemu_mutex_unlock_iothread(); } } + migrate_del_blocker(dump_migration_blocker); =20 return 0; } @@ -1927,11 +1931,6 @@ void qmp_dump_guest_memory(bool paging, const char *= file, Error *local_err =3D NULL; bool detach_p =3D false; =20 - if (runstate_check(RUN_STATE_INMIGRATE)) { - error_setg(errp, "Dump not allowed during incoming migration."); - return; - } - /* if there is a dump in background, we should wait until the dump * finished */ if (dump_in_progress()) { @@ -2005,6 +2004,21 @@ void qmp_dump_guest_memory(bool paging, const char *= file, return; } =20 + if (!dump_migration_blocker) { + error_setg(&dump_migration_blocker, + "Live migration disabled: dump-guest-memory in progress= "); + } + + /* + * Allows even for -only-migratable, but forbid migration during the + * process of dump guest memory. + */ + if (migrate_add_blocker_internal(dump_migration_blocker, errp)) { + /* Remember to release the fd before passing it over to dump state= */ + close(fd); + return; + } + s =3D &dump_state_global; dump_state_prepare(s); =20 --=20 2.31.1