qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: [PATCH 4/5] qom: let object_new use a module if the type is not present
Date: Tue, 29 Oct 2024 13:26:08 +0100	[thread overview]
Message-ID: <20241029122609.514347-5-pbonzini@redhat.com> (raw)
In-Reply-To: <20241029122609.514347-1-pbonzini@redhat.com>

object_initialize() can use modules (it was added there because
virtio-gpu-device is a child device of virtio-gpu-pci; commit
64f7aece8ea, "object_initialize: try module load", 2020-09-15).
object_new() cannot; make things consistent.

qdev_new() is now just a simple wrapper that returns DeviceState.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/qdev.c | 16 ----------------
 qom/object.c   |  2 +-
 2 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index db36f54d914..17c454334c6 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -146,22 +146,6 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp)
 
 DeviceState *qdev_new(const char *name)
 {
-    ObjectClass *oc = object_class_by_name(name);
-#ifdef CONFIG_MODULES
-    if (!oc) {
-        int rv = module_load_qom(name, &error_fatal);
-        if (rv > 0) {
-            oc = object_class_by_name(name);
-        } else {
-            error_report("could not find a module for type '%s'", name);
-            exit(1);
-        }
-    }
-#endif
-    if (!oc) {
-        error_report("unknown type '%s'", name);
-        abort();
-    }
     return DEVICE(object_new(name));
 }
 
diff --git a/qom/object.c b/qom/object.c
index 29155c64639..9edc06d391f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -790,7 +790,7 @@ Object *object_new_with_class(ObjectClass *klass)
 
 Object *object_new(const char *typename)
 {
-    TypeImpl *ti = type_get_by_name_noload(typename);
+    TypeImpl *ti = type_get_or_load_by_name(typename, &error_fatal);
 
     return object_new_with_type(ti);
 }
-- 
2.47.0



  parent reply	other threads:[~2024-10-29 12:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29 12:26 [PATCH 0/5] qom: module loading cleanups Paolo Bonzini
2024-10-29 12:26 ` [PATCH 1/5] qom: remove unused function Paolo Bonzini
2024-10-29 12:35   ` Daniel P. Berrangé
2024-10-29 12:26 ` [PATCH 2/5] qom: use object_new_with_class when possible Paolo Bonzini
2024-10-29 19:51   ` Philippe Mathieu-Daudé
2024-10-29 12:26 ` [PATCH 3/5] qom: centralize module-loading functionality Paolo Bonzini
2024-10-29 12:26 ` Paolo Bonzini [this message]
2024-10-29 12:26 ` [PATCH 5/5] qom: allow user-creatable classes to be in modules Paolo Bonzini
2024-10-29 17:05 ` [PATCH 0/5] qom: module loading cleanups Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241029122609.514347-5-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).