QOM & QDev patches
- Remove DeviceState::opts (Akihiko) - Replace container_get by machine/object_get_container (Peter) - Remove InterfaceInfo::concrete_class field (Paolo) - Reduce machine_containers[] scope (Philippe) -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmeABNgACgkQ4+MsLN6t wN4XtQ/+NyXEK9vjq+yXnk7LRxTDQBrXxNc71gLqNA8rGwXTuELIXOthNW+UM2a9 CdnVbrIX/FRfQLXTHx0C2ENteafrR1oXDQmEOz1UeYgaCWJsNdVe3r1MYUdHcwVM 90JcSbYhrvxFE/p/6WhTjjv2DXn4E8witsPwRc8EBi5bHeFz6cNPzhdF59A3ljZF 0zr1MLHJHhwR6OoBbm9HM8x8i4Zw4LoKEjo8cCgcBfPQIMKf0HQ4XsinIDwn0VXN S3jIysNyGHlptHOiJuErILZtzrm4F2lGwYan89jxuElfWjC7SVB2z4CQkQtPceIJ HRBrE7VPwJ566OAThoSwPG3jXT1yCDOYmNCX1kJOMo9rYh3MwG0VrbMr5iwfYk8Z wO+8IyMAx7m8FibdsoMmxtI1PYTf0JQaCB6MSwdoAMMQVp1FDWBun2g+swLjQgO4 15iSB+PMIZe7Ywd0b63VZrUMHKwMxd9RFYEbbsdA8DRI50W3HMQPZAJiGXt7RxJ9 p9qxqg0WGpVjgTnInt/KH4axiWPD5cru+THVYk6dvOdtTM5wj2jEswWy2vQ6LkEF MgxaUXfja8E20AXvdr6uXKwcKOIJ9+TaU5AhUmjpvacjJhy5eQdoFt9OnIMQt25U KTtapCVsong5JzYZWhITNCMf5w2YGCJGJJekxdrqBvFk+FkMR38= =+TLu -----END PGP SIGNATURE----- Merge tag 'qom-qdev-20250109' of https://github.com/philmd/qemu into staging QOM & QDev patches - Remove DeviceState::opts (Akihiko) - Replace container_get by machine/object_get_container (Peter) - Remove InterfaceInfo::concrete_class field (Paolo) - Reduce machine_containers[] scope (Philippe) # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCAAdFiEE+qvnXhKRciHc/Wuy4+MsLN6twN4FAmeABNgACgkQ4+MsLN6t # wN4XtQ/+NyXEK9vjq+yXnk7LRxTDQBrXxNc71gLqNA8rGwXTuELIXOthNW+UM2a9 # CdnVbrIX/FRfQLXTHx0C2ENteafrR1oXDQmEOz1UeYgaCWJsNdVe3r1MYUdHcwVM # 90JcSbYhrvxFE/p/6WhTjjv2DXn4E8witsPwRc8EBi5bHeFz6cNPzhdF59A3ljZF # 0zr1MLHJHhwR6OoBbm9HM8x8i4Zw4LoKEjo8cCgcBfPQIMKf0HQ4XsinIDwn0VXN # S3jIysNyGHlptHOiJuErILZtzrm4F2lGwYan89jxuElfWjC7SVB2z4CQkQtPceIJ # HRBrE7VPwJ566OAThoSwPG3jXT1yCDOYmNCX1kJOMo9rYh3MwG0VrbMr5iwfYk8Z # wO+8IyMAx7m8FibdsoMmxtI1PYTf0JQaCB6MSwdoAMMQVp1FDWBun2g+swLjQgO4 # 15iSB+PMIZe7Ywd0b63VZrUMHKwMxd9RFYEbbsdA8DRI50W3HMQPZAJiGXt7RxJ9 # p9qxqg0WGpVjgTnInt/KH4axiWPD5cru+THVYk6dvOdtTM5wj2jEswWy2vQ6LkEF # MgxaUXfja8E20AXvdr6uXKwcKOIJ9+TaU5AhUmjpvacjJhy5eQdoFt9OnIMQt25U # KTtapCVsong5JzYZWhITNCMf5w2YGCJGJJekxdrqBvFk+FkMR38= # =+TLu # -----END PGP SIGNATURE----- # gpg: Signature made Thu 09 Jan 2025 12:18:16 EST # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full] # Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE * tag 'qom-qdev-20250109' of https://github.com/philmd/qemu: system: Inline machine_containers[] in qemu_create_machine_containers() qom: remove unused InterfaceInfo::concrete_class field qom: Remove container_get() qom: Use object_get_container() qom: Add object_get_container() qdev: Use machine_get_container() qdev: Add machine_get_container() qdev: Make qdev_get_machine() not use container_get() qdev: Implement qdev_create_fake_machine() for user emulation qdev: Remove opts member hw/pci: Use -1 as the default value for rombar Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
commit
290f950361
@ -35,7 +35,9 @@
|
|||||||
#include "qemu/atomic.h"
|
#include "qemu/atomic.h"
|
||||||
#include "qapi/qapi-builtin-visit.h"
|
#include "qapi/qapi-builtin-visit.h"
|
||||||
#include "qemu/units.h"
|
#include "qemu/units.h"
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if defined(CONFIG_USER_ONLY)
|
||||||
|
#include "hw/qdev-core.h"
|
||||||
|
#else
|
||||||
#include "hw/boards.h"
|
#include "hw/boards.h"
|
||||||
#endif
|
#endif
|
||||||
#include "internal-common.h"
|
#include "internal-common.h"
|
||||||
@ -124,6 +126,10 @@ static int tcg_init_machine(MachineState *ms)
|
|||||||
tcg_prologue_init();
|
tcg_prologue_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_USER_ONLY
|
||||||
|
qdev_create_fake_machine();
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ static int qmp_query_cryptodev_foreach(Object *obj, void *data)
|
|||||||
QCryptodevInfoList *qmp_query_cryptodev(Error **errp)
|
QCryptodevInfoList *qmp_query_cryptodev(Error **errp)
|
||||||
{
|
{
|
||||||
QCryptodevInfoList *list = NULL;
|
QCryptodevInfoList *list = NULL;
|
||||||
Object *objs = container_get(object_get_root(), "/objects");
|
Object *objs = object_get_container("objects");
|
||||||
|
|
||||||
object_child_foreach(objs, qmp_query_cryptodev_foreach, &list);
|
object_child_foreach(objs, qmp_query_cryptodev_foreach, &list);
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ static void cryptodev_backend_stats_cb(StatsResultList **result,
|
|||||||
switch (target) {
|
switch (target) {
|
||||||
case STATS_TARGET_CRYPTODEV:
|
case STATS_TARGET_CRYPTODEV:
|
||||||
{
|
{
|
||||||
Object *objs = container_get(object_get_root(), "/objects");
|
Object *objs = object_get_container("objects");
|
||||||
StatsArgs stats_args;
|
StatsArgs stats_args;
|
||||||
stats_args.result.stats = result;
|
stats_args.result.stats = result;
|
||||||
stats_args.names = names;
|
stats_args.names = names;
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
Object *get_chardevs_root(void)
|
Object *get_chardevs_root(void)
|
||||||
{
|
{
|
||||||
return container_get(object_get_root(), "/chardevs");
|
return object_get_container("chardevs");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chr_be_event(Chardev *s, QEMUChrEvent event)
|
static void chr_be_event(Chardev *s, QEMUChrEvent event)
|
||||||
|
@ -121,8 +121,7 @@ void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
|
|||||||
name ? name : "unnamed-gpio-out", n);
|
name ? name : "unnamed-gpio-out", n);
|
||||||
if (input_pin && !OBJECT(input_pin)->parent) {
|
if (input_pin && !OBJECT(input_pin)->parent) {
|
||||||
/* We need a name for object_property_set_link to work */
|
/* We need a name for object_property_set_link to work */
|
||||||
object_property_add_child(container_get(qdev_get_machine(),
|
object_property_add_child(machine_get_container("unattached"),
|
||||||
"/unattached"),
|
|
||||||
"non-qdev-gpio[*]", OBJECT(input_pin));
|
"non-qdev-gpio[*]", OBJECT(input_pin));
|
||||||
}
|
}
|
||||||
object_property_set_link(OBJECT(dev), propname,
|
object_property_set_link(OBJECT(dev), propname,
|
||||||
|
@ -46,3 +46,4 @@ system_ss.add(files(
|
|||||||
'vm-change-state-handler.c',
|
'vm-change-state-handler.c',
|
||||||
'clock-vmstate.c',
|
'clock-vmstate.c',
|
||||||
))
|
))
|
||||||
|
user_ss.add(files('qdev-user.c'))
|
||||||
|
19
hw/core/qdev-user.c
Normal file
19
hw/core/qdev-user.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* QDev helpers specific to user emulation.
|
||||||
|
*
|
||||||
|
* Copyright 2025 Linaro, Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qom/object.h"
|
||||||
|
#include "hw/qdev-core.h"
|
||||||
|
|
||||||
|
void qdev_create_fake_machine(void)
|
||||||
|
{
|
||||||
|
Object *fake_machine_obj;
|
||||||
|
|
||||||
|
fake_machine_obj = object_property_add_new_container(object_get_root(),
|
||||||
|
"machine");
|
||||||
|
object_property_add_new_container(fake_machine_obj, "unattached");
|
||||||
|
}
|
@ -476,8 +476,7 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
|
|||||||
if (!obj->parent) {
|
if (!obj->parent) {
|
||||||
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
|
gchar *name = g_strdup_printf("device[%d]", unattached_count++);
|
||||||
|
|
||||||
object_property_add_child(container_get(qdev_get_machine(),
|
object_property_add_child(machine_get_container("unattached"),
|
||||||
"/unattached"),
|
|
||||||
name, obj);
|
name, obj);
|
||||||
unattached_parent = true;
|
unattached_parent = true;
|
||||||
g_free(name);
|
g_free(name);
|
||||||
@ -691,7 +690,6 @@ static void device_finalize(Object *obj)
|
|||||||
dev->canonical_path = NULL;
|
dev->canonical_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
qobject_unref(dev->opts);
|
|
||||||
g_free(dev->id);
|
g_free(dev->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,12 +816,28 @@ Object *qdev_get_machine(void)
|
|||||||
static Object *dev;
|
static Object *dev;
|
||||||
|
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
dev = container_get(object_get_root(), "/machine");
|
dev = object_resolve_path_component(object_get_root(), "machine");
|
||||||
|
/*
|
||||||
|
* Any call to this function before machine is created is treated
|
||||||
|
* as a programming error as of now.
|
||||||
|
*/
|
||||||
|
assert(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object *machine_get_container(const char *name)
|
||||||
|
{
|
||||||
|
Object *container, *machine;
|
||||||
|
|
||||||
|
machine = qdev_get_machine();
|
||||||
|
container = object_resolve_path_component(machine, name);
|
||||||
|
assert(object_dynamic_cast(container, TYPE_CONTAINER));
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
char *qdev_get_human_name(DeviceState *dev)
|
char *qdev_get_human_name(DeviceState *dev)
|
||||||
{
|
{
|
||||||
g_assert(dev != NULL);
|
g_assert(dev != NULL);
|
||||||
|
@ -65,9 +65,9 @@ void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Loop through all sysbus devices that were spawned outside the machine */
|
/* Loop through all sysbus devices that were spawned outside the machine */
|
||||||
container = container_get(qdev_get_machine(), "/peripheral");
|
container = machine_get_container("peripheral");
|
||||||
find_sysbus_device(container, &find);
|
find_sysbus_device(container, &find);
|
||||||
container = container_get(qdev_get_machine(), "/peripheral-anon");
|
container = machine_get_container("peripheral-anon");
|
||||||
find_sysbus_device(container, &find);
|
find_sysbus_device(container, &find);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ static int check_fdc(Object *obj, void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char * const fdc_container_path[] = {
|
static const char * const fdc_container_path[] = {
|
||||||
"/unattached", "/peripheral", "/peripheral-anon"
|
"unattached", "peripheral", "peripheral-anon"
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -477,7 +477,7 @@ static ISADevice *pc_find_fdc0(void)
|
|||||||
CheckFdcState state = { 0 };
|
CheckFdcState state = { 0 };
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
|
for (i = 0; i < ARRAY_SIZE(fdc_container_path); i++) {
|
||||||
container = container_get(qdev_get_machine(), fdc_container_path[i]);
|
container = machine_get_container(fdc_container_path[i]);
|
||||||
object_child_foreach(container, check_fdc, &state);
|
object_child_foreach(container, check_fdc, &state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ static const Property pci_props[] = {
|
|||||||
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
|
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
|
||||||
DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
|
DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
|
||||||
DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX),
|
DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX),
|
||||||
DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1),
|
DEFINE_PROP_INT32("rombar", PCIDevice, rom_bar, -1),
|
||||||
DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
|
DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
|
||||||
QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
|
QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
|
||||||
DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present,
|
DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present,
|
||||||
|
@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
|
|||||||
{
|
{
|
||||||
uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);
|
uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);
|
||||||
off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;
|
off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;
|
||||||
DeviceState *dev = DEVICE(vdev);
|
|
||||||
char *name;
|
char *name;
|
||||||
int fd = vdev->vbasedev.fd;
|
int fd = vdev->vbasedev.fd;
|
||||||
|
|
||||||
@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vfio_opt_rom_in_denylist(vdev)) {
|
if (vfio_opt_rom_in_denylist(vdev)) {
|
||||||
if (dev->opts && qdict_haskey(dev->opts, "rombar")) {
|
if (vdev->pdev.rom_bar > 0) {
|
||||||
warn_report("Device at %s is known to cause system instability"
|
warn_report("Device at %s is known to cause system instability"
|
||||||
" issues during option rom execution",
|
" issues during option rom execution",
|
||||||
vdev->vbasedev.name);
|
vdev->vbasedev.name);
|
||||||
error_printf("Proceeding anyway since user specified"
|
error_printf("Proceeding anyway since user specified"
|
||||||
" non zero value for rombar\n");
|
" positive value for rombar\n");
|
||||||
} else {
|
} else {
|
||||||
warn_report("Rom loading for device at %s has been disabled"
|
warn_report("Rom loading for device at %s has been disabled"
|
||||||
" due to system instability issues",
|
" due to system instability issues",
|
||||||
|
@ -148,7 +148,7 @@ struct PCIDevice {
|
|||||||
uint32_t romsize;
|
uint32_t romsize;
|
||||||
bool has_rom;
|
bool has_rom;
|
||||||
MemoryRegion rom;
|
MemoryRegion rom;
|
||||||
uint32_t rom_bar;
|
int32_t rom_bar;
|
||||||
|
|
||||||
/* INTx routing notifier */
|
/* INTx routing notifier */
|
||||||
PCIINTxRoutingNotifier intx_routing_notifier;
|
PCIINTxRoutingNotifier intx_routing_notifier;
|
||||||
|
@ -248,10 +248,6 @@ struct DeviceState {
|
|||||||
* @pending_deleted_expires_ms: optional timeout for deletion events
|
* @pending_deleted_expires_ms: optional timeout for deletion events
|
||||||
*/
|
*/
|
||||||
int64_t pending_deleted_expires_ms;
|
int64_t pending_deleted_expires_ms;
|
||||||
/**
|
|
||||||
* @opts: QDict of options for the device
|
|
||||||
*/
|
|
||||||
QDict *opts;
|
|
||||||
/**
|
/**
|
||||||
* @hotplugged: was device added after PHASE_MACHINE_READY?
|
* @hotplugged: was device added after PHASE_MACHINE_READY?
|
||||||
*/
|
*/
|
||||||
@ -1027,6 +1023,26 @@ const char *qdev_fw_name(DeviceState *dev);
|
|||||||
void qdev_assert_realized_properly(void);
|
void qdev_assert_realized_properly(void);
|
||||||
Object *qdev_get_machine(void);
|
Object *qdev_get_machine(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qdev_create_fake_machine(): Create a fake machine container.
|
||||||
|
*
|
||||||
|
* .. note::
|
||||||
|
* This function is a kludge for user emulation (USER_ONLY)
|
||||||
|
* because when thread (TYPE_CPU) are realized, qdev_realize()
|
||||||
|
* access a machine container.
|
||||||
|
*/
|
||||||
|
void qdev_create_fake_machine(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* machine_get_container:
|
||||||
|
* @name: The name of container to lookup
|
||||||
|
*
|
||||||
|
* Get a container of the machine (QOM path "/machine/NAME").
|
||||||
|
*
|
||||||
|
* Returns: the machine container object.
|
||||||
|
*/
|
||||||
|
Object *machine_get_container(const char *name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qdev_get_human_name() - Return a human-readable name for a device
|
* qdev_get_human_name() - Return a human-readable name for a device
|
||||||
* @dev: The device. Must be a valid and non-NULL pointer.
|
* @dev: The device. Must be a valid and non-NULL pointer.
|
||||||
|
@ -573,12 +573,15 @@ struct InterfaceInfo {
|
|||||||
*
|
*
|
||||||
* The class for all interfaces. Subclasses of this class should only add
|
* The class for all interfaces. Subclasses of this class should only add
|
||||||
* virtual methods.
|
* virtual methods.
|
||||||
|
*
|
||||||
|
* Note that most of the fields of ObjectClass are unused (all except
|
||||||
|
* "type", in fact). They are only present in InterfaceClass to allow
|
||||||
|
* @object_class_dynamic_cast to work with both regular classes and interfaces.
|
||||||
*/
|
*/
|
||||||
struct InterfaceClass
|
struct InterfaceClass
|
||||||
{
|
{
|
||||||
ObjectClass parent_class;
|
ObjectClass parent_class;
|
||||||
/* private: */
|
/* private: */
|
||||||
ObjectClass *concrete_class;
|
|
||||||
Type interface_type;
|
Type interface_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1510,6 +1513,16 @@ const char *object_property_get_type(Object *obj, const char *name,
|
|||||||
*/
|
*/
|
||||||
Object *object_get_root(void);
|
Object *object_get_root(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* object_get_container:
|
||||||
|
* @name: the name of container to lookup
|
||||||
|
*
|
||||||
|
* Lookup a root level container.
|
||||||
|
*
|
||||||
|
* Returns: the container with @name.
|
||||||
|
*/
|
||||||
|
Object *object_get_container(const char *name);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* object_get_objects_root:
|
* object_get_objects_root:
|
||||||
@ -2007,17 +2020,6 @@ int object_child_foreach(Object *obj, int (*fn)(Object *child, void *opaque),
|
|||||||
int object_child_foreach_recursive(Object *obj,
|
int object_child_foreach_recursive(Object *obj,
|
||||||
int (*fn)(Object *child, void *opaque),
|
int (*fn)(Object *child, void *opaque),
|
||||||
void *opaque);
|
void *opaque);
|
||||||
/**
|
|
||||||
* container_get:
|
|
||||||
* @root: root of the #path, e.g., object_get_root()
|
|
||||||
* @path: path to the container
|
|
||||||
*
|
|
||||||
* Return a container object whose path is @path. Create more containers
|
|
||||||
* along the path if necessary.
|
|
||||||
*
|
|
||||||
* Returns: the container object.
|
|
||||||
*/
|
|
||||||
Object *container_get(Object *root, const char *path);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* object_property_add_new_container:
|
* object_property_add_new_container:
|
||||||
|
@ -34,27 +34,4 @@ Object *object_property_add_new_container(Object *obj, const char *name)
|
|||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *container_get(Object *root, const char *path)
|
|
||||||
{
|
|
||||||
Object *obj, *child;
|
|
||||||
char **parts;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
parts = g_strsplit(path, "/", 0);
|
|
||||||
assert(parts != NULL && parts[0] != NULL && !parts[0][0]);
|
|
||||||
obj = root;
|
|
||||||
|
|
||||||
for (i = 1; parts[i] != NULL; i++, obj = child) {
|
|
||||||
child = object_resolve_path_component(obj, parts[i]);
|
|
||||||
if (!child) {
|
|
||||||
child = object_property_add_new_container(obj, parts[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_strfreev(parts);
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
type_init(container_register_types)
|
type_init(container_register_types)
|
||||||
|
13
qom/object.c
13
qom/object.c
@ -314,7 +314,6 @@ static void type_initialize_interface(TypeImpl *ti, TypeImpl *interface_type,
|
|||||||
g_free((char *)info.name);
|
g_free((char *)info.name);
|
||||||
|
|
||||||
new_iface = (InterfaceClass *)iface_impl->class;
|
new_iface = (InterfaceClass *)iface_impl->class;
|
||||||
new_iface->concrete_class = ti->class;
|
|
||||||
new_iface->interface_type = interface_type;
|
new_iface->interface_type = interface_type;
|
||||||
|
|
||||||
ti->class->interfaces = g_slist_append(ti->class->interfaces, new_iface);
|
ti->class->interfaces = g_slist_append(ti->class->interfaces, new_iface);
|
||||||
@ -1751,6 +1750,16 @@ static Object *object_root_initialize(void)
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object *object_get_container(const char *name)
|
||||||
|
{
|
||||||
|
Object *container;
|
||||||
|
|
||||||
|
container = object_resolve_path_component(object_get_root(), name);
|
||||||
|
assert(object_dynamic_cast(container, TYPE_CONTAINER));
|
||||||
|
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
Object *object_get_root(void)
|
Object *object_get_root(void)
|
||||||
{
|
{
|
||||||
static Object *root;
|
static Object *root;
|
||||||
@ -1764,7 +1773,7 @@ Object *object_get_root(void)
|
|||||||
|
|
||||||
Object *object_get_objects_root(void)
|
Object *object_get_objects_root(void)
|
||||||
{
|
{
|
||||||
return container_get(object_get_root(), "/objects");
|
return object_get_container("objects");
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *object_get_internal_root(void)
|
Object *object_get_internal_root(void)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "qemu/module.h"
|
#include "qemu/module.h"
|
||||||
#include "qapi/qapi-commands-block.h"
|
#include "qapi/qapi-commands-block.h"
|
||||||
|
|
||||||
#define PR_MANAGER_PATH "/objects"
|
#define PR_MANAGER_PATH "objects"
|
||||||
|
|
||||||
typedef struct PRManagerData {
|
typedef struct PRManagerData {
|
||||||
PRManager *pr_mgr;
|
PRManager *pr_mgr;
|
||||||
@ -135,7 +135,7 @@ PRManagerInfoList *qmp_query_pr_managers(Error **errp)
|
|||||||
{
|
{
|
||||||
PRManagerInfoList *head = NULL;
|
PRManagerInfoList *head = NULL;
|
||||||
PRManagerInfoList **prev = &head;
|
PRManagerInfoList **prev = &head;
|
||||||
Object *container = container_get(object_get_root(), PR_MANAGER_PATH);
|
Object *container = object_get_container(PR_MANAGER_PATH);
|
||||||
|
|
||||||
object_child_foreach(container, query_one_pr_manager, &prev);
|
object_child_foreach(container, query_one_pr_manager, &prev);
|
||||||
return head;
|
return head;
|
||||||
|
@ -258,7 +258,7 @@ static void portio_list_add_1(PortioList *piolist,
|
|||||||
object_ref(&mrpio->mr);
|
object_ref(&mrpio->mr);
|
||||||
object_unparent(OBJECT(&mrpio->mr));
|
object_unparent(OBJECT(&mrpio->mr));
|
||||||
if (!piolist->owner) {
|
if (!piolist->owner) {
|
||||||
owner = container_get(qdev_get_machine(), "/unattached");
|
owner = machine_get_container("unattached");
|
||||||
} else {
|
} else {
|
||||||
owner = piolist->owner;
|
owner = piolist->owner;
|
||||||
}
|
}
|
||||||
|
@ -1238,7 +1238,7 @@ static void memory_region_do_init(MemoryRegion *mr,
|
|||||||
char *name_array = g_strdup_printf("%s[*]", escaped_name);
|
char *name_array = g_strdup_printf("%s[*]", escaped_name);
|
||||||
|
|
||||||
if (!owner) {
|
if (!owner) {
|
||||||
owner = container_get(qdev_get_machine(), "/unattached");
|
owner = machine_get_container("unattached");
|
||||||
}
|
}
|
||||||
|
|
||||||
object_property_add_child(owner, name_array, OBJECT(mr));
|
object_property_add_child(owner, name_array, OBJECT(mr));
|
||||||
|
@ -348,7 +348,7 @@ static Object *qdev_get_peripheral(void)
|
|||||||
static Object *dev;
|
static Object *dev;
|
||||||
|
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
dev = container_get(qdev_get_machine(), "/peripheral");
|
dev = machine_get_container("peripheral");
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
@ -359,7 +359,7 @@ static Object *qdev_get_peripheral_anon(void)
|
|||||||
static Object *dev;
|
static Object *dev;
|
||||||
|
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
dev = container_get(qdev_get_machine(), "/peripheral-anon");
|
dev = machine_get_container("peripheral-anon");
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
@ -631,6 +631,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
|
|||||||
char *id;
|
char *id;
|
||||||
DeviceState *dev = NULL;
|
DeviceState *dev = NULL;
|
||||||
BusState *bus = NULL;
|
BusState *bus = NULL;
|
||||||
|
QDict *properties;
|
||||||
|
|
||||||
driver = qdict_get_try_str(opts, "driver");
|
driver = qdict_get_try_str(opts, "driver");
|
||||||
if (!driver) {
|
if (!driver) {
|
||||||
@ -712,13 +713,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set properties */
|
/* set properties */
|
||||||
dev->opts = qdict_clone_shallow(opts);
|
properties = qdict_clone_shallow(opts);
|
||||||
qdict_del(dev->opts, "driver");
|
qdict_del(properties, "driver");
|
||||||
qdict_del(dev->opts, "bus");
|
qdict_del(properties, "bus");
|
||||||
qdict_del(dev->opts, "id");
|
qdict_del(properties, "id");
|
||||||
|
|
||||||
object_set_properties_from_keyval(&dev->parent_obj, dev->opts, from_json,
|
object_set_properties_from_keyval(&dev->parent_obj, properties, from_json,
|
||||||
errp);
|
errp);
|
||||||
|
qobject_unref(properties);
|
||||||
if (*errp) {
|
if (*errp) {
|
||||||
goto err_del_dev;
|
goto err_del_dev;
|
||||||
}
|
}
|
||||||
@ -1098,7 +1100,7 @@ static GSList *qdev_build_hotpluggable_device_list(Object *peripheral)
|
|||||||
static void peripheral_device_del_completion(ReadLineState *rs,
|
static void peripheral_device_del_completion(ReadLineState *rs,
|
||||||
const char *str)
|
const char *str)
|
||||||
{
|
{
|
||||||
Object *peripheral = container_get(qdev_get_machine(), "/peripheral");
|
Object *peripheral = machine_get_container("peripheral");
|
||||||
GSList *list, *item;
|
GSList *list, *item;
|
||||||
|
|
||||||
list = qdev_build_hotpluggable_device_list(peripheral);
|
list = qdev_build_hotpluggable_device_list(peripheral);
|
||||||
|
19
system/vl.c
19
system/vl.c
@ -2113,18 +2113,16 @@ static void parse_memory_options(void)
|
|||||||
loc_pop(&loc);
|
loc_pop(&loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const machine_containers[] = {
|
|
||||||
"unattached",
|
|
||||||
"peripheral",
|
|
||||||
"peripheral-anon"
|
|
||||||
};
|
|
||||||
|
|
||||||
static void qemu_create_machine_containers(Object *machine)
|
static void qemu_create_machine_containers(Object *machine)
|
||||||
{
|
{
|
||||||
int i;
|
static const char *const containers[] = {
|
||||||
|
"unattached",
|
||||||
|
"peripheral",
|
||||||
|
"peripheral-anon",
|
||||||
|
};
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(machine_containers); i++) {
|
for (unsigned i = 0; i < ARRAY_SIZE(containers); i++) {
|
||||||
object_property_add_new_container(machine, machine_containers[i]);
|
object_property_add_new_container(machine, containers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2137,8 +2135,7 @@ static void qemu_create_machine(QDict *qdict)
|
|||||||
object_property_add_child(object_get_root(), "machine",
|
object_property_add_child(object_get_root(), "machine",
|
||||||
OBJECT(current_machine));
|
OBJECT(current_machine));
|
||||||
qemu_create_machine_containers(OBJECT(current_machine));
|
qemu_create_machine_containers(OBJECT(current_machine));
|
||||||
object_property_add_child(container_get(OBJECT(current_machine),
|
object_property_add_child(machine_get_container("unattached"),
|
||||||
"/unattached"),
|
|
||||||
"sysbus", OBJECT(sysbus_get_default()));
|
"sysbus", OBJECT(sysbus_get_default()));
|
||||||
|
|
||||||
if (machine_class->minimum_page_bits) {
|
if (machine_class->minimum_page_bits) {
|
||||||
|
@ -1160,7 +1160,7 @@ DisplayState *init_displaystate(void)
|
|||||||
* all QemuConsoles are created and the order / numbering
|
* all QemuConsoles are created and the order / numbering
|
||||||
* doesn't change any more */
|
* doesn't change any more */
|
||||||
name = g_strdup_printf("console[%d]", con->index);
|
name = g_strdup_printf("console[%d]", con->index);
|
||||||
object_property_add_child(container_get(object_get_root(), "/backend"),
|
object_property_add_child(object_get_container("backend"),
|
||||||
name, OBJECT(con));
|
name, OBJECT(con));
|
||||||
g_free(name);
|
g_free(name);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ dbus_chardev_init(DBusDisplay *dpy)
|
|||||||
dpy->notifier.notify = dbus_display_on_notify;
|
dpy->notifier.notify = dbus_display_on_notify;
|
||||||
dbus_display_notifier_add(&dpy->notifier);
|
dbus_display_notifier_add(&dpy->notifier);
|
||||||
|
|
||||||
object_child_foreach(container_get(object_get_root(), "/chardevs"),
|
object_child_foreach(object_get_container("chardevs"),
|
||||||
dbus_display_chardev_foreach, dpy);
|
dbus_display_chardev_foreach, dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user