From nobody Fri May 17 06:07:25 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 1632328661530277.7897451394555; Wed, 22 Sep 2021 09:37:41 -0700 (PDT) Received: from localhost ([::1]:60236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mT5Fc-0005jo-6k for importer@patchew.org; Wed, 22 Sep 2021 12:37:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4yo-0007eV-Ly for qemu-devel@nongnu.org; Wed, 22 Sep 2021 12:20:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4ym-0000cg-EB for qemu-devel@nongnu.org; Wed, 22 Sep 2021 12:20:18 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-PKU9zcDAPmSk-xsTZaJBgA-1; Wed, 22 Sep 2021 12:20:14 -0400 Received: by mail-qt1-f197.google.com with SMTP id w10-20020ac87e8a000000b002a68361412bso9840508qtj.7 for ; Wed, 22 Sep 2021 09:20:14 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a2:9100::d3ec]) by smtp.gmail.com with ESMTPSA id z186sm2094811qke.59.2021.09.22.09.20.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 09:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632327615; 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=2cjd8utIBAh8JzqAuJRPGpgy/cy0qCGBlHK1sSTFBVI=; b=alhlQVmq8XS9vsdqxXnk1rRF1pjiDiE13VOyB2fBG5DavuYJBdcJsXj+gzb/b+4knMHoGz iCYbP6XqUFu3eIdHuDN6663fP92Qqgn1gh9cWPkRsKaa4JpAdm0QzybEoneDlcyuTS+HDv cC9eVJPBJOToNb3TnwkKgc+CXkzchi0= X-MC-Unique: PKU9zcDAPmSk-xsTZaJBgA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2cjd8utIBAh8JzqAuJRPGpgy/cy0qCGBlHK1sSTFBVI=; b=SfT17WHOnndXlMOikadruPZ9tkLhyA4LO7fJazOHz1FlNKaIRkt8IPlzZ/5aM4at8s HHfOJCXghTR6Q5zct/4h5ruSs+tSnIgjM83e+FzNY5W0cE+TW/PxCN0u8DDHNzNlHUrK OszAHI47uAFgNOHS/FHAzx/FYKxrGRG5+OJRskorJPPGKcdjDPjVgvl72HHGf/nhRK+w IcXDU1D5Bk5xewK6VbztHdGRG7A2QdEbDtZZ8VaXuSJ35KU1f1Yq8hVyl1VCVXCvqsYS bKrlVdg7GqbEB9jEhY/zyhxtkNTvEeYUddJynh3/QgD7NHkLyiSfBkZ5bGDamFwjNSLN ChrA== X-Gm-Message-State: AOAM530L8qvFhLuquEdIIrLgr0RvbdQZ+yh5QW+5bWYKTIg1LHNIlUp9 Zghm9ffkAxhu1x9xZ4EmkamkkBZNhnFn5y1JNEv6uaMYHQiwKuQcu6Juc18s5IUM/Auws0nipil mcpfmBbF+DmuCT2nO/EkoV65o6qt2YalL+UCcviqPgy4G4EgHtubKHKFAD+xta2LB X-Received: by 2002:a37:6708:: with SMTP id b8mr31070qkc.283.1632327613848; Wed, 22 Sep 2021 09:20:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc7kkKzLDNTYSaPRglIrk4GOAIuUytdkK4VE5g4o8+6iXc6TR9jeSpJgfaBOFljJY+KsWRQA== X-Received: by 2002:a37:6708:: with SMTP id b8mr31039qkc.283.1632327613604; Wed, 22 Sep 2021 09:20:13 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v3 1/3] migration: Make migration blocker work for snapshots too Date: Wed, 22 Sep 2021 12:20:07 -0400 Message-Id: <20210922162009.125622-2-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922162009.125622-1-peterx@redhat.com> References: <20210922162009.125622-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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.472, 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: 1632328662958100001 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. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- migration/migration.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index bb909781b7..6f7177daa0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2048,15 +2048,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 Fri May 17 06:07:25 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 163232879578163.66379026688969; Wed, 22 Sep 2021 09:39:55 -0700 (PDT) Received: from localhost ([::1]:36740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mT5Hm-0000di-Nm for importer@patchew.org; Wed, 22 Sep 2021 12:39:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4yr-0007jD-AN for qemu-devel@nongnu.org; Wed, 22 Sep 2021 12:20:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4yo-0000dn-Qz for qemu-devel@nongnu.org; Wed, 22 Sep 2021 12:20:21 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-314-bsN8iyseM5ifMTK_IrU2iA-1; Wed, 22 Sep 2021 12:20:16 -0400 Received: by mail-qk1-f197.google.com with SMTP id h4-20020a05620a244400b004334ede5036so10823183qkn.13 for ; Wed, 22 Sep 2021 09:20:16 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a2:9100::d3ec]) by smtp.gmail.com with ESMTPSA id z186sm2094811qke.59.2021.09.22.09.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 09:20:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632327617; 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=1lqAmhYOfqA4rnTNpzJDoCXhwIm0tgwIW69+uoJ6iSY=; b=Ak8ktG2RV1E05r/NGrSuT4K44n0DDzT3Ig6GIV95YIUZ8C4xbaw9ySRTcylUGLsvi7NLIc ZGRK1AmLtBjjx1WBJPo4STTClwELP2kTVAwTsbQvgiKTI5FktbseGi0MGQdslgZBSIIKum WzWUISpvnPEWojJZ82EzBDvVJuQgteY= X-MC-Unique: bsN8iyseM5ifMTK_IrU2iA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1lqAmhYOfqA4rnTNpzJDoCXhwIm0tgwIW69+uoJ6iSY=; b=u8DoeufAphusL6fZT7lTQG/yGWkSXiSyeMU1jQqPYMraKs/cTHEvxVlSXjZtxRSD1M ueJitdOgaNI+UZGzM0pz1MRaDi4RKUXKFU43uLEje0GP6qguoM4ztPEPnxKl7ABIEk7V o3Hq/tWRVaugafXWVkDeaZ14KlIN4MuEGZCyLst1tyIn5SEZMVv/rcO8jMTNrysMy42m 9JYvPIESEtqBKY3Av8DOdWPHCoIQM1spXy1CnkT2gosv0ICKY1Z1bfMhQwECMYPpiaZf MtPfTFqU1xbpkej+HjNwtn3EE0sZy+I2sau9pnUNFI2JfHFx4QIWN5+HcX97x0jIxaMp nkPQ== X-Gm-Message-State: AOAM530ejqRiYcQaW52FSgg6wMG7AM1UUp6NOun6tCyRYbP4+Uqk2eWn KjHJ+Ll+YFXonILAXj/7iFG6hOMfNL2ikKXdHy0AXZdIcZTFJqf8VzbaY9e/QJE8kFEgqxlMxGu Kkm6XeVFM2+JrA4q53sYRwPftmcOf3RiiM5Qh0te7WHdePO3/Y0T66pKvzYc9ig5q X-Received: by 2002:a37:747:: with SMTP id 68mr55483qkh.526.1632327615731; Wed, 22 Sep 2021 09:20:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYNLuS8P9WbH4x4Frw/tBir01OxR8g38esnwbAf5Zv2z4DI5BzGbnH156SioV/ETAJIBbaaw== X-Received: by 2002:a37:747:: with SMTP id 68mr55451qkh.526.1632327615453; Wed, 22 Sep 2021 09:20:15 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v3 2/3] migration: Add migrate_add_blocker_internal() Date: Wed, 22 Sep 2021 12:20:08 -0400 Message-Id: <20210922162009.125622-3-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922162009.125622-1-peterx@redhat.com> References: <20210922162009.125622-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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.472, 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: 1632328796831100001 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 6f7177daa0..d6207c53f0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2039,15 +2039,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), @@ -2060,6 +2053,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 Fri May 17 06:07:25 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 1632333677599536.0932273568908; Wed, 22 Sep 2021 11:01:17 -0700 (PDT) Received: from localhost ([::1]:37166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mT6YW-0004NC-8g for importer@patchew.org; Wed, 22 Sep 2021 14:01:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4yz-0007pU-A3 for qemu-devel@nongnu.org; Wed, 22 Sep 2021 12:20:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mT4yw-0000jk-NG for qemu-devel@nongnu.org; Wed, 22 Sep 2021 12:20:29 -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-293-sc4kdDmiP8qUxaVMw8S9SA-1; Wed, 22 Sep 2021 12:20:18 -0400 Received: by mail-qv1-f70.google.com with SMTP id z6-20020a056214060600b0037a3f6bd9abso13393747qvw.3 for ; Wed, 22 Sep 2021 09:20:18 -0700 (PDT) Received: from t490s.redhat.com ([2607:fea8:56a2:9100::d3ec]) by smtp.gmail.com with ESMTPSA id z186sm2094811qke.59.2021.09.22.09.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 09:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632327625; 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=IIEoX8C4rt317Lbcem8lIPCypmHung6wiz+VWorucyc=; b=HNMXQ2GCdL/YaQPd6U+wYuIRW5tXjgCiJJE7L1WAnUK7vvSvBBbvVHyITG+ZjfEVJrs34S RMyUjviFHh9g1NIYmC0v/VZzJuV5rCQn3yrGELrTmBpTsTgJQm9NSrI0rA/C/++M0fozZU wf+147HTK1pyx5h9nlmxiiouLa2oKMw= X-MC-Unique: sc4kdDmiP8qUxaVMw8S9SA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IIEoX8C4rt317Lbcem8lIPCypmHung6wiz+VWorucyc=; b=dsU5wYqGV7NvEGfVYZRImeO1yrwoXe80YeKmwdPRQZ334Kt9YHrfunxQzR4rIKwIz0 0ooarCkippMokoPkfnVTjm2AEQF1X6hERG1HkPUrm3zKTARFNpAp0C5n4ItUW/SArrSL XkVT9eyYsY3YurXm3A1iW8zRqwhix1F/7j2cPKu1DF8YluytEiHIKCFdY4gqVtnklznX Mfb9GzjU9GNmJ3kCtfVd5d5UN/zsS3wtxj70UpsbizgtEd/r7qcWumn6xWAW320GboP/ 7gUkiv5RJ0VmJsGAR6jWl33mGpg4WT5BKTAtUtjdhjpVNF/VAiksKWWWnE0a4ViX9R77 XJVQ== X-Gm-Message-State: AOAM533lmR8YCzGKHcknLjAffBNFnSbacY673V6GhRC7rILomw++BX67 oovaWqsciwdlVflEeomIY1m7y7zunoRNtKswvAMQb631sCuhCkqRgXJO0cBrXs2Tyv68OeZqlC5 vS7juSmjMIsvKpqqSDnJjQH1eLyNty+P0v7OyaBtAu36cuwnE/0mcvCGzv1OEAYKq X-Received: by 2002:a05:620a:5b4:: with SMTP id q20mr97795qkq.8.1632327617728; Wed, 22 Sep 2021 09:20:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcy8gWGB60XeOjHC6FqjGTdZrcAt47ht9t1JBbLi+miTbfabG5DeGU71CmTxwR7/prXq/2oQ== X-Received: by 2002:a05:620a:5b4:: with SMTP id q20mr97755qkq.8.1632327617404; Wed, 22 Sep 2021 09:20:17 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v3 3/3] dump-guest-memory: Block live migration Date: Wed, 22 Sep 2021 12:20:09 -0400 Message-Id: <20210922162009.125622-4-peterx@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922162009.125622-1-peterx@redhat.com> References: <20210922162009.125622-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: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.472, 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: 1632333679551100001 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 Reviewed-by: Juan Quintela Reviewed-by: Marc-Andr=C3=A9 Lureau --- dump/dump.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dump/dump.c b/dump/dump.c index ab625909f3..662d0a62cd 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; } @@ -2005,6 +2009,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