From patchwork Mon Jan 13 17:36:02 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: 856937 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1546118wrc; Mon, 13 Jan 2025 09:38:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVArA+G3duglpY2iYy22pVlKm5gWISTtp1Aplgn7Y/iByeW0ih/Q5lpIY5x4X9fXgvmXtDGKQ==@linaro.org X-Google-Smtp-Source: AGHT+IHDc4H2qCF0MlbVOCPsQ8GG2ep35gErssmDkRWS6JQ311WcKd66Ol7FdeuZDvI386Q1o9I6 X-Received: by 2002:a05:620a:4492:b0:7b6:d3e5:4f45 with SMTP id af79cd13be357-7bcd971725dmr3354027385a.30.1736789912766; Mon, 13 Jan 2025 09:38:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736789912; cv=none; d=google.com; s=arc-20240605; b=HaiQkdGAhwMQTcsY5HOFfFEITvYrIwMmcVP5yZV0VMvoxpozKbpsAXoVP1BjwrlVYF Fi2iaxaCaOhf5ryw5dpdJgvzL2KkqL0Bb0DQVSZBYaKTu9pYnVg8Jq8HnZSHKZDVIWUf gL6WFkR32VZ3MFmSMwYX7REkk2sHqGinlacINBmWrQRRtUSzKU63jRp99Ec19LgTMJYt 7W5rvIVIInZXPf3FHeQKIagDdAY4EcLa/o/KJKdpXi5hK9YT0b6oLwIj29CDz0gowo/d Y0QNqiLnhr74xXrh9AMGnVeYcW2E3HrmCcngxAzG5ITq7PaLO+irz2f2MfyfgzHZvZY/ wTEw== 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=9K5rXE6D64Zw+S58ipW/6GTsDDRWIpLeh+hDNnJwfH8=; fh=Pa0Kx7VcbCaepe9+5NP9LrCZ4BMLIY/WxZiYNx05RvE=; b=Q2XV5TWe8veGjcor/wKCSV8/OKvwfxo6uZHUP65JxomZD8W3VSpdgNvvmGrbHuL6AT eec8lOGHAsqJg0uNdC9Oc2tp5ZyWKfbNifwW98X6uQnSW9MyNNuBGsYx36+rSVXKFfAE RM6wWEVddqNUZxPNT1KjY1qFkBzsv9kS2HFj9xsMxv6WRLDJOyGK87fNhl2Ym9CnwJ/k c+iB9Llnv3A1f3UW1mB41l9DJQD7PTiiZd6yCFKVoVpynmp7xKIc5GlwBheVi4Ew0uwZ DTIq1bDa7R+YuFYkkLpmv2zquhPslHoaGihHNPnBj52X7ZuVkyLZIS45oOWS7V8ZPUib rx2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pa8XMhZu; 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-7bce330725csi1094616085a.303.2025.01.13.09.38.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Jan 2025 09:38:32 -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=pa8XMhZu; 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 1tXONL-00038H-Nj; Mon, 13 Jan 2025 12:37:20 -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 1tXOMe-0002Dm-CK for qemu-devel@nongnu.org; Mon, 13 Jan 2025 12:36:39 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tXOMb-00071m-IK for qemu-devel@nongnu.org; Mon, 13 Jan 2025 12:36:36 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43675b1155bso52677665e9.2 for ; Mon, 13 Jan 2025 09:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736789791; x=1737394591; 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=9K5rXE6D64Zw+S58ipW/6GTsDDRWIpLeh+hDNnJwfH8=; b=pa8XMhZuQryc7Yv0MpNGgdb2FGiLGzIkyls63oDyRSUYyTde5S8o/tzXx0S35/Eup9 yRtere6zhIWrs3GDXDyBNcr8//Q4Xo1lhDTPr7v6+8RKYqpGMRZkHpDfLBRFucyuupDf iijectX/HJ7z5Zv4GmmxLDyoAfcKtlBucu+GoGyrlP32VspuQKOn6QYx7IXIKxTjK/3r JeMCpQ8XB6dcPvtdHn3xvLMBNBPpjI9Whnv/DW3KWO1iIzZnrzZYEfsyK6BGpFeYGuIi DBBoUwp4p2/hWFf5PF/bkbWu57tGYvkWraNMtkP3gIsdUYkBWS+e147hnjOxWKC7//Ad 2rtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736789791; x=1737394591; 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=9K5rXE6D64Zw+S58ipW/6GTsDDRWIpLeh+hDNnJwfH8=; b=mHq58KqdFyOP2i+qQj7P+ATMext0QYwcHV7AbSc+dBZzUaakeXy5BT84EM0F0o+F+T eUWP3tOccgjo06J/nxbfD2SccYCoPeUeodBBtPwlEITB+vfzexHCB/OtOsAUBwS+Xyim IGcqR78PQmBvMiTMntOpfYWqIr5oCDsrOzxAh9apagTWDTeFvZkQ7Sdf7JFjrWaHqfH1 4YErCooJ178i2+CjMsl3XM8pGfX7BxQCIxg2BEX6kvIXXargL8pKsd84uqqgvhebdcYO G+bfQt5imHyJ/9792XHVIvk9E5K1BwJubKukK2jU/uI/+sTOyBnj41AOg8+tqYkpo0wT nY8A== X-Gm-Message-State: AOJu0Yz3LSmKwUUWKahvhCapa8327yNvPYi34fveB2Yinf+RcL9sAXym 3A5rT+O0V241pkp+UGLBMwYE3YfbczMr+F/w8sHsCv2favyVXc7iVPpMN3NMEwfmtVhmwUlr9E3 umfs= X-Gm-Gg: ASbGncstrfkXXliEnCapXhurC9Tj0KqvDdLFKKqlm3LQ7rB927grTQqPfhVuaTW24Z0 94VFxGlW/R1JFsIKqeM/vM91DzvZ1aLJhEi2Bk6vAOW/cGG1DMbznP6oxqDseKxk/wjP3aBH+sq ZwAh3Rtg7Z9AK2490cUgBue3mQwEEdeF9Jm38YE5IuauhrT8suk5M98SifI9aWCzHmzB/6Co5D/ FbxJ1+7epfigg3XznAR29pzi0Cm456qK3nDTT+t7xLb4auSeksEju70DB1xqDkeb+J9pxyG/vfB i3T1V6us4N3ndzObV/Y4NpD5Z/oC5l0= X-Received: by 2002:a05:600c:354e:b0:434:f9c4:a850 with SMTP id 5b1f17b1804b1-436e269c42dmr223133295e9.10.1736789790784; Mon, 13 Jan 2025 09:36:30 -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-436e9dc860bsm150457005e9.9.2025.01.13.09.36.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Jan 2025 09:36:30 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Igor Mammedov Subject: [PULL v2 10/55] hw/qdev: Check qbus_is_hotpluggable in hotplug_unplug_allowed_common Date: Mon, 13 Jan 2025 18:36:02 +0100 Message-ID: <20250113173604.46931-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113173604.46931-1-philmd@linaro.org> References: <20250113173604.46931-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 [PMD: Split from bigger patch, part 5/6] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Message-Id: <20250110091908.64454-6-philmd@linaro.org> --- 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 81f747b38fa..e27d25c5859 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -675,11 +675,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; @@ -911,12 +906,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;