From patchwork Fri Jan 10 09:19:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 856214 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp133568wrc; Fri, 10 Jan 2025 01:20:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUPHJSrKVgM/aZYLTlRpattELW6IWxp1DYnWQ89KZzWZlIPnvFvi4y7VBrok1HzqldLO20+nA==@linaro.org X-Google-Smtp-Source: AGHT+IHZAsMyo+WEwqEjDfgre+haCaKdJ1uZ2k212mwwSbj0s7+CO+C+5IaUP17F4XJCEHTMHdjw X-Received: by 2002:a05:6214:2b98:b0:6d8:ad76:497d with SMTP id 6a1803df08f44-6dfa3a93c7emr99808786d6.10.1736500806188; Fri, 10 Jan 2025 01:20:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736500806; cv=none; d=google.com; s=arc-20240605; b=gcizBCAkvxwjZzxc4BeCknuFVvkjiHUbG+f12wIUsqBDpRqTBBBtK3eWbrGuk0f0dX 7Z0eJuo6d4Tk5VPIIyBCEPDxGCs4fdUIhW3A9iMmUFG+w16kF3pWd040KhH8e7N5U6NM sCcP7ItgNmpuT9YAHjMgZkgOC5BVpnU0LhLA/3/Tt0+RUBRXUrQig5pGVgRDsTNQgu3o bdqzP7LCJIgg8+tCyiVleDPMjbuS6mf8gmm+A4U3K6SY0ms4UZzHYoW8jTpw2NBIswYy BWtwmxgIvAd0vbByn0BDDVfaCWqLpz6f35PiCth75ISkEFH7sor7Oh+o5EBRI6bgVJgN Imrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MvotUkgIAo4Bek1E23vWcUJA+NmHBkCSsm3lADq1RFM=; fh=XimDjJFGOz1tEVlhrez7cAg54nTzgWY7MGINAk/Ymt8=; b=Uuf1Uh2Eb50favfPrJoiEpQSO2ZEWXUto18ssycenrFoA4SHJCB/iDEid6PMg8tQPU oAOYtffVkDNc241I/s9uUzx5aFAuIOTUL6gWPJQQX0JkcZQNwmTmwoOcDPu7MHLFOY9M ChuHYfTb6RjL53ysQjHdJGPUIFDG9WyROpuwU2fK5RMrfztxP8zxmOu07Zl/KGkI2hts dgh5tDLVW4CJfL/ocy2j5ey2sGgCCVKwCM6J4GAUManNiY0KyJg+jLTIJWWkkd4D8RNC /cV+025pDX4WAYTyh1LP1ZyvEqt712OIwP9WjLTOVcHiG5b5IUq7LjfMroN2liCwVVi1 pMLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lEn35KpD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dfae027542si16711656d6.488.2025.01.10.01.20.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jan 2025 01:20:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lEn35KpD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , Eduardo Habkost , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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(DeviceState *dev) return NULL; } +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 = qdev_get_machine(); + if (!qdev_hotplug_unplug_allowed_common(dev, bus, errp)) { + return false; + } + if (object_dynamic_cast(m_obj, TYPE_MACHINE)) { machine = MACHINE(m_obj); mc = MACHINE_GET_CLASS(machine); @@ -49,7 +59,8 @@ bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp) 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); } HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev)