From nobody Fri Dec 19 17:12:00 2025 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1696623750; cv=none; d=zohomail.com; s=zohoarc; b=T57d+fqmtu1hkN7mdQFLtTdptr+rjGZt5iVWkZXjeB1lgOwUaq/BFAYxWrXCXza08wyyfKwOcDAC80fSo5AZ9SSTPO5v3RI1ChA16uR15ktoaphIV9FrEG+OMVdDChZNtFC2wZm0sF8fZs5FI3w3ZdMktEb7EEpu9JG1WAwD3Ok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696623750; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dAy7l69Vys7V3wlSX1d6pN71zQIe0P3DoLfLqC49yLc=; b=MJGOc+7e5FjyqF/3TXT7GvWHzslSwZlaby0/y8dTEUvhIoGTxCcbbwHpKma4SyPHscFEeIp0XGdZu/TwQcu8dskXjOo3qXXZ/WzAYJ0QWYc8c55+Siq1AW1VpflDhvzGvx7J8BsHRLPg6vi4MbkQ+eoza6fMD/sKOKmt1/TGcDE= 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 1696623750640103.86464794232268; Fri, 6 Oct 2023 13:22:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qorJr-0008Er-Ek; Fri, 06 Oct 2023 16:21:07 -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 1qorJo-0008DE-Oy; Fri, 06 Oct 2023 16:21:04 -0400 Received: from forwardcorp1c.mail.yandex.net ([2a02:6b8:c03:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qorJm-0005mQ-PL; Fri, 06 Oct 2023 16:21:04 -0400 Received: from mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:3a8c:0:640:ec94:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 5F4E660EFC; Fri, 6 Oct 2023 23:21:00 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:b403::1:3c]) by mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id kKgI6e5OrCg0-nsKsNsQQ; Fri, 06 Oct 2023 23:20:59 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1696623659; bh=dAy7l69Vys7V3wlSX1d6pN71zQIe0P3DoLfLqC49yLc=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=bkRHgiPjX4+V6M4BcIH8EXB+5ho+jILkI61RJ0JhSzIo8y8D40oX8c510wTtWlfuU cuaMErKY+MZ41d1qwBq+fz8efVBBnsbIvMiWLkpIV6lSm7OBQjnFL3WBB19+9keQLf UaCmE5XXtPskLIji4aUaRa7Kq4CIlKXMfvZJoHKQ= Authentication-Results: mail-nwsmtp-smtp-corp-main-62.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, dave@treblig.org, armbru@redhat.com, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, hreitz@redhat.com, kwolf@redhat.com, raphael.norwitz@nutanix.com, mst@redhat.com, yc-core@yandex-team.ru, vsementsov@yandex-team.ru, den-plotnikov@yandex-team.ru, daniil.tatianin@yandex.ru Subject: [PATCH 3/4] qapi: device-sync-config: check runstate Date: Fri, 6 Oct 2023 23:20:44 +0300 Message-Id: <20231006202045.1161543-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231006202045.1161543-1-vsementsov@yandex-team.ru> References: <20231006202045.1161543-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=2a02:6b8:c03:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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.29 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 @yandex-team.ru) X-ZM-MESSAGEID: 1696623751685100001 Content-Type: text/plain; charset="utf-8" Command result is racy if allow it during migration. Let's allow the sync only in RUNNING state. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/sysemu/runstate.h | 1 + softmmu/qdev-monitor.c | 27 ++++++++++++++++++++++++++- softmmu/runstate.c | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 08afb97695..1fc14c8122 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -5,6 +5,7 @@ #include "qemu/notify.h" =20 bool runstate_check(RunState state); +const char *current_run_state_str(void); void runstate_set(RunState new_state); RunState runstate_get(void); bool runstate_is_running(void); diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index b6da24389f..b485375049 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -23,6 +23,7 @@ #include "monitor/monitor.h" #include "monitor/qdev.h" #include "sysemu/arch_init.h" +#include "sysemu/runstate.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" #include "qapi/qapi-events-qdev.h" @@ -1002,7 +1003,31 @@ int qdev_sync_config(DeviceState *dev, Error **errp) =20 void qmp_x_device_sync_config(const char *id, Error **errp) { - DeviceState *dev =3D find_device_state(id, errp); + MigrationState *s =3D migrate_get_current(); + DeviceState *dev; + + /* + * During migration there is a race between syncing`config and migrati= ng it, + * so let's just not allow it. + * + * Moreover, let's not rely on setting up interrupts in paused state, = which + * may be a part of migration process. + */ + + if (migration_is_running(s->state)) { + error_setg(errp, "Config synchronization is not allowed " + "during migration."); + return; + } + + if (!runstate_is_running()) { + error_setg(errp, "Config synchronization allowed only in '%s' stat= e, " + "current state is '%s'", RunState_str(RUN_STATE_RUNNING= ), + current_run_state_str()); + return; + } + + dev =3D find_device_state(id, errp); if (!dev) { return; } diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 1652ed0439..3a8211474e 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -181,6 +181,11 @@ bool runstate_check(RunState state) return current_run_state =3D=3D state; } =20 +const char *current_run_state_str(void) +{ + return RunState_str(current_run_state); +} + static void runstate_init(void) { const RunStateTransition *p; --=20 2.34.1