From nobody Sun Apr 6 21:59:22 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1736500806; cv=none; d=zohomail.com; s=zohoarc; b=j5K4xF959MrRzgKwV1MHWo8ji65KfCZiaAulsoOmegb5MW3yt6kLIo/gK5n1RneFwxEfAS8YBBsLwl5l1JZ2HvXuDKfhIcraPKRcdL7DJBdVxbGPUZvsYyOKXevGFLKrWKw6c63LOhR32NoeXtyWHEcowxittBeIo6lsw+L/62c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736500806; h=Content-Type: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=MvotUkgIAo4Bek1E23vWcUJA+NmHBkCSsm3lADq1RFM=; b=a18ya6FkUG2l/t1hq1FqcGAyinpSvfyUrySvnzO6SSUoPHWljBQmja+bUl/oYDjne5AYMIVRrpYiW3YXorJU4LEKlf1nMNPaUkJvOV8iPhqwN1iVzZ7NxjK3ueA1qk55XbjT4m9HYSCqXtmUE86XUepHYKmnaZbR7/XM7u7QBuQ= 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 1736500806988188.50689339823964; Fri, 10 Jan 2025 01:20:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tWBAw-0007Gr-GJ; Fri, 10 Jan 2025 04:19:31 -0500 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 1tWBAu-0007Gi-G6 for qemu-devel@nongnu.org; Fri, 10 Jan 2025 04:19:28 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tWBAs-0007Jc-DI for qemu-devel@nongnu.org; Fri, 10 Jan 2025 04:19:28 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4361f664af5so21250175e9.1 for ; Fri, 10 Jan 2025 01:19:25 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9e03ffcsm46058505e9.20.2025.01.10.01.19.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Jan 2025 01:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736500764; x=1737105564; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MvotUkgIAo4Bek1E23vWcUJA+NmHBkCSsm3lADq1RFM=; b=lEn35KpDgJoIqyYbuZOgDIj/Gr0Hk8pkPgVSv/47PL/rTc0WQnhiGJ2kwz+D+ETRbz /kO6uB4sO0Z9wOxg+baFf8eLx3Qr9H6gKrdJsr77myhJmvXB8wBl8ou2kkUkMMOW0kcl fT4/YnPl8VHMI6ua4YZA+NRo4K+iVGHIiA2/Z+awlbVHMkD2qRl0xhqsxVGH58YYgKab /vPDsjG5/7SB2fadfYcPUw7fwl9mTr663/fhAYAOGKTcfIUgajS7XCySR7AhH3H92EYs NtijjhJ0bE1HWRLt90TrH8FRReqwrNuRSiP9sAVmTv4VrmvFu69IHwWt9vuDhGIAts1g 4aUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736500764; x=1737105564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MvotUkgIAo4Bek1E23vWcUJA+NmHBkCSsm3lADq1RFM=; b=CUV70NYiX+zeO3tSrHOxgfUY20UxlNq2VV50fEYETdRO45uB3oFo9egzCeXXmNSLGN h7qsCNMdEzbv66gKUmGLK8BcXW0erJvteFQ7QpkdNNZ+00d8ZZX3B+h50NdN1P6OFFzx IkpQFozNKOo8m8al2Hhb7Lp39w3ChZ2WCfrzdKV52DdKMQGCN1kaGIcEmnTqi0ZmEGF1 /sq2+EeNcGK1eC0P9nzgahS+UINPgZGp4lIDm8ZzxO3uZ1touiFkuL9HBKRwnrTcXGM6 9ySQyClUc15nJRsi0P+zb3o245GKLUlk6QHrWE7Ioha36NbkaC8GPNvVX6LcbHBOX9Jy nCmA== X-Gm-Message-State: AOJu0YxyK5whSpNLtJR7Au0ztXtCxYtp50C9qK93dr7tEX9Fl5rLzZQ/ /CSBuLmRd2zE8cpNua+NtR9RBtbWszQSTQAMypURF6Xe6kBmGvFuImFhz3GxoGr7WhbgoRWSsLM /2WQ= X-Gm-Gg: ASbGncvUj8RUflVBLFpGsjdepcNe6F9nzp6iItIJDl7VK+wBDIomvpdiaEiswkkuxlo OsArUva+Bd0jCdrJa5fgBjD9bL27ON84MwigOMeZtPK3mX5zno8EH9XXl1doEu8XlV8zQuq9oYC /5pueABcHrnw/CH3oDpsO/328eJC3uNFHoLYpRR+jSEzXtNc6yEVdvjKxHmJ7SDac+Vrx56N1p+ cFMGBE+RjXRwfHPq/mVj6+BDvc5W+yuh4S+uSgdsGRgLWb4BMYluHYDMWMKHpt6xUKSs45gnYKN WxDqFCHJqE5CvtnmsrYJiTm+EKrtuFlmEn2V X-Google-Smtp-Source: AGHT+IFcMZVi+Klm6BsG/GFtfr1xkX8kQrnP1WcBDkynGdid7nxw4ZKK5LGDdjTnt9rd3eA1di/PFw== X-Received: by 2002:a05:600c:354e:b0:434:f9c4:a850 with SMTP id 5b1f17b1804b1-436e269c42dmr102934975e9.10.1736500764275; Fri, 10 Jan 2025 01:19:24 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , Eduardo Habkost , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Paolo Bonzini , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 3/6] hw/qdev: Introduce qdev_hotplug_unplug_allowed_common() Date: Fri, 10 Jan 2025 10:19:05 +0100 Message-ID: <20250110091908.64454-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110091908.64454-1-philmd@linaro.org> References: <20250110091908.64454-1-philmd@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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 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 @linaro.org) X-ZM-MESSAGEID: 1736500809790019000 From: Akihiko Odaki Introduce qdev_hotplug_unplug_allowed_common() to hold common code between checking hot-plug/unplug is allowed. Signed-off-by: Akihiko Odaki Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/qdev-hotplug.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c index dc35110e735..168d7964740 100644 --- a/hw/core/qdev-hotplug.c +++ b/hw/core/qdev-hotplug.c @@ -30,12 +30,22 @@ HotplugHandler *qdev_get_machine_hotplug_handler(Device= State *dev) return NULL; } =20 +static bool qdev_hotplug_unplug_allowed_common(DeviceState *dev, BusState = *bus, + Error **errp) +{ + return true; +} + bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp) { MachineState *machine; MachineClass *mc; Object *m_obj =3D qdev_get_machine(); =20 + if (!qdev_hotplug_unplug_allowed_common(dev, bus, errp)) { + return false; + } + if (object_dynamic_cast(m_obj, TYPE_MACHINE)) { machine =3D MACHINE(m_obj); mc =3D MACHINE_GET_CLASS(machine); @@ -49,7 +59,8 @@ bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus= , Error **errp) =20 bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp) { - return !qdev_unplug_blocked(dev, errp); + return !qdev_unplug_blocked(dev, errp) && + qdev_hotplug_unplug_allowed_common(dev, dev->parent_bus, errp); } =20 HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) --=20 2.47.1