[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/49] qom: use object_new_with_class when possible
From: |
Paolo Bonzini |
Subject: |
[PULL 12/49] qom: use object_new_with_class when possible |
Date: |
Thu, 31 Oct 2024 18:51:36 +0100 |
A small optimization/code simplification, that also makes it clear that
we won't look for a type in a not-loaded-yet module---the module will
have been loaded by a call to module_object_class_by_name(), if present.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/core/qdev.c | 5 +++--
qom/object_interfaces.c | 2 +-
qom/qom-qmp-cmds.c | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index db36f54d914..2f740fa55e9 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -167,10 +167,11 @@ DeviceState *qdev_new(const char *name)
DeviceState *qdev_try_new(const char *name)
{
- if (!module_object_class_by_name(name)) {
+ ObjectClass *oc = module_object_class_by_name(name);
+ if (!oc) {
return NULL;
}
- return DEVICE(object_new(name));
+ return DEVICE(object_new_with_class(oc));
}
static QTAILQ_HEAD(, DeviceListener) device_listeners
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index e0833c8bfe4..1f2aa133066 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -108,7 +108,7 @@ Object *user_creatable_add_type(const char *type, const
char *id,
}
assert(qdict);
- obj = object_new(type);
+ obj = object_new_with_class(klass);
object_set_properties_from_qdict(obj, qdict, v, &local_err);
if (local_err) {
goto out;
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index e91a2353472..69a8e17aa80 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -141,7 +141,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const
char *typename,
return NULL;
}
- obj = object_new(typename);
+ obj = object_new_with_class(klass);
object_property_iter_init(&iter, obj);
while ((prop = object_property_iter_next(&iter))) {
--
2.47.0
- [PULL 03/49] ci: enable rust in the Fedora system build job, (continued)
- [PULL 03/49] ci: enable rust in the Fedora system build job, Paolo Bonzini, 2024/10/31
- [PULL 02/49] tests: add 'rust' and 'bindgen' to CI package list, Paolo Bonzini, 2024/10/31
- [PULL 04/49] target/i386: fix CPUID check for LFENCE and SFENCE, Paolo Bonzini, 2024/10/31
- [PULL 06/49] configure: detect 64-bit MIPS, Paolo Bonzini, 2024/10/31
- [PULL 05/49] scripts: remove erroneous file that breaks git clone on Windows, Paolo Bonzini, 2024/10/31
- [PULL 07/49] configure, meson: deprecate 32-bit MIPS, Paolo Bonzini, 2024/10/31
- [PULL 08/49] MAINTAINERS: Add myself as a reviewer of x86 general architecture support, Paolo Bonzini, 2024/10/31
- [PULL 09/49] accel: remove dead statement and useless assertion, Paolo Bonzini, 2024/10/31
- [PULL 10/49] i386/cpu: Drop the check of phys_bits in host_cpu_realizefn(), Paolo Bonzini, 2024/10/31
- [PULL 11/49] qom: remove unused function, Paolo Bonzini, 2024/10/31
- [PULL 12/49] qom: use object_new_with_class when possible,
Paolo Bonzini <=
- [PULL 13/49] qom: centralize module-loading functionality, Paolo Bonzini, 2024/10/31
- [PULL 15/49] qom: allow user-creatable classes to be in modules, Paolo Bonzini, 2024/10/31
- [PULL 18/49] target/i386: Expose bits related to SRSO vulnerability, Paolo Bonzini, 2024/10/31
- [PULL 16/49] target/i386: Fix minor typo in NO_NESTED_DATA_BP feature bit, Paolo Bonzini, 2024/10/31
- [PULL 17/49] target/i386: Add PerfMonV2 feature bit, Paolo Bonzini, 2024/10/31
- [PULL 20/49] target/i386/hvf: fix handling of XSAVE-related CPUID bits, Paolo Bonzini, 2024/10/31
- [PULL 19/49] target/i386: Expose new feature bits in CPUID 8000_0021_EAX/EBX, Paolo Bonzini, 2024/10/31
- [PULL 21/49] tests/lcitool: Update libvirt-ci and add libcbor dependency, Paolo Bonzini, 2024/10/31
- [PULL 23/49] hw/core: Add Enclave Image Format (EIF) related helpers, Paolo Bonzini, 2024/10/31
- [PULL 22/49] device/virtio-nsm: Support for Nitro Secure Module device, Paolo Bonzini, 2024/10/31