From patchwork Mon Jan 13 17:35:59 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: 856934 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1545760wrc; Mon, 13 Jan 2025 09:37:35 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUx6obzcPBYJ0WJIVcnZWhj4i956Ms2ASd2mH0ydf9xpDN7q3O4HxnmTVnSoKNkvJ/A67kOXw==@linaro.org X-Google-Smtp-Source: AGHT+IHLMdEsHq83RXhhQfvUTSzt7kAFgCd735UMx3bJYVsKGQhe2bD9lrtdUF6rskW0qLcIMoy1 X-Received: by 2002:a05:622a:154:b0:466:a93f:c1c9 with SMTP id d75a77b69052e-46c7102c947mr268141301cf.24.1736789855717; Mon, 13 Jan 2025 09:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736789855; cv=none; d=google.com; s=arc-20240605; b=jDy8KtzbOajc/0DuDGAnOnQYQg3Bj1xP0eBmg7csSw+F0z/EFLzqVzMfM0ijXPwy21 sUx50mIKmIuJ0jwjALYXlpyPOz5jT0XGXw4w3Fkckdj+j03whs0I88USaH01VKvaiT+0 dRrOtASEJo/gYwW6Gxnona2uHc7I3uLq24OPwbTAX8Oksd5NMRhefcKfNJIfA6dN21Ta 8/X8jk77Rl6qQL9Cp2HWSnP5YWKqCZ0VWAhlWxb5f4Meyy6KMERz6QuIId47J+657kpo ti1oeUE3QUrfdJqN3iXDzlxBLlIsXJv4LWduSc4Fk7SSSaI8EqBFM7eI3aeG3+2lEYWQ jAJw== 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=UfFTRmuQecjymNg1z1Zlqe+xEmRGvh9kuRZqED+itwE=; fh=Pa0Kx7VcbCaepe9+5NP9LrCZ4BMLIY/WxZiYNx05RvE=; b=boIlU7oLyd9Jwkt4ZqxUBZuUYi/A/WN5Bc/aj7wONwKZM6+mIayize9+2j3wrwlSUC Ce1O+6CGY9/y6fcrk48AzOetIDSumazbwNqddHHBJZZ2UOoPEuGhXD/kRZxxzg3h+dzh n0y/ieffYHRuoKZVtDmG7C52IRk3ABrVASI4Zsq3/wG7dSBjQ9kEXCCmdfUho6WpB9YW VbajRYeY2KOitUoHPSi4Y4FWTC8Q2twBR2GdBjcbY0e0I70/6Z74qSI00FpBj7xL5Zdv fQD2PhhIziiSJMkBSTvGNUpEfap8j7uyMONZYzuIae5z5gtYA2KB+IX2xvI1VKD5UY2D uzqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZOKvLh+J; 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 d75a77b69052e-46c87331457si94775561cf.121.2025.01.13.09.37.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Jan 2025 09:37:35 -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=ZOKvLh+J; 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 1tXONF-0002da-JC; Mon, 13 Jan 2025 12:37:13 -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 1tXOMT-00023W-Vv for qemu-devel@nongnu.org; Mon, 13 Jan 2025 12:36:26 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tXOMO-0006zd-1M for qemu-devel@nongnu.org; Mon, 13 Jan 2025 12:36:25 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-436249df846so31978425e9.3 for ; Mon, 13 Jan 2025 09:36:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736789777; x=1737394577; 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=UfFTRmuQecjymNg1z1Zlqe+xEmRGvh9kuRZqED+itwE=; b=ZOKvLh+JkRlsluoteN1EmHKMLQzwVivrz/7yL6YLeQUSk6RRmvnztPdqb+ZJEb/XA5 fv5CIi12lvCZJBqmD02g78AN2yiXSXh8vfL9E9ZxgNOl2uLe84OqloymcS2zi4OJZRLi 46IcbFOtfSWwf3A7VWo6xuzZqFxd5VjqB4TshbzLXW+5e1xVOoUQYKzZ8mMg3y0p/NN/ gjB7u4lBb45bcJoA+tUJ6J7BWHtbHTivjdqBhsekWNxcVmubw89sgbt7UHYUwhh0xxaG +MHpaZOPPsfd1hXz0qswHv7Lg+NijhTXBPRzALX8CYHt4iPf5c+BDDAWRPagpKjebbOf 4c+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736789777; x=1737394577; 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=UfFTRmuQecjymNg1z1Zlqe+xEmRGvh9kuRZqED+itwE=; b=GABy7RcfIUQMEs2bKyieROM5cTssYccyUFtdHAiBRsgYf+rH1CGKzmLstz1EfetiwO y84/BSbguZA2b618kgm+EhZ4SMnnA8BzyrGNW4cwcUHJWqZIUNSRYxRFvsNDlH5W2PBw VXLSiKiPUNOB0/SDkkAp7HPhYsQUAIh1tzt6WZLkS9StEWrQOM6SndwgQ56ce+pKSqTt ogd8XnI1KCPGZgoxKp1wo0WzcdBBRO3tL2/9c7nNZvZAs6x8wtIQ6ShHuibpbhtrAE2M 66L2bJ9BYNM+paHQ2ObC2KihjlqZ4sj0NbvXqnhSBFiyTD0RZr6aR5EdcXut7D/CmEsK 0oBw== X-Gm-Message-State: AOJu0YwHkVyxp3p64ttWV69FaQofpkEUOVJO9oejUnKJovRO3jDtH4s/ IVo/+bWHwDrraPJm+SRnkeAhOaS2WVQ9zFkCCMjMItI1O5zAJ4PndTaJiMZMFsbLmIPF9hGoyZP xMwY= X-Gm-Gg: ASbGncsjkQOSMroN526NjI6d71us2PoKiD14HFJR08yjG2my9i6d1L2ynt4JHhLcF7L 8ddWi2K185uiK38yxWS5Jrf5xoWs5b3ZFZbMZO3px/fXvNL7yIlPl8mCILxaZS+DUIGNYOpMg6B J4SXSjBL0NiT+IKyBqRa0PTxCk/n8x1Q3r7721qpN3R4wKmkS9y/YxjN0xZ0mjKZs08BnSJs0PL u/HmNaVdqC6Y9QfnCbP3MoKTzH3f283nqkDDiyeQJFmxCLkI8fb3T0WCFbOAIu7aLVCOv/zZ/Hm rP3jR+exIy1bmfphdPMgr3/KF2o7Q9A= X-Received: by 2002:a05:600c:1f95:b0:434:a525:7257 with SMTP id 5b1f17b1804b1-436e26d946cmr167014235e9.21.1736789776632; Mon, 13 Jan 2025 09:36:16 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a8e4b81d7sm12730247f8f.73.2025.01.13.09.36.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 13 Jan 2025 09:36:15 -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 07/55] hw/qdev: Factor qdev_hotunplug_allowed() out Date: Mon, 13 Jan 2025 18:35:59 +0100 Message-ID: <20250113173604.46931-3-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::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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 Factor qdev_hotunplug_allowed() out of qdev_unplug(). Start checking the device is not blocked. Signed-off-by: Akihiko Odaki [PMD: Split from bigger patch, part 2/6] Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Igor Mammedov Message-Id: <20250110091908.64454-3-philmd@linaro.org> --- include/hw/qdev-core.h | 1 + hw/core/qdev-hotplug.c | 5 +++++ system/qdev-monitor.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 930b00fb09a..530f3da7021 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -541,6 +541,7 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id, HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev); HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev); bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp); +bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp); /** * qdev_get_hotplug_handler() - Get handler responsible for device wiring diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c index 19fbb11a316..dc35110e735 100644 --- a/hw/core/qdev-hotplug.c +++ b/hw/core/qdev-hotplug.c @@ -47,6 +47,11 @@ bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp) return true; } +bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp) +{ + return !qdev_unplug_blocked(dev, errp); +} + HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev) { if (dev->parent_bus) { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 83388dc0c4a..511d1aa83c2 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -909,7 +909,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) HotplugHandlerClass *hdc; Error *local_err = NULL; - if (qdev_unplug_blocked(dev, errp)) { + if (!qdev_hotunplug_allowed(dev, errp)) { return; }