From nobody Wed Nov 27 02:33:17 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1702186488; cv=none; d=zohomail.com; s=zohoarc; b=Q5HR092RmHkDEXUGYf2xo655V6yctuYnXQM509SIAPFoOalguMJeLWRQS2S8FhGlJ1jlNTlUBu+GkMHbf25fNaTcqna4fHARUcJpP8X0MvC/Lr8mKRXuxXrTTs3AYuGsdDNeWDRaTMu4bAMgC7e68rO31gxAwv10Nt4GJ74ZmoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702186488; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BBcDYo7+RkPWNies+zq0eFCRukVsPbfSClQvBCISWAw=; b=A4ijAujpZd5hqeYjpRFVwNAxJi1yVgvqxCT6CdZjhoa6sBOR5MBQus4p6bY2hmqlV1D/ncGmxskhxQizCvGPR1BG8TwEXvcSfBkjJwivniKvqlA1YjcUzIr2AnTJEaga5jRgCjXG++MemHPQh0hinFvUvCAmnGOfmvC3wfXpWnk= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1702186488893606.449349979608; Sat, 9 Dec 2023 21:34:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCCSi-00054u-Bq; Sun, 10 Dec 2023 00:34:44 -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 1rCCSf-00050O-N6 for qemu-devel@nongnu.org; Sun, 10 Dec 2023 00:34:41 -0500 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCCSe-0003m2-0N for qemu-devel@nongnu.org; Sun, 10 Dec 2023 00:34:41 -0500 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-35d77fb7d94so14111045ab.0 for ; Sat, 09 Dec 2023 21:34:39 -0800 (PST) Received: from localhost ([157.82.205.15]) by smtp.gmail.com with UTF8SMTPSA id az4-20020a170902a58400b001c71ec1866fsm4229405plb.258.2023.12.09.21.34.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Dec 2023 21:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1702186478; x=1702791278; darn=nongnu.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=BBcDYo7+RkPWNies+zq0eFCRukVsPbfSClQvBCISWAw=; b=gC+rDT0goHJpjEQ6iegMCdiBbPP9+K1xDFpi6bhQ9sxV9mpPrWPA+kQnfQFk7QjFyN GBxc7+TdsxxWj0+p3gg6h+WHV+nCchUwS3SrergpnDK5sZrTpW5BwB5UpisNAXr9FLV2 Xa+tpZSsMhx3e8V2mPkEbIwMhx5zbm3He+SNmf7Ol+JllUbxF9HkW5yyVduaUWZY+hWF PUBLpnvE4u4SiWhL3Ky3y9oCm8EupRVLO7jSMWmXRHKV8FEPHZS4v5WmY7tfT24pIe8k xaBgWd1A44xH0wFdIehrqVAtZPiuDdjr8FL6nKOMsg/zEWY8WaKtpcLXQXrx+31QB6IG 3lQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702186478; x=1702791278; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BBcDYo7+RkPWNies+zq0eFCRukVsPbfSClQvBCISWAw=; b=qp38PxLXMtxp4imWorj3/VcrFDpoftk79mQcgnmlBa81a0qwnD2irGyLKoHto7ft/x h+ZwOoGQfkJlP+1SrhepaBd0MRec6KY5ahGuz5FF0CZopy2mbIhPGb9IENH2iEOAal9j dwaP+r4M/5f+sZUm/pvzIj4czW1xP8CzNYBetuFzBLedgLEmE3lecmQGdZ7Y0PhEh2/S sJbHDBUwiWnDYxcqqiW0eIHZBmlwyqHsknhL89q7EOrmmddMVYAn920Hh5zNkNql966X Oq1laVTBXeySfFyrlUoY4FYIRuo6kWqqmfK7u+HT0wQDvCerF7FfP6a4CIxoHmR6aCNg nAvw== X-Gm-Message-State: AOJu0YxX6pkyMMgcTrhVgMy37VU4ZAeWaaTaqfX8Rl1mlc4RWGImo3CU 2Gx5ehcOYXGvuWAFhfiREMmd0gSNkVEVavB13qxZIA== X-Google-Smtp-Source: AGHT+IE9gHlaTUSgC0UexfAyQnInd5fdL+xkqHN91pGwG4d08Yru1vGisOvUvb+RabIyAjJ0OWCvaw== X-Received: by 2002:a05:6e02:1648:b0:35d:4db2:4ed3 with SMTP id v8-20020a056e02164800b0035d4db24ed3mr4282306ilu.3.1702186478756; Sat, 09 Dec 2023 21:34:38 -0800 (PST) From: Akihiko Odaki Date: Sun, 10 Dec 2023 14:34:36 +0900 Subject: [PATCH v2] qdev: Report an error for machine without HotplugHandler MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231210-bus-v2-1-34ebf5726fa0@daynix.com> X-B4-Tracking: v=1; b=H4sIAOtNdWUC/1WMwQ7CIBBEf6XZs5hCwVpP/ofpAWFr9yAYUNKm4 d9de/MyyZvMvA0yJsIMl2aDhIUyxcCgDg242YYHCvLMoFrVSQ5x/2TRG6uNdsYPZgBevhJOtOy W28g8U37HtO7SIn/t/79IIcXUG91iZ8/+pK7eroGWo4tPGGutX9VYPeeXAAAA To: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost Cc: qemu-devel@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.4 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: none client-ip=2607:f8b0:4864:20::132; envelope-from=akihiko.odaki@daynix.com; helo=mail-il1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1702186489741100001 The HotplugHandler of the machine will be used when the parent bus does not exist, but the machine may not have one. Report an error in such a case instead of aborting. Fixes: 7716b8ca74 ("qdev: HotplugHandler: Add support for unplugging BUS-le= ss devices") Signed-off-by: Akihiko Odaki --- Changes in v2: - Fixed indention. - Link to v1: https://lore.kernel.org/r/20231202-bus-v1-1-f7540e3a8d62@dayn= ix.com --- system/qdev-monitor.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index a13db763e5..5fe5d49c20 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -927,9 +927,16 @@ void qdev_unplug(DeviceState *dev, Error **errp) qdev_hot_removed =3D true; =20 hotplug_ctrl =3D qdev_get_hotplug_handler(dev); - /* hotpluggable device MUST have HotplugHandler, if it doesn't - * then something is very wrong with it */ - g_assert(hotplug_ctrl); + if (!hotplug_ctrl) { + /* + * hotpluggable bus MUST have HotplugHandler, if it doesn't + * then something is very wrong with it + */ + assert(!dev->parent_bus); + + error_setg(errp, "The machine does not support hotplugging for a d= evice without parent bus"); + return; + } =20 /* If device supports async unplug just request it to be done, * otherwise just remove it synchronously */ --- base-commit: 4705fc0c8511d073bee4751c3c974aab2b10a970 change-id: 20231202-bus-75a454c5d959 Best regards, --=20 Akihiko Odaki