From nobody Tue Feb 10 02:48:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635792228; cv=none; d=zohomail.com; s=zohoarc; b=hPwHj9wwo/BIgG0cCUzq+/9JVFECRPBDLA8dYKKjWYqGyjEZ9Ye5ihUjdK1oAtZx3mCn/R3Qa3a7AFKfWpuNK8ZrF4LfYWzkfy40f1jeZ/gAxpzWkKP0pcgv3kGURQgmW3gst+sSQvJ2Aj4FXaDUtmmVj8mHW9wPwk3bM9Lg7+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635792228; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=wrRJbxTfXKoNE9RhSD+9rCBC0L1fCrHGd+SeOdkp/14=; b=MlOzVdVaGKbivEmYfLEJQekGHlkl3xMHwgNo9+/eQE9IZgkxxwYCd+TKnn5Z7gNm7Bq6Wk7bMg7JqFnsduxo6vyoF5TGRQsifm7UqEeBfgztOD3RNIXgty5L1ULfxgOdamQ79yO9gIsOwHpeS/1QCcgkG3TJXhBWifND4BTuT1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 163579222896314.932150986269335; Mon, 1 Nov 2021 11:43:48 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-Kma0uXH0Me2UvzfY7CrWSw-1; Mon, 01 Nov 2021 14:43:46 -0400 Received: by mail-wm1-f69.google.com with SMTP id m1-20020a1ca301000000b003231d5b3c4cso50553wme.5 for ; Mon, 01 Nov 2021 11:43:46 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (62.red-83-57-168.dynamicip.rima-tde.net. [83.57.168.62]) by smtp.gmail.com with ESMTPSA id u16sm275280wmc.21.2021.11.01.11.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 11:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635792228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wrRJbxTfXKoNE9RhSD+9rCBC0L1fCrHGd+SeOdkp/14=; b=Wl6vIytR1dLYwH7oMrX8MdoM05i1HhKrwF8uh7mIjgF1X7UJ/LJnoxFHzRkGpaOU1fEP0I Pkbm/zLJhDqvTUzqHd2tnpG+UIUIIcrWklQaCOlzWg1qGK50LTNRS6TEDQWCclPd21Ovxm i8hcScd/amiC3Jed4uajZb7JltKB7l0= X-MC-Unique: Kma0uXH0Me2UvzfY7CrWSw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wrRJbxTfXKoNE9RhSD+9rCBC0L1fCrHGd+SeOdkp/14=; b=4BAQWisw29K2TFO7aVQqKA5aBbL1gvpYPNJeytmMfiPTWVWHsg+85S4/LnvjujQ0fx OHKGKq34SpBPF0f0KYv4h3qRv3/8OJuea/pXDeVUK6FnXGXJKZGSAPe3OACu+ghZJg8J 95hA4z5FOf53mvHnHkYVvejwGkgCC/yVt/PX21aNUiD07BwtP2kSye+EAw0Yg+LTOaXf mTe0wyZhBbvWYxYVLiqGaMcXo8r9fEZdLKN9hNJ5Z2sr29zbKzHeBnfbg6K1VHpEojZF LX4dm1jjnYhQ4zNSp5Fpd7iXYsIPTLdlq3vN64cywjxRRbkpZYRb60b26/lEYeoy5ozP 7Wpg== X-Gm-Message-State: AOAM530NMsm1H0zuygvxCBS+r4kJj/N0ErbAvL2A9TEg2NuSquH3WtlU qISmE+Yg6ZhImYfdD67aWsJNInUCOtjjuIvYZUbuNVizl9FQXPees6k66KNZxv27Mn4oGbZ2ioA 67DQ533EvPtKpZA== X-Received: by 2002:a5d:6a4d:: with SMTP id t13mr11122612wrw.104.1635792225735; Mon, 01 Nov 2021 11:43:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2utyBz54X2ezIzxsjFjSLvMDAbTQkGqrOuc8GVm1HB/EpzH9jSQ7tuQC1VbotVp26ooV79w== X-Received: by 2002:a5d:6a4d:: with SMTP id t13mr11122591wrw.104.1635792225597; Mon, 01 Nov 2021 11:43:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Marcel Apfelbaum , Damien Hedde , Alistair Francis Subject: [PULL 09/10] qdev-monitor: Check sysbus device type before creating it Date: Mon, 1 Nov 2021 19:42:58 +0100 Message-Id: <20211101184259.2859090-10-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211101184259.2859090-1-philmd@redhat.com> References: <20211101184259.2859090-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635792230486100001 From: Damien Hedde Add an early check to test if the requested sysbus device type is allowed by the current machine before creating the device. This impacts both -device cli option and device_add qmp command. Before this patch, the check was done well after the device has been created (in a machine init done notifier). We can now report the error right away. Signed-off-by: Damien Hedde Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Eduardo Habkost Message-Id: <20211029142258.484907-3-damien.hedde@greensocs.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- softmmu/qdev-monitor.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index 4851de51a5c..e49d9773d2d 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -42,6 +42,7 @@ #include "qemu/cutils.h" #include "hw/qdev-properties.h" #include "hw/clock.h" +#include "hw/boards.h" =20 /* * Aliases were a bad idea from the start. Let's keep them @@ -254,6 +255,16 @@ static DeviceClass *qdev_get_device_class(const char *= *driver, Error **errp) return NULL; } =20 + if (object_class_dynamic_cast(oc, TYPE_SYS_BUS_DEVICE)) { + /* sysbus devices need to be allowed by the machine */ + MachineClass *mc =3D MACHINE_CLASS(object_get_class(qdev_get_machi= ne())); + if (!device_type_is_dynamic_sysbus(mc, *driver)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver", + "a dynamic sysbus device type for the machine"); + return NULL; + } + } + return dc; } =20 --=20 2.31.1