* [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
@ 2011-09-16 16:00 Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 01/14] apic: rename apic.id -> apic.index Anthony Liguori
` (16 more replies)
0 siblings, 17 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Jan Kiszka, Markus Armbruster, Paolo Bonzini
This series introduces an infrastructure to remove anonymous devices from qdev.
Anonymous devices are one of the big gaps between qdev and QOM so removing is
a prerequisite to incrementally merging QOM.
Besides the infrastructure, I also converted almost all of the possible PC
devices to have unique names. Please not that naming is not a property of
devices but rather of the thing that creates the devices (usually machines).
The names are ugly but this is because of the alternating device/bus hierarchy
in qdev. For now, the names use '::' as deliminators but I think Jan has
convinced me that down the road, we should use '/' as a deliminator such that
the resulting names are actually valid paths (using a canonical path format).
^ permalink raw reply [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 01/14] apic: rename apic.id -> apic.index
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 02/14] qdev: enforce that no devices overload the id property Anthony Liguori
` (15 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
This clashes with the qdev name property. This shouldn't affect compatibility
since the apic is a no_user device.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/apic.c | 2 +-
hw/pc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/apic.c b/hw/apic.c
index d8f56c8..e92be49 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -1010,7 +1010,7 @@ static SysBusDeviceInfo apic_info = {
.qdev.reset = apic_reset,
.qdev.no_user = 1,
.qdev.props = (Property[]) {
- DEFINE_PROP_UINT8("id", APICState, id, -1),
+ DEFINE_PROP_UINT8("index", APICState, id, -1),
DEFINE_PROP_PTR("cpu_env", APICState, cpu_env),
DEFINE_PROP_END_OF_LIST(),
}
diff --git a/hw/pc.c b/hw/pc.c
index 5bc845a..f0f7db0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -876,7 +876,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
static int apic_mapped;
dev = qdev_create(NULL, "apic");
- qdev_prop_set_uint8(dev, "id", apic_id);
+ qdev_prop_set_uint8(dev, "index", apic_id);
qdev_prop_set_ptr(dev, "cpu_env", env);
qdev_init_nofail(dev);
d = sysbus_from_qdev(dev);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 02/14] qdev: enforce that no devices overload the id property
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 01/14] apic: rename apic.id -> apic.index Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 03/14] qdev: push id into qdev_create calls Anthony Liguori
` (14 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/qdev.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index a223d41..0e267a7 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -47,9 +47,17 @@ static BusState *qbus_find(const char *path);
/* Register a new device type. */
void qdev_register(DeviceInfo *info)
{
+ int i;
+
assert(info->size >= sizeof(DeviceState));
assert(!info->next);
+ if (info->props) {
+ for (i = 0; info->props[i].name; i++) {
+ g_assert_cmpstr(info->props[i].name, !=, "id");
+ }
+ }
+
info->next = device_info_list;
device_info_list = info;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 03/14] qdev: push id into qdev_create calls
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 01/14] apic: rename apic.id -> apic.index Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 02/14] qdev: enforce that no devices overload the id property Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer Anthony Liguori
` (13 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
This is preparation for enforcing an "all devices must have unique names" rule
which is one of the fundamental gaps between QOM and qdev. This is a mechanical
conversion other than a few manual changes in qdev.c to introduce the new
parameter.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/apb_pci.c | 2 +-
hw/arm11mpcore.c | 2 +-
hw/arm_sysctl.c | 2 +-
hw/armv7m.c | 6 +++---
hw/axis_dev88.c | 2 +-
hw/bonito.c | 2 +-
hw/empty_slot.c | 2 +-
hw/escc.c | 4 ++--
hw/esp.c | 2 +-
hw/etraxfs.h | 2 +-
hw/fdc.c | 4 ++--
hw/fw_cfg.c | 2 +-
hw/grackle_pci.c | 2 +-
hw/grlib.h | 6 +++---
hw/gt64xxx.c | 2 +-
hw/i2c.c | 2 +-
hw/ide/qdev.c | 2 +-
hw/integratorcp.c | 2 +-
hw/intel-hda.c | 2 +-
hw/isa-bus.c | 6 +++---
hw/lan9118.c | 2 +-
hw/lm32.h | 4 ++--
hw/m48t59.c | 2 +-
hw/milkymist-hw.h | 22 +++++++++++-----------
hw/mips_jazz.c | 4 ++--
hw/mips_mipssim.c | 2 +-
hw/musicpal.c | 4 ++--
hw/nand.c | 2 +-
hw/nseries.c | 4 ++--
hw/omap1.c | 2 +-
hw/omap2.c | 2 +-
hw/pc.c | 2 +-
hw/pc_piix.c | 2 +-
hw/pci.c | 4 ++--
hw/piix_pci.c | 2 +-
hw/pxa2xx.c | 2 +-
hw/pxa2xx_dma.c | 4 ++--
hw/pxa2xx_gpio.c | 2 +-
hw/pxa2xx_pic.c | 2 +-
hw/qdev.c | 19 ++++++++-----------
hw/qdev.h | 4 ++--
hw/realview.c | 4 ++--
hw/s390-virtio-bus.c | 2 +-
hw/s390-virtio.c | 4 ++--
hw/scsi-bus.c | 2 +-
hw/sm501.c | 2 +-
hw/smbus_eeprom.c | 2 +-
hw/smc91c111.c | 2 +-
hw/spapr_llan.c | 2 +-
hw/spapr_vio.c | 2 +-
hw/spapr_vscsi.c | 2 +-
hw/spapr_vty.c | 2 +-
hw/spitz.c | 2 +-
hw/ssi.c | 2 +-
hw/stellaris.c | 2 +-
hw/strongarm.c | 4 ++--
hw/sun4m.c | 30 +++++++++++++++---------------
hw/sun4u.c | 4 ++--
hw/syborg.c | 4 ++--
hw/sysbus.c | 4 ++--
hw/unin_pci.c | 8 ++++----
hw/usb-bus.c | 2 +-
hw/versatilepb.c | 2 +-
hw/vexpress.c | 4 ++--
hw/xilinx.h | 10 +++++-----
65 files changed, 125 insertions(+), 128 deletions(-)
diff --git a/hw/apb_pci.c b/hw/apb_pci.c
index c232946..8661e15 100644
--- a/hw/apb_pci.c
+++ b/hw/apb_pci.c
@@ -326,7 +326,7 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,
PCIBridge *br;
/* Ultrasparc PBM main bus */
- dev = qdev_create(NULL, "pbm");
+ dev = qdev_create(NULL, "pbm", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
/* apb_config */
diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
index 7d60ef6..0e456a2 100644
--- a/hw/arm11mpcore.c
+++ b/hw/arm11mpcore.c
@@ -67,7 +67,7 @@ static int realview_mpcore_init(SysBusDevice *dev)
int n;
int i;
- priv = qdev_create(NULL, "arm11mpcore_priv");
+ priv = qdev_create(NULL, "arm11mpcore_priv", NULL);
qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu);
qdev_init_nofail(priv);
s->priv = sysbus_from_qdev(priv);
diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c
index 17cf6f7..9a408ce 100644
--- a/hw/arm_sysctl.c
+++ b/hw/arm_sysctl.c
@@ -379,7 +379,7 @@ void arm_sysctl_init(uint32_t base, uint32_t sys_id, uint32_t proc_id)
{
DeviceState *dev;
- dev = qdev_create(NULL, "realview_sysctl");
+ dev = qdev_create(NULL, "realview_sysctl", NULL);
qdev_prop_set_uint32(dev, "sys_id", sys_id);
qdev_init_nofail(dev);
qdev_prop_set_uint32(dev, "proc_id", proc_id);
diff --git a/hw/armv7m.c b/hw/armv7m.c
index 28d41b8..518379b 100644
--- a/hw/armv7m.c
+++ b/hw/armv7m.c
@@ -134,12 +134,12 @@ static void armv7m_bitband_init(void)
{
DeviceState *dev;
- dev = qdev_create(NULL, "ARM,bitband-memory");
+ dev = qdev_create(NULL, "ARM,bitband-memory", NULL);
qdev_prop_set_uint32(dev, "base", 0x20000000);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0x22000000);
- dev = qdev_create(NULL, "ARM,bitband-memory");
+ dev = qdev_create(NULL, "ARM,bitband-memory", NULL);
qdev_prop_set_uint32(dev, "base", 0x40000000);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0x42000000);
@@ -205,7 +205,7 @@ qemu_irq *armv7m_init(MemoryRegion *address_space_mem,
memory_region_add_subregion(address_space_mem, 0x20000000, sram);
armv7m_bitband_init();
- nvic = qdev_create(NULL, "armv7m_nvic");
+ nvic = qdev_create(NULL, "armv7m_nvic", NULL);
env->nvic = nvic;
qdev_init_nofail(nvic);
cpu_pic = arm_pic_init_cpu(env);
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index 73eb39d..752c573 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -294,7 +294,7 @@ void axisdev88_init (ram_addr_t ram_size,
cpu_irq = cris_pic_init_cpu(env);
- dev = qdev_create(NULL, "etraxfs,pic");
+ dev = qdev_create(NULL, "etraxfs,pic", NULL);
/* FIXME: Is there a proper way to signal vectors to the CPU core? */
qdev_prop_set_ptr(dev, "interrupt_vector", &env->interrupt_vector);
qdev_init_nofail(dev);
diff --git a/hw/bonito.c b/hw/bonito.c
index fdb8198..d079833 100644
--- a/hw/bonito.c
+++ b/hw/bonito.c
@@ -771,7 +771,7 @@ PCIBus *bonito_init(qemu_irq *pic)
PCIBonitoState *s;
PCIDevice *d;
- dev = qdev_create(NULL, "Bonito-pcihost");
+ dev = qdev_create(NULL, "Bonito-pcihost", NULL);
pcihost = FROM_SYSBUS(BonitoState, sysbus_from_qdev(dev));
b = pci_register_bus(&pcihost->busdev.qdev, "pci", pci_bonito_set_irq,
pci_bonito_map_irq, pic, get_system_memory(),
diff --git a/hw/empty_slot.c b/hw/empty_slot.c
index da8adc4..7a14d65 100644
--- a/hw/empty_slot.c
+++ b/hw/empty_slot.c
@@ -59,7 +59,7 @@ void empty_slot_init(target_phys_addr_t addr, uint64_t slot_size)
SysBusDevice *s;
EmptySlot *e;
- dev = qdev_create(NULL, "empty_slot");
+ dev = qdev_create(NULL, "empty_slot", NULL);
s = sysbus_from_qdev(dev);
e = FROM_SYSBUS(EmptySlot, s);
e->size = slot_size;
diff --git a/hw/escc.c b/hw/escc.c
index 13c7e66..1e6bfb8 100644
--- a/hw/escc.c
+++ b/hw/escc.c
@@ -691,7 +691,7 @@ MemoryRegion *escc_init(target_phys_addr_t base, qemu_irq irqA, qemu_irq irqB,
SysBusDevice *s;
SerialState *d;
- dev = qdev_create(NULL, "escc");
+ dev = qdev_create(NULL, "escc", NULL);
qdev_prop_set_uint32(dev, "disabled", 0);
qdev_prop_set_uint32(dev, "frequency", clock);
qdev_prop_set_uint32(dev, "it_shift", it_shift);
@@ -852,7 +852,7 @@ void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "escc");
+ dev = qdev_create(NULL, "escc", NULL);
qdev_prop_set_uint32(dev, "disabled", disabled);
qdev_prop_set_uint32(dev, "frequency", clock);
qdev_prop_set_uint32(dev, "it_shift", it_shift);
diff --git a/hw/esp.c b/hw/esp.c
index ca41f80..5e48578 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -714,7 +714,7 @@ void esp_init(target_phys_addr_t espaddr, int it_shift,
SysBusDevice *s;
ESPState *esp;
- dev = qdev_create(NULL, "esp");
+ dev = qdev_create(NULL, "esp", NULL);
esp = DO_UPCAST(ESPState, busdev.qdev, dev);
esp->dma_memory_read = dma_memory_read;
esp->dma_memory_write = dma_memory_write;
diff --git a/hw/etraxfs.h b/hw/etraxfs.h
index 1554b0b..69e2617 100644
--- a/hw/etraxfs.h
+++ b/hw/etraxfs.h
@@ -34,7 +34,7 @@ etraxfs_eth_init(NICInfo *nd, target_phys_addr_t base, int phyaddr,
DeviceState *dev;
qemu_check_nic_model(nd, "fseth");
- dev = qdev_create(NULL, "etraxfs-eth");
+ dev = qdev_create(NULL, "etraxfs-eth", NULL);
qdev_set_nic_properties(dev, nd);
qdev_prop_set_uint32(dev, "phyaddr", phyaddr);
qdev_prop_set_ptr(dev, "dma_out", dma_out);
diff --git a/hw/fdc.c b/hw/fdc.c
index 433af73..4c7bd04 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1825,7 +1825,7 @@ void fdctrl_init_sysbus(qemu_irq irq, int dma_chann,
DeviceState *dev;
FDCtrlSysBus *sys;
- dev = qdev_create(NULL, "sysbus-fdc");
+ dev = qdev_create(NULL, "sysbus-fdc", NULL);
sys = DO_UPCAST(FDCtrlSysBus, busdev.qdev, dev);
fdctrl = &sys->state;
fdctrl->dma_chann = dma_chann; /* FIXME */
@@ -1846,7 +1846,7 @@ void sun4m_fdctrl_init(qemu_irq irq, target_phys_addr_t io_base,
DeviceState *dev;
FDCtrlSysBus *sys;
- dev = qdev_create(NULL, "SUNW,fdtwo");
+ dev = qdev_create(NULL, "SUNW,fdtwo", NULL);
if (fds[0]) {
qdev_prop_set_drive_nofail(dev, "drive", fds[0]->bdrv);
}
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index 8df265c..e2193d5 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -484,7 +484,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
SysBusDevice *d;
FWCfgState *s;
- dev = qdev_create(NULL, "fw_cfg");
+ dev = qdev_create(NULL, "fw_cfg", NULL);
qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port);
qdev_prop_set_uint32(dev, "data_iobase", data_port);
qdev_init_nofail(dev);
diff --git a/hw/grackle_pci.c b/hw/grackle_pci.c
index 9d3ff7d..4b2146d 100644
--- a/hw/grackle_pci.c
+++ b/hw/grackle_pci.c
@@ -69,7 +69,7 @@ PCIBus *pci_grackle_init(uint32_t base, qemu_irq *pic,
SysBusDevice *s;
GrackleState *d;
- dev = qdev_create(NULL, "grackle");
+ dev = qdev_create(NULL, "grackle", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
d = FROM_SYSBUS(GrackleState, s);
diff --git a/hw/grlib.h b/hw/grlib.h
index fdf4b11..d02b64c 100644
--- a/hw/grlib.h
+++ b/hw/grlib.h
@@ -51,7 +51,7 @@ DeviceState *grlib_irqmp_create(target_phys_addr_t base,
assert(cpu_irqs != NULL);
- dev = qdev_create(NULL, "grlib,irqmp");
+ dev = qdev_create(NULL, "grlib,irqmp", NULL);
qdev_prop_set_ptr(dev, "set_pil_in", set_pil_in);
qdev_prop_set_ptr(dev, "set_pil_in_opaque", env);
@@ -82,7 +82,7 @@ DeviceState *grlib_gptimer_create(target_phys_addr_t base,
DeviceState *dev;
int i;
- dev = qdev_create(NULL, "grlib,gptimer");
+ dev = qdev_create(NULL, "grlib,gptimer", NULL);
qdev_prop_set_uint32(dev, "nr-timers", nr_timers);
qdev_prop_set_uint32(dev, "frequency", freq);
qdev_prop_set_uint32(dev, "irq-line", base_irq);
@@ -109,7 +109,7 @@ DeviceState *grlib_apbuart_create(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "grlib,apbuart");
+ dev = qdev_create(NULL, "grlib,apbuart", NULL);
qdev_prop_set_chr(dev, "chrdev", serial);
if (qdev_init(dev)) {
diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
index 1c34253..85d969f 100644
--- a/hw/gt64xxx.c
+++ b/hw/gt64xxx.c
@@ -1086,7 +1086,7 @@ PCIBus *gt64120_register(qemu_irq *pic)
GT64120State *d;
DeviceState *dev;
- dev = qdev_create(NULL, "gt64120");
+ dev = qdev_create(NULL, "gt64120", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
d = FROM_SYSBUS(GT64120State, s);
diff --git a/hw/i2c.c b/hw/i2c.c
index 49b9ecb..e2ba194 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -189,7 +189,7 @@ DeviceState *i2c_create_slave(i2c_bus *bus, const char *name, uint8_t addr)
{
DeviceState *dev;
- dev = qdev_create(&bus->qbus, name);
+ dev = qdev_create(&bus->qbus, name, NULL);
qdev_prop_set_uint8(dev, "address", addr);
qdev_init_nofail(dev);
return dev;
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 4207127..8c868b5 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -102,7 +102,7 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive)
{
DeviceState *dev;
- dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd");
+ dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd", NULL);
qdev_prop_set_uint32(dev, "unit", unit);
qdev_prop_set_drive_nofail(dev, "drive", drive->bdrv);
qdev_init_nofail(dev);
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 9a289b4..34ead1b 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -495,7 +495,7 @@ static void integratorcp_init(ram_addr_t ram_size,
memory_region_init_alias(ram_alias, "ram.alias", ram, 0, ram_size);
memory_region_add_subregion(address_space_mem, 0x80000000, ram_alias);
- dev = qdev_create(NULL, "integrator_core");
+ dev = qdev_create(NULL, "integrator_core", NULL);
qdev_prop_set_uint32(dev, "memsz", ram_size >> 20);
qdev_init_nofail(dev);
sysbus_mmio_map((SysBusDevice *)dev, 0, 0x10000000);
diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index 4272204..1ee2527 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -1280,7 +1280,7 @@ int intel_hda_and_codec_init(PCIBus *bus)
controller = pci_create_simple(bus, -1, "intel-hda");
hdabus = QLIST_FIRST(&controller->qdev.child_bus);
- codec = qdev_create(hdabus, "hda-duplex");
+ codec = qdev_create(hdabus, "hda-duplex", NULL);
qdev_init_nofail(codec);
return 0;
}
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 1cb497f..31d4d01 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -46,7 +46,7 @@ ISABus *isa_bus_new(DeviceState *dev)
return NULL;
}
if (NULL == dev) {
- dev = qdev_create(NULL, "isabus-bridge");
+ dev = qdev_create(NULL, "isabus-bridge", NULL);
qdev_init_nofail(dev);
}
@@ -132,7 +132,7 @@ ISADevice *isa_create(const char *name)
hw_error("Tried to create isa device %s with no isa bus present.",
name);
}
- dev = qdev_create(&isabus->qbus, name);
+ dev = qdev_create(&isabus->qbus, name, NULL);
return DO_UPCAST(ISADevice, qdev, dev);
}
@@ -144,7 +144,7 @@ ISADevice *isa_try_create(const char *name)
hw_error("Tried to create isa device %s with no isa bus present.",
name);
}
- dev = qdev_try_create(&isabus->qbus, name);
+ dev = qdev_try_create(&isabus->qbus, name, NULL);
return DO_UPCAST(ISADevice, qdev, dev);
}
diff --git a/hw/lan9118.c b/hw/lan9118.c
index 73a8661..83963ea 100644
--- a/hw/lan9118.c
+++ b/hw/lan9118.c
@@ -1185,7 +1185,7 @@ void lan9118_init(NICInfo *nd, uint32_t base, qemu_irq irq)
SysBusDevice *s;
qemu_check_nic_model(nd, "lan9118");
- dev = qdev_create(NULL, "lan9118");
+ dev = qdev_create(NULL, "lan9118", NULL);
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
diff --git a/hw/lm32.h b/hw/lm32.h
index 0a67632..bb9538b 100644
--- a/hw/lm32.h
+++ b/hw/lm32.h
@@ -6,7 +6,7 @@ static inline DeviceState *lm32_pic_init(qemu_irq cpu_irq)
DeviceState *dev;
SysBusDevice *d;
- dev = qdev_create(NULL, "lm32-pic");
+ dev = qdev_create(NULL, "lm32-pic", NULL);
qdev_init_nofail(dev);
d = sysbus_from_qdev(dev);
sysbus_connect_irq(d, 0, cpu_irq);
@@ -18,7 +18,7 @@ static inline DeviceState *lm32_juart_init(void)
{
DeviceState *dev;
- dev = qdev_create(NULL, "lm32-juart");
+ dev = qdev_create(NULL, "lm32-juart", NULL);
qdev_init_nofail(dev);
return dev;
diff --git a/hw/m48t59.c b/hw/m48t59.c
index 0cc361e..50927b7 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -635,7 +635,7 @@ M48t59State *m48t59_init(qemu_irq IRQ, target_phys_addr_t mem_base,
M48t59SysBusState *d;
M48t59State *state;
- dev = qdev_create(NULL, "m48t59");
+ dev = qdev_create(NULL, "m48t59", NULL);
qdev_prop_set_uint32(dev, "type", type);
qdev_prop_set_uint32(dev, "size", size);
qdev_prop_set_uint32(dev, "io_base", io_base);
diff --git a/hw/milkymist-hw.h b/hw/milkymist-hw.h
index 20de68e..ce556ff 100644
--- a/hw/milkymist-hw.h
+++ b/hw/milkymist-hw.h
@@ -9,7 +9,7 @@ static inline DeviceState *milkymist_uart_create(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-uart");
+ dev = qdev_create(NULL, "milkymist-uart", NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, rx_irq);
@@ -22,7 +22,7 @@ static inline DeviceState *milkymist_hpdmc_create(target_phys_addr_t base)
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-hpdmc");
+ dev = qdev_create(NULL, "milkymist-hpdmc", NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
@@ -33,7 +33,7 @@ static inline DeviceState *milkymist_memcard_create(target_phys_addr_t base)
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-memcard");
+ dev = qdev_create(NULL, "milkymist-memcard", NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
@@ -45,7 +45,7 @@ static inline DeviceState *milkymist_vgafb_create(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-vgafb");
+ dev = qdev_create(NULL, "milkymist-vgafb", NULL);
qdev_prop_set_uint32(dev, "fb_offset", fb_offset);
qdev_prop_set_uint32(dev, "fb_mask", fb_mask);
qdev_init_nofail(dev);
@@ -61,7 +61,7 @@ static inline DeviceState *milkymist_sysctl_create(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-sysctl");
+ dev = qdev_create(NULL, "milkymist-sysctl", NULL);
qdev_prop_set_uint32(dev, "frequency", freq_hz);
qdev_prop_set_uint32(dev, "systemid", system_id);
qdev_prop_set_uint32(dev, "capabilities", capabilities);
@@ -80,7 +80,7 @@ static inline DeviceState *milkymist_pfpu_create(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-pfpu");
+ dev = qdev_create(NULL, "milkymist-pfpu", NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, irq);
@@ -142,7 +142,7 @@ static inline DeviceState *milkymist_tmu2_create(target_phys_addr_t base,
XFree(configs);
XCloseDisplay(d);
- dev = qdev_create(NULL, "milkymist-tmu2");
+ dev = qdev_create(NULL, "milkymist-tmu2", NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, irq);
@@ -159,7 +159,7 @@ static inline DeviceState *milkymist_ac97_create(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-ac97");
+ dev = qdev_create(NULL, "milkymist-ac97", NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, crrequest_irq);
@@ -176,7 +176,7 @@ static inline DeviceState *milkymist_minimac_create(target_phys_addr_t base,
DeviceState *dev;
qemu_check_nic_model(&nd_table[0], "minimac");
- dev = qdev_create(NULL, "milkymist-minimac");
+ dev = qdev_create(NULL, "milkymist-minimac", NULL);
qdev_set_nic_properties(dev, &nd_table[0]);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
@@ -192,7 +192,7 @@ static inline DeviceState *milkymist_minimac2_create(target_phys_addr_t base,
DeviceState *dev;
qemu_check_nic_model(&nd_table[0], "minimac2");
- dev = qdev_create(NULL, "milkymist-minimac2");
+ dev = qdev_create(NULL, "milkymist-minimac2", NULL);
qdev_prop_set_taddr(dev, "buffers_base", buffers_base);
qdev_set_nic_properties(dev, &nd_table[0]);
qdev_init_nofail(dev);
@@ -209,7 +209,7 @@ static inline DeviceState *milkymist_softusb_create(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "milkymist-softusb");
+ dev = qdev_create(NULL, "milkymist-softusb", NULL);
qdev_prop_set_uint32(dev, "pmem_base", pmem_base);
qdev_prop_set_uint32(dev, "pmem_size", pmem_size);
qdev_prop_set_uint32(dev, "dmem_base", dmem_base);
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index f3c9f93..315886b 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -195,7 +195,7 @@ void mips_jazz_init (ram_addr_t ram_size,
/* Video card */
switch (jazz_model) {
case JAZZ_MAGNUM:
- dev = qdev_create(NULL, "sysbus-g364");
+ dev = qdev_create(NULL, "sysbus-g364", NULL);
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x60080000);
@@ -284,7 +284,7 @@ void mips_jazz_init (ram_addr_t ram_size,
audio_init(i8259, NULL);
/* NVRAM */
- dev = qdev_create(NULL, "ds1225y");
+ dev = qdev_create(NULL, "ds1225y", NULL);
qdev_init_nofail(dev);
sysbus = sysbus_from_qdev(dev);
sysbus_mmio_map(sysbus, 0, 0x80009000);
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index ac65555..e684e8a 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -119,7 +119,7 @@ static void mipsnet_init(int base, qemu_irq irq, NICInfo *nd)
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "mipsnet");
+ dev = qdev_create(NULL, "mipsnet", NULL);
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
diff --git a/hw/musicpal.c b/hw/musicpal.c
index ade5a91..f204bff 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -1586,7 +1586,7 @@ static void musicpal_init(ram_addr_t ram_size,
sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL);
qemu_check_nic_model(&nd_table[0], "mv88w8618");
- dev = qdev_create(NULL, "mv88w8618_eth");
+ dev = qdev_create(NULL, "mv88w8618_eth", NULL);
qdev_set_nic_properties(dev, &nd_table[0]);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
@@ -1622,7 +1622,7 @@ static void musicpal_init(ram_addr_t ram_size,
}
wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
- dev = qdev_create(NULL, "mv88w8618_audio");
+ dev = qdev_create(NULL, "mv88w8618_audio", NULL);
s = sysbus_from_qdev(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
qdev_init_nofail(dev);
diff --git a/hw/nand.c b/hw/nand.c
index c27783e..2069439 100644
--- a/hw/nand.c
+++ b/hw/nand.c
@@ -604,7 +604,7 @@ DeviceState *nand_init(BlockDriverState *bdrv, int manf_id, int chip_id)
if (nand_flash_ids[chip_id].size == 0) {
hw_error("%s: Unsupported NAND chip ID.\n", __FUNCTION__);
}
- dev = qdev_create(NULL, "nand");
+ dev = qdev_create(NULL, "nand", NULL);
qdev_prop_set_uint8(dev, "manufacturer_id", manf_id);
qdev_prop_set_uint8(dev, "chip_id", chip_id);
if (bdrv) {
diff --git a/hw/nseries.c b/hw/nseries.c
index af287dd..14dc0be 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -167,7 +167,7 @@ static void n8x0_nand_setup(struct n800_s *s)
char *otp_region;
DriveInfo *dinfo;
- s->nand = qdev_create(NULL, "onenand");
+ s->nand = qdev_create(NULL, "onenand", NULL);
qdev_prop_set_uint16(s->nand, "manufacturer_id", NAND_MFR_SAMSUNG);
/* Either 0x40 or 0x48 are OK for the device ID */
qdev_prop_set_uint16(s->nand, "device_id", 0x48);
@@ -767,7 +767,7 @@ static void n8x0_uart_setup(struct n800_s *s)
static void n8x0_usb_setup(struct n800_s *s)
{
SysBusDevice *dev;
- s->usb = qdev_create(NULL, "tusb6010");
+ s->usb = qdev_create(NULL, "tusb6010", NULL);
dev = sysbus_from_qdev(s->usb);
qdev_init_nofail(s->usb);
sysbus_connect_irq(dev, 0,
diff --git a/hw/omap1.c b/hw/omap1.c
index 614fd31..c2dc173 100644
--- a/hw/omap1.c
+++ b/hw/omap1.c
@@ -3845,7 +3845,7 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,
s->irq[1][OMAP_INT_KEYBOARD], s->irq[1][OMAP_INT_MPUIO],
s->wakeup, omap_findclk(s, "clk32-kHz"));
- s->gpio = qdev_create(NULL, "omap-gpio");
+ s->gpio = qdev_create(NULL, "omap-gpio", NULL);
qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model);
qdev_init_nofail(s->gpio);
sysbus_connect_irq(sysbus_from_qdev(s->gpio), 0,
diff --git a/hw/omap2.c b/hw/omap2.c
index ca088d9..96533b6 100644
--- a/hw/omap2.c
+++ b/hw/omap2.c
@@ -2378,7 +2378,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,
omap_findclk(s, "i2c2.fclk"),
omap_findclk(s, "i2c2.iclk"));
- s->gpio = qdev_create(NULL, "omap2-gpio");
+ s->gpio = qdev_create(NULL, "omap2-gpio", NULL);
qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model);
qdev_prop_set_ptr(s->gpio, "iclk", omap_findclk(s, "gpio_iclk"));
qdev_prop_set_ptr(s->gpio, "fclk0", omap_findclk(s, "gpio1_dbclk"));
diff --git a/hw/pc.c b/hw/pc.c
index f0f7db0..236f742 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -875,7 +875,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
SysBusDevice *d;
static int apic_mapped;
- dev = qdev_create(NULL, "apic");
+ dev = qdev_create(NULL, "apic", NULL);
qdev_prop_set_uint8(dev, "index", apic_id);
qdev_prop_set_ptr(dev, "cpu_env", env);
qdev_init_nofail(dev);
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 75d96d9..960589a 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -59,7 +59,7 @@ static void ioapic_init(IsaIrqState *isa_irq_state)
SysBusDevice *d;
unsigned int i;
- dev = qdev_create(NULL, "ioapic");
+ dev = qdev_create(NULL, "ioapic", NULL);
qdev_init_nofail(dev);
d = sysbus_from_qdev(dev);
sysbus_mmio_map(d, 0, 0xfec00000);
diff --git a/hw/pci.c b/hw/pci.c
index af74003..67efbb2 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1723,7 +1723,7 @@ PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
{
DeviceState *dev;
- dev = qdev_create(&bus->qbus, name);
+ dev = qdev_create(&bus->qbus, name, NULL);
qdev_prop_set_uint32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
return DO_UPCAST(PCIDevice, qdev, dev);
@@ -1735,7 +1735,7 @@ PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
{
DeviceState *dev;
- dev = qdev_try_create(&bus->qbus, name);
+ dev = qdev_try_create(&bus->qbus, name, NULL);
if (!dev) {
return NULL;
}
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 8f6ea42..14ebcee 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -281,7 +281,7 @@ static PCIBus *i440fx_common_init(const char *device_name,
PIIX3State *piix3;
PCII440FXState *f;
- dev = qdev_create(NULL, "i440FX-pcihost");
+ dev = qdev_create(NULL, "i440FX-pcihost", NULL);
s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev));
s->address_space = address_space_mem;
b = pci_bus_new(&s->busdev.qdev, NULL, pci_address_space,
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index 2aa8760..82538dd 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -1514,7 +1514,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(target_phys_addr_t base,
SysBusDevice *i2c_dev;
PXA2xxI2CState *s;
- i2c_dev = sysbus_from_qdev(qdev_create(NULL, "pxa2xx_i2c"));
+ i2c_dev = sysbus_from_qdev(qdev_create(NULL, "pxa2xx_i2c", NULL));
qdev_prop_set_uint32(&i2c_dev->qdev, "size", region_size + 1);
qdev_prop_set_uint32(&i2c_dev->qdev, "offset",
base - (base & (~region_size) & TARGET_PAGE_MASK));
diff --git a/hw/pxa2xx_dma.c b/hw/pxa2xx_dma.c
index 07ec2db..ba22860 100644
--- a/hw/pxa2xx_dma.c
+++ b/hw/pxa2xx_dma.c
@@ -483,7 +483,7 @@ DeviceState *pxa27x_dma_init(target_phys_addr_t base, qemu_irq irq)
{
DeviceState *dev;
- dev = qdev_create(NULL, "pxa2xx-dma");
+ dev = qdev_create(NULL, "pxa2xx-dma", NULL);
qdev_prop_set_int32(dev, "channels", PXA27X_DMA_NUM_CHANNELS);
qdev_init_nofail(dev);
@@ -497,7 +497,7 @@ DeviceState *pxa255_dma_init(target_phys_addr_t base, qemu_irq irq)
{
DeviceState *dev;
- dev = qdev_create(NULL, "pxa2xx-dma");
+ dev = qdev_create(NULL, "pxa2xx-dma", NULL);
qdev_prop_set_int32(dev, "channels", PXA27X_DMA_NUM_CHANNELS);
qdev_init_nofail(dev);
diff --git a/hw/pxa2xx_gpio.c b/hw/pxa2xx_gpio.c
index 200b0cf..b1433f0 100644
--- a/hw/pxa2xx_gpio.c
+++ b/hw/pxa2xx_gpio.c
@@ -257,7 +257,7 @@ DeviceState *pxa2xx_gpio_init(target_phys_addr_t base,
{
DeviceState *dev;
- dev = qdev_create(NULL, "pxa2xx-gpio");
+ dev = qdev_create(NULL, "pxa2xx-gpio", NULL);
qdev_prop_set_int32(dev, "lines", lines);
qdev_prop_set_int32(dev, "ncpu", env->cpu_index);
qdev_init_nofail(dev);
diff --git a/hw/pxa2xx_pic.c b/hw/pxa2xx_pic.c
index bdd82e6..d69aee9 100644
--- a/hw/pxa2xx_pic.c
+++ b/hw/pxa2xx_pic.c
@@ -251,7 +251,7 @@ static int pxa2xx_pic_post_load(void *opaque, int version_id)
DeviceState *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)
{
- DeviceState *dev = qdev_create(NULL, "pxa2xx_pic");
+ DeviceState *dev = qdev_create(NULL, "pxa2xx_pic", NULL);
int iomemtype;
PXA2xxPICState *s = FROM_SYSBUS(PXA2xxPICState, sysbus_from_qdev(dev));
diff --git a/hw/qdev.c b/hw/qdev.c
index 0e267a7..aeebdb9 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -88,7 +88,7 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)
return NULL;
}
-static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
+static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const char *id)
{
DeviceState *dev;
@@ -107,17 +107,18 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
}
dev->instance_id_alias = -1;
dev->state = DEV_STATE_CREATED;
+ dev->id = id;
return dev;
}
/* Create a new device. This only initializes the device state structure
and allows properties to be set. qdev_init should be called to
initialize the actual device emulation. */
-DeviceState *qdev_create(BusState *bus, const char *name)
+DeviceState *qdev_create(BusState *bus, const char *name, const char *id)
{
DeviceState *dev;
- dev = qdev_try_create(bus, name);
+ dev = qdev_try_create(bus, name, id);
if (!dev) {
if (bus) {
hw_error("Unknown device '%s' for bus '%s'\n", name,
@@ -130,7 +131,7 @@ DeviceState *qdev_create(BusState *bus, const char *name)
return dev;
}
-DeviceState *qdev_try_create(BusState *bus, const char *name)
+DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id)
{
DeviceInfo *info;
@@ -143,7 +144,7 @@ DeviceState *qdev_try_create(BusState *bus, const char *name)
return NULL;
}
- return qdev_create_from_info(bus, info);
+ return qdev_create_from_info(bus, info, id);
}
static void qdev_print_devinfo(DeviceInfo *info)
@@ -226,7 +227,7 @@ int qdev_device_help(QemuOpts *opts)
DeviceState *qdev_device_add(QemuOpts *opts)
{
- const char *driver, *path, *id;
+ const char *driver, *path;
DeviceInfo *info;
DeviceState *qdev;
BusState *bus;
@@ -271,11 +272,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
}
/* create device, set properties */
- qdev = qdev_create_from_info(bus, info);
- id = qemu_opts_id(opts);
- if (id) {
- qdev->id = id;
- }
+ qdev = qdev_create_from_info(bus, info, qemu_opts_id(opts));
if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
qdev_free(qdev);
return NULL;
diff --git a/hw/qdev.h b/hw/qdev.h
index 8a13ec9..626a1b6 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -121,8 +121,8 @@ typedef struct GlobalProperty {
/*** Board API. This should go away once we have a machine config file. ***/
-DeviceState *qdev_create(BusState *bus, const char *name);
-DeviceState *qdev_try_create(BusState *bus, const char *name);
+DeviceState *qdev_create(BusState *bus, const char *name, const char *id);
+DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id);
int qdev_device_help(QemuOpts *opts);
DeviceState *qdev_device_add(QemuOpts *opts);
int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
diff --git a/hw/realview.c b/hw/realview.c
index 549bb15..301739a 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -204,14 +204,14 @@ static void realview_init(ram_addr_t ram_size,
}
sys_id = is_pb ? 0x01780500 : 0xc1400400;
- sysctl = qdev_create(NULL, "realview_sysctl");
+ sysctl = qdev_create(NULL, "realview_sysctl", NULL);
qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
qdev_init_nofail(sysctl);
qdev_prop_set_uint32(sysctl, "proc_id", proc_id);
sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, 0x10000000);
if (is_mpcore) {
- dev = qdev_create(NULL, is_pb ? "a9mpcore_priv": "realview_mpcore");
+ dev = qdev_create(NULL, is_pb ? "a9mpcore_priv": "realview_mpcore", NULL);
qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
qdev_init_nofail(dev);
busdev = sysbus_from_qdev(dev);
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index e2f3e32..2252b04 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -70,7 +70,7 @@ VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size)
DeviceState *dev;
/* Create bridge device */
- dev = qdev_create(NULL, "s390-virtio-bridge");
+ dev = qdev_create(NULL, "s390-virtio-bridge", NULL);
qdev_init_nofail(dev);
/* Create bus on bridge device */
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index acbf026..5a954e0 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -255,7 +255,7 @@ static void s390_init(ram_addr_t my_ram_size,
exit(1);
}
- dev = qdev_create((BusState *)s390_bus, "virtio-net-s390");
+ dev = qdev_create((BusState *)s390_bus, "virtio-net-s390", NULL);
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
}
@@ -270,7 +270,7 @@ static void s390_init(ram_addr_t my_ram_size,
continue;
}
- dev = qdev_create((BusState *)s390_bus, "virtio-blk-s390");
+ dev = qdev_create((BusState *)s390_bus, "virtio-blk-s390", NULL);
qdev_prop_set_drive_nofail(dev, "drive", dinfo->bdrv);
qdev_init_nofail(dev);
}
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 0248294..459d54c 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -99,7 +99,7 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv,
DeviceState *dev;
driver = bdrv_is_sg(bdrv) ? "scsi-generic" : "scsi-disk";
- dev = qdev_create(&bus->qbus, driver);
+ dev = qdev_create(&bus->qbus, driver, NULL);
qdev_prop_set_uint32(dev, "scsi-id", unit);
if (qdev_prop_exists(dev, "removable")) {
qdev_prop_set_bit(dev, "removable", removable);
diff --git a/hw/sm501.c b/hw/sm501.c
index 1ed0a7e..c0f003c 100644
--- a/hw/sm501.c
+++ b/hw/sm501.c
@@ -1430,7 +1430,7 @@ void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq,
0x54, sm501_2d_engine_index);
/* bridge to usb host emulation module */
- dev = qdev_create(NULL, "sysbus-ohci");
+ dev = qdev_create(NULL, "sysbus-ohci", NULL);
qdev_prop_set_uint32(dev, "num-ports", 2);
qdev_prop_set_taddr(dev, "dma-offset", base);
qdev_init_nofail(dev);
diff --git a/hw/smbus_eeprom.c b/hw/smbus_eeprom.c
index 5d080ab..ea7c123 100644
--- a/hw/smbus_eeprom.c
+++ b/hw/smbus_eeprom.c
@@ -137,7 +137,7 @@ void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
for (i = 0; i < nb_eeprom; i++) {
DeviceState *eeprom;
- eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
+ eeprom = qdev_create((BusState *)smbus, "smbus-eeprom", NULL);
qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init_nofail(eeprom);
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index 3a8a85c..127ec91 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -786,7 +786,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)
SysBusDevice *s;
qemu_check_nic_model(nd, "smc91c111");
- dev = qdev_create(NULL, "smc91c111");
+ dev = qdev_create(NULL, "smc91c111", NULL);
qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
diff --git a/hw/spapr_llan.c b/hw/spapr_llan.c
index c18efc7..76a3b71 100644
--- a/hw/spapr_llan.c
+++ b/hw/spapr_llan.c
@@ -201,7 +201,7 @@ void spapr_vlan_create(VIOsPAPRBus *bus, uint32_t reg, NICInfo *nd,
DeviceState *dev;
VIOsPAPRDevice *sdev;
- dev = qdev_create(&bus->bus, "spapr-vlan");
+ dev = qdev_create(&bus->bus, "spapr-vlan", NULL);
qdev_prop_set_uint32(dev, "reg", reg);
qdev_set_nic_properties(dev, nd);
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index ce6558b..cd2641b 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -649,7 +649,7 @@ VIOsPAPRBus *spapr_vio_bus_init(void)
DeviceInfo *qinfo;
/* Create bridge device */
- dev = qdev_create(NULL, "spapr-vio-bridge");
+ dev = qdev_create(NULL, "spapr-vio-bridge", NULL);
qdev_init_nofail(dev);
/* Create bus on bridge device */
diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
index fc9ac6a..f2a8cc5 100644
--- a/hw/spapr_vscsi.c
+++ b/hw/spapr_vscsi.c
@@ -899,7 +899,7 @@ void spapr_vscsi_create(VIOsPAPRBus *bus, uint32_t reg,
DeviceState *dev;
VIOsPAPRDevice *sdev;
- dev = qdev_create(&bus->bus, "spapr-vscsi");
+ dev = qdev_create(&bus->bus, "spapr-vscsi", NULL);
qdev_prop_set_uint32(dev, "reg", reg);
qdev_init_nofail(dev);
diff --git a/hw/spapr_vty.c b/hw/spapr_vty.c
index f5046d9..08502c1 100644
--- a/hw/spapr_vty.c
+++ b/hw/spapr_vty.c
@@ -122,7 +122,7 @@ void spapr_vty_create(VIOsPAPRBus *bus,
DeviceState *dev;
VIOsPAPRDevice *sdev;
- dev = qdev_create(&bus->bus, "spapr-vty");
+ dev = qdev_create(&bus->bus, "spapr-vty", NULL);
qdev_prop_set_uint32(dev, "reg", reg);
qdev_prop_set_chr(dev, "chardev", chardev);
qdev_init_nofail(dev);
diff --git a/hw/spitz.c b/hw/spitz.c
index 0adae59..90183d4 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -154,7 +154,7 @@ static void sl_flash_register(PXA2xxState *cpu, int size)
{
DeviceState *dev;
- dev = qdev_create(NULL, "sl-nand");
+ dev = qdev_create(NULL, "sl-nand", NULL);
qdev_prop_set_uint8(dev, "manf_id", NAND_MFR_SAMSUNG);
if (size == FLASH_128M)
diff --git a/hw/ssi.c b/hw/ssi.c
index 3f4c5f9..c068aed 100644
--- a/hw/ssi.c
+++ b/hw/ssi.c
@@ -45,7 +45,7 @@ void ssi_register_slave(SSISlaveInfo *info)
DeviceState *ssi_create_slave(SSIBus *bus, const char *name)
{
DeviceState *dev;
- dev = qdev_create(&bus->qbus, name);
+ dev = qdev_create(&bus->qbus, name, NULL);
qdev_init_nofail(dev);
return dev;
}
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 2bf1c23..2345692 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1350,7 +1350,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
qemu_check_nic_model(&nd_table[0], "stellaris");
- enet = qdev_create(NULL, "stellaris_enet");
+ enet = qdev_create(NULL, "stellaris_enet", NULL);
qdev_set_nic_properties(enet, &nd_table[0]);
qdev_init_nofail(enet);
sysbus_mmio_map(sysbus_from_qdev(enet), 0, 0x40048000);
diff --git a/hw/strongarm.c b/hw/strongarm.c
index 6097ea2..2d98893 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -610,7 +610,7 @@ static DeviceState *strongarm_gpio_init(target_phys_addr_t base,
DeviceState *dev;
int i;
- dev = qdev_create(NULL, "strongarm-gpio");
+ dev = qdev_create(NULL, "strongarm-gpio", NULL);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
@@ -1570,7 +1570,7 @@ StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
s->ppc = sysbus_create_varargs("strongarm-ppc", 0x90060000, NULL);
for (i = 0; sa_serial[i].io_base; i++) {
- DeviceState *dev = qdev_create(NULL, "strongarm-uart");
+ DeviceState *dev = qdev_create(NULL, "strongarm-uart", NULL);
qdev_prop_set_chr(dev, "chardev", serial_hds[i]);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0,
diff --git a/hw/sun4m.c b/hw/sun4m.c
index dcaed38..ebf1dde 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -373,7 +373,7 @@ static void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "iommu");
+ dev = qdev_create(NULL, "iommu", NULL);
qdev_prop_set_uint32(dev, "version", version);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -389,7 +389,7 @@ static void *sparc32_dma_init(target_phys_addr_t daddr, qemu_irq parent_irq,
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "sparc32_dma");
+ dev = qdev_create(NULL, "sparc32_dma", NULL);
qdev_prop_set_ptr(dev, "iommu_opaque", iommu);
qdev_prop_set_uint32(dev, "is_ledma", is_ledma);
qdev_init_nofail(dev);
@@ -410,7 +410,7 @@ static void lance_init(NICInfo *nd, target_phys_addr_t leaddr,
qemu_check_nic_model(&nd_table[0], "lance");
- dev = qdev_create(NULL, "lance");
+ dev = qdev_create(NULL, "lance", NULL);
qdev_set_nic_properties(dev, nd);
qdev_prop_set_ptr(dev, "dma", dma_opaque);
qdev_init_nofail(dev);
@@ -429,7 +429,7 @@ static DeviceState *slavio_intctl_init(target_phys_addr_t addr,
SysBusDevice *s;
unsigned int i, j;
- dev = qdev_create(NULL, "slavio_intctl");
+ dev = qdev_create(NULL, "slavio_intctl", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -457,7 +457,7 @@ static void slavio_timer_init_all(target_phys_addr_t addr, qemu_irq master_irq,
SysBusDevice *s;
unsigned int i;
- dev = qdev_create(NULL, "slavio_timer");
+ dev = qdev_create(NULL, "slavio_timer", NULL);
qdev_prop_set_uint32(dev, "num_cpus", num_cpus);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -484,7 +484,7 @@ static void slavio_misc_init(target_phys_addr_t base,
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "slavio_misc");
+ dev = qdev_create(NULL, "slavio_misc", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
if (base) {
@@ -520,7 +520,7 @@ static void ecc_init(target_phys_addr_t base, qemu_irq irq, uint32_t version)
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "eccmemctl");
+ dev = qdev_create(NULL, "eccmemctl", NULL);
qdev_prop_set_uint32(dev, "version", version);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -536,7 +536,7 @@ static void apc_init(target_phys_addr_t power_base, qemu_irq cpu_halt)
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "apc");
+ dev = qdev_create(NULL, "apc", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
/* Power management (APC) XXX: not a Slavio device */
@@ -550,7 +550,7 @@ static void tcx_init(target_phys_addr_t addr, int vram_size, int width,
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "SUNW,tcx");
+ dev = qdev_create(NULL, "SUNW,tcx", NULL);
qdev_prop_set_taddr(dev, "addr", addr);
qdev_prop_set_uint32(dev, "vram_size", vram_size);
qdev_prop_set_uint16(dev, "width", width);
@@ -585,7 +585,7 @@ static void idreg_init(target_phys_addr_t addr)
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "macio_idreg");
+ dev = qdev_create(NULL, "macio_idreg", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -621,7 +621,7 @@ static void afx_init(target_phys_addr_t addr)
DeviceState *dev;
SysBusDevice *s;
- dev = qdev_create(NULL, "tcx_afx");
+ dev = qdev_create(NULL, "tcx_afx", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -664,7 +664,7 @@ static void prom_init(target_phys_addr_t addr, const char *bios_name)
char *filename;
int ret;
- dev = qdev_create(NULL, "openprom");
+ dev = qdev_create(NULL, "openprom", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -750,7 +750,7 @@ static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size,
(unsigned int)(max_mem / (1024 * 1024)));
exit(1);
}
- dev = qdev_create(NULL, "memory");
+ dev = qdev_create(NULL, "memory", NULL);
s = sysbus_from_qdev(dev);
d = FROM_SYSBUS(RamDevice, s);
@@ -1470,7 +1470,7 @@ static DeviceState *sbi_init(target_phys_addr_t addr, qemu_irq **parent_irq)
SysBusDevice *s;
unsigned int i;
- dev = qdev_create(NULL, "sbi");
+ dev = qdev_create(NULL, "sbi", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -1665,7 +1665,7 @@ static DeviceState *sun4c_intctl_init(target_phys_addr_t addr,
SysBusDevice *s;
unsigned int i;
- dev = qdev_create(NULL, "sun4c_intctl");
+ dev = qdev_create(NULL, "sun4c_intctl", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 32e6ab9..ab6020f 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -595,7 +595,7 @@ static void prom_init(target_phys_addr_t addr, const char *bios_name)
char *filename;
int ret;
- dev = qdev_create(NULL, "openprom");
+ dev = qdev_create(NULL, "openprom", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
@@ -674,7 +674,7 @@ static void ram_init(target_phys_addr_t addr, ram_addr_t RAM_size)
RamDevice *d;
/* allocate RAM */
- dev = qdev_create(NULL, "memory");
+ dev = qdev_create(NULL, "memory", NULL);
s = sysbus_from_qdev(dev);
d = FROM_SYSBUS(RamDevice, s);
diff --git a/hw/syborg.c b/hw/syborg.c
index bc200e4..5725f8a 100644
--- a/hw/syborg.c
+++ b/hw/syborg.c
@@ -62,7 +62,7 @@ static void syborg_init(ram_addr_t ram_size,
sysbus_create_simple("syborg,rtc", 0xC0001000, NULL);
- dev = qdev_create(NULL, "syborg,timer");
+ dev = qdev_create(NULL, "syborg,timer", NULL);
qdev_prop_set_uint32(dev, "frequency", 1000000);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);
@@ -81,7 +81,7 @@ static void syborg_init(ram_addr_t ram_size,
SysBusDevice *s;
qemu_check_nic_model(&nd_table[0], "virtio");
- dev = qdev_create(NULL, "syborg,virtio-net");
+ dev = qdev_create(NULL, "syborg,virtio-net", NULL);
qdev_set_nic_properties(dev, &nd_table[0]);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
diff --git a/hw/sysbus.c b/hw/sysbus.c
index 4fab5a4..7809aa1 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -182,7 +182,7 @@ DeviceState *sysbus_create_varargs(const char *name,
qemu_irq irq;
int n;
- dev = qdev_create(NULL, name);
+ dev = qdev_create(NULL, name, NULL);
s = sysbus_from_qdev(dev);
qdev_init_nofail(dev);
if (addr != (target_phys_addr_t)-1) {
@@ -210,7 +210,7 @@ DeviceState *sysbus_try_create_varargs(const char *name,
qemu_irq irq;
int n;
- dev = qdev_try_create(NULL, name);
+ dev = qdev_try_create(NULL, name, NULL);
if (!dev) {
return NULL;
}
diff --git a/hw/unin_pci.c b/hw/unin_pci.c
index 600cd1e..8fa346f 100644
--- a/hw/unin_pci.c
+++ b/hw/unin_pci.c
@@ -211,7 +211,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
/* Use values found on a real PowerMac */
/* Uninorth main bus */
- dev = qdev_create(NULL, "uni-north");
+ dev = qdev_create(NULL, "uni-north", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
d = FROM_SYSBUS(UNINState, s);
@@ -237,7 +237,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
/* Uninorth AGP bus */
pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north-agp");
- dev = qdev_create(NULL, "uni-north-agp");
+ dev = qdev_create(NULL, "uni-north-agp", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, 0xf0800000);
@@ -247,7 +247,7 @@ PCIBus *pci_pmac_init(qemu_irq *pic,
#if 0
/* XXX: not needed for now */
pci_create_simple(d->host_state.bus, PCI_DEVFN(14, 0), "uni-north-pci");
- dev = qdev_create(NULL, "uni-north-pci");
+ dev = qdev_create(NULL, "uni-north-pci", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, 0xf4800000);
@@ -267,7 +267,7 @@ PCIBus *pci_pmac_u3_init(qemu_irq *pic,
/* Uninorth AGP bus */
- dev = qdev_create(NULL, "u3-agp");
+ dev = qdev_create(NULL, "u3-agp", NULL);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
d = FROM_SYSBUS(UNINState, s);
diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 93f640d..4c3682e 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -132,7 +132,7 @@ USBDevice *usb_create(USBBus *bus, const char *name)
}
#endif
- dev = qdev_create(&bus->qbus, name);
+ dev = qdev_create(&bus->qbus, name, NULL);
return DO_UPCAST(USBDevice, qdev, dev);
}
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 49f8f5f..b713aac 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -198,7 +198,7 @@ static void versatile_init(ram_addr_t ram_size,
/* SDRAM at address zero. */
cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM);
- sysctl = qdev_create(NULL, "realview_sysctl");
+ sysctl = qdev_create(NULL, "realview_sysctl", NULL);
qdev_prop_set_uint32(sysctl, "sys_id", 0x41007004);
qdev_init_nofail(sysctl);
qdev_prop_set_uint32(sysctl, "proc_id", 0x02000000);
diff --git a/hw/vexpress.c b/hw/vexpress.c
index c9766dd..191a5a2 100644
--- a/hw/vexpress.c
+++ b/hw/vexpress.c
@@ -85,7 +85,7 @@ static void vexpress_a9_init(ram_addr_t ram_size,
ram_offset | IO_MEM_RAM);
/* 0x1e000000 A9MPCore (SCU) private memory region */
- dev = qdev_create(NULL, "a9mpcore_priv");
+ dev = qdev_create(NULL, "a9mpcore_priv", NULL);
qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
qdev_init_nofail(dev);
busdev = sysbus_from_qdev(dev);
@@ -109,7 +109,7 @@ static void vexpress_a9_init(ram_addr_t ram_size,
proc_id = 0x0c000191;
/* 0x10000000 System registers */
- sysctl = qdev_create(NULL, "realview_sysctl");
+ sysctl = qdev_create(NULL, "realview_sysctl", NULL);
qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
qdev_init_nofail(sysctl);
qdev_prop_set_uint32(sysctl, "proc_id", proc_id);
diff --git a/hw/xilinx.h b/hw/xilinx.h
index 35f35bd..6eb0d35 100644
--- a/hw/xilinx.h
+++ b/hw/xilinx.h
@@ -6,7 +6,7 @@ xilinx_intc_create(target_phys_addr_t base, qemu_irq irq, int kind_of_intr)
{
DeviceState *dev;
- dev = qdev_create(NULL, "xilinx,intc");
+ dev = qdev_create(NULL, "xilinx,intc", NULL);
qdev_prop_set_uint32(dev, "kind-of-intr", kind_of_intr);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, base);
@@ -20,7 +20,7 @@ xilinx_timer_create(target_phys_addr_t base, qemu_irq irq, int nr, int freq)
{
DeviceState *dev;
- dev = qdev_create(NULL, "xilinx,timer");
+ dev = qdev_create(NULL, "xilinx,timer", NULL);
qdev_prop_set_uint32(dev, "nr-timers", nr);
qdev_prop_set_uint32(dev, "frequency", freq);
qdev_init_nofail(dev);
@@ -38,7 +38,7 @@ xilinx_ethlite_create(NICInfo *nd, target_phys_addr_t base, qemu_irq irq,
qemu_check_nic_model(nd, "xilinx-ethlite");
- dev = qdev_create(NULL, "xilinx,ethlite");
+ dev = qdev_create(NULL, "xilinx,ethlite", NULL);
qdev_set_nic_properties(dev, nd);
qdev_prop_set_uint32(dev, "txpingpong", txpingpong);
qdev_prop_set_uint32(dev, "rxpingpong", rxpingpong);
@@ -56,7 +56,7 @@ xilinx_axiethernet_create(void *dmach,
DeviceState *dev;
qemu_check_nic_model(nd, "xilinx-axienet");
- dev = qdev_create(NULL, "xilinx,axienet");
+ dev = qdev_create(NULL, "xilinx,axienet", NULL);
qdev_set_nic_properties(dev, nd);
qdev_prop_set_uint32(dev, "c_rxmem", rxmem);
qdev_prop_set_uint32(dev, "c_txmem", txmem);
@@ -75,7 +75,7 @@ xilinx_axiethernetdma_create(void *dmach,
{
DeviceState *dev = NULL;
- dev = qdev_create(NULL, "xilinx,axidma");
+ dev = qdev_create(NULL, "xilinx,axidma", NULL);
qdev_prop_set_uint32(dev, "freqhz", freqhz);
qdev_prop_set_ptr(dev, "dmach", dmach);
qdev_init_nofail(dev);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (2 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 03/14] qdev: push id into qdev_create calls Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-19 7:34 ` Gerd Hoffmann
2011-09-16 16:00 ` [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking Anthony Liguori
` (12 subsequent siblings)
16 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
qdev has this quirk that it owns a seemingly arbitrary QemuOpts pointer. That's
because qdev expects a static string for the id (which really makes no sense
since ids are supposed to be provided by the user). Instead of managing just
the id pointer, we currently take ownership of the entire QemuOpts structure
that was used to create the device just to keep the name around.
Just strdup the pointer we actually need.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/qdev.c | 3 ++-
hw/qdev.h | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index aeebdb9..41ed872 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -107,7 +107,7 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const
}
dev->instance_id_alias = -1;
dev->state = DEV_STATE_CREATED;
- dev->id = id;
+ dev->id = g_strdup(id);
return dev;
}
@@ -414,6 +414,7 @@ void qdev_free(DeviceState *dev)
qemu_opts_del(dev->opts);
}
QLIST_REMOVE(dev, sibling);
+ g_free(dev->id);
for (prop = dev->info->props; prop && prop->name; prop++) {
if (prop->info->free) {
prop->info->free(dev, prop);
diff --git a/hw/qdev.h b/hw/qdev.h
index 626a1b6..c86736a 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -30,7 +30,7 @@ enum {
/* This structure should not be accessed directly. We declare it here
so that it can be embedded in individual device state structures. */
struct DeviceState {
- const char *id;
+ char *id;
enum DevState state;
QemuOpts *opts;
int hotplugged;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (3 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-19 7:35 ` Gerd Hoffmann
2011-09-16 16:00 ` [Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming Anthony Liguori
` (11 subsequent siblings)
16 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
This was only used because id's memory was stored in opts.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/qdev.c | 5 ++---
hw/qdev.h | 1 -
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 41ed872..3096667 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -281,7 +281,6 @@ DeviceState *qdev_device_add(QemuOpts *opts)
qerror_report(QERR_DEVICE_INIT_FAILED, driver);
return NULL;
}
- qdev->opts = opts;
return qdev;
}
@@ -410,8 +409,6 @@ void qdev_free(DeviceState *dev)
vmstate_unregister(dev, dev->info->vmsd, dev);
if (dev->info->exit)
dev->info->exit(dev);
- if (dev->opts)
- qemu_opts_del(dev->opts);
}
QLIST_REMOVE(dev, sibling);
g_free(dev->id);
@@ -921,6 +918,8 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
qemu_opts_del(opts);
return -1;
}
+ qemu_opts_del(opts);
+
return 0;
}
diff --git a/hw/qdev.h b/hw/qdev.h
index c86736a..d15a47e 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -32,7 +32,6 @@ enum {
struct DeviceState {
char *id;
enum DevState state;
- QemuOpts *opts;
int hotplugged;
DeviceInfo *info;
BusState *parent_bus;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (4 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-17 18:39 ` Blue Swirl
2011-09-16 16:00 ` [Qemu-devel] [PATCH 07/14] sysbus: add an id argument to sysbus_create_simple() Anthony Liguori
` (10 subsequent siblings)
16 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
By using a prefix of "::" in the name, we can safely derive the composed device
name from the parent device and busses name. For instance, if the "::i440fx"
device created a device named "piix3", it would look like this:
static void i440fx_initfn(...)
{
s->piix3 = qdev_create("PIIX3", "::piix3");
...
The resulting device would be named "::i440fx::i440fx.0::piix3". The reason for
the middle "::i440fx.0" blob is that there are two levels of the tree hierarchy
here and the bus level already has it's name derived from the parent device.
We'll eliminate the bus level of the hierarchy in due time, but for now we have
to just live with the ugly names.
This patch lets qdev names be specified as a printf style format string which is
convenient for creating devices like "::smbus-eeprom[%d]".
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/qdev.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
hw/qdev.h | 8 ++++-
2 files changed, 78 insertions(+), 9 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 3096667..6bf6650 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -88,9 +88,10 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)
return NULL;
}
-static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const char *id)
+static DeviceState *qdev_create_from_infov(BusState *bus, DeviceInfo *info, const char *id, va_list ap)
{
DeviceState *dev;
+ char *name = NULL;
assert(bus->info == info->bus_info);
dev = g_malloc0(info->size);
@@ -107,18 +108,50 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const
}
dev->instance_id_alias = -1;
dev->state = DEV_STATE_CREATED;
- dev->id = g_strdup(id);
+
+ if (id) {
+ name = g_strdup_vprintf(id, ap);
+ if (name[0] == ':' && name[1] == ':') {
+ const char *parent_bus, *parent_device;
+ char *full_name;
+
+ if (dev->parent_bus && dev->parent_bus->parent) {
+ parent_device = dev->parent_bus->parent->id;
+ parent_bus = dev->parent_bus->name;
+
+ full_name = g_strdup_printf("%s%s%s",
+ dev->parent_bus->parent->id,
+ dev->parent_bus->name,
+ name);
+ g_free(name);
+ name = full_name;
+ }
+ }
+ }
+ dev->id = name;
+ return dev;
+}
+
+static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const char *id, ...)
+{
+ DeviceState *dev;
+ va_list ap;
+
+ va_start(ap, id);
+ dev = qdev_create_from_infov(bus, info, id, ap);
+ va_end(ap);
+
return dev;
}
/* Create a new device. This only initializes the device state structure
and allows properties to be set. qdev_init should be called to
initialize the actual device emulation. */
-DeviceState *qdev_create(BusState *bus, const char *name, const char *id)
+DeviceState *qdev_createv(BusState *bus, const char *name, const char *id, va_list ap)
{
DeviceState *dev;
- dev = qdev_try_create(bus, name, id);
+ dev = qdev_try_createv(bus, name, id, ap);
if (!dev) {
if (bus) {
hw_error("Unknown device '%s' for bus '%s'\n", name,
@@ -131,7 +164,19 @@ DeviceState *qdev_create(BusState *bus, const char *name, const char *id)
return dev;
}
-DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id)
+DeviceState *qdev_create(BusState *bus, const char *name, const char *id, ...)
+{
+ DeviceState *dev;
+ va_list ap;
+
+ va_start(ap, id);
+ dev = qdev_createv(bus, name, id, ap);
+ va_end(ap);
+
+ return dev;
+}
+
+DeviceState *qdev_try_createv(BusState *bus, const char *name, const char *id, va_list ap)
{
DeviceInfo *info;
@@ -144,7 +189,19 @@ DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id)
return NULL;
}
- return qdev_create_from_info(bus, info, id);
+ return qdev_create_from_infov(bus, info, id, ap);
+}
+
+DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id, ...)
+{
+ DeviceState *dev;
+ va_list ap;
+
+ va_start(ap, id);
+ dev = qdev_try_createv(bus, name, id, ap);
+ va_end(ap);
+
+ return dev;
}
static void qdev_print_devinfo(DeviceInfo *info)
@@ -231,6 +288,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
DeviceInfo *info;
DeviceState *qdev;
BusState *bus;
+ const char *id;
driver = qemu_opt_get(opts, "driver");
if (!driver) {
@@ -271,8 +329,15 @@ DeviceState *qdev_device_add(QemuOpts *opts)
return NULL;
}
+ id = qemu_opts_id(opts);
+
/* create device, set properties */
- qdev = qdev_create_from_info(bus, info, qemu_opts_id(opts));
+ if (id) {
+ qdev = qdev_create_from_info(bus, info, "%s", id);
+ } else {
+ qdev = qdev_create_from_info(bus, info, NULL);
+ }
+
if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
qdev_free(qdev);
return NULL;
diff --git a/hw/qdev.h b/hw/qdev.h
index d15a47e..a2b7a08 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -120,8 +120,12 @@ typedef struct GlobalProperty {
/*** Board API. This should go away once we have a machine config file. ***/
-DeviceState *qdev_create(BusState *bus, const char *name, const char *id);
-DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id);
+DeviceState *qdev_create(BusState *bus, const char *name, const char *id, ...)
+ GCC_FMT_ATTR(3, 4);
+DeviceState *qdev_createv(BusState *bus, const char *name, const char *id, va_list ap);
+DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id, ...)
+ GCC_FMT_ATTR(3, 4);
+DeviceState *qdev_try_createv(BusState *bus, const char *name, const char *id, va_list ap);
int qdev_device_help(QemuOpts *opts);
DeviceState *qdev_device_add(QemuOpts *opts);
int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 07/14] sysbus: add an id argument to sysbus_create_simple()
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (5 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 08/14] sysbus: make create_varargs take an id Anthony Liguori
` (9 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
This is mechanical.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/arm11mpcore.c | 2 +-
hw/axis_dev88.c | 2 +-
hw/collie.c | 2 +-
hw/integratorcp.c | 14 +++++++-------
hw/kvmclock.c | 2 +-
hw/lm32_boards.c | 14 +++++++-------
hw/mainstone.c | 2 +-
hw/musicpal.c | 14 +++++++-------
hw/pc.c | 2 +-
hw/petalogix_s3adsp1800_mmu.c | 2 +-
hw/ppce500_mpc8544ds.c | 2 +-
hw/pxa2xx.c | 18 ++++++++++++------
hw/realview.c | 32 ++++++++++++++++----------------
hw/spitz.c | 6 +++---
hw/stellaris.c | 10 +++++-----
hw/strongarm.c | 3 ++-
hw/sun4m.c | 2 +-
hw/syborg.c | 18 +++++++++---------
hw/sysbus.h | 6 ++++--
hw/tosa.c | 4 ++--
hw/versatilepb.c | 24 ++++++++++++------------
hw/vexpress.c | 22 +++++++++++-----------
22 files changed, 106 insertions(+), 97 deletions(-)
diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
index 0e456a2..9bbd684 100644
--- a/hw/arm11mpcore.c
+++ b/hw/arm11mpcore.c
@@ -78,7 +78,7 @@ static int realview_mpcore_init(SysBusDevice *dev)
/* ??? IRQ routing is hardcoded to "normal" mode. */
for (n = 0; n < 4; n++) {
gic = sysbus_create_simple("realview_gic", 0x10040000 + n * 0x10000,
- s->cpuic[10 + n]);
+ s->cpuic[10 + n], NULL);
for (i = 0; i < 64; i++) {
s->rvic[n][i] = qdev_get_gpio_in(gic, i);
}
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index 752c573..6987387 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -335,7 +335,7 @@ void axisdev88_init (ram_addr_t ram_size,
for (i = 0; i < 4; i++) {
sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
- irq[0x14 + i]);
+ irq[0x14 + i], NULL);
}
if (!kernel_filename) {
diff --git a/hw/collie.c b/hw/collie.c
index a10cc1b..c123bf1 100644
--- a/hw/collie.c
+++ b/hw/collie.c
@@ -43,7 +43,7 @@ static void collie_init(ram_addr_t ram_size,
dinfo ? dinfo->bdrv : NULL, (64 * 1024),
512, 4, 0x00, 0x00, 0x00, 0x00, 0);
- sysbus_create_simple("scoop", 0x40800000, NULL);
+ sysbus_create_simple("scoop", 0x40800000, NULL, NULL);
collie_binfo.kernel_filename = kernel_filename;
collie_binfo.kernel_cmdline = kernel_cmdline;
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index 34ead1b..a163cf1 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -507,20 +507,20 @@ static void integratorcp_init(ram_addr_t ram_size,
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
- sysbus_create_simple("integrator_pic", 0xca000000, pic[26]);
+ sysbus_create_simple("integrator_pic", 0xca000000, pic[26], NULL);
sysbus_create_varargs("integrator_pit", 0x13000000,
pic[5], pic[6], pic[7], NULL);
- sysbus_create_simple("pl031", 0x15000000, pic[8]);
- sysbus_create_simple("pl011", 0x16000000, pic[1]);
- sysbus_create_simple("pl011", 0x17000000, pic[2]);
+ sysbus_create_simple("pl031", 0x15000000, pic[8], NULL);
+ sysbus_create_simple("pl011", 0x16000000, pic[1], NULL);
+ sysbus_create_simple("pl011", 0x17000000, pic[2], NULL);
icp_control_init(0xcb000000);
- sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]);
- sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]);
+ sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3], NULL);
+ sysbus_create_simple("pl050_mouse", 0x19000000, pic[4], NULL);
sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL);
if (nd_table[0].vlan)
smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
- sysbus_create_simple("pl110", 0xc0000000, pic[22]);
+ sysbus_create_simple("pl110", 0xc0000000, pic[22], NULL);
integrator_binfo.ram_size = ram_size;
integrator_binfo.kernel_filename = kernel_filename;
diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index b73aec4..f920b10 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -103,7 +103,7 @@ void kvmclock_create(void)
if (kvm_enabled() &&
first_cpu->cpuid_kvm_features & ((1ULL << KVM_FEATURE_CLOCKSOURCE) |
(1ULL << KVM_FEATURE_CLOCKSOURCE2))) {
- sysbus_create_simple("kvmclock", -1, NULL);
+ sysbus_create_simple("kvmclock", -1, NULL, NULL);
}
}
diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c
index 97e1c00..0ffb70d 100644
--- a/hw/lm32_boards.c
+++ b/hw/lm32_boards.c
@@ -123,9 +123,9 @@ static void lm32_evr_init(ram_addr_t ram_size_not_used,
irq[i] = qdev_get_gpio_in(env->pic_state, i);
}
- sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]);
- sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
- sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
+ sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq], NULL);
+ sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq], NULL);
+ sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq], NULL);
/* make sure juart isn't the first chardev */
env->juart_state = lm32_juart_init();
@@ -217,10 +217,10 @@ static void lm32_uclinux_init(ram_addr_t ram_size_not_used,
irq[i] = qdev_get_gpio_in(env->pic_state, i);
}
- sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]);
- sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]);
- sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]);
- sysbus_create_simple("lm32-timer", timer2_base, irq[timer2_irq]);
+ sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq], NULL);
+ sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq], NULL);
+ sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq], NULL);
+ sysbus_create_simple("lm32-timer", timer2_base, irq[timer2_irq], NULL);
/* make sure juart isn't the first chardev */
env->juart_state = lm32_juart_init();
diff --git a/hw/mainstone.c b/hw/mainstone.c
index 336f31e..ba4941c 100644
--- a/hw/mainstone.c
+++ b/hw/mainstone.c
@@ -141,7 +141,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
}
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
- qdev_get_gpio_in(cpu->gpio, 0));
+ qdev_get_gpio_in(cpu->gpio, 0), NULL);
/* setup keypad */
printf("map addr %p\n", &map);
diff --git a/hw/musicpal.c b/hw/musicpal.c
index f204bff..1a4f865 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -1522,7 +1522,7 @@ static void musicpal_init(ram_addr_t ram_size,
cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off);
dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
- cpu_pic[ARM_PIC_CPU_IRQ]);
+ cpu_pic[ARM_PIC_CPU_IRQ], NULL);
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
@@ -1583,7 +1583,7 @@ static void musicpal_init(ram_addr_t ram_size,
#endif
}
- sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL);
+ sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL, NULL);
qemu_check_nic_model(&nd_table[0], "mv88w8618");
dev = qdev_create(NULL, "mv88w8618_eth", NULL);
@@ -1592,16 +1592,16 @@ static void musicpal_init(ram_addr_t ram_size,
sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);
- sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
+ sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL, NULL);
musicpal_misc_init();
- dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
- i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL);
+ dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ], NULL);
+ i2c_dev = sysbus_create_simple("gpio_i2c", -1, NULL, NULL);
i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
- lcd_dev = sysbus_create_simple("musicpal_lcd", MP_LCD_BASE, NULL);
- key_dev = sysbus_create_simple("musicpal_key", -1, NULL);
+ lcd_dev = sysbus_create_simple("musicpal_lcd", MP_LCD_BASE, NULL, NULL);
+ key_dev = sysbus_create_simple("musicpal_key", -1, NULL, NULL);
/* I2C read data */
qdev_connect_gpio_out(i2c_dev, 0,
diff --git a/hw/pc.c b/hw/pc.c
index 236f742..a6d0f47 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -875,7 +875,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)
SysBusDevice *d;
static int apic_mapped;
- dev = qdev_create(NULL, "apic", NULL);
+ dev = qdev_create(NULL, "apic", "::apic[%d]", apic_id);
qdev_prop_set_uint8(dev, "index", apic_id);
qdev_prop_set_ptr(dev, "cpu_env", env);
qdev_init_nofail(dev);
diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c
index 66fb96d..cc81ba7 100644
--- a/hw/petalogix_s3adsp1800_mmu.c
+++ b/hw/petalogix_s3adsp1800_mmu.c
@@ -160,7 +160,7 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size,
irq[i] = qdev_get_gpio_in(dev, i);
}
- sysbus_create_simple("xilinx,uartlite", 0x84000000, irq[3]);
+ sysbus_create_simple("xilinx,uartlite", 0x84000000, irq[3], NULL);
/* 2 timers at irq 2 @ 62 Mhz. */
xilinx_timer_create(0x83c00000, irq[0], 2, 62 * 1000000);
xilinx_ethlite_create(&nd_table[0], 0x81000000, irq[1], 0, 0);
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index 1274a3e..f2989a8 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -286,7 +286,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
}
/* General Utility device */
- sysbus_create_simple("mpc8544-guts", MPC8544_UTIL_BASE, NULL);
+ sysbus_create_simple("mpc8544-guts", MPC8544_UTIL_BASE, NULL, NULL);
/* PCI */
dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE,
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index 82538dd..089d54d 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -2166,20 +2166,23 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
for (i = 0; pxa27x_ssp[i].io_base; i ++) {
DeviceState *dev;
dev = sysbus_create_simple("pxa2xx-ssp", pxa27x_ssp[i].io_base,
- qdev_get_gpio_in(s->pic, pxa27x_ssp[i].irqn));
+ qdev_get_gpio_in(s->pic, pxa27x_ssp[i].irqn),
+ NULL);
s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
}
if (usb_enabled) {
sysbus_create_simple("sysbus-ohci", 0x4c000000,
- qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
+ qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1),
+ NULL);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
sysbus_create_simple("pxa2xx_rtc", 0x40900000,
- qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM));
+ qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM),
+ NULL);
s->i2c[0] = pxa2xx_i2c_init(0x40301600,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_I2C), 0xffff);
@@ -2302,20 +2305,23 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)
for (i = 0; pxa255_ssp[i].io_base; i ++) {
DeviceState *dev;
dev = sysbus_create_simple("pxa2xx-ssp", pxa255_ssp[i].io_base,
- qdev_get_gpio_in(s->pic, pxa255_ssp[i].irqn));
+ qdev_get_gpio_in(s->pic, pxa255_ssp[i].irqn),
+ NULL);
s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
}
if (usb_enabled) {
sysbus_create_simple("sysbus-ohci", 0x4c000000,
- qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
+ qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1),
+ NULL);
}
s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000);
s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000);
sysbus_create_simple("pxa2xx_rtc", 0x40900000,
- qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM));
+ qdev_get_gpio_in(s->pic, PXA2XX_PIC_RTCALARM),
+ NULL);
s->i2c[0] = pxa2xx_i2c_init(0x40301600,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_I2C), 0xffff);
diff --git a/hw/realview.c b/hw/realview.c
index 301739a..0f532d9 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -227,31 +227,31 @@ static void realview_init(ram_addr_t ram_size,
} else {
uint32_t gic_addr = is_pb ? 0x1e000000 : 0x10040000;
/* For now just create the nIRQ GIC, and ignore the others. */
- dev = sysbus_create_simple("realview_gic", gic_addr, cpu_irq[0]);
+ dev = sysbus_create_simple("realview_gic", gic_addr, cpu_irq[0], NULL);
}
for (n = 0; n < 64; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
- sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]);
- sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]);
+ sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20], NULL);
+ sysbus_create_simple("pl050_mouse", 0x10007000, pic[21], NULL);
- sysbus_create_simple("pl011", 0x10009000, pic[12]);
- sysbus_create_simple("pl011", 0x1000a000, pic[13]);
- sysbus_create_simple("pl011", 0x1000b000, pic[14]);
- sysbus_create_simple("pl011", 0x1000c000, pic[15]);
+ sysbus_create_simple("pl011", 0x10009000, pic[12], NULL);
+ sysbus_create_simple("pl011", 0x1000a000, pic[13], NULL);
+ sysbus_create_simple("pl011", 0x1000b000, pic[14], NULL);
+ sysbus_create_simple("pl011", 0x1000c000, pic[15], NULL);
/* DMA controller is optional, apparently. */
- sysbus_create_simple("pl081", 0x10030000, pic[24]);
+ sysbus_create_simple("pl081", 0x10030000, pic[24], NULL);
- sysbus_create_simple("sp804", 0x10011000, pic[4]);
- sysbus_create_simple("sp804", 0x10012000, pic[5]);
+ sysbus_create_simple("sp804", 0x10011000, pic[4], NULL);
+ sysbus_create_simple("sp804", 0x10012000, pic[5], NULL);
- sysbus_create_simple("pl061", 0x10013000, pic[6]);
- sysbus_create_simple("pl061", 0x10014000, pic[7]);
- gpio2 = sysbus_create_simple("pl061", 0x10015000, pic[8]);
+ sysbus_create_simple("pl061", 0x10013000, pic[6], NULL);
+ sysbus_create_simple("pl061", 0x10014000, pic[7], NULL);
+ gpio2 = sysbus_create_simple("pl061", 0x10015000, pic[8], NULL);
- sysbus_create_simple("pl111", 0x10020000, pic[23]);
+ sysbus_create_simple("pl111", 0x10020000, pic[23], NULL);
dev = sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL);
/* Wire up MMC card detect and read-only signals. These have
@@ -269,7 +269,7 @@ static void realview_init(ram_addr_t ram_size,
qdev_connect_gpio_out(dev, 0, mmc_irq[0]);
qdev_connect_gpio_out(dev, 1, mmc_irq[1]);
- sysbus_create_simple("pl031", 0x10017000, pic[10]);
+ sysbus_create_simple("pl031", 0x10017000, pic[10], NULL);
if (!is_pb) {
dev = sysbus_create_varargs("realview_pci", 0x60000000,
@@ -300,7 +300,7 @@ static void realview_init(ram_addr_t ram_size,
}
}
- dev = sysbus_create_simple("realview_i2c", 0x10002000, NULL);
+ dev = sysbus_create_simple("realview_i2c", 0x10002000, NULL, NULL);
i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
i2c_create_slave(i2c, "ds1338", 0x68);
diff --git a/hw/spitz.c b/hw/spitz.c
index 90183d4..ea49cdf 100644
--- a/hw/spitz.c
+++ b/hw/spitz.c
@@ -468,7 +468,7 @@ static void spitz_keyboard_register(PXA2xxState *cpu)
DeviceState *dev;
SpitzKeyboardState *s;
- dev = sysbus_create_simple("spitz-keyboard", -1, NULL);
+ dev = sysbus_create_simple("spitz-keyboard", -1, NULL, NULL);
s = FROM_SYSBUS(SpitzKeyboardState, sysbus_from_qdev(dev));
for (i = 0; i < SPITZ_KEY_SENSE_NUM; i ++)
@@ -913,9 +913,9 @@ static void spitz_common_init(ram_addr_t ram_size,
spitz_ssp_attach(cpu);
- scp0 = sysbus_create_simple("scoop", 0x10800000, NULL);
+ scp0 = sysbus_create_simple("scoop", 0x10800000, NULL, NULL);
if (model != akita) {
- scp1 = sysbus_create_simple("scoop", 0x08800040, NULL);
+ scp1 = sysbus_create_simple("scoop", 0x08800040, NULL, NULL);
}
spitz_scoop_gpio_setup(cpu, scp0, scp1);
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 2345692..8d344c8 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1290,7 +1290,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
if (board->dc2 & (0x10000 << i)) {
dev = sysbus_create_simple("stellaris-gptm",
0x40030000 + i * 0x1000,
- pic[timer_irq[i]]);
+ pic[timer_irq[i]], NULL);
/* TODO: This is incorrect, but we get away with it because
the ADC output is only ever pulsed. */
qdev_connect_gpio_out(dev, 0, adc);
@@ -1302,7 +1302,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
for (i = 0; i < 7; i++) {
if (board->dc4 & (1 << i)) {
gpio_dev[i] = sysbus_create_simple("pl061_luminary", gpio_addr[i],
- pic[gpio_irq[i]]);
+ pic[gpio_irq[i]], NULL);
for (j = 0; j < 8; j++) {
gpio_in[i][j] = qdev_get_gpio_in(gpio_dev[i], j);
gpio_out[i][j] = NULL;
@@ -1311,7 +1311,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
}
if (board->dc2 & (1 << 12)) {
- dev = sysbus_create_simple("stellaris-i2c", 0x40020000, pic[8]);
+ dev = sysbus_create_simple("stellaris-i2c", 0x40020000, pic[8], NULL);
i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
if (board->peripherals & BP_OLED_I2C) {
i2c_create_slave(i2c, "ssd0303", 0x3d);
@@ -1321,11 +1321,11 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
for (i = 0; i < 4; i++) {
if (board->dc2 & (1 << i)) {
sysbus_create_simple("pl011_luminary", 0x4000c000 + i * 0x1000,
- pic[uart_irq[i]]);
+ pic[uart_irq[i]], NULL);
}
}
if (board->dc2 & (1 << 4)) {
- dev = sysbus_create_simple("pl022", 0x40008000, pic[7]);
+ dev = sysbus_create_simple("pl022", 0x40008000, pic[7], NULL);
if (board->peripherals & BP_OLED_SSI) {
DeviceState *mux;
void *bus;
diff --git a/hw/strongarm.c b/hw/strongarm.c
index 2d98893..a532d52 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -1563,7 +1563,8 @@ StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
NULL);
sysbus_create_simple("strongarm-rtc", 0x90010000,
- qdev_get_gpio_in(s->pic, SA_PIC_RTC_ALARM));
+ qdev_get_gpio_in(s->pic, SA_PIC_RTC_ALARM),
+ NULL);
s->gpio = strongarm_gpio_init(0x90040000, s->pic);
diff --git a/hw/sun4m.c b/hw/sun4m.c
index ebf1dde..4e33228 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -938,7 +938,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
if (hwdef->cs_base) {
sysbus_create_simple("SUNW,CS4231", hwdef->cs_base,
- slavio_irq[5]);
+ slavio_irq[5], NULL);
}
if (hwdef->dbri_base) {
diff --git a/hw/syborg.c b/hw/syborg.c
index 5725f8a..9057578 100644
--- a/hw/syborg.c
+++ b/hw/syborg.c
@@ -55,12 +55,12 @@ static void syborg_init(ram_addr_t ram_size,
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_simple("syborg,interrupt", 0xC0000000,
- cpu_pic[ARM_PIC_CPU_IRQ]);
+ cpu_pic[ARM_PIC_CPU_IRQ], NULL);
for (i = 0; i < 64; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
- sysbus_create_simple("syborg,rtc", 0xC0001000, NULL);
+ sysbus_create_simple("syborg,rtc", 0xC0001000, NULL, NULL);
dev = qdev_create(NULL, "syborg,timer", NULL);
qdev_prop_set_uint32(dev, "frequency", 1000000);
@@ -68,13 +68,13 @@ static void syborg_init(ram_addr_t ram_size,
sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0xC0002000);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[1]);
- sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2]);
- sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3]);
- sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4]);
- sysbus_create_simple("syborg,serial", 0xC0006000, pic[5]);
- sysbus_create_simple("syborg,serial", 0xC0007000, pic[6]);
- sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]);
- sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]);
+ sysbus_create_simple("syborg,keyboard", 0xC0003000, pic[2], NULL);
+ sysbus_create_simple("syborg,pointer", 0xC0004000, pic[3], NULL);
+ sysbus_create_simple("syborg,framebuffer", 0xC0005000, pic[4], NULL);
+ sysbus_create_simple("syborg,serial", 0xC0006000, pic[5], NULL);
+ sysbus_create_simple("syborg,serial", 0xC0007000, pic[6], NULL);
+ sysbus_create_simple("syborg,serial", 0xC0008000, pic[7], NULL);
+ sysbus_create_simple("syborg,serial", 0xC0009000, pic[8], NULL);
if (nd_table[0].vlan || nd_table[0].netdev) {
DeviceState *dev;
diff --git a/hw/sysbus.h b/hw/sysbus.h
index 6c36537..536e667 100644
--- a/hw/sysbus.h
+++ b/hw/sysbus.h
@@ -73,8 +73,10 @@ DeviceState *sysbus_create_varargs(const char *name,
DeviceState *sysbus_try_create_varargs(const char *name,
target_phys_addr_t addr, ...);
static inline DeviceState *sysbus_create_simple(const char *name,
- target_phys_addr_t addr,
- qemu_irq irq)
+ target_phys_addr_t addr,
+ qemu_irq irq,
+ const char *id,
+ ...)
{
return sysbus_create_varargs(name, addr, irq, NULL);
}
diff --git a/hw/tosa.c b/hw/tosa.c
index 7b407f4..35b10ee 100644
--- a/hw/tosa.c
+++ b/hw/tosa.c
@@ -221,8 +221,8 @@ static void tosa_init(ram_addr_t ram_size,
tmio = tc6393xb_init(0x10000000,
qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_TC6393XB_INT));
- scp0 = sysbus_create_simple("scoop", 0x08800000, NULL);
- scp1 = sysbus_create_simple("scoop", 0x14800040, NULL);
+ scp0 = sysbus_create_simple("scoop", 0x08800000, NULL, NULL);
+ scp1 = sysbus_create_simple("scoop", 0x14800040, NULL, NULL);
tosa_gpio_setup(cpu, scp0, scp1, tmio);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index b713aac..8df18ec 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -210,14 +210,14 @@ static void versatile_init(ram_addr_t ram_size,
for (n = 0; n < 32; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
}
- dev = sysbus_create_simple("versatilepb_sic", 0x10003000, NULL);
+ dev = sysbus_create_simple("versatilepb_sic", 0x10003000, NULL, NULL);
for (n = 0; n < 32; n++) {
sysbus_connect_irq(sysbus_from_qdev(dev), n, pic[n]);
sic[n] = qdev_get_gpio_in(dev, n);
}
- sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]);
- sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]);
+ sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3], NULL);
+ sysbus_create_simple("pl050_mouse", 0x10007000, sic[4], NULL);
dev = sysbus_create_varargs("versatile_pci", 0x40000000,
sic[27], sic[28], sic[29], sic[30], NULL);
@@ -244,18 +244,18 @@ static void versatile_init(ram_addr_t ram_size,
n--;
}
- sysbus_create_simple("pl011", 0x101f1000, pic[12]);
- sysbus_create_simple("pl011", 0x101f2000, pic[13]);
- sysbus_create_simple("pl011", 0x101f3000, pic[14]);
- sysbus_create_simple("pl011", 0x10009000, sic[6]);
+ sysbus_create_simple("pl011", 0x101f1000, pic[12], NULL);
+ sysbus_create_simple("pl011", 0x101f2000, pic[13], NULL);
+ sysbus_create_simple("pl011", 0x101f3000, pic[14], NULL);
+ sysbus_create_simple("pl011", 0x10009000, sic[6], NULL);
- sysbus_create_simple("pl080", 0x10130000, pic[17]);
- sysbus_create_simple("sp804", 0x101e2000, pic[4]);
- sysbus_create_simple("sp804", 0x101e3000, pic[5]);
+ sysbus_create_simple("pl080", 0x10130000, pic[17], NULL);
+ sysbus_create_simple("sp804", 0x101e2000, pic[4], NULL);
+ sysbus_create_simple("sp804", 0x101e3000, pic[5], NULL);
/* The versatile/PB actually has a modified Color LCD controller
that includes hardware cursor support from the PL111. */
- dev = sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]);
+ dev = sysbus_create_simple("pl110_versatile", 0x10120000, pic[16], NULL);
/* Wire up the mux control signals from the SYS_CLCD register */
qdev_connect_gpio_out(sysctl, 0, qdev_get_gpio_in(dev, 0));
@@ -263,7 +263,7 @@ static void versatile_init(ram_addr_t ram_size,
sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL);
/* Add PL031 Real Time Clock. */
- sysbus_create_simple("pl031", 0x101e8000, pic[10]);
+ sysbus_create_simple("pl031", 0x101e8000, pic[10], NULL);
/* Memory map for Versatile/PB: */
/* 0x10000000 System registers. */
diff --git a/hw/vexpress.c b/hw/vexpress.c
index 191a5a2..47265da 100644
--- a/hw/vexpress.c
+++ b/hw/vexpress.c
@@ -126,22 +126,22 @@ static void vexpress_a9_init(ram_addr_t ram_size,
qdev_connect_gpio_out(dev, 1,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN));
- sysbus_create_simple("pl050_keyboard", 0x10006000, pic[12]);
- sysbus_create_simple("pl050_mouse", 0x10007000, pic[13]);
+ sysbus_create_simple("pl050_keyboard", 0x10006000, pic[12], NULL);
+ sysbus_create_simple("pl050_mouse", 0x10007000, pic[13], NULL);
- sysbus_create_simple("pl011", 0x10009000, pic[5]);
- sysbus_create_simple("pl011", 0x1000a000, pic[6]);
- sysbus_create_simple("pl011", 0x1000b000, pic[7]);
- sysbus_create_simple("pl011", 0x1000c000, pic[8]);
+ sysbus_create_simple("pl011", 0x10009000, pic[5], NULL);
+ sysbus_create_simple("pl011", 0x1000a000, pic[6], NULL);
+ sysbus_create_simple("pl011", 0x1000b000, pic[7], NULL);
+ sysbus_create_simple("pl011", 0x1000c000, pic[8], NULL);
/* 0x1000f000 SP805 WDT */
- sysbus_create_simple("sp804", 0x10011000, pic[2]);
- sysbus_create_simple("sp804", 0x10012000, pic[3]);
+ sysbus_create_simple("sp804", 0x10011000, pic[2], NULL);
+ sysbus_create_simple("sp804", 0x10012000, pic[3], NULL);
/* 0x10016000 Serial Bus DVI */
- sysbus_create_simple("pl031", 0x10017000, pic[4]); /* RTC */
+ sysbus_create_simple("pl031", 0x10017000, pic[4], NULL); /* RTC */
/* 0x1001a000 Compact Flash */
@@ -150,14 +150,14 @@ static void vexpress_a9_init(ram_addr_t ram_size,
/* Daughterboard peripherals : 0x10020000 .. 0x20000000 */
/* 0x10020000 PL111 CLCD (daughterboard) */
- sysbus_create_simple("pl111", 0x10020000, pic[44]);
+ sysbus_create_simple("pl111", 0x10020000, pic[44], NULL);
/* 0x10060000 AXI RAM */
/* 0x100e0000 PL341 Dynamic Memory Controller */
/* 0x100e1000 PL354 Static Memory Controller */
/* 0x100e2000 System Configuration Controller */
- sysbus_create_simple("sp804", 0x100e4000, pic[48]);
+ sysbus_create_simple("sp804", 0x100e4000, pic[48], NULL);
/* 0x100e5000 SP805 Watchdog module */
/* 0x100e6000 BP147 TrustZone Protection Controller */
/* 0x100e9000 PL301 'Fast' AXI matrix */
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 08/14] sysbus: make create_varargs take an id
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (6 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 07/14] sysbus: add an id argument to sysbus_create_simple() Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 09/14] fw_cfg: add name to global fw_cfg device Anthony Liguori
` (8 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
This is mostly mechanical but also changes sysbus_create_simple() in order to
call into the new create_varargs.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/axis_dev88.c | 4 +-
hw/integratorcp.c | 5 ++-
hw/musicpal.c | 3 +-
hw/pc.c | 2 +-
hw/ppce500_mpc8544ds.c | 2 +-
hw/pxa2xx.c | 4 +-
hw/r2d.c | 4 +-
hw/realview.c | 4 +-
hw/stellaris.c | 2 +-
hw/strongarm.c | 10 ++++---
hw/sysbus.c | 67 +++++++++++++++++++++++++++++++++++++++++++----
hw/sysbus.h | 33 ++++++++++++-----------
hw/versatilepb.c | 8 +++---
hw/vexpress.c | 2 +-
14 files changed, 105 insertions(+), 45 deletions(-)
diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c
index 6987387..e0982d9 100644
--- a/hw/axis_dev88.c
+++ b/hw/axis_dev88.c
@@ -330,8 +330,8 @@ void axisdev88_init (ram_addr_t ram_size,
}
/* 2 timers. */
- sysbus_create_varargs("etraxfs,timer", 0x3001e000, irq[0x1b], nmi[1], NULL);
- sysbus_create_varargs("etraxfs,timer", 0x3005e000, irq[0x1b], nmi[1], NULL);
+ sysbus_create_varargs("etraxfs,timer", 0x3001e000, NULL, irq[0x1b], nmi[1], NULL);
+ sysbus_create_varargs("etraxfs,timer", 0x3005e000, NULL, irq[0x1b], nmi[1], NULL);
for (i = 0; i < 4; i++) {
sysbus_create_simple("etraxfs,serial", 0x30026000 + i * 0x2000,
diff --git a/hw/integratorcp.c b/hw/integratorcp.c
index a163cf1..37ad898 100644
--- a/hw/integratorcp.c
+++ b/hw/integratorcp.c
@@ -502,13 +502,14 @@ static void integratorcp_init(ram_addr_t ram_size,
cpu_pic = arm_pic_init_cpu(env);
dev = sysbus_create_varargs("integrator_pic", 0x14000000,
+ NULL,
cpu_pic[ARM_PIC_CPU_IRQ],
cpu_pic[ARM_PIC_CPU_FIQ], NULL);
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
sysbus_create_simple("integrator_pic", 0xca000000, pic[26], NULL);
- sysbus_create_varargs("integrator_pit", 0x13000000,
+ sysbus_create_varargs("integrator_pit", 0x13000000, NULL,
pic[5], pic[6], pic[7], NULL);
sysbus_create_simple("pl031", 0x15000000, pic[8], NULL);
sysbus_create_simple("pl011", 0x16000000, pic[1], NULL);
@@ -516,7 +517,7 @@ static void integratorcp_init(ram_addr_t ram_size,
icp_control_init(0xcb000000);
sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3], NULL);
sysbus_create_simple("pl050_mouse", 0x19000000, pic[4], NULL);
- sysbus_create_varargs("pl181", 0x1c000000, pic[23], pic[24], NULL);
+ sysbus_create_varargs("pl181", 0x1c000000, NULL, pic[23], pic[24], NULL);
if (nd_table[0].vlan)
smc91c111_init(&nd_table[0], 0xc8000000, pic[27]);
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 1a4f865..edca3dc 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -1526,7 +1526,8 @@ static void musicpal_init(ram_addr_t ram_size,
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
- sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, pic[MP_TIMER1_IRQ],
+ sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, NULL,
+ pic[MP_TIMER1_IRQ],
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
pic[MP_TIMER4_IRQ], NULL);
diff --git a/hw/pc.c b/hw/pc.c
index a6d0f47..db5d5f3 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1132,7 +1132,7 @@ void pc_basic_device_init(qemu_irq *isa_irq,
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (!no_hpet) {
- DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL);
+ DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL, NULL);
if (hpet) {
for (i = 0; i < 24; i++) {
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index f2989a8..50c9e24 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -289,7 +289,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
sysbus_create_simple("mpc8544-guts", MPC8544_UTIL_BASE, NULL, NULL);
/* PCI */
- dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE,
+ dev = sysbus_create_varargs("e500-pcihost", MPC8544_PCI_REGS_BASE, NULL,
mpic[pci_irq_nrs[0]], mpic[pci_irq_nrs[1]],
mpic[pci_irq_nrs[2]], mpic[pci_irq_nrs[3]],
NULL);
diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c
index 089d54d..c3eddba 100644
--- a/hw/pxa2xx.c
+++ b/hw/pxa2xx.c
@@ -2093,7 +2093,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)
s->dma = pxa27x_dma_init(0x40000000,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_DMA));
- sysbus_create_varargs("pxa27x-timer", 0x40a00000,
+ sysbus_create_varargs("pxa27x-timer", 0x40a00000, NULL,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 0),
qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 1),
qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 2),
@@ -2232,7 +2232,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)
s->dma = pxa255_dma_init(0x40000000,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_DMA));
- sysbus_create_varargs("pxa25x-timer", 0x40a00000,
+ sysbus_create_varargs("pxa25x-timer", 0x40a00000, NULL,
qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 0),
qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 1),
qdev_get_gpio_in(s->pic, PXA2XX_PIC_OST_0 + 2),
diff --git a/hw/r2d.c b/hw/r2d.c
index b8b0df3..624e465 100644
--- a/hw/r2d.c
+++ b/hw/r2d.c
@@ -255,8 +255,8 @@ static void r2d_init(ram_addr_t ram_size,
/* Register peripherals */
s = sh7750_init(env);
irq = r2d_fpga_init(0x04000000, sh7750_irl(s));
- sysbus_create_varargs("sh_pci", 0x1e200000, irq[PCI_INTA], irq[PCI_INTB],
- irq[PCI_INTC], irq[PCI_INTD], NULL);
+ sysbus_create_varargs("sh_pci", 0x1e200000, NULL, irq[PCI_INTA],
+ irq[PCI_INTB], irq[PCI_INTC], irq[PCI_INTD], NULL);
sm501_init(0x10000000, SM501_VRAM_SIZE, irq[SM501], serial_hds[2]);
diff --git a/hw/realview.c b/hw/realview.c
index 0f532d9..4b33534 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -253,7 +253,7 @@ static void realview_init(ram_addr_t ram_size,
sysbus_create_simple("pl111", 0x10020000, pic[23], NULL);
- dev = sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL);
+ dev = sysbus_create_varargs("pl181", 0x10005000, NULL, pic[17], pic[18], NULL);
/* Wire up MMC card detect and read-only signals. These have
* to go to both the PL061 GPIO and the sysctl register.
* Note that the PL181 orders these lines (readonly,inserted)
@@ -272,7 +272,7 @@ static void realview_init(ram_addr_t ram_size,
sysbus_create_simple("pl031", 0x10017000, pic[10], NULL);
if (!is_pb) {
- dev = sysbus_create_varargs("realview_pci", 0x60000000,
+ dev = sysbus_create_varargs("realview_pci", 0x60000000, NULL,
pic[48], pic[49], pic[50], pic[51], NULL);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
if (usb_enabled) {
diff --git a/hw/stellaris.c b/hw/stellaris.c
index 8d344c8..cebd224 100644
--- a/hw/stellaris.c
+++ b/hw/stellaris.c
@@ -1280,7 +1280,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,
flash_size, sram_size, kernel_filename, cpu_model);
if (board->dc1 & (1 << 16)) {
- dev = sysbus_create_varargs("stellaris-adc", 0x40038000,
+ dev = sysbus_create_varargs("stellaris-adc", 0x40038000, NULL,
pic[14], pic[15], pic[16], pic[17], NULL);
adc = qdev_get_gpio_in(dev, 0);
} else {
diff --git a/hw/strongarm.c b/hw/strongarm.c
index a532d52..1255dfb 100644
--- a/hw/strongarm.c
+++ b/hw/strongarm.c
@@ -1552,10 +1552,10 @@ StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
sdram_size) | IO_MEM_RAM);
pic = arm_pic_init_cpu(s->env);
- s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000,
+ s->pic = sysbus_create_varargs("strongarm_pic", 0x90050000, NULL,
pic[ARM_PIC_CPU_IRQ], pic[ARM_PIC_CPU_FIQ], NULL);
- sysbus_create_varargs("pxa25x-timer", 0x90000000,
+ sysbus_create_varargs("pxa25x-timer", 0x90000000, NULL,
qdev_get_gpio_in(s->pic, SA_PIC_OSTC0),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC1),
qdev_get_gpio_in(s->pic, SA_PIC_OSTC2),
@@ -1568,7 +1568,7 @@ StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
s->gpio = strongarm_gpio_init(0x90040000, s->pic);
- s->ppc = sysbus_create_varargs("strongarm-ppc", 0x90060000, NULL);
+ s->ppc = sysbus_create_varargs("strongarm-ppc", 0x90060000, NULL, NULL);
for (i = 0; sa_serial[i].io_base; i++) {
DeviceState *dev = qdev_create(NULL, "strongarm-uart", NULL);
@@ -1581,7 +1581,9 @@ StrongARMState *sa1110_init(unsigned int sdram_size, const char *rev)
}
s->ssp = sysbus_create_varargs("strongarm-ssp", 0x80070000,
- qdev_get_gpio_in(s->pic, SA_PIC_SSP), NULL);
+ NULL,
+ qdev_get_gpio_in(s->pic, SA_PIC_SSP),
+ NULL);
s->ssp_bus = (SSIBus *)qdev_get_child_bus(s->ssp, "ssi");
return s;
diff --git a/hw/sysbus.c b/hw/sysbus.c
index 7809aa1..f756731 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -174,7 +174,8 @@ void sysbus_register_dev(const char *name, size_t size, sysbus_initfn init)
}
DeviceState *sysbus_create_varargs(const char *name,
- target_phys_addr_t addr, ...)
+ target_phys_addr_t addr,
+ const char *id, ...)
{
DeviceState *dev;
SysBusDevice *s;
@@ -182,13 +183,18 @@ DeviceState *sysbus_create_varargs(const char *name,
qemu_irq irq;
int n;
- dev = qdev_create(NULL, name, NULL);
+ if (id) {
+ dev = qdev_create(NULL, name, "%s", id);
+ } else {
+ dev = qdev_create(NULL, name, NULL);
+ }
+
s = sysbus_from_qdev(dev);
qdev_init_nofail(dev);
if (addr != (target_phys_addr_t)-1) {
sysbus_mmio_map(s, 0, addr);
}
- va_start(va, addr);
+ va_start(va, id);
n = 0;
while (1) {
irq = va_arg(va, qemu_irq);
@@ -201,8 +207,57 @@ DeviceState *sysbus_create_varargs(const char *name,
return dev;
}
+DeviceState *sysbus_create_simple(const char *name,
+ target_phys_addr_t addr,
+ qemu_irq irq,
+ const char *id,
+ ...)
+{
+ DeviceState *dev;
+ char *fullname;
+ va_list ap;
+
+ va_start(ap, id);
+ if (id) {
+ fullname = g_strdup_vprintf(id, ap);
+ } else {
+ fullname = g_strdup("");
+ }
+ va_end(ap);
+
+ dev = sysbus_create_varargs(name, addr, fullname, irq, NULL);
+ g_free(fullname);
+
+ return dev;
+}
+
+DeviceState *sysbus_try_create_simple(const char *name,
+ target_phys_addr_t addr,
+ qemu_irq irq,
+ const char *id,
+ ...)
+{
+ DeviceState *dev;
+ char *fullname;
+ va_list ap;
+
+ va_start(ap, id);
+ if (id) {
+ fullname = g_strdup_vprintf(id, ap);
+ } else {
+ fullname = g_strdup("");
+ }
+ va_end(ap);
+
+ dev = sysbus_try_create_varargs(name, addr, fullname, irq, NULL);
+ g_free(fullname);
+
+ return dev;
+}
+
DeviceState *sysbus_try_create_varargs(const char *name,
- target_phys_addr_t addr, ...)
+ target_phys_addr_t addr,
+ const char *id, ...)
{
DeviceState *dev;
SysBusDevice *s;
@@ -210,7 +265,7 @@ DeviceState *sysbus_try_create_varargs(const char *name,
qemu_irq irq;
int n;
- dev = qdev_try_create(NULL, name, NULL);
+ dev = qdev_try_create(NULL, name, "%s", id);
if (!dev) {
return NULL;
}
@@ -219,7 +274,7 @@ DeviceState *sysbus_try_create_varargs(const char *name,
if (addr != (target_phys_addr_t)-1) {
sysbus_mmio_map(s, 0, addr);
}
- va_start(va, addr);
+ va_start(va, id);
n = 0;
while (1) {
irq = va_arg(va, qemu_irq);
diff --git a/hw/sysbus.h b/hw/sysbus.h
index 536e667..6f01d18 100644
--- a/hw/sysbus.h
+++ b/hw/sysbus.h
@@ -69,23 +69,24 @@ void sysbus_del_io(SysBusDevice *dev, MemoryRegion *mem);
/* Legacy helper function for creating devices. */
DeviceState *sysbus_create_varargs(const char *name,
- target_phys_addr_t addr, ...);
+ target_phys_addr_t addr,
+ const char *id, ...);
DeviceState *sysbus_try_create_varargs(const char *name,
- target_phys_addr_t addr, ...);
-static inline DeviceState *sysbus_create_simple(const char *name,
- target_phys_addr_t addr,
- qemu_irq irq,
- const char *id,
- ...)
-{
- return sysbus_create_varargs(name, addr, irq, NULL);
-}
+ target_phys_addr_t addr,
+ const char *id, ...);
-static inline DeviceState *sysbus_try_create_simple(const char *name,
- target_phys_addr_t addr,
- qemu_irq irq)
-{
- return sysbus_try_create_varargs(name, addr, irq, NULL);
-}
+DeviceState *sysbus_create_simple(const char *name,
+ target_phys_addr_t addr,
+ qemu_irq irq,
+ const char *id,
+ ...)
+ GCC_FMT_ATTR(4, 5);
+
+DeviceState *sysbus_try_create_simple(const char *name,
+ target_phys_addr_t addr,
+ qemu_irq irq,
+ const char *id,
+ ...)
+ GCC_FMT_ATTR(4, 5);
#endif /* !HW_SYSBUS_H */
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 8df18ec..c753d1f 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -205,7 +205,7 @@ static void versatile_init(ram_addr_t ram_size,
sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, 0x10000000);
cpu_pic = arm_pic_init_cpu(env);
- dev = sysbus_create_varargs("pl190", 0x10140000,
+ dev = sysbus_create_varargs("pl190", 0x10140000, NULL,
cpu_pic[0], cpu_pic[1], NULL);
for (n = 0; n < 32; n++) {
pic[n] = qdev_get_gpio_in(dev, n);
@@ -219,7 +219,7 @@ static void versatile_init(ram_addr_t ram_size,
sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3], NULL);
sysbus_create_simple("pl050_mouse", 0x10007000, sic[4], NULL);
- dev = sysbus_create_varargs("versatile_pci", 0x40000000,
+ dev = sysbus_create_varargs("versatile_pci", 0x40000000, NULL,
sic[27], sic[28], sic[29], sic[30], NULL);
pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
@@ -259,8 +259,8 @@ static void versatile_init(ram_addr_t ram_size,
/* Wire up the mux control signals from the SYS_CLCD register */
qdev_connect_gpio_out(sysctl, 0, qdev_get_gpio_in(dev, 0));
- sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL);
- sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL);
+ sysbus_create_varargs("pl181", 0x10005000, NULL, sic[22], sic[1], NULL);
+ sysbus_create_varargs("pl181", 0x1000b000, NULL, sic[23], sic[2], NULL);
/* Add PL031 Real Time Clock. */
sysbus_create_simple("pl031", 0x101e8000, pic[10], NULL);
diff --git a/hw/vexpress.c b/hw/vexpress.c
index 47265da..b9ad2de 100644
--- a/hw/vexpress.c
+++ b/hw/vexpress.c
@@ -119,7 +119,7 @@ static void vexpress_a9_init(ram_addr_t ram_size,
/* 0x10002000 serial bus PCI */
/* 0x10004000 PL041 audio */
- dev = sysbus_create_varargs("pl181", 0x10005000, pic[9], pic[10], NULL);
+ dev = sysbus_create_varargs("pl181", 0x10005000, NULL, pic[9], pic[10], NULL);
/* Wire up MMC card detect and read-only signals */
qdev_connect_gpio_out(dev, 0,
qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT));
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 09/14] fw_cfg: add name to global fw_cfg device
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (7 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 08/14] sysbus: make create_varargs take an id Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 10/14] isa: add name parameter to device creation Anthony Liguori
` (7 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/fw_cfg.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index e2193d5..e37a427 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -484,7 +484,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
SysBusDevice *d;
FWCfgState *s;
- dev = qdev_create(NULL, "fw_cfg", NULL);
+ dev = qdev_create(NULL, "fw_cfg", "::fw_cfg");
qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port);
qdev_prop_set_uint32(dev, "data_iobase", data_port);
qdev_init_nofail(dev);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 10/14] isa: add name parameter to device creation
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (8 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 09/14] fw_cfg: add name to global fw_cfg device Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 11/14] pci: obtain devfn before initializing the device Anthony Liguori
` (6 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
This is mostly mechanical minus the changes to isa_simple_create()
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/cs4231a.c | 2 +-
hw/fdc.h | 2 +-
hw/gus.c | 2 +-
hw/ide/isa.c | 2 +-
hw/isa-bus.c | 30 ++++++++++++++++++++++++------
hw/isa.h | 9 ++++++---
hw/m48t59.c | 2 +-
hw/mc146818rtc.c | 2 +-
hw/mips_fulong2e.c | 2 +-
hw/mips_malta.c | 2 +-
hw/mips_r4k.c | 2 +-
hw/pc.c | 8 ++++----
hw/pc.h | 12 ++++++------
hw/ppc_prep.c | 2 +-
hw/sb16.c | 2 +-
hw/sun4u.c | 2 +-
16 files changed, 52 insertions(+), 31 deletions(-)
diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index 598f032..802be0f 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -661,7 +661,7 @@ static int cs4231a_initfn (ISADevice *dev)
int cs4231a_init (qemu_irq *pic)
{
- isa_create_simple ("cs4231a");
+ isa_create_simple ("cs4231a", NULL);
return 0;
}
diff --git a/hw/fdc.h b/hw/fdc.h
index 09f73c6..98a12c0 100644
--- a/hw/fdc.h
+++ b/hw/fdc.h
@@ -11,7 +11,7 @@ static inline void fdctrl_init_isa(DriveInfo **fds)
{
ISADevice *dev;
- dev = isa_try_create("isa-fdc");
+ dev = isa_try_create("isa-fdc", NULL);
if (!dev) {
return;
}
diff --git a/hw/gus.c b/hw/gus.c
index 37e543a..c22659e 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -296,7 +296,7 @@ static int gus_initfn (ISADevice *dev)
int GUS_init (qemu_irq *pic)
{
- isa_create_simple ("gus");
+ isa_create_simple ("gus", NULL);
return 0;
}
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 28b69d2..46cadde 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -81,7 +81,7 @@ ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
ISADevice *dev;
ISAIDEState *s;
- dev = isa_create("isa-ide");
+ dev = isa_create("isa-ide", NULL);
qdev_prop_set_uint32(&dev->qdev, "iobase", iobase);
qdev_prop_set_uint32(&dev->qdev, "iobase2", iobase2);
qdev_prop_set_uint32(&dev->qdev, "irq", isairq);
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 31d4d01..fb81737 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -124,7 +124,7 @@ void isa_qdev_register(ISADeviceInfo *info)
qdev_register(&info->qdev);
}
-ISADevice *isa_create(const char *name)
+static ISADevice *isa_createv(const char *name, const char *id, va_list ap)
{
DeviceState *dev;
@@ -132,27 +132,45 @@ ISADevice *isa_create(const char *name)
hw_error("Tried to create isa device %s with no isa bus present.",
name);
}
- dev = qdev_create(&isabus->qbus, name, NULL);
+ dev = qdev_createv(&isabus->qbus, name, id, ap);
return DO_UPCAST(ISADevice, qdev, dev);
}
-ISADevice *isa_try_create(const char *name)
+ISADevice *isa_create(const char *name, const char *id, ...)
+{
+ ISADevice *dev;
+ va_list ap;
+
+ va_start(ap, id);
+ dev = isa_createv(name, id, ap);
+ va_end(ap);
+
+ return dev;
+}
+
+ISADevice *isa_try_create(const char *name, const char *id, ...)
{
DeviceState *dev;
+ va_list ap;
if (!isabus) {
hw_error("Tried to create isa device %s with no isa bus present.",
name);
}
- dev = qdev_try_create(&isabus->qbus, name, NULL);
+ va_start(ap, id);
+ dev = qdev_try_create(&isabus->qbus, name, id, ap);
+ va_end(ap);
return DO_UPCAST(ISADevice, qdev, dev);
}
-ISADevice *isa_create_simple(const char *name)
+ISADevice *isa_create_simple(const char *name, const char *id, ...)
{
ISADevice *dev;
+ va_list ap;
- dev = isa_create(name);
+ va_start(ap, id);
+ dev = isa_create(name, id, ap);
+ va_end(ap);
qdev_init_nofail(&dev->qdev);
return dev;
}
diff --git a/hw/isa.h b/hw/isa.h
index f344699..26264d6 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -33,9 +33,12 @@ void isa_init_ioport(ISADevice *dev, uint16_t ioport);
void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
void isa_qdev_register(ISADeviceInfo *info);
MemoryRegion *isa_address_space(ISADevice *dev);
-ISADevice *isa_create(const char *name);
-ISADevice *isa_try_create(const char *name);
-ISADevice *isa_create_simple(const char *name);
+ISADevice *isa_create(const char *name, const char *id, ...)
+ GCC_FMT_ATTR(2, 3);
+ISADevice *isa_try_create(const char *name, const char *id, ...)
+ GCC_FMT_ATTR(2, 3);
+ISADevice *isa_create_simple(const char *name, const char *id, ...)
+ GCC_FMT_ATTR(2, 3);
extern target_phys_addr_t isa_mem_base;
diff --git a/hw/m48t59.c b/hw/m48t59.c
index 50927b7..d1950f7 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -661,7 +661,7 @@ M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type)
ISADevice *dev;
M48t59State *s;
- dev = isa_create("m48t59_isa");
+ dev = isa_create("m48t59_isa", NULL);
qdev_prop_set_uint32(&dev->qdev, "type", type);
qdev_prop_set_uint32(&dev->qdev, "size", size);
qdev_prop_set_uint32(&dev->qdev, "io_base", io_base);
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index feb3b25..cf46d6e 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -646,7 +646,7 @@ ISADevice *rtc_init(int base_year, qemu_irq intercept_irq)
ISADevice *dev;
RTCState *s;
- dev = isa_create("mc146818rtc");
+ dev = isa_create("mc146818rtc", NULL);
s = DO_UPCAST(RTCState, dev, dev);
qdev_prop_set_int32(&dev->qdev, "base_year", base_year);
qdev_init_nofail(&dev->qdev);
diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c
index f52b8c5..55f7bfd 100644
--- a/hw/mips_fulong2e.c
+++ b/hw/mips_fulong2e.c
@@ -363,7 +363,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
DMA_init(0, cpu_exit_irq);
/* Super I/O */
- isa_create_simple("i8042");
+ isa_create_simple("i8042", NULL);
rtc_init(2000, NULL);
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index e7cdf20..81503ff 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -952,7 +952,7 @@ void mips_malta_init (ram_addr_t ram_size,
DMA_init(0, cpu_exit_irq);
/* Super I/O */
- isa_create_simple("i8042");
+ isa_create_simple("i8042", NULL);
rtc_init(2000, NULL);
serial_isa_init(0, serial_hds[0]);
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 5d002c5..ac54d6b 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -294,7 +294,7 @@ void mips_r4k_init (ram_addr_t ram_size,
hd[MAX_IDE_DEVS * i],
hd[MAX_IDE_DEVS * i + 1]);
- isa_create_simple("i8042");
+ isa_create_simple("i8042", NULL);
}
static QEMUMachine mips_machine = {
diff --git a/hw/pc.c b/hw/pc.c
index db5d5f3..cc9f857 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1103,7 +1103,7 @@ void pc_vga_init(PCIBus *pci_bus)
* For nographic case, sga is enabled at all times
*/
if (display_type == DT_NOGRAPHIC) {
- isa_create_simple("sga");
+ isa_create_simple("sga", NULL);
}
}
@@ -1161,11 +1161,11 @@ void pc_basic_device_init(qemu_irq *isa_irq,
}
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
- i8042 = isa_create_simple("i8042");
+ i8042 = isa_create_simple("i8042", NULL);
i8042_setup_a20_line(i8042, &a20_line[0]);
if (!no_vmport) {
vmport_init();
- vmmouse = isa_try_create("vmmouse");
+ vmmouse = isa_try_create("vmmouse", NULL);
} else {
vmmouse = NULL;
}
@@ -1173,7 +1173,7 @@ void pc_basic_device_init(qemu_irq *isa_irq,
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
qdev_init_nofail(&vmmouse->qdev);
}
- port92 = isa_create_simple("port92");
+ port92 = isa_create_simple("port92", NULL);
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
diff --git a/hw/pc.h b/hw/pc.h
index dae736e..77ec26f 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -23,7 +23,7 @@ static inline bool serial_isa_init(int index, CharDriverState *chr)
{
ISADevice *dev;
- dev = isa_try_create("isa-serial");
+ dev = isa_try_create("isa-serial", NULL);
if (!dev) {
return false;
}
@@ -42,7 +42,7 @@ static inline bool parallel_init(int index, CharDriverState *chr)
{
ISADevice *dev;
- dev = isa_try_create("isa-parallel");
+ dev = isa_try_create("isa-parallel", NULL);
if (!dev) {
return false;
}
@@ -88,7 +88,7 @@ static inline ISADevice *pit_init(int base, int irq)
{
ISADevice *dev;
- dev = isa_create("isa-pit");
+ dev = isa_create("isa-pit", NULL);
qdev_prop_set_uint32(&dev->qdev, "iobase", base);
qdev_prop_set_uint32(&dev->qdev, "irq", irq);
qdev_init_nofail(&dev->qdev);
@@ -108,7 +108,7 @@ void hpet_pit_enable(void);
/* vmport.c */
static inline void vmport_init(void)
{
- isa_create_simple("vmport");
+ isa_create_simple("vmport", NULL);
}
void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque);
void vmmouse_get_data(uint32_t *data);
@@ -208,7 +208,7 @@ static inline int isa_vga_init(void)
{
ISADevice *dev;
- dev = isa_try_create("isa-vga");
+ dev = isa_try_create("isa-vga", NULL);
if (!dev) {
fprintf(stderr, "Warning: isa-vga not available\n");
return 0;
@@ -233,7 +233,7 @@ static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd)
qemu_check_nic_model(nd, "ne2k_isa");
- dev = isa_try_create("ne2k_isa");
+ dev = isa_try_create("ne2k_isa", NULL);
if (!dev) {
return false;
}
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 515de42..b5f40c9 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -688,7 +688,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
hd[2 * i],
hd[2 * i + 1]);
}
- isa_create_simple("i8042");
+ isa_create_simple("i8042", NULL);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
DMA_init(1, cpu_exit_irq);
diff --git a/hw/sb16.c b/hw/sb16.c
index a76df1b..a92a5d1 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -1393,7 +1393,7 @@ static int sb16_initfn (ISADevice *dev)
int SB16_init (qemu_irq *pic)
{
- isa_create_simple ("sb16");
+ isa_create_simple ("sb16", NULL);
return 0;
}
diff --git a/hw/sun4u.c b/hw/sun4u.c
index ab6020f..ff9088e 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -794,7 +794,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
pci_cmd646_ide_init(pci_bus, hd, 1);
- isa_create_simple("i8042");
+ isa_create_simple("i8042", NULL);
for(i = 0; i < MAX_FD; i++) {
fd[i] = drive_get(IF_FLOPPY, 0, i);
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 11/14] pci: obtain devfn before initializing the device
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (9 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 10/14] isa: add name parameter to device creation Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 12/14] pci: give pci devices a default name Anthony Liguori
` (5 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
We need devfn to be allocated before the device is initialized in order to
derive the name from the devfn.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/pci.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 67efbb2..abad900 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -731,14 +731,8 @@ static void pci_config_free(PCIDevice *pci_dev)
g_free(pci_dev->used);
}
-/* -1 for devfn means auto assign */
-static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
- const char *name, int devfn,
- const PCIDeviceInfo *info)
+static int pci_assign_devfn(PCIBus *bus, int devfn, const char *name)
{
- PCIConfigReadFunc *config_read = info->config_read;
- PCIConfigWriteFunc *config_write = info->config_write;
-
if (devfn < 0) {
for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices);
devfn += PCI_FUNC_MAX) {
@@ -746,13 +740,30 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
goto found;
}
error_report("PCI: no slot/function available for %s, all in use", name);
- return NULL;
+ return -1;
found: ;
} else if (bus->devices[devfn]) {
error_report("PCI: slot %d function %d not available for %s, in use by %s",
PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name);
+ return -1;
+ }
+
+ return devfn;
+}
+
+/* -1 for devfn means auto assign */
+static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus,
+ const char *name, int devfn,
+ const PCIDeviceInfo *info)
+{
+ PCIConfigReadFunc *config_read = info->config_read;
+ PCIConfigWriteFunc *config_write = info->config_write;
+
+ devfn = pci_assign_devfn(bus, devfn, name);
+ if (devfn == -1) {
return NULL;
}
+
pci_dev->bus = bus;
pci_dev->devfn = devfn;
pstrcpy(pci_dev->name, sizeof(pci_dev->name), name);
@@ -1723,7 +1734,10 @@ PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
{
DeviceState *dev;
+ devfn = pci_assign_devfn(bus, devfn, name);
+
dev = qdev_create(&bus->qbus, name, NULL);
+
qdev_prop_set_uint32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
return DO_UPCAST(PCIDevice, qdev, dev);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 12/14] pci: give pci devices a default name.
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (10 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 11/14] pci: obtain devfn before initializing the device Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 13/14] ide: give IDE drives a default name in qdev Anthony Liguori
` (4 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
Bus names are derived from names so now that PCI devices have a name, they also
have different bus names.
pc_piix relies on the bus name (*sigh*) so we need to update it.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/pc_piix.c | 6 ++++--
hw/pci.c | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 960589a..8f0ebd6 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -181,8 +181,10 @@ static void pc_init1(MemoryRegion *system_memory,
} else {
dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
}
- idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
- idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
+ idebus[0] = qdev_get_child_bus(&dev->qdev,
+ "::i440fx::i440fx.0::slot[1.1].0");
+ idebus[1] = qdev_get_child_bus(&dev->qdev,
+ "::i440fx::i440fx.0::slot[1.1].1");
} else {
for(i = 0; i < MAX_IDE_BUS; i++) {
ISADevice *dev;
diff --git a/hw/pci.c b/hw/pci.c
index abad900..b889ac3 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1736,7 +1736,8 @@ PCIDevice *pci_create_multifunction(PCIBus *bus, int devfn, bool multifunction,
devfn = pci_assign_devfn(bus, devfn, name);
- dev = qdev_create(&bus->qbus, name, NULL);
+ dev = qdev_create(&bus->qbus, name, "::slot[%d.%d]",
+ (devfn >> 3) & 0x1F, (devfn & 0x7));
qdev_prop_set_uint32(dev, "addr", devfn);
qdev_prop_set_bit(dev, "multifunction", multifunction);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 13/14] ide: give IDE drives a default name in qdev
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (11 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 12/14] pci: give pci devices a default name Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 14/14] pc: assign names to machine created devices Anthony Liguori
` (3 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/ide/qdev.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 8c868b5..760314c 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -102,7 +102,8 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive)
{
DeviceState *dev;
- dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd", NULL);
+ dev = qdev_create(&bus->qbus, drive->media_cd ? "ide-cd" : "ide-hd",
+ "::drive[%d]", unit);
qdev_prop_set_uint32(dev, "unit", unit);
qdev_prop_set_drive_nofail(dev, "drive", drive->bdrv);
qdev_init_nofail(dev);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [Qemu-devel] [PATCH 14/14] pc: assign names to machine created devices
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (12 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 13/14] ide: give IDE drives a default name in qdev Anthony Liguori
@ 2011-09-16 16:00 ` Anthony Liguori
2011-09-16 16:22 ` [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (2 subsequent siblings)
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:00 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, Markus Armbruster,
Paolo Bonzini
This gives names to all of the devices created by the PC machine. This need to
be unique to the pc, but not necessarily unique to the device.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/fdc.h | 2 +-
hw/kvmclock.c | 2 +-
hw/pc.c | 11 ++++++-----
hw/pc.h | 12 ++++++------
hw/pc_piix.c | 2 +-
hw/piix_pci.c | 2 +-
hw/smbus_eeprom.c | 3 ++-
7 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/hw/fdc.h b/hw/fdc.h
index 98a12c0..6545540 100644
--- a/hw/fdc.h
+++ b/hw/fdc.h
@@ -11,7 +11,7 @@ static inline void fdctrl_init_isa(DriveInfo **fds)
{
ISADevice *dev;
- dev = isa_try_create("isa-fdc", NULL);
+ dev = isa_try_create("isa-fdc", "::fdc");
if (!dev) {
return;
}
diff --git a/hw/kvmclock.c b/hw/kvmclock.c
index f920b10..193430d 100644
--- a/hw/kvmclock.c
+++ b/hw/kvmclock.c
@@ -103,7 +103,7 @@ void kvmclock_create(void)
if (kvm_enabled() &&
first_cpu->cpuid_kvm_features & ((1ULL << KVM_FEATURE_CLOCKSOURCE) |
(1ULL << KVM_FEATURE_CLOCKSOURCE2))) {
- sysbus_create_simple("kvmclock", -1, NULL, NULL);
+ sysbus_create_simple("kvmclock", -1, NULL, "::kvmclock");
}
}
diff --git a/hw/pc.c b/hw/pc.c
index cc9f857..7d112b1 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1103,7 +1103,7 @@ void pc_vga_init(PCIBus *pci_bus)
* For nographic case, sga is enabled at all times
*/
if (display_type == DT_NOGRAPHIC) {
- isa_create_simple("sga", NULL);
+ isa_create_simple("sga", "::sga");
}
}
@@ -1132,7 +1132,8 @@ void pc_basic_device_init(qemu_irq *isa_irq,
register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
if (!no_hpet) {
- DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL, NULL);
+ DeviceState *hpet = sysbus_try_create_simple("hpet", HPET_BASE, NULL,
+ "::hpet");
if (hpet) {
for (i = 0; i < 24; i++) {
@@ -1161,11 +1162,11 @@ void pc_basic_device_init(qemu_irq *isa_irq,
}
a20_line = qemu_allocate_irqs(handle_a20_line_change, first_cpu, 2);
- i8042 = isa_create_simple("i8042", NULL);
+ i8042 = isa_create_simple("i8042", "::i8042");
i8042_setup_a20_line(i8042, &a20_line[0]);
if (!no_vmport) {
vmport_init();
- vmmouse = isa_try_create("vmmouse", NULL);
+ vmmouse = isa_try_create("vmmouse", "::vmmouse");
} else {
vmmouse = NULL;
}
@@ -1173,7 +1174,7 @@ void pc_basic_device_init(qemu_irq *isa_irq,
qdev_prop_set_ptr(&vmmouse->qdev, "ps2_mouse", i8042);
qdev_init_nofail(&vmmouse->qdev);
}
- port92 = isa_create_simple("port92", NULL);
+ port92 = isa_create_simple("port92", "::port92");
port92_init(port92, &a20_line[1]);
cpu_exit_irq = qemu_allocate_irqs(cpu_request_exit, NULL, 1);
diff --git a/hw/pc.h b/hw/pc.h
index 77ec26f..e103aa2 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -23,7 +23,7 @@ static inline bool serial_isa_init(int index, CharDriverState *chr)
{
ISADevice *dev;
- dev = isa_try_create("isa-serial", NULL);
+ dev = isa_try_create("isa-serial", "::ttyS%d", index);
if (!dev) {
return false;
}
@@ -42,7 +42,7 @@ static inline bool parallel_init(int index, CharDriverState *chr)
{
ISADevice *dev;
- dev = isa_try_create("isa-parallel", NULL);
+ dev = isa_try_create("isa-parallel", "::ppt%d", index);
if (!dev) {
return false;
}
@@ -88,7 +88,7 @@ static inline ISADevice *pit_init(int base, int irq)
{
ISADevice *dev;
- dev = isa_create("isa-pit", NULL);
+ dev = isa_create("isa-pit", "::pit");
qdev_prop_set_uint32(&dev->qdev, "iobase", base);
qdev_prop_set_uint32(&dev->qdev, "irq", irq);
qdev_init_nofail(&dev->qdev);
@@ -108,7 +108,7 @@ void hpet_pit_enable(void);
/* vmport.c */
static inline void vmport_init(void)
{
- isa_create_simple("vmport", NULL);
+ isa_create_simple("vmport", "::vmport");
}
void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque);
void vmmouse_get_data(uint32_t *data);
@@ -208,7 +208,7 @@ static inline int isa_vga_init(void)
{
ISADevice *dev;
- dev = isa_try_create("isa-vga", NULL);
+ dev = isa_try_create("isa-vga", "::vga");
if (!dev) {
fprintf(stderr, "Warning: isa-vga not available\n");
return 0;
@@ -233,7 +233,7 @@ static inline bool isa_ne2000_init(int base, int irq, NICInfo *nd)
qemu_check_nic_model(nd, "ne2k_isa");
- dev = isa_try_create("ne2k_isa", NULL);
+ dev = isa_try_create("ne2k_isa", "::ne2k@0x%x", base);
if (!dev) {
return false;
}
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 8f0ebd6..91ed44d 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -59,7 +59,7 @@ static void ioapic_init(IsaIrqState *isa_irq_state)
SysBusDevice *d;
unsigned int i;
- dev = qdev_create(NULL, "ioapic", NULL);
+ dev = qdev_create(NULL, "ioapic", "::ioapic");
qdev_init_nofail(dev);
d = sysbus_from_qdev(dev);
sysbus_mmio_map(d, 0, 0xfec00000);
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 14ebcee..5b4b889 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -281,7 +281,7 @@ static PCIBus *i440fx_common_init(const char *device_name,
PIIX3State *piix3;
PCII440FXState *f;
- dev = qdev_create(NULL, "i440FX-pcihost", NULL);
+ dev = qdev_create(NULL, "i440FX-pcihost", "::i440fx");
s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev));
s->address_space = address_space_mem;
b = pci_bus_new(&s->busdev.qdev, NULL, pci_address_space,
diff --git a/hw/smbus_eeprom.c b/hw/smbus_eeprom.c
index ea7c123..3c3d619 100644
--- a/hw/smbus_eeprom.c
+++ b/hw/smbus_eeprom.c
@@ -137,7 +137,8 @@ void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
for (i = 0; i < nb_eeprom; i++) {
DeviceState *eeprom;
- eeprom = qdev_create((BusState *)smbus, "smbus-eeprom", NULL);
+ eeprom = qdev_create((BusState *)smbus, "smbus-eeprom",
+ "::eeprom[%d]", i);
qdev_prop_set_uint8(eeprom, "address", 0x50 + i);
qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
qdev_init_nofail(eeprom);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (13 preceding siblings ...)
2011-09-16 16:00 ` [Qemu-devel] [PATCH 14/14] pc: assign names to machine created devices Anthony Liguori
@ 2011-09-16 16:22 ` Anthony Liguori
2011-09-16 16:48 ` Jan Kiszka
2011-09-17 18:41 ` Blue Swirl
16 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:22 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Paolo Bonzini, qemu-devel, Markus Armbruster,
Jan Kiszka
On 09/16/2011 11:00 AM, Anthony Liguori wrote:
> This series introduces an infrastructure to remove anonymous devices from qdev.
> Anonymous devices are one of the big gaps between qdev and QOM so removing is
> a prerequisite to incrementally merging QOM.
>
> Besides the infrastructure, I also converted almost all of the possible PC
> devices to have unique names. Please not that naming is not a property of
> devices but rather of the thing that creates the devices (usually machines).
>
> The names are ugly but this is because of the alternating device/bus hierarchy
> in qdev. For now, the names use '::' as deliminators but I think Jan has
> convinced me that down the road, we should use '/' as a deliminator such that
> the resulting names are actually valid paths (using a canonical path format).
>
>
Here's a diffstat:
apb_pci.c | 2
apic.c | 2
arm11mpcore.c | 4 -
arm_sysctl.c | 2
armv7m.c | 6 +-
axis_dev88.c | 8 +--
bonito.c | 2
collie.c | 2
cs4231a.c | 2
empty_slot.c | 2
escc.c | 4 -
esp.c | 2
etraxfs.h | 2
fdc.c | 4 -
fdc.h | 2
fw_cfg.c | 2
grackle_pci.c | 2
grlib.h | 6 +-
gt64xxx.c | 2
gus.c | 2
i2c.c | 2
ide/isa.c | 2
ide/qdev.c | 3 -
integratorcp.c | 21 +++++-----
intel-hda.c | 2
isa-bus.c | 32 +++++++++++----
isa.h | 9 ++--
kvmclock.c | 2
lan9118.c | 2
lm32.h | 4 -
lm32_boards.c | 14 +++---
m48t59.c | 4 -
mainstone.c | 2
mc146818rtc.c | 2
milkymist-hw.h | 22 +++++-----
mips_fulong2e.c | 2
mips_jazz.c | 4 -
mips_malta.c | 2
mips_mipssim.c | 2
mips_r4k.c | 2
musicpal.c | 21 +++++-----
nand.c | 2
nseries.c | 4 -
omap1.c | 2
omap2.c | 2
pc.c | 15 +++----
pc.h | 12 ++---
pc_piix.c | 8 ++-
pci.c | 35 +++++++++++-----
petalogix_s3adsp1800_mmu.c | 2
piix_pci.c | 2
ppc_prep.c | 2
ppce500_mpc8544ds.c | 4 -
pxa2xx.c | 24 +++++++----
pxa2xx_dma.c | 4 -
pxa2xx_gpio.c | 2
pxa2xx_pic.c | 2
qdev.c | 94 +++++++++++++++++++++++++++++++++++++++------
qdev.h | 11 +++--
r2d.c | 4 -
realview.c | 40 +++++++++----------
s390-virtio-bus.c | 2
s390-virtio.c | 4 -
sb16.c | 2
scsi-bus.c | 2
sm501.c | 2
smbus_eeprom.c | 3 -
smc91c111.c | 2
spapr_llan.c | 2
spapr_vio.c | 2
spapr_vscsi.c | 2
spapr_vty.c | 2
spitz.c | 8 +--
ssi.c | 2
stellaris.c | 14 +++---
strongarm.c | 17 ++++----
sun4m.c | 32 +++++++--------
sun4u.c | 6 +-
syborg.c | 22 +++++-----
sysbus.c | 67 +++++++++++++++++++++++++++++---
sysbus.h | 31 ++++++++------
tosa.c | 4 -
unin_pci.c | 8 +--
usb-bus.c | 2
versatilepb.c | 34 ++++++++--------
vexpress.c | 28 ++++++-------
xilinx.h | 10 ++--
87 files changed, 490 insertions(+), 307 deletions(-)
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (14 preceding siblings ...)
2011-09-16 16:22 ` [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
@ 2011-09-16 16:48 ` Jan Kiszka
2011-09-16 16:54 ` Anthony Liguori
2011-09-16 18:21 ` Anthony Liguori
2011-09-17 18:41 ` Blue Swirl
16 siblings, 2 replies; 39+ messages in thread
From: Jan Kiszka @ 2011-09-16 16:48 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, qemu-devel@nongnu.org, Markus Armbruster,
Paolo Bonzini
On 2011-09-16 18:00, Anthony Liguori wrote:
> This series introduces an infrastructure to remove anonymous devices from qdev.
> Anonymous devices are one of the big gaps between qdev and QOM so removing is
> a prerequisite to incrementally merging QOM.
>
> Besides the infrastructure, I also converted almost all of the possible PC
> devices to have unique names. Please not that naming is not a property of
> devices but rather of the thing that creates the devices (usually machines).
>
> The names are ugly but this is because of the alternating device/bus hierarchy
> in qdev. For now, the names use '::' as deliminators but I think Jan has
> convinced me that down the road, we should use '/' as a deliminator such that
> the resulting names are actually valid paths (using a canonical path format).
I still don't see why we need to store strings as device references.
Everyone that lacks a reference (QEMU-external users) can pass in a path
- which can be a device name in the simple case. That path is resolved
to an object reference before proceeding with the requested service. If
an object should be serialized in whatever way and we need a stable
name, a central service could return this by walking up the composition
tree until a user-assigned name is found.
So there is really no need to bother device model developers with the
topics "How do I define a unique name?" or "Do I need an index or will
there be never more than one foo device?".
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 16:48 ` Jan Kiszka
@ 2011-09-16 16:54 ` Anthony Liguori
2011-09-16 17:03 ` Jan Kiszka
2011-09-16 17:11 ` Kevin Wolf
2011-09-16 18:21 ` Anthony Liguori
1 sibling, 2 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 16:54 UTC (permalink / raw)
To: Jan Kiszka
Cc: Peter Maydell, Paolo Bonzini, qemu-devel@nongnu.org,
Markus Armbruster
On 09/16/2011 11:48 AM, Jan Kiszka wrote:
> On 2011-09-16 18:00, Anthony Liguori wrote:
>> This series introduces an infrastructure to remove anonymous devices from qdev.
>> Anonymous devices are one of the big gaps between qdev and QOM so removing is
>> a prerequisite to incrementally merging QOM.
>>
>> Besides the infrastructure, I also converted almost all of the possible PC
>> devices to have unique names. Please not that naming is not a property of
>> devices but rather of the thing that creates the devices (usually machines).
>>
>> The names are ugly but this is because of the alternating device/bus hierarchy
>> in qdev. For now, the names use '::' as deliminators but I think Jan has
>> convinced me that down the road, we should use '/' as a deliminator such that
>> the resulting names are actually valid paths (using a canonical path format).
>
> I still don't see why we need to store strings as device references.
> Everyone that lacks a reference (QEMU-external users) can pass in a path
> - which can be a device name in the simple case. That path is resolved
> to an object reference before proceeding with the requested service. If
> an object should be serialized in whatever way and we need a stable
> name, a central service could return this by walking up the composition
> tree until a user-assigned name is found.
>
> So there is really no need to bother device model developers with the
> topics "How do I define a unique name?"
This series just asks the device model developer to come up with a unique *when*
they're doing device composition. Even with a totally path based interface,
this is always going to be a firm requirement.
I think it may be possible to eliminate required device names by having a formal
notion of composition and have the devices store the names of the composed
devices as part of the reference to that device. You could then have user
created devices use a separate hash table to track the names of those devices.
But, we can't easily do this today. Having either a fully qualified name or a
composition name as part of qdev_create() is the Right Thing IMHO so I think
this is the stepping stone to something more sophisticated.
Regards,
Anthony Liguori
or "Do I need an index or will
> there be never more than one foo device?".
>
> Jan
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 16:54 ` Anthony Liguori
@ 2011-09-16 17:03 ` Jan Kiszka
2011-09-16 18:06 ` Anthony Liguori
2011-09-16 17:11 ` Kevin Wolf
1 sibling, 1 reply; 39+ messages in thread
From: Jan Kiszka @ 2011-09-16 17:03 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Paolo Bonzini, qemu-devel@nongnu.org,
Markus Armbruster
On 2011-09-16 18:54, Anthony Liguori wrote:
> On 09/16/2011 11:48 AM, Jan Kiszka wrote:
>> On 2011-09-16 18:00, Anthony Liguori wrote:
>>> This series introduces an infrastructure to remove anonymous devices from qdev.
>>> Anonymous devices are one of the big gaps between qdev and QOM so removing is
>>> a prerequisite to incrementally merging QOM.
>>>
>>> Besides the infrastructure, I also converted almost all of the possible PC
>>> devices to have unique names. Please not that naming is not a property of
>>> devices but rather of the thing that creates the devices (usually machines).
>>>
>>> The names are ugly but this is because of the alternating device/bus hierarchy
>>> in qdev. For now, the names use '::' as deliminators but I think Jan has
>>> convinced me that down the road, we should use '/' as a deliminator such that
>>> the resulting names are actually valid paths (using a canonical path format).
>>
>> I still don't see why we need to store strings as device references.
>> Everyone that lacks a reference (QEMU-external users) can pass in a path
>> - which can be a device name in the simple case. That path is resolved
>> to an object reference before proceeding with the requested service. If
>> an object should be serialized in whatever way and we need a stable
>> name, a central service could return this by walking up the composition
>> tree until a user-assigned name is found.
>>
>> So there is really no need to bother device model developers with the
>> topics "How do I define a unique name?"
>
> This series just asks the device model developer to come up with a unique *when*
> they're doing device composition. Even with a totally path based interface,
> this is always going to be a firm requirement.
It will happen automatically - by defining a link to the child in the
parent device. Requesting unique names is redundant.
>
> I think it may be possible to eliminate required device names by having a formal
> notion of composition and have the devices store the names of the composed
> devices as part of the reference to that device. You could then have user
> created devices use a separate hash table to track the names of those devices.
>
> But, we can't easily do this today. Having either a fully qualified name or a
> composition name as part of qdev_create() is the Right Thing IMHO so I think
> this is the stepping stone to something more sophisticated.
A name for an internal reference is the wrong tool IMHO.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 16:54 ` Anthony Liguori
2011-09-16 17:03 ` Jan Kiszka
@ 2011-09-16 17:11 ` Kevin Wolf
2011-09-16 18:03 ` Anthony Liguori
1 sibling, 1 reply; 39+ messages in thread
From: Kevin Wolf @ 2011-09-16 17:11 UTC (permalink / raw)
To: Anthony Liguori
Cc: Jan Kiszka, Paolo Bonzini, qemu-devel@nongnu.org,
Markus Armbruster, Peter Maydell
Am 16.09.2011 18:54, schrieb Anthony Liguori:
> On 09/16/2011 11:48 AM, Jan Kiszka wrote:
>> On 2011-09-16 18:00, Anthony Liguori wrote:
>>> This series introduces an infrastructure to remove anonymous devices from qdev.
>>> Anonymous devices are one of the big gaps between qdev and QOM so removing is
>>> a prerequisite to incrementally merging QOM.
>>>
>>> Besides the infrastructure, I also converted almost all of the possible PC
>>> devices to have unique names. Please not that naming is not a property of
>>> devices but rather of the thing that creates the devices (usually machines).
>>>
>>> The names are ugly but this is because of the alternating device/bus hierarchy
>>> in qdev. For now, the names use '::' as deliminators but I think Jan has
>>> convinced me that down the road, we should use '/' as a deliminator such that
>>> the resulting names are actually valid paths (using a canonical path format).
>>
>> I still don't see why we need to store strings as device references.
>> Everyone that lacks a reference (QEMU-external users) can pass in a path
>> - which can be a device name in the simple case. That path is resolved
>> to an object reference before proceeding with the requested service. If
>> an object should be serialized in whatever way and we need a stable
>> name, a central service could return this by walking up the composition
>> tree until a user-assigned name is found.
>>
>> So there is really no need to bother device model developers with the
>> topics "How do I define a unique name?"
>
> This series just asks the device model developer to come up with a unique *when*
> they're doing device composition. Even with a totally path based interface,
> this is always going to be a firm requirement.
>
> I think it may be possible to eliminate required device names by having a formal
> notion of composition and have the devices store the names of the composed
> devices as part of the reference to that device. You could then have user
> created devices use a separate hash table to track the names of those devices.
>
> But, we can't easily do this today. Having either a fully qualified name or a
> composition name as part of qdev_create() is the Right Thing IMHO so I think
> this is the stepping stone to something more sophisticated.
Actually, as I said, I think this naming scheme is already by far too
sophisticated. Jan is completely right, there is no point in duplicating
paths in a name. Either we assign names only if the user specified one,
or we auto-generate a really simple name that doesn't resemble a path,
can be easily typed and is actually useful to have in addition to paths
(my "#foo-1" suggestion).
Kevin
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 17:11 ` Kevin Wolf
@ 2011-09-16 18:03 ` Anthony Liguori
2011-09-19 7:26 ` Jan Kiszka
2011-09-19 7:41 ` Kevin Wolf
0 siblings, 2 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 18:03 UTC (permalink / raw)
To: Kevin Wolf
Cc: Peter Maydell, Jan Kiszka, qemu-devel@nongnu.org,
Markus Armbruster, Paolo Bonzini
On 09/16/2011 12:11 PM, Kevin Wolf wrote:
> Am 16.09.2011 18:54, schrieb Anthony Liguori:
>> This series just asks the device model developer to come up with a unique *when*
>> they're doing device composition. Even with a totally path based interface,
>> this is always going to be a firm requirement.
>>
>> I think it may be possible to eliminate required device names by having a formal
>> notion of composition and have the devices store the names of the composed
>> devices as part of the reference to that device. You could then have user
>> created devices use a separate hash table to track the names of those devices.
>>
>> But, we can't easily do this today. Having either a fully qualified name or a
>> composition name as part of qdev_create() is the Right Thing IMHO so I think
>> this is the stepping stone to something more sophisticated.
>
> Actually, as I said, I think this naming scheme is already by far too
> sophisticated. Jan is completely right, there is no point in duplicating
> paths in a name. Either we assign names only if the user specified one,
> or we auto-generate a really simple name that doesn't resemble a path,
> can be easily typed and is actually useful to have in addition to paths
> (my "#foo-1" suggestion).
Names have to be relatively stable. Instantiation ordering should not affect
names nor should hotplug. Otherwise two device models will end up with devices
with different names.
Jan's point is that there is a stable path that could be used for the name and
satisfy these purposes. This is the composition path. Either a device is
created by the user (and therefore has a stable name and sits on the '/' part of
the path) or is created through composition and has a derived named from a user
created device. Since the composed device is tied to its parent's lifecycle,
the path is always valid.
So this is a simplification that I plan on running with. For now, I think this
series is the right next step because it gives us a path name for the name
(although different syntax) and let's us enforce that all devices has a
canonical path.
Independent of that, Jan suggested that we could have what's essentially an
alias. This is just a short name (could be in the form '%s-%d' %
(class.lower(), object_count). This alias is just a hash table. It has nothing
to do with the core device model.
I think what you're really getting at is that you want to be able to do
something like 'ide0-hd0' to refer to a device via the command line or HMP.
I don't really disagree with that either. But that's a layer on top of the core
device model. We shouldn't push every UI feature we want into the core device
model.
Regards,
Anthony Liguori
>
> Kevin
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 17:03 ` Jan Kiszka
@ 2011-09-16 18:06 ` Anthony Liguori
0 siblings, 0 replies; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 18:06 UTC (permalink / raw)
To: Jan Kiszka
Cc: Peter Maydell, qemu-devel@nongnu.org, Markus Armbruster,
Paolo Bonzini
On 09/16/2011 12:03 PM, Jan Kiszka wrote:
> On 2011-09-16 18:54, Anthony Liguori wrote:
>> On 09/16/2011 11:48 AM, Jan Kiszka wrote:
>>> On 2011-09-16 18:00, Anthony Liguori wrote:
>>>> This series introduces an infrastructure to remove anonymous devices from qdev.
>>>> Anonymous devices are one of the big gaps between qdev and QOM so removing is
>>>> a prerequisite to incrementally merging QOM.
>>>>
>>>> Besides the infrastructure, I also converted almost all of the possible PC
>>>> devices to have unique names. Please not that naming is not a property of
>>>> devices but rather of the thing that creates the devices (usually machines).
>>>>
>>>> The names are ugly but this is because of the alternating device/bus hierarchy
>>>> in qdev. For now, the names use '::' as deliminators but I think Jan has
>>>> convinced me that down the road, we should use '/' as a deliminator such that
>>>> the resulting names are actually valid paths (using a canonical path format).
>>>
>>> I still don't see why we need to store strings as device references.
>>> Everyone that lacks a reference (QEMU-external users) can pass in a path
>>> - which can be a device name in the simple case. That path is resolved
>>> to an object reference before proceeding with the requested service. If
>>> an object should be serialized in whatever way and we need a stable
>>> name, a central service could return this by walking up the composition
>>> tree until a user-assigned name is found.
>>>
>>> So there is really no need to bother device model developers with the
>>> topics "How do I define a unique name?"
>>
>> This series just asks the device model developer to come up with a unique *when*
>> they're doing device composition. Even with a totally path based interface,
>> this is always going to be a firm requirement.
>
> It will happen automatically - by defining a link to the child in the
> parent device. Requesting unique names is redundant.
How do you link in qdev today? The only place we have to hook is qdev_create().
In QOM, you do this:
struct PIIX3 {
RTC rtc;
};
static void piix3_initfn(...)
{
plug_add_child(PLUG(s), "rtc", &s->rtc);
}
This will initialize s->rtc (setting its name to be the composition path) and
create the property in the PIIX3.
You might disagree as to whether the name should be stored, but hopefully you at
least agree that this is the right programming model.
Regards,
Anthony Liguori
>
>>
>> I think it may be possible to eliminate required device names by having a formal
>> notion of composition and have the devices store the names of the composed
>> devices as part of the reference to that device. You could then have user
>> created devices use a separate hash table to track the names of those devices.
>>
>> But, we can't easily do this today. Having either a fully qualified name or a
>> composition name as part of qdev_create() is the Right Thing IMHO so I think
>> this is the stepping stone to something more sophisticated.
>
> A name for an internal reference is the wrong tool IMHO.
>
> Jan
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 16:48 ` Jan Kiszka
2011-09-16 16:54 ` Anthony Liguori
@ 2011-09-16 18:21 ` Anthony Liguori
2011-09-19 7:34 ` Jan Kiszka
1 sibling, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-16 18:21 UTC (permalink / raw)
To: Jan Kiszka
Cc: Peter Maydell, qemu-devel@nongnu.org, Markus Armbruster,
Paolo Bonzini
On 09/16/2011 11:48 AM, Jan Kiszka wrote:
> On 2011-09-16 18:00, Anthony Liguori wrote:
>> This series introduces an infrastructure to remove anonymous devices from qdev.
>> Anonymous devices are one of the big gaps between qdev and QOM so removing is
>> a prerequisite to incrementally merging QOM.
>>
>> Besides the infrastructure, I also converted almost all of the possible PC
>> devices to have unique names. Please not that naming is not a property of
>> devices but rather of the thing that creates the devices (usually machines).
>>
>> The names are ugly but this is because of the alternating device/bus hierarchy
>> in qdev. For now, the names use '::' as deliminators but I think Jan has
>> convinced me that down the road, we should use '/' as a deliminator such that
>> the resulting names are actually valid paths (using a canonical path format).
>
> I still don't see why we need to store strings as device references.
> Everyone that lacks a reference (QEMU-external users) can pass in a path
> - which can be a device name in the simple case.
Thinking more about this. I think a critical requirement is to be able to ask a
device how to reference itself. IOW, there needs to be a device_get_name(dev)
that returns something that can be meaningfully used to later reference the device.
With your no name stored in a device proposal, you would have something like this:
const char *device_get_name(Device *dev)
{
if (dev->parent) { // created through composition, ask parent
return device_get_child_name(dev->parent, dev);
} else { // user created, return user supplied name
return dev->name;
}
}
device_get_child_name() ends up becoming complicated unless you maintain a list
of children and their name mappings. That means Device needs to store a hash
table even though those pointers are not the canonical references since the
composition devices are embedded in the parent Device.
I think this leads to a lot of complexity without much real life gain. I think
having the parent generate and set the child's name during creation is a
significant simplification.
Regards,
Anthony Liguori
That path is resolved
> to an object reference before proceeding with the requested service. If
> an object should be serialized in whatever way and we need a stable
> name, a central service could return this by walking up the composition
> tree until a user-assigned name is found.
>
> So there is really no need to bother device model developers with the
> topics "How do I define a unique name?" or "Do I need an index or will
> there be never more than one foo device?".
>
> Jan
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming
2011-09-16 16:00 ` [Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming Anthony Liguori
@ 2011-09-17 18:39 ` Blue Swirl
0 siblings, 0 replies; 39+ messages in thread
From: Blue Swirl @ 2011-09-17 18:39 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Paolo Bonzini, qemu-devel, Markus Armbruster,
Jan Kiszka
On Fri, Sep 16, 2011 at 4:00 PM, Anthony Liguori <aliguori@us.ibm.com> wrote:
> By using a prefix of "::" in the name, we can safely derive the composed device
> name from the parent device and busses name. For instance, if the "::i440fx"
> device created a device named "piix3", it would look like this:
>
> static void i440fx_initfn(...)
> {
> s->piix3 = qdev_create("PIIX3", "::piix3");
> ...
>
> The resulting device would be named "::i440fx::i440fx.0::piix3". The reason for
> the middle "::i440fx.0" blob is that there are two levels of the tree hierarchy
> here and the bus level already has it's name derived from the parent device.
It could make sense to name the intermediate level by bus type, like
::i440fx::pci.0::piix3.
> We'll eliminate the bus level of the hierarchy in due time, but for now we have
> to just live with the ugly names.
>
> This patch lets qdev names be specified as a printf style format string which is
> convenient for creating devices like "::smbus-eeprom[%d]".
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
> hw/qdev.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
> hw/qdev.h | 8 ++++-
> 2 files changed, 78 insertions(+), 9 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 3096667..6bf6650 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -88,9 +88,10 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const char *name)
> return NULL;
> }
>
> -static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const char *id)
> +static DeviceState *qdev_create_from_infov(BusState *bus, DeviceInfo *info, const char *id, va_list ap)
> {
> DeviceState *dev;
> + char *name = NULL;
>
> assert(bus->info == info->bus_info);
> dev = g_malloc0(info->size);
> @@ -107,18 +108,50 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const
> }
> dev->instance_id_alias = -1;
> dev->state = DEV_STATE_CREATED;
> - dev->id = g_strdup(id);
> +
> + if (id) {
> + name = g_strdup_vprintf(id, ap);
> + if (name[0] == ':' && name[1] == ':') {
> + const char *parent_bus, *parent_device;
> + char *full_name;
> +
> + if (dev->parent_bus && dev->parent_bus->parent) {
> + parent_device = dev->parent_bus->parent->id;
> + parent_bus = dev->parent_bus->name;
> +
> + full_name = g_strdup_printf("%s%s%s",
> + dev->parent_bus->parent->id,
> + dev->parent_bus->name,
> + name);
> + g_free(name);
> + name = full_name;
> + }
> + }
> + }
> + dev->id = name;
> + return dev;
> +}
> +
> +static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info, const char *id, ...)
> +{
> + DeviceState *dev;
> + va_list ap;
> +
> + va_start(ap, id);
> + dev = qdev_create_from_infov(bus, info, id, ap);
> + va_end(ap);
> +
> return dev;
> }
>
> /* Create a new device. This only initializes the device state structure
> and allows properties to be set. qdev_init should be called to
> initialize the actual device emulation. */
> -DeviceState *qdev_create(BusState *bus, const char *name, const char *id)
> +DeviceState *qdev_createv(BusState *bus, const char *name, const char *id, va_list ap)
> {
> DeviceState *dev;
>
> - dev = qdev_try_create(bus, name, id);
> + dev = qdev_try_createv(bus, name, id, ap);
> if (!dev) {
> if (bus) {
> hw_error("Unknown device '%s' for bus '%s'\n", name,
> @@ -131,7 +164,19 @@ DeviceState *qdev_create(BusState *bus, const char *name, const char *id)
> return dev;
> }
>
> -DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id)
> +DeviceState *qdev_create(BusState *bus, const char *name, const char *id, ...)
> +{
> + DeviceState *dev;
> + va_list ap;
> +
> + va_start(ap, id);
> + dev = qdev_createv(bus, name, id, ap);
> + va_end(ap);
> +
> + return dev;
> +}
> +
> +DeviceState *qdev_try_createv(BusState *bus, const char *name, const char *id, va_list ap)
> {
> DeviceInfo *info;
>
> @@ -144,7 +189,19 @@ DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id)
> return NULL;
> }
>
> - return qdev_create_from_info(bus, info, id);
> + return qdev_create_from_infov(bus, info, id, ap);
> +}
> +
> +DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id, ...)
> +{
> + DeviceState *dev;
> + va_list ap;
> +
> + va_start(ap, id);
> + dev = qdev_try_createv(bus, name, id, ap);
> + va_end(ap);
> +
> + return dev;
> }
>
> static void qdev_print_devinfo(DeviceInfo *info)
> @@ -231,6 +288,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> DeviceInfo *info;
> DeviceState *qdev;
> BusState *bus;
> + const char *id;
>
> driver = qemu_opt_get(opts, "driver");
> if (!driver) {
> @@ -271,8 +329,15 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> return NULL;
> }
>
> + id = qemu_opts_id(opts);
> +
> /* create device, set properties */
> - qdev = qdev_create_from_info(bus, info, qemu_opts_id(opts));
> + if (id) {
> + qdev = qdev_create_from_info(bus, info, "%s", id);
> + } else {
> + qdev = qdev_create_from_info(bus, info, NULL);
> + }
> +
> if (qemu_opt_foreach(opts, set_property, qdev, 1) != 0) {
> qdev_free(qdev);
> return NULL;
> diff --git a/hw/qdev.h b/hw/qdev.h
> index d15a47e..a2b7a08 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
> @@ -120,8 +120,12 @@ typedef struct GlobalProperty {
>
> /*** Board API. This should go away once we have a machine config file. ***/
>
> -DeviceState *qdev_create(BusState *bus, const char *name, const char *id);
> -DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id);
> +DeviceState *qdev_create(BusState *bus, const char *name, const char *id, ...)
> + GCC_FMT_ATTR(3, 4);
> +DeviceState *qdev_createv(BusState *bus, const char *name, const char *id, va_list ap);
> +DeviceState *qdev_try_create(BusState *bus, const char *name, const char *id, ...)
> + GCC_FMT_ATTR(3, 4);
> +DeviceState *qdev_try_createv(BusState *bus, const char *name, const char *id, va_list ap);
> int qdev_device_help(QemuOpts *opts);
> DeviceState *qdev_device_add(QemuOpts *opts);
> int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
> --
> 1.7.4.1
>
>
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
` (15 preceding siblings ...)
2011-09-16 16:48 ` Jan Kiszka
@ 2011-09-17 18:41 ` Blue Swirl
16 siblings, 0 replies; 39+ messages in thread
From: Blue Swirl @ 2011-09-17 18:41 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Paolo Bonzini, qemu-devel, Markus Armbruster,
Jan Kiszka
On Fri, Sep 16, 2011 at 4:00 PM, Anthony Liguori <aliguori@us.ibm.com> wrote:
> This series introduces an infrastructure to remove anonymous devices from qdev.
> Anonymous devices are one of the big gaps between qdev and QOM so removing is
> a prerequisite to incrementally merging QOM.
>
> Besides the infrastructure, I also converted almost all of the possible PC
> devices to have unique names. Please not that naming is not a property of
> devices but rather of the thing that creates the devices (usually machines).
>
> The names are ugly but this is because of the alternating device/bus hierarchy
> in qdev. For now, the names use '::' as deliminators but I think Jan has
> convinced me that down the road, we should use '/' as a deliminator such that
> the resulting names are actually valid paths (using a canonical path format).
The patches look fine to me (assuming s/::/\//g).
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 18:03 ` Anthony Liguori
@ 2011-09-19 7:26 ` Jan Kiszka
2011-09-19 14:05 ` Anthony Liguori
2011-09-19 7:41 ` Kevin Wolf
1 sibling, 1 reply; 39+ messages in thread
From: Jan Kiszka @ 2011-09-19 7:26 UTC (permalink / raw)
To: Anthony Liguori
Cc: Kevin Wolf, Paolo Bonzini, Peter Maydell, qemu-devel@nongnu.org,
Markus Armbruster
On 2011-09-16 20:03, Anthony Liguori wrote:
> On 09/16/2011 12:11 PM, Kevin Wolf wrote:
>> Am 16.09.2011 18:54, schrieb Anthony Liguori:
>>> This series just asks the device model developer to come up with a unique *when*
>>> they're doing device composition. Even with a totally path based interface,
>>> this is always going to be a firm requirement.
>>>
>>> I think it may be possible to eliminate required device names by having a formal
>>> notion of composition and have the devices store the names of the composed
>>> devices as part of the reference to that device. You could then have user
>>> created devices use a separate hash table to track the names of those devices.
>>>
>>> But, we can't easily do this today. Having either a fully qualified name or a
>>> composition name as part of qdev_create() is the Right Thing IMHO so I think
>>> this is the stepping stone to something more sophisticated.
>>
>> Actually, as I said, I think this naming scheme is already by far too
>> sophisticated. Jan is completely right, there is no point in duplicating
>> paths in a name. Either we assign names only if the user specified one,
>> or we auto-generate a really simple name that doesn't resemble a path,
>> can be easily typed and is actually useful to have in addition to paths
>> (my "#foo-1" suggestion).
>
> Names have to be relatively stable. Instantiation ordering should not affect
> names nor should hotplug. Otherwise two device models will end up with devices
> with different names.
>
> Jan's point is that there is a stable path that could be used for the name and
> satisfy these purposes. This is the composition path. Either a device is
> created by the user (and therefore has a stable name and sits on the '/' part of
> the path) or is created through composition and has a derived named from a user
> created device. Since the composed device is tied to its parent's lifecycle,
> the path is always valid.
>
> So this is a simplification that I plan on running with. For now, I think this
> series is the right next step because it gives us a path name for the name
> (although different syntax) and let's us enforce that all devices has a
> canonical path.
For something that changes lots of devices and, at the same time, is
going to be removed again, I'm hesitating to call it the right direction.
A right step would be, IMHO, to introduce a generic introspectable
device link so that parent devices can reference their children and a
visitor can derive a child's relative name from that link name. Then
make sure this link type is consistently used.
I really dislike this focusing on assigning names internally and using
them in QEMU-internal APIs. They should just fall out of the core when
external interaction is required.
>
> Independent of that, Jan suggested that we could have what's essentially an
> alias. This is just a short name (could be in the form '%s-%d' %
> (class.lower(), object_count). This alias is just a hash table. It has nothing
> to do with the core device model.
I can't remember suggesting such thing.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-16 16:00 ` [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer Anthony Liguori
@ 2011-09-19 7:34 ` Gerd Hoffmann
2011-09-19 16:27 ` Anthony Liguori
0 siblings, 1 reply; 39+ messages in thread
From: Gerd Hoffmann @ 2011-09-19 7:34 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Paolo Bonzini, qemu-devel, Markus Armbruster,
Jan Kiszka
On 09/16/11 18:00, Anthony Liguori wrote:
> qdev has this quirk that it owns a seemingly arbitrary QemuOpts pointer. That's
> because qdev expects a static string for the id (which really makes no sense
> since ids are supposed to be provided by the user). Instead of managing just
> the id pointer, we currently take ownership of the entire QemuOpts structure
> that was used to create the device just to keep the name around.
FYI: Keeping the pointer to the QemuOpts has one more reason: It will
free the QemuOpts on hot-unplug, which is needed to free the id from
QemuOpts point of view, which in turn allows to re-use the id when
hot-plugging the same (or another) device later on.
cheers,
Gerd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 18:21 ` Anthony Liguori
@ 2011-09-19 7:34 ` Jan Kiszka
0 siblings, 0 replies; 39+ messages in thread
From: Jan Kiszka @ 2011-09-19 7:34 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, qemu-devel@nongnu.org, Markus Armbruster,
Paolo Bonzini
On 2011-09-16 20:21, Anthony Liguori wrote:
> On 09/16/2011 11:48 AM, Jan Kiszka wrote:
>> On 2011-09-16 18:00, Anthony Liguori wrote:
>>> This series introduces an infrastructure to remove anonymous devices from qdev.
>>> Anonymous devices are one of the big gaps between qdev and QOM so removing is
>>> a prerequisite to incrementally merging QOM.
>>>
>>> Besides the infrastructure, I also converted almost all of the possible PC
>>> devices to have unique names. Please not that naming is not a property of
>>> devices but rather of the thing that creates the devices (usually machines).
>>>
>>> The names are ugly but this is because of the alternating device/bus hierarchy
>>> in qdev. For now, the names use '::' as deliminators but I think Jan has
>>> convinced me that down the road, we should use '/' as a deliminator such that
>>> the resulting names are actually valid paths (using a canonical path format).
>>
>> I still don't see why we need to store strings as device references.
>> Everyone that lacks a reference (QEMU-external users) can pass in a path
>> - which can be a device name in the simple case.
>
> Thinking more about this. I think a critical requirement is to be able to ask a
> device how to reference itself. IOW, there needs to be a device_get_name(dev)
> that returns something that can be meaningfully used to later reference the device.
>
> With your no name stored in a device proposal, you would have something like this:
I would not even store a name in the device unless it is user-assigned.
That can be created on demand if we did our homework correctly.
>
> const char *device_get_name(Device *dev)
> {
> if (dev->parent) { // created through composition, ask parent
> return device_get_child_name(dev->parent, dev);
> } else { // user created, return user supplied name
> return dev->name;
> }
> }
>
> device_get_child_name() ends up becoming complicated unless you maintain a list
> of children and their name mappings. That means Device needs to store a hash
> table even though those pointers are not the canonical references since the
> composition devices are embedded in the parent Device.
As said in the other mail, the link name of the parent to its child is
the name we need to look up here. In turn that means a child likely
should know what link is referring to it in the composing parent. Can be
a feature of a generic device link so that we can also easily walk
graphs in both directions.
>
> I think this leads to a lot of complexity without much real life gain. I think
> having the parent generate and set the child's name during creation is a
> significant simplification.
The parent creates the name, no question, but in a different way you
still think of: by naming its link. Let's focus on how to do
inter-device referencing. This is actually the more important topic IMO,
but if we do it right, naming just falls out of it as a byproduct.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking
2011-09-16 16:00 ` [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking Anthony Liguori
@ 2011-09-19 7:35 ` Gerd Hoffmann
0 siblings, 0 replies; 39+ messages in thread
From: Gerd Hoffmann @ 2011-09-19 7:35 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Paolo Bonzini, qemu-devel, Markus Armbruster,
Jan Kiszka
On 09/16/11 18:00, Anthony Liguori wrote:
> This was only used because id's memory was stored in opts.
No, see reply for patch #4.
cheers,
Gerd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-16 18:03 ` Anthony Liguori
2011-09-19 7:26 ` Jan Kiszka
@ 2011-09-19 7:41 ` Kevin Wolf
1 sibling, 0 replies; 39+ messages in thread
From: Kevin Wolf @ 2011-09-19 7:41 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Jan Kiszka, qemu-devel@nongnu.org,
Markus Armbruster, Paolo Bonzini
Am 16.09.2011 20:03, schrieb Anthony Liguori:
> On 09/16/2011 12:11 PM, Kevin Wolf wrote:
>> Am 16.09.2011 18:54, schrieb Anthony Liguori:
>>> This series just asks the device model developer to come up with a unique *when*
>>> they're doing device composition. Even with a totally path based interface,
>>> this is always going to be a firm requirement.
>>>
>>> I think it may be possible to eliminate required device names by having a formal
>>> notion of composition and have the devices store the names of the composed
>>> devices as part of the reference to that device. You could then have user
>>> created devices use a separate hash table to track the names of those devices.
>>>
>>> But, we can't easily do this today. Having either a fully qualified name or a
>>> composition name as part of qdev_create() is the Right Thing IMHO so I think
>>> this is the stepping stone to something more sophisticated.
>>
>> Actually, as I said, I think this naming scheme is already by far too
>> sophisticated. Jan is completely right, there is no point in duplicating
>> paths in a name. Either we assign names only if the user specified one,
>> or we auto-generate a really simple name that doesn't resemble a path,
>> can be easily typed and is actually useful to have in addition to paths
>> (my "#foo-1" suggestion).
>
> Names have to be relatively stable. Instantiation ordering should not affect
> names nor should hotplug. Otherwise two device models will end up with devices
> with different names.
But that's what you have paths for. If you introduce name that are meant
to fulfill the same requirements, the only thing you have achieved is
duplication.
This is why I think that _if_ we have names, they should address a
different requirement, like being easy to remember and type. That there
are user-assigned names inclines me to think that this is what they are
meant for. But if they do just the same thing as paths already do, there
is no reason to have them.
> Independent of that, Jan suggested that we could have what's essentially an
> alias. This is just a short name (could be in the form '%s-%d' %
> (class.lower(), object_count). This alias is just a hash table. It has nothing
> to do with the core device model.
>
> I think what you're really getting at is that you want to be able to do
> something like 'ide0-hd0' to refer to a device via the command line or HMP.
>
> I don't really disagree with that either. But that's a layer on top of the core
> device model. We shouldn't push every UI feature we want into the core device
> model.
Doing it outside the device model certainly works, too. I was just
trying to make your names somewhat useful. If it turns out that we have
no use for them in the device mode, let's use paths for everything and
abandon names.
Kevin
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-19 7:26 ` Jan Kiszka
@ 2011-09-19 14:05 ` Anthony Liguori
2011-09-19 14:24 ` Kevin Wolf
0 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-19 14:05 UTC (permalink / raw)
To: Jan Kiszka
Cc: Kevin Wolf, Paolo Bonzini, qemu-devel@nongnu.org,
Markus Armbruster, Peter Maydell
On 09/19/2011 02:26 AM, Jan Kiszka wrote:
> On 2011-09-16 20:03, Anthony Liguori wrote:
>> So this is a simplification that I plan on running with. For now, I think this
>> series is the right next step because it gives us a path name for the name
>> (although different syntax) and let's us enforce that all devices has a
>> canonical path.
>
> For something that changes lots of devices and, at the same time, is
> going to be removed again, I'm hesitating to call it the right direction.
>
> A right step would be, IMHO, to introduce a generic introspectable
> device link so that parent devices can reference their children and a
> visitor can derive a child's relative name from that link name. Then
> make sure this link type is consistently used.
>
> I really dislike this focusing on assigning names internally and using
> them in QEMU-internal APIs. They should just fall out of the core when
> external interaction is required.
I thought a lot about this over the weekend and decided that I should go in a
different direction based on this discussion.
Starting with the requirement that you have to be able to ask the device for an
unambiguous reference to itself, I see two possible approaches:
1) Store the unambiguous reference within the child, derive unambiguous
reference from the composition hierarchy.
2) Store a reference to the composition parent in the child. When asked for the
unambiguous reference, use parent point to generate the reference.
These two approaches have subtle differences. For (1), all devices must be
given globally unique names. For (2), all devices must be given names that are
unique to its composition parent.
I really dislike having a 'Device *parent' pointer because I fear it will be
abused, but there a number of elegant advantages to this model. For instance:
a) There is nothing special about user created devices. All user created
devices sit on the root of the composition hierarchy. The names must be unique
within that level of the composition tree. However, once you get one level
down, it's a new namespace. This means you can achieve uniqueness without
special characters or any of that nonsense.
b) We have proper path components without parsing a string and assigning special
meaning to characters.
Point (b) is especially important because I spent a lot of time thinking about
how to address Kevin's concerns about usability. I think we can significantly
improve path usability by trying to do an unambiguous match from right-to-left
on the path components. For instance, if you have:
/i440fx
/i440fx/piix3
/i440fx/piix3/ide
/i440fx/slot[1.0]
/i440fx/slot[2.0]
You can do:
-device isa-serial,bus=piix3 (or)
-device isa-serial,bus=i440fx/piix3 (or)
-device isa-serial,bus=/i440fx/piix3
The first two examples are relevant, but unambiguous paths, matched from
right-to-left. The last example is an absolute path. Since the vast majority
of the time, you have an unambiguous path by simple taking the last and possibly
second-to-last path component, I think that most of the time you can use very
short relative paths.
I think this ends up being a big usability improvement and the only way to
implement this (1) is parsing device names and extract paths which is even more
evil than having a composition parent link in the Device.
So I'm now rebasing my series and switching to this model. It's a rather
significant change but I think I have a grip on how to do it.
Regards,
Anthony Liguori
>
>>
>> Independent of that, Jan suggested that we could have what's essentially an
>> alias. This is just a short name (could be in the form '%s-%d' %
>> (class.lower(), object_count). This alias is just a hash table. It has nothing
>> to do with the core device model.
>
> I can't remember suggesting such thing.
>
> Jan
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-19 14:05 ` Anthony Liguori
@ 2011-09-19 14:24 ` Kevin Wolf
2011-09-20 8:32 ` Jan Kiszka
0 siblings, 1 reply; 39+ messages in thread
From: Kevin Wolf @ 2011-09-19 14:24 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Jan Kiszka, qemu-devel@nongnu.org,
Markus Armbruster, Paolo Bonzini
Am 19.09.2011 16:05, schrieb Anthony Liguori:
> On 09/19/2011 02:26 AM, Jan Kiszka wrote:
>> On 2011-09-16 20:03, Anthony Liguori wrote:
>>> So this is a simplification that I plan on running with. For now, I think this
>>> series is the right next step because it gives us a path name for the name
>>> (although different syntax) and let's us enforce that all devices has a
>>> canonical path.
>>
>> For something that changes lots of devices and, at the same time, is
>> going to be removed again, I'm hesitating to call it the right direction.
>>
>> A right step would be, IMHO, to introduce a generic introspectable
>> device link so that parent devices can reference their children and a
>> visitor can derive a child's relative name from that link name. Then
>> make sure this link type is consistently used.
>>
>> I really dislike this focusing on assigning names internally and using
>> them in QEMU-internal APIs. They should just fall out of the core when
>> external interaction is required.
>
> I thought a lot about this over the weekend and decided that I should go in a
> different direction based on this discussion.
> [...]
Sounds like a good direction to me. (At least until someone brings up
the details :-))
Kevin
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-19 7:34 ` Gerd Hoffmann
@ 2011-09-19 16:27 ` Anthony Liguori
2011-09-20 6:36 ` Gerd Hoffmann
0 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-19 16:27 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, qemu-devel,
Markus Armbruster, Paolo Bonzini
On 09/19/2011 02:34 AM, Gerd Hoffmann wrote:
> On 09/16/11 18:00, Anthony Liguori wrote:
>> qdev has this quirk that it owns a seemingly arbitrary QemuOpts pointer. That's
>> because qdev expects a static string for the id (which really makes no sense
>> since ids are supposed to be provided by the user). Instead of managing just
>> the id pointer, we currently take ownership of the entire QemuOpts structure
>> that was used to create the device just to keep the name around.
>
> FYI: Keeping the pointer to the QemuOpts has one more reason: It will free the
> QemuOpts on hot-unplug, which is needed to free the id from QemuOpts point of
> view, which in turn allows to re-use the id when hot-plugging the same (or
> another) device later on.
You mean, tie QemuOpts life cycle to devices life cycle such that you cannot
accidentally create a non-device QemuOpts that conflicts with the id of a device?
Regard,
Anthony Liguori
>
> cheers,
> Gerd
>
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-19 16:27 ` Anthony Liguori
@ 2011-09-20 6:36 ` Gerd Hoffmann
2011-09-20 13:04 ` Anthony Liguori
0 siblings, 1 reply; 39+ messages in thread
From: Gerd Hoffmann @ 2011-09-20 6:36 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Anthony Liguori, Jan Kiszka, qemu-devel,
Markus Armbruster, Paolo Bonzini
On 09/19/11 18:27, Anthony Liguori wrote:
> On 09/19/2011 02:34 AM, Gerd Hoffmann wrote:
>> FYI: Keeping the pointer to the QemuOpts has one more reason: It will
>> free the
>> QemuOpts on hot-unplug, which is needed to free the id from QemuOpts
>> point of
>> view, which in turn allows to re-use the id when hot-plugging the same
>> (or
>> another) device later on.
>
> You mean, tie QemuOpts life cycle to devices life cycle
Yes.
> such that you
> cannot accidentally create a non-device QemuOpts that conflicts with the
> id of a device?
Device QemuOpts have their own id namespace, so this is just about
conflicts within devices. This ...
device_add e1000,id=nic1
device_del nic1
device_add e1000,id=nic1
... will work only if you free the QemuOpts when deleting a device,
otherwise QemuOpts will complain that nic1 is used already.
cheers,
Gerd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1)
2011-09-19 14:24 ` Kevin Wolf
@ 2011-09-20 8:32 ` Jan Kiszka
0 siblings, 0 replies; 39+ messages in thread
From: Jan Kiszka @ 2011-09-20 8:32 UTC (permalink / raw)
To: Kevin Wolf
Cc: Paolo Bonzini, Markus Armbruster, qemu-devel@nongnu.org,
Peter Maydell
On 2011-09-19 16:24, Kevin Wolf wrote:
> Am 19.09.2011 16:05, schrieb Anthony Liguori:
>> On 09/19/2011 02:26 AM, Jan Kiszka wrote:
>>> On 2011-09-16 20:03, Anthony Liguori wrote:
>>>> So this is a simplification that I plan on running with. For now, I think this
>>>> series is the right next step because it gives us a path name for the name
>>>> (although different syntax) and let's us enforce that all devices has a
>>>> canonical path.
>>>
>>> For something that changes lots of devices and, at the same time, is
>>> going to be removed again, I'm hesitating to call it the right direction.
>>>
>>> A right step would be, IMHO, to introduce a generic introspectable
>>> device link so that parent devices can reference their children and a
>>> visitor can derive a child's relative name from that link name. Then
>>> make sure this link type is consistently used.
>>>
>>> I really dislike this focusing on assigning names internally and using
>>> them in QEMU-internal APIs. They should just fall out of the core when
>>> external interaction is required.
>>
>> I thought a lot about this over the weekend and decided that I should go in a
>> different direction based on this discussion.
>> [...]
>
> Sounds like a good direction to me. (At least until someone brings up
> the details :-))
Yeah. Maybe we should keep this at concept level to avoid getting into
disagreement again. ;)
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-20 6:36 ` Gerd Hoffmann
@ 2011-09-20 13:04 ` Anthony Liguori
2011-09-20 13:21 ` Gerd Hoffmann
0 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-20 13:04 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Peter Maydell, Jan Kiszka, Markus Armbruster, qemu-devel,
Paolo Bonzini
On 09/20/2011 01:36 AM, Gerd Hoffmann wrote:
> On 09/19/11 18:27, Anthony Liguori wrote:
>> On 09/19/2011 02:34 AM, Gerd Hoffmann wrote:
>>> FYI: Keeping the pointer to the QemuOpts has one more reason: It will
>>> free the
>>> QemuOpts on hot-unplug, which is needed to free the id from QemuOpts
>>> point of
>>> view, which in turn allows to re-use the id when hot-plugging the same
>>> (or
>>> another) device later on.
>>
>> You mean, tie QemuOpts life cycle to devices life cycle
>
> Yes.
>
>> such that you
>> cannot accidentally create a non-device QemuOpts that conflicts with the
>> id of a device?
>
> Device QemuOpts have their own id namespace, so this is just about conflicts
> within devices. This ...
>
> device_add e1000,id=nic1
> device_del nic1
> device_add e1000,id=nic1
>
> ... will work only if you free the QemuOpts when deleting a device, otherwise
> QemuOpts will complain that nic1 is used already.
But we can just verify that the id specified for qdev is unique at creation time
and fail creation if it isn't, no?
Since not all devices are assigned names via qemuopts, that seems like a safer
approach anyway.
Regards,
Anthony Liguori
>
> cheers,
> Gerd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-20 13:04 ` Anthony Liguori
@ 2011-09-20 13:21 ` Gerd Hoffmann
2011-09-20 13:55 ` Anthony Liguori
0 siblings, 1 reply; 39+ messages in thread
From: Gerd Hoffmann @ 2011-09-20 13:21 UTC (permalink / raw)
To: Anthony Liguori
Cc: Peter Maydell, Jan Kiszka, Markus Armbruster, qemu-devel,
Paolo Bonzini
On 09/20/11 15:04, Anthony Liguori wrote:
> On 09/20/2011 01:36 AM, Gerd Hoffmann wrote:
>> On 09/19/11 18:27, Anthony Liguori wrote:
>>> On 09/19/2011 02:34 AM, Gerd Hoffmann wrote:
>>>> FYI: Keeping the pointer to the QemuOpts has one more reason: It will
>>>> free the
>>>> QemuOpts on hot-unplug, which is needed to free the id from QemuOpts
>>>> point of
>>>> view, which in turn allows to re-use the id when hot-plugging the same
>>>> (or
>>>> another) device later on.
>>>
>>> You mean, tie QemuOpts life cycle to devices life cycle
>>
>> Yes.
>>
>>> such that you
>>> cannot accidentally create a non-device QemuOpts that conflicts with the
>>> id of a device?
>>
>> Device QemuOpts have their own id namespace, so this is just about
>> conflicts
>> within devices. This ...
>>
>> device_add e1000,id=nic1
>> device_del nic1
>> device_add e1000,id=nic1
>>
>> ... will work only if you free the QemuOpts when deleting a device,
>> otherwise
>> QemuOpts will complain that nic1 is used already.
>
> But we can just verify that the id specified for qdev is unique at
> creation time and fail creation if it isn't, no?
>
> Since not all devices are assigned names via qemuopts, that seems like a
> safer approach anyway.
I think that happens anyway (didn't check the source though).
Problem is that QemuOpts wants IDs being unique too, so keep the
QemuOpts hanging around instead of releasing them makes QemuOpts
complain about nic1 not being unique although there isn't such a device
in qdev space. Oh, and not releasing the QemuOpts would also leak
memory on each hot-unplug.
cheers,
Gerd
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-20 13:21 ` Gerd Hoffmann
@ 2011-09-20 13:55 ` Anthony Liguori
2011-09-20 14:11 ` Gerd Hoffmann
0 siblings, 1 reply; 39+ messages in thread
From: Anthony Liguori @ 2011-09-20 13:55 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: qemu-devel, Peter Maydell, Paolo Bonzini, Markus Armbruster,
Jan Kiszka
On 09/20/2011 08:21 AM, Gerd Hoffmann wrote:
> On 09/20/11 15:04, Anthony Liguori wrote:
>> On 09/20/2011 01:36 AM, Gerd Hoffmann wrote:
>>> On 09/19/11 18:27, Anthony Liguori wrote:
>>>> On 09/19/2011 02:34 AM, Gerd Hoffmann wrote:
>>>>> FYI: Keeping the pointer to the QemuOpts has one more reason: It will
>>>>> free the
>>>>> QemuOpts on hot-unplug, which is needed to free the id from QemuOpts
>>>>> point of
>>>>> view, which in turn allows to re-use the id when hot-plugging the same
>>>>> (or
>>>>> another) device later on.
>>>>
>>>> You mean, tie QemuOpts life cycle to devices life cycle
>>>
>>> Yes.
>>>
>>>> such that you
>>>> cannot accidentally create a non-device QemuOpts that conflicts with the
>>>> id of a device?
>>>
>>> Device QemuOpts have their own id namespace, so this is just about
>>> conflicts
>>> within devices. This ...
>>>
>>> device_add e1000,id=nic1
>>> device_del nic1
>>> device_add e1000,id=nic1
>>>
>>> ... will work only if you free the QemuOpts when deleting a device,
>>> otherwise
>>> QemuOpts will complain that nic1 is used already.
>>
>> But we can just verify that the id specified for qdev is unique at
>> creation time and fail creation if it isn't, no?
>>
>> Since not all devices are assigned names via qemuopts, that seems like a
>> safer approach anyway.
>
> I think that happens anyway (didn't check the source though).
>
> Problem is that QemuOpts wants IDs being unique too, so keep the QemuOpts
> hanging around instead of releasing them makes QemuOpts complain about nic1 not
> being unique although there isn't such a device in qdev space.
I don't think we have a firm requirement that the QemuOpts namespace == device
namespace. At any rate, it's not enforced today because devices can be created
(with an id) outside of device_add.
> Oh, and not
> releasing the QemuOpts would also leak memory on each hot-unplug.
If you look at my patch, opts is freed at the end of device_add so there is no leak.
Regards,
Anthony Liguori
>
> cheers,
> Gerd
>
>
>
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
2011-09-20 13:55 ` Anthony Liguori
@ 2011-09-20 14:11 ` Gerd Hoffmann
0 siblings, 0 replies; 39+ messages in thread
From: Gerd Hoffmann @ 2011-09-20 14:11 UTC (permalink / raw)
To: Anthony Liguori
Cc: qemu-devel, Peter Maydell, Paolo Bonzini, Markus Armbruster,
Jan Kiszka
Hi,
>> Oh, and not
>> releasing the QemuOpts would also leak memory on each hot-unplug.
>
> If you look at my patch, opts is freed at the end of device_add so there
> is no leak.
Ah, ok. Missed that.
cheers,
Gerd
^ permalink raw reply [flat|nested] 39+ messages in thread
end of thread, other threads:[~2011-09-20 14:11 UTC | newest]
Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 01/14] apic: rename apic.id -> apic.index Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 02/14] qdev: enforce that no devices overload the id property Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 03/14] qdev: push id into qdev_create calls Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer Anthony Liguori
2011-09-19 7:34 ` Gerd Hoffmann
2011-09-19 16:27 ` Anthony Liguori
2011-09-20 6:36 ` Gerd Hoffmann
2011-09-20 13:04 ` Anthony Liguori
2011-09-20 13:21 ` Gerd Hoffmann
2011-09-20 13:55 ` Anthony Liguori
2011-09-20 14:11 ` Gerd Hoffmann
2011-09-16 16:00 ` [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking Anthony Liguori
2011-09-19 7:35 ` Gerd Hoffmann
2011-09-16 16:00 ` [Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming Anthony Liguori
2011-09-17 18:39 ` Blue Swirl
2011-09-16 16:00 ` [Qemu-devel] [PATCH 07/14] sysbus: add an id argument to sysbus_create_simple() Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 08/14] sysbus: make create_varargs take an id Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 09/14] fw_cfg: add name to global fw_cfg device Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 10/14] isa: add name parameter to device creation Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 11/14] pci: obtain devfn before initializing the device Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 12/14] pci: give pci devices a default name Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 13/14] ide: give IDE drives a default name in qdev Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 14/14] pc: assign names to machine created devices Anthony Liguori
2011-09-16 16:22 ` [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
2011-09-16 16:48 ` Jan Kiszka
2011-09-16 16:54 ` Anthony Liguori
2011-09-16 17:03 ` Jan Kiszka
2011-09-16 18:06 ` Anthony Liguori
2011-09-16 17:11 ` Kevin Wolf
2011-09-16 18:03 ` Anthony Liguori
2011-09-19 7:26 ` Jan Kiszka
2011-09-19 14:05 ` Anthony Liguori
2011-09-19 14:24 ` Kevin Wolf
2011-09-20 8:32 ` Jan Kiszka
2011-09-19 7:41 ` Kevin Wolf
2011-09-16 18:21 ` Anthony Liguori
2011-09-19 7:34 ` Jan Kiszka
2011-09-17 18:41 ` Blue Swirl
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).