From patchwork Fri Jan 10 09:19:07 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: 856216 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp133569wrc; Fri, 10 Jan 2025 01:20:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUCcf1TJh/ETG3mK30mbpuMsF+J2mv1bs6UPD7D/zMhGUArvVIwrtJ2qlnQNDxHjuqGJyksmg==@linaro.org X-Google-Smtp-Source: AGHT+IGsMZgaavbwgchKBU+7KHF2ULE1XdLZ6Ag36GrP/25gEoqabc8G6+YMJl2MQ4OINV6OzYhz X-Received: by 2002:a05:620a:2481:b0:7b6:ece3:825d with SMTP id af79cd13be357-7bcd9726520mr1333289285a.12.1736500806196; 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=kD/sdvjaJidVrQwordXFy4+DMaByBNbAEp7XN5DQKozj+DkLjzKgz6qw8vYmitCspY AH8m/a9fecL+481clwO8CdAU98bDiIaykrKQnkutZXqpRm6ccKgTzojcngbS2sdHZRpR ydcKwwpAS0H9v5YBVyWwuyaEsopH3lOKfZyBvi2iiMfXSG+TP8jGL7k/lt0Uumw+8i+3 ekMpW55mdkGTqwtTa2pwosN22hC5ujzAthaAv7Ct2vaE8MrifjWsvLLBW3ts44E2rizJ pN8nHemszud1tcQlGH9UDBYwuG0e+Ln8rVjIujDk2cT3EB+lf5Ioz7lH4q1YaVSZYvGG L7Vg== 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=lbWTpaNvctHav635rFcNQUuqidCEawKdhGTCRMBGzHE=; fh=XimDjJFGOz1tEVlhrez7cAg54nTzgWY7MGINAk/Ymt8=; b=RbtoLvoYM9K4/P6EmWcTRa0lxla3mr7uzzdcDRvpLxHftglbvQggSrzDfd8LWMXx4U Ta5CAGc+xCD5dVSZU9OCBMROVM9L6a+QrVnkRd1SdgdqhXDwT7JpOEcAQQzgH4pFevdM q2j8MbpqzVVkEjZjqDdeUBxrk8R0wRbA60Y+8xa10Fqb96U3e88YZN/Z1+7pPf+zI6t+ TO7AECWblJF6afTLNdQlLdEcpf2osZhKr5TEgubmekH6SovZcFf2MjFKA9GkdqRKvd8u DsHX4x+c++40qHgucoJFeF4eBgnj7u/mybxXEydTkrTf6aMA75USkPT5j1sBqgCE/j2U bF4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aVSeDlBP; 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 af79cd13be357-7bce34fdbbcsi385034985a.395.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=aVSeDlBP; 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 1tWBBB-0007IV-GX; Fri, 10 Jan 2025 04:19:50 -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 1tWBB3-0007Hi-LN for qemu-devel@nongnu.org; Fri, 10 Jan 2025 04:19:38 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tWBB1-0007Kb-LV for qemu-devel@nongnu.org; Fri, 10 Jan 2025 04:19:37 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3862f32a33eso825785f8f.3 for ; Fri, 10 Jan 2025 01:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736500774; x=1737105574; 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=lbWTpaNvctHav635rFcNQUuqidCEawKdhGTCRMBGzHE=; b=aVSeDlBPoOI3A6W5SQO72hCOE0jkbLLqBNCcuX6vO20JXolLREwQxR7mhtq6EKcXp0 cpTv0oIJX7vvS80P3OnSymPqPcGzCLUwsWK855EnA31WvEeMdLPnJY3RJqq9527Khldv h+bTpbs8Kp7BysU8y4K5KqG3qXuZ+B4HFtF2Pct2BZgyaeE6hOC3NXVjIfEbqUFujOAN UUW9NtdfHdrqI583EET4kW7Bhd8hvnMmEYCb9Bf+Qx6iCX1pGr8ZlITEA0h+zlQtAFob S6IymRkYCUuBWeaN+z0UBSYEaMkaksUdJwC6ZyJahBTVFnxC9yO98Vd0BZlUxLAdhAWF nAsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736500774; x=1737105574; 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=lbWTpaNvctHav635rFcNQUuqidCEawKdhGTCRMBGzHE=; b=te1HObNYj78lh5BBx45X5gR6iFmKdVc32xZDj6PxHI6BOPNc33sKGjv0pipOXW1nOz VB4TssoROXqcypAcgAArDV7VIsG1Ovia2dvlz0NoIS3cgf7oGxEYstcuhDrJgCVLLgdV qYzvoJjotMYLmP/VfzH9l3NXGK0AR2iodPVbeKswaUl9GMp5SQitQtMj/yltSxEXIYJX ob4OonufjpCDzl8CP7NoxrZNRgUpGYCXDjUBc+eQzQRP0UNjpj6sfsrxPebYgKnjuyP2 xHE+ezviJyoFKob+A9NOhWcCXrsafPMCVDgm5xp97quXcFhIoVDUB3F7BGsjFo1wDWWN GPJQ== X-Gm-Message-State: AOJu0Yzy7mFOhVSWhzqk+sDkWFvxloQxt8mlR4ExbVuoSj7E1jOLwj4u gzTFsm1xQTyPo/RkdHm6IH7bL866pvcbVoSn3x8CGprjsI1a4GxUGvNeUtqQBLKQ9HU9zgXQsF+ 1NBY= X-Gm-Gg: ASbGncsOp8aUwGqSUrrzIwl7qHIff+MVo+qggE/Cyuyi4ssoIbGLQ867FMtf4Flk2sR yGocOmfT/OuUA42u5VYt2PtbTqkaom1q3R42zQceROMXICJMvVDxihURbCABSk7caE5i6SwxZJI 4UlxaLaDtJrO0bwqSncJaHWB7N3u210y/3xDTa4rhJvTOOxdIs+l0BemIubmfy3AdzGYrzdK0B6 9BUtgKonGJCZFft8kQ8HiCE6rpJVQHLWYwn88ivJiolNiKjtiNCbBHm7BNSvhUFiQRx4KJvYYkZ 5XHy5d69SUXdbVt57jaqyNqKrDXFe9XDZ7bR X-Received: by 2002:a5d:47a6:0:b0:385:f195:2a8 with SMTP id ffacd0b85a97d-38a87312734mr9184234f8f.30.1736500773832; Fri, 10 Jan 2025 01:19:33 -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-436dd15766fsm55592855e9.2.2025.01.10.01.19.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Jan 2025 01:19:33 -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 5/6] hw/qdev: Check qbus_is_hotpluggable in hotplug_unplug_allowed_common Date: Fri, 10 Jan 2025 10:19:07 +0100 Message-ID: <20250110091908.64454-6-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::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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 Check the same code once in the common helper. Signed-off-by: Akihiko Odaki Signed-off-by: Philippe Mathieu-Daudé --- hw/core/qdev-hotplug.c | 8 ++++++++ system/qdev-monitor.c | 11 ----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c index 1d77fffb5e0..f6422cd0e4e 100644 --- a/hw/core/qdev-hotplug.c +++ b/hw/core/qdev-hotplug.c @@ -42,6 +42,14 @@ static bool qdev_hotplug_unplug_allowed_common(DeviceState *dev, BusState *bus, return false; } + if (bus) { + if (!qbus_is_hotpluggable(bus)) { + error_setg(errp, "Bus '%s' does not support hotplugging", + bus->name); + return false; + } + } + return true; } diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index f28b2e95459..99b638c0aca 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -674,11 +674,6 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts, return NULL; } - if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(bus)) { - error_setg(errp, "Bus '%s' does not support hotplugging", bus->name); - return NULL; - } - if (migration_is_running()) { error_setg(errp, "device_add not allowed while migrating"); return NULL; @@ -909,12 +904,6 @@ void qdev_unplug(DeviceState *dev, Error **errp) return; } - if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) { - error_setg(errp, "Bus '%s' does not support hotplugging", - dev->parent_bus->name); - return; - } - if (migration_is_running() && !dev->allow_unplug_during_migration) { error_setg(errp, "device_del not allowed while migrating"); return;