refactor PC machine, i440fx and piix3 to take advantage of QOM
cover refactor PC machine, i440fx and piix3 to take advantage of QOM
From: Anthony Liguori <[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4) i440fx_init is trivialized to creating devices and setting properties
5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where machine->init disappears completely in favor of just creating a handful of devices.
The two stage initialization of QOM is important here. instance_init() is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
realize() (which is still called DeviceState::init today) will be called right before the guest starts up for the first time.
--- Makefile.target | 3 +- hw/hpet.c | 39 +--- hw/hpet_emul.h | 41 +++ hw/i440fx.c | 431 ++++++++++++++++++++++++++ hw/i440fx.h | 78 +++++ hw/i8254_internal.h | 2 +- hw/mc146818rtc.c | 26 -- hw/mc146818rtc.h | 29 ++ hw/pc.c | 838 +++++++++++++++++++++++++++++++++++++++++++++------ hw/pc.h | 46 +--- hw/pc_piix.c | 762 ---------------------------------------------- hw/pci_host.c | 26 ++ hw/pci_host.h | 5 + hw/piix3.c | 274 +++++++++++++++++ hw/piix3.h | 79 +++++ hw/piix_pci.c | 600 ------------------------------------ memory.c | 94 +++++-- memory.h | 8 + 18 files changed, 1795 insertions(+), 1586 deletions(-) create mode 100644 hw/i440fx.c create mode 100644 hw/i440fx.h delete mode 100644 hw/pc_piix.c create mode 100644 hw/piix3.c create mode 100644 hw/piix3.h delete mode 100644 hw/piix_pci.c
--
PATCH 1/6 eliminate piix_pci.c and module i440fx and piix3
From: Anthony Liguori <[email protected]>
The big picture about the patch is shown as follows:
1) pc_init creates an I440FX, any bus devices (ISA serial port, PCI vga and nics, etc.), sets properties appropriately, and realizes the devices.
2) I440FX is-a PCIHost, has-a I440FX-PMC, has-a PIIX3
3) PIIX3 has-a RTC, has-a I8042, has-a DMAController, etc.
i440fx-pcihost => i440fx
i440fx => i440fx-pmc
i440fx_pmc is Programmable Memory Controller which integrated in I440FX chipset, and move ram initialization into i440fx-pmc.
It might seem like a small change, but it better reflects the fact that the PMC is contained within the i440fx which we will now reflect in composition in the next few changesets.
--- Makefile.target | 2 +- hw/i440fx.c | 431 +++++++++++++++++++++++++++++++++++++++ hw/i440fx.h | 78 +++++++ hw/piix3.c | 274 +++++++++++++++++++++++++ hw/piix3.h | 79 ++++++++ hw/piix_pci.c | 600 ------------------------------------------------------- 6 files changed, 863 insertions(+), 601 deletions(-) create mode 100644 hw/i440fx.c create mode 100644 hw/i440fx.h create mode 100644 hw/piix3.c create mode 100644 hw/piix3.h delete mode 100644 hw/piix_pci.c
Makefile.target +1 -1
@@ -247,7 +247,7 @@ obj-y += device-hotplug.o # Hardware support obj-i386-y += mc146818rtc.o pc.o obj-i386-y += apic_common.o apic.o kvmvapic.o -obj-i386-y += sga.o ioapic_common.o ioapic.o piix_pci.o +obj-i386-y += sga.o ioapic_common.o ioapic.o i440fx.o piix3.o obj-i386-y += vmport.o obj-i386-y += pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o
hw/i440fx.c new file +431 -0
431 lines not on this page · raw message
hw/i440fx.h new file +78 -0
78 lines not on this page · raw message
hw/piix3.c new file +274 -0
274 lines not on this page · raw message
hw/piix3.h new file +79 -0
79 lines not on this page · raw message
hw/piix_pci.c deleted +0 -600
600 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 2/6 convert MemoryRegion to QOM
In reply to Wanpeng LiFrom: Anthony Liguori <[email protected]>
--- memory.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++---------------- memory.h | 8 +++++ 2 files changed, 78 insertions(+), 24 deletions(-)
memory.c +70 -24
@@ -797,35 +797,26 @@ static bool memory_region_wrong_endianness(MemoryRegion *mr)#endif } -void memory_region_init (MemoryRegion *mr, -const char *name, -uint64_t size) +void memory_region_set_name (MemoryRegion *mr,const char *name) +{ + mr->name =g_strdup (name); +} + +void memory_region_set_size (MemoryRegion *mr,uint64_t size) { - mr->ops =NULL ; - mr->parent =NULL ; mr->size =int128_make64 (size);if (size ==UINT64_MAX ) { mr->size =int128_2_64 (); } - mr->addr =0 ; - mr->subpage = false; - mr->enabled = true; - mr->terminates = false; - mr->ram = false; - mr->readable = true; - mr->readonly = false; - mr->rom_device = false; - mr->destructor = memory_region_destructor_none; - mr->priority =0 ; - mr->may_overlap = false; - mr->alias =NULL ; -QTAILQ_INIT (&mr->subregions); -memset (&mr->subregions_link,0 ,sizeof mr->subregions_link); -QTAILQ_INIT (&mr->coalesced); - mr->name =g_strdup (name); - mr->dirty_log_mask =0 ; - mr->ioeventfd_nb =0 ; - mr->ioeventfds =NULL ; +} + +void memory_region_init (MemoryRegion *mr, +const char *name, +uint64_t size) +{ +object_initialize (mr,TYPE_MEMORY_REGION ); +memory_region_set_name (mr, name); +memory_region_set_size (mr, size); } static bool memory_region_access_valid(MemoryRegion *mr,
@@ -1640,3 +1631,58 @@ void mtree_info(fprintf_function mon_printf, void *f)mtree_print_mr (mon_printf, f, address_space_io.root,0 ,0 , &ml_head); } } + +static void memory_region_initfn (Object *obj) +{ +MemoryRegion *mr =MEMORY_REGION (obj); + mr->ops =NULL ; + mr->parent =NULL ; + mr->size =int128_2_64 (); + mr->addr =0 ; + mr->subpage = false; + mr->enabled = true; + mr->terminates = false; + mr->ram = false; + mr->readable = true; + mr->readonly = false; + mr->rom_device = false; + mr->destructor = memory_region_destructor_none; + mr->priority =0 ; + mr->may_overlap = false; + mr->alias =NULL ; + mr->name =NULL ; +QTAILQ_INIT (&mr->subregions); +memset (&mr->subregions_link,0 ,sizeof mr->subregions_link); +QTAILQ_INIT (&mr->coalesced); + mr->dirty_log_mask =0 ; + mr->ioeventfd_nb =0 ; + mr->ioeventfds =NULL ; +} + +static void memory_region_finalize (Object *obj) +{ +MemoryRegion *mr =MEMORY_REGION (obj); + +assert (QTAILQ_EMPTY (&mr->subregions)); + mr->destructor (mr); +memory_region_clear_coalescing (mr); +if (mr->name) { +g_free ((char *)mr->name); + } +g_free (mr->ioeventfds); +} + +static TypeInfo memory_region_type = { + .name =TYPE_MEMORY_REGION , + .parent =TYPE_OBJECT , + .instance_size =sizeof (MemoryRegion), + .instance_init = memory_region_initfn, + .instance_finalize = memory_region_finalize, +}; + +static void register_devices (void ) +{ +type_register_static (&memory_region_type); +} + +type_init (register_devices);
memory.h +8 -0
@@ -25,6 +25,7 @@#include "iorange.h" #include "ioport.h" #include "int128.h" +#include "qemu/object.h" typedef struct MemoryRegionOps MemoryRegionOps ;typedef struct MemoryRegion MemoryRegion ;
@@ -116,6 +117,9 @@ struct MemoryRegionOps {typedef struct CoalescedMemoryRange CoalescedMemoryRange ;typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd ; +#define TYPE_MEMORY_REGION "memory-region" +#define MEMORY_REGION (obj) OBJECT_CHECK(MemoryRegion, (obj), TYPE_MEMORY_REGION) +struct MemoryRegion {/* All fields are private - violators will be prosecuted */ const MemoryRegionOps *ops;
@@ -719,6 +723,10 @@ void memory_global_dirty_log_stop(void);void mtree_info (fprintf_function mon_printf,void *f); +void memory_region_set_name (MemoryRegion *mr,const char *name); + +void memory_region_set_size (MemoryRegion *mr,uint64_t size); +#endif #endif
Signature · 1 line
1.7.5.4
PATCH 3/6 convert pci-host to QOM
In reply to Wanpeng LiFrom: Anthony Liguori <[email protected]>
--- hw/pci_host.c | 26 ++++++++++++++++++++++++++ hw/pci_host.h | 5 +++++ 2 files changed, 31 insertions(+), 0 deletions(-)
hw/pci_host.c +26 -0
@@ -162,4 +162,30 @@ const MemoryRegionOps pci_host_data_be_ops = { .endianness = DEVICE_BIG_ENDIAN, }; +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value) +{ +object_property_set_link (OBJECT (s),OBJECT (value),"mmio" ,NULL ); +} + +static void pci_host_initfn (Object *obj) +{ +PCIHostState *s =PCI_HOST (obj); + +object_property_add_link (obj,"mmio" ,TYPE_MEMORY_REGION , + (Object **)&s->address_space,NULL ); +} + +static TypeInfo pci_host_type = { + .name =TYPE_PCI_HOST , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (PCIHostState), + .instance_init = pci_host_initfn, +}; + +static void register_devices (void ) +{ +type_register_static (&pci_host_type); +} + +type_init (register_devices);
hw/pci_host.h +5 -0
@@ -30,6 +30,9 @@#include "sysbus.h" +#define TYPE_PCI_HOST "pci-host" +#define PCI_HOST (obj) OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST) +struct PCIHostState {SysBusDevice busdev;MemoryRegion conf_mem;
@@ -49,6 +52,8 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,void pci_data_write (PCIBus *s,uint32_t addr,uint32_t val,int len);uint32_t pci_data_read (PCIBus *s,uint32_t addr,int len); +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value); +extern const MemoryRegionOps pci_host_conf_le_ops;extern const MemoryRegionOps pci_host_conf_be_ops;extern const MemoryRegionOps pci_host_data_le_ops;
Signature · 1 line
1.7.5.4
Re: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
Quoted 9 lines · Wanpeng Li
hw/pci_host.c +1
-0@@ -162,4 +162,30 @@ const MemoryRegionOps pci_host_data_be_ops = { .endianness = DEVICE_BIG_ENDIAN, }; +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value)
hw/pci_host.c const MemoryRegionOps pci_host_data_be_ops = { · line 175
Quoted 10 lines
hw/pci_host.c +10
-0+{ +object_property_set_link (OBJECT (s),OBJECT (value),"mmio" ,NULL ); +} + +static void pci_host_initfn (Object *obj) +{ +PCIHostState *s =PCI_HOST (obj); + +object_property_add_link (obj,"mmio" ,TYPE_MEMORY_REGION , + (Object **)&s->address_space,NULL );
This patch has tabs instead of 4-space indent.
Re: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
In reply to Wanpeng LiQuoted 76 lines · Wanpeng Li
From: Anthony Liguori <[email protected]>
Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---
hw/pci_host.c| 26 ++++++++++++++++++++++++++hw/pci_host.h| 5 +++++2 files changed, 31 insertions(+), 0 deletions(-)hw/pci_host.c +26
-0@@ -162,4 +162,30 @@ const MemoryRegionOps pci_host_data_be_ops = { .endianness = DEVICE_BIG_ENDIAN, }; +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value) +{ +object_property_set_link (OBJECT (s),OBJECT (value),"mmio" ,NULL ); +} + +static void pci_host_initfn (Object *obj) +{ +PCIHostState *s =PCI_HOST (obj); + +object_property_add_link (obj,"mmio" ,TYPE_MEMORY_REGION , + (Object **)&s->address_space,NULL ); +} + +static TypeInfo pci_host_type = { + .name =TYPE_PCI_HOST , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (PCIHostState), + .instance_init = pci_host_initfn, +}; + +static void register_devices (void ) +{ +type_register_static (&pci_host_type); +} + +type_init (register_devices);hw/pci_host.h +5
-0@@ -30,6 +30,9 @@#include "sysbus.h" +#define TYPE_PCI_HOST "pci-host" +#define PCI_HOST (obj) OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST) +struct PCIHostState {SysBusDevice busdev;MemoryRegion conf_mem;@@ -49,6 +52,8 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,void pci_data_write (PCIBus *s,uint32_t addr,uint32_t val,int len);uint32_t pci_data_read (PCIBus *s,uint32_t addr,int len); +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value); +extern const MemoryRegionOps pci_host_conf_le_ops;extern const MemoryRegionOps pci_host_conf_be_ops;extern const MemoryRegionOps pci_host_data_le_ops;Signature · 5 lines
1.7.5.4 From 72bc193e6e25cb393437317843a701b82a9b9233 Mon Sep 17 00:00:00 2001
From: Wanpeng Li <[email protected]>
Date: Thu, 22 Mar 2012 17:57:30 +0800
Subject: [PATCH 3/6] convert pci-host to QOM
From: Anthony Liguori <[email protected]>
--- hw/pci_host.c | 26 ++++++++++++++++++++++++++ hw/pci_host.h | 5 +++++ 2 files changed, 31 insertions(+), 0 deletions(-)
hw/pci_host.c +26 -0
@@ -162,4 +162,30 @@ const MemoryRegionOps pci_host_data_be_ops = { .endianness = DEVICE_BIG_ENDIAN, }; +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value) +{ +object_property_set_link (OBJECT (s),OBJECT (value),"mmio" ,NULL ); +} + +static void pci_host_initfn (Object *obj) +{ +PCIHostState *s =PCI_HOST (obj); + +object_property_add_link (obj,"mmio" ,TYPE_MEMORY_REGION , + (Object **)&s->address_space,NULL ); +} + +static TypeInfo pci_host_type = { + .name =TYPE_PCI_HOST , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (PCIHostState), + .instance_init = pci_host_initfn, +}; + +static void register_devices (void ) +{ +type_register_static (&pci_host_type); +} + +type_init (register_devices);
hw/pci_host.h +5 -0
@@ -30,6 +30,9 @@#include "sysbus.h" +#define TYPE_PCI_HOST "pci-host" +#define PCI_HOST (obj) OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST) +struct PCIHostState {SysBusDevice busdev;MemoryRegion conf_mem;
@@ -49,6 +52,8 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,void pci_data_write (PCIBus *s,uint32_t addr,uint32_t val,int len);uint32_t pci_data_read (PCIBus *s,uint32_t addr,int len); +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value); +extern const MemoryRegionOps pci_host_conf_le_ops;extern const MemoryRegionOps pci_host_conf_be_ops;extern const MemoryRegionOps pci_host_data_le_ops;
Signature · 1 line
1.7.5.4
Re: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
In reply to Wanpeng LiAm 26.03.2012 04:06, schrieb Wanpeng Li:
Quoted 5 lines
From: Anthony Liguori <[email protected]>
Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Wanpeng Li <[email protected]>
Some minor formal comments inline, otherwise looks okay.
Quoted 17 lines
--- hw/pci_host.c | 26 ++++++++++++++++++++++++++ hw/pci_host.h | 5 +++++ 2 files changed, 31 insertions(+), 0 deletions(-)hw/pci_host.c +4
-0@@ -162,4 +162,30 @@ const MemoryRegionOps pci_host_data_be_ops = { .endianness = DEVICE_BIG_ENDIAN, }; +void pci_host_set_mmio (PCIHostState *s,MemoryRegion *value) +{ +object_property_set_link (OBJECT (s),OBJECT (value),"mmio" ,NULL ); +}
hw/pci_host.c const MemoryRegionOps pci_host_data_be_ops = { · line 178
Quoted 10 lines
hw/pci_host.c +10
-0+ +static void pci_host_initfn (Object *obj) +{ +PCIHostState *s =PCI_HOST (obj); + +object_property_add_link (obj,"mmio" ,TYPE_MEMORY_REGION , + (Object **)&s->address_space,NULL ); +} + +static TypeInfo pci_host_type = {
I thought the convention was ..._type_info (in case we ever need to do a mass conversion again). And please make it static const.
hw/pci_host.c const MemoryRegionOps pci_host_data_be_ops = { · line 185
Quoted 7 lines
hw/pci_host.c +7
-0+ .name = TYPE_PCI_HOST, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(PCIHostState), + .instance_init = pci_host_initfn, +}; + +static void register_devices (void )
pci_host_register_types please.
hw/pci_host.c const MemoryRegionOps pci_host_data_be_ops = { · line 190
Quoted 5 lines
hw/pci_host.c +5
-0+{ +type_register_static (&pci_host_type); +} + +type_init (register_devices);
No semicolon please, it's not a statement.
There's still some tabs left in the revised version, please run script/checkpatch.pl and repost a v3 inline so that we can comment on it.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 4/6 prepare to create HPET, RTC and i8254 through composition
In reply to Wanpeng LiFrom: Anthony Liguori <[email protected]>
The HPET usually sits on the LPC bus (which replaces ISA in modern systems). It's sometimes a dedicated chip but can certain co-exist in a Super IO chip. I think in terms of where it would live in this hypothetical device model, putting it in the PIIX is rational.
--- hw/hpet.c | 39 ++------------------------------------- hw/hpet_emul.h | 41 +++++++++++++++++++++++++++++++++++++++++ hw/i8254_internal.h | 2 +- hw/mc146818rtc.c | 26 -------------------------- hw/mc146818rtc.h | 29 +++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 64 deletions(-)
hw/hpet.c +2 -37
@@ -42,41 +42,6 @@#define HPET_MSI_SUPPORT 0 -struct HPETState ; -typedef struct HPETTimer {/* timers */ -uint8_t tn;/*timer number*/ -QEMUTimer *qemu_timer; -struct HPETState *state; -/* Memory-mapped, software visible timer registers */ -uint64_t config;/* configuration/cap */ -uint64_t cmp;/* comparator */ -uint64_t fsb;/* FSB route */ -/* Hidden register state */ -uint64_t period;/* Last value written to comparator */ -uint8_t wrap_flag;/* timer pop will indicate wrap for one-shot 32-bit -* mode. Next pop will be actual timer expiration. -*/ -}HPETTimer ; - -typedef struct HPETState { -SysBusDevice busdev; -MemoryRegion iomem; -uint64_t hpet_offset; -qemu_irq irqs[HPET_NUM_IRQ_ROUTES ]; -uint32_t flags; -uint8_t rtc_irq_level; -qemu_irq pit_enabled; -uint8_t num_timers; -HPETTimer timer[HPET_MAX_TIMERS ]; - -/* Memory-mapped, software visible registers */ -uint64_t capability;/* capabilities */ -uint64_t config;/* configuration */ -uint64_t isr;/* interrupt status reg */ -uint64_t hpet_counter;/* main counter */ -uint8_t hpet_id;/* instance id */ -}HPETState ; -static uint32_t hpet_in_legacy_mode (HPETState *s) {return s->config &HPET_CFG_LEGACY ;
@@ -278,7 +243,7 @@ static const VMStateDescription vmstate_hpet_timer = { };static const VMStateDescription vmstate_hpet = { - .name ="hpet" , + .name =TYPE_HPET , .version_id =2 , .minimum_version_id =1 , .minimum_version_id_old =1 ,
@@ -746,7 +711,7 @@ static void hpet_device_class_init(ObjectClass *klass, void *data) }static TypeInfo hpet_device_info = { - .name ="hpet" , + .name =TYPE_HPET , .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (HPETState), .class_init = hpet_device_class_init,
hw/hpet_emul.h +41 -0
51 lines not on this page · raw message
hw/i8254_internal.h +1 -1
@@ -26,7 +26,6 @@#define QEMU_I8254_INTERNAL_H #include "hw.h" -#include "pc.h" #include "isa.h" typedef struct PITChannelState {
@@ -57,6 +56,7 @@ typedef struct PITCommonState {PITChannelState channels[3 ]; } PITCommonState; +#define TYPE_PIT "isa-pit"#define TYPE_PIT_COMMON "pit-common"#define PIT_COMMON (obj) \ OBJECT_CHECK(PITCommonState, (obj), TYPE_PIT_COMMON)
hw/mc146818rtc.c +0 -26
@@ -80,32 +80,6 @@#define REG_C_PF 0x40#define REG_C_AF 0x20 -typedef struct RTCState { -ISADevice dev; -MemoryRegion io; -uint8_t cmos_data[128 ]; -uint8_t cmos_index; -struct tm current_tm; -int32_t base_year; -qemu_irq irq; -qemu_irq sqw_irq; -int it_shift; -/* periodic timer */ -QEMUTimer *periodic_timer; -int64_t next_periodic_time; -/* second update */ -int64_t next_second_time; -uint16_t irq_reinject_on_ack_count; -uint32_t irq_coalesced; -uint32_t period; -QEMUTimer *coalesced_timer; -QEMUTimer *second_timer; -QEMUTimer *second_timer2; -Notifier clock_reset_notifier; -LostTickPolicy lost_tick_policy; -Notifier suspend_notifier; -}RTCState ; -static void rtc_set_time (RTCState *s);static void rtc_copy_date (RTCState *s);
hw/mc146818rtc.h +29 -0
@@ -2,9 +2,38 @@#define MC146818RTC_H #include "isa.h" +#include "notify.h" #define RTC_ISA_IRQ 8 +#define TYPE_RTC "mc146818rtc" + +typedef struct RTCState { +ISADevice dev; +MemoryRegion io; +uint8_t cmos_data[128 ]; +uint8_t cmos_index; +struct tm current_tm; +int32_t base_year; +qemu_irq irq; +qemu_irq sqw_irq; +int it_shift; +/* periodic timer */ +QEMUTimer *periodic_timer; +int64_t next_periodic_time; +/* second update */ +int64_t next_second_time; +uint16_t irq_reinject_on_ack_count; +uint32_t irq_coalesced; +uint32_t period; +QEMUTimer *coalesced_timer; +QEMUTimer *second_timer; +QEMUTimer *second_timer2; +Notifier clock_reset_notifier; +LostTickPolicy lost_tick_policy; +Notifier suspend_notifier; +}RTCState ; +ISADevice *rtc_init (ISABus *bus,int base_year,qemu_irq intercept_irq);void rtc_set_memory (ISADevice *dev,int addr,int val);void rtc_set_date (ISADevice *dev,const struct tm *tm);
Signature · 1 line
1.7.5.4
PATCH 5/6 merge pc_piix.c to pc.c
In reply to Wanpeng LiFrom: Anthony Liguori <[email protected]>
--- Makefile.target | 1 - hw/pc.c | 816 +++++++++++++++++++++++++++++++++++++++++++++++++------ hw/pc.h | 20 +- hw/pc_piix.c | 762 --------------------------------------------------- 4 files changed, 739 insertions(+), 860 deletions(-) delete mode 100644 hw/pc_piix.c
Makefile.target +0 -1
@@ -251,7 +251,6 @@ obj-i386-y += sga.o ioapic_common.o ioapic.o i440fx.o piix3.o obj-i386-y += vmport.o obj-i386-y += pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o -obj-i386-y += pc_piix.o obj-i386-y += pc_sysfw.o obj-i386-$(CONFIG_KVM) += kvm/clock.o kvm/apic.o kvm/i8259.o kvm/ioapic.o kvm/i8254.o obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
hw/pc.c +735 -81
891 lines not on this page · raw message
hw/pc.h +4 -16
@@ -9,6 +9,7 @@#include "net.h" #include "memory.h" #include "ioapic.h" +#include "i440fx.h" /* PC-style peripherals (also used by other machines). */
@@ -117,7 +118,6 @@ void pc_memory_init(MemoryRegion *system_memory,qemu_irq *pc_allocate_cpu_irq (void );DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus);void pc_basic_device_init (ISABus *isa_bus,qemu_irq *gsi, -ISADevice **rtc_state,ISADevice **floppy,bool no_vmport);void pc_init_ne2k_isa (ISABus *bus,NICInfo *nd);
@@ -148,21 +148,9 @@ void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);/* hpet.c */ extern int no_hpet; -/* piix_pci.c */ -struct PCII440FXState ; -typedef struct PCII440FXState PCII440FXState ; - -PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn, -ISABus **isa_bus,qemu_irq *pic, -MemoryRegion *address_space_mem, -MemoryRegion *address_space_io, -ram_addr_t ram_size, -target_phys_addr_t pci_hole_start, -target_phys_addr_t pci_hole_size, -target_phys_addr_t pci_hole64_start, -target_phys_addr_t pci_hole64_size, -MemoryRegion *pci_memory, -MemoryRegion *ram_memory); +/* pcspk.c */ +void pcskp_init (ISADevice *pit); +int pcskp_audio_init (qemu_irq *pic);/* piix4.c */ extern PCIDevice *piix4_dev;
hw/pc_piix.c deleted +0 -762
762 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Re: [Qemu-devel] [PATCH 5/6] merge pc_piix.c to pc.c
Quoted 12 lines · Wanpeng Li
From: Anthony Liguori <[email protected]>
hw/pc.c +1
-1@@ -889,7 +900,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)DeviceState *dev;static int apic_mapped; -if (kvm_irqchip_in_kernel ()) { +if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { dev =qdev_create (NULL ,"kvm-apic" ); }else { dev =qdev_create (NULL ,"apic" );
hw/pc.c static DeviceState *apic_init(void *env, uint8_t apic_id) · line 923
Quoted 6 lines
hw/pc.c +1
-1@@ -908,7 +919,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) }/* KVM does not support MSI yet. */ -if (!kvm_irqchip_in_kernel ()) { +if (!kvm_enabled () || !kvm_irqchip_in_kernel ()) { msi_supported = true;
Why these changes?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 5/6] merge pc_piix.c to pc.c
Quoted 15 lines · Avi Kivity
Quoted 14 lines · Wanpeng Li
From: Anthony Liguori <[email protected]>
hw/pc.c +1
-1@@ -889,7 +900,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)DeviceState *dev;static int apic_mapped; -if (kvm_irqchip_in_kernel ()) { +if (kvm_enabled () &&kvm_irqchip_in_kernel ()) { dev =qdev_create (NULL ,"kvm-apic" ); }else { dev =qdev_create (NULL ,"apic" );@@ -908,7 +919,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) }
Quoted 7 lines
hw/pc.c static DeviceState *apic_init(void *env, uint8_t apic_id) · line 923
Quoted 4 lines
hw/pc.c +1
-1/* KVM does not support MSI yet. */ -if (!kvm_irqchip_in_kernel ()) { +if (!kvm_enabled () || !kvm_irqchip_in_kernel ()) { msi_supported = true;Why these changes?
Yep, they are obsolete, likely related to the rebase of the original patch. A lot of code is moved around here, and I bet there are more artifacts...
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Re: [Qemu-devel] [PATCH 5/6] merge pc_piix.c to pc.c
Quoted 24 lines · Jan Kiszka
Quoted 15 lines · Avi Kivity
Quoted 14 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
hw/pc.c +1
-1@@ -889,7 +900,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)DeviceState *dev;static int apic_mapped; -if (kvm_irqchip_in_kernel ()) { +if (kvm_enabled ()&&kvm_irqchip_in_kernel ()) { dev =qdev_create (NULL ,"kvm-apic" ); }else { dev =qdev_create (NULL ,"apic" );@@ -908,7 +919,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id) }Quoted 7 lines
hw/pc.c static DeviceState *apic_init(void *env, uint8_t apic_id) · line 923
Quoted 4 lines
hw/pc.c +1
-1/* KVM does not support MSI yet. */ -if (!kvm_irqchip_in_kernel ()) { +if (!kvm_enabled () || !kvm_irqchip_in_kernel ()) { msi_supported = true;Why these changes?
Quoted 3 lines
Yep, they are obsolete, likely related to the rebase of the original patch. A lot of code is moved around here, and I bet there are more artifacts...
git should have thrown a rebase error here. I think that means the conflicts were ignored.
For something like this, if there's a rebase error, you pretty much have to repeat the copy/paste of the code for the section that threw a rebase error.
I'd suggest rebasing again but this time, be a bit more careful when resolving conflicts.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
PATCH 6/6 make some functions static
In reply to Wanpeng LiFrom: Anthony Liguori <[email protected]>
--- hw/pc.c | 22 +++++++++++----------- hw/pc.h | 26 -------------------------- 2 files changed, 11 insertions(+), 37 deletions(-)
hw/pc.c +11 -11
@@ -98,7 +98,7 @@ static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };static struct e820_table e820_table;struct hpet_fw_config hpet_cfg = {.count =UINT8_MAX }; -void gsi_handler (void *opaque,int n,int level) +static void gsi_handler (void *opaque,int n,int level) {GSIState *s = opaque;
@@ -116,7 +116,7 @@ static void ioport80_write(void *opaque, uint32_t addr, uint32_t data)/* MSDOS compatibility mode FPU exception support */ static qemu_irq ferr_irq; -void pc_register_ferr_irq (qemu_irq irq) +static void pc_register_ferr_irq (qemu_irq irq) { ferr_irq = irq; }
@@ -339,7 +339,7 @@ static void pc_cmos_init_late(void *opaque)qemu_unregister_reset (pc_cmos_init_late, opaque); } -void pc_cmos_init (ram_addr_t ram_size,ram_addr_t above_4g_mem_size, +static void pc_cmos_init (ram_addr_t ram_size,ram_addr_t above_4g_mem_size,const char *boot_device,ISADevice *floppy,BusState *idebus0,BusState *idebus1,ISADevice *s)
@@ -869,7 +869,7 @@ static const int ne2000_irq[NE2000_NB_MAX] = { 9, 10, 11, 3, 4, 5 };static const int parallel_io[MAX_PARALLEL_PORTS ] = {0x378 ,0x278 ,0x3bc };static const int parallel_irq[MAX_PARALLEL_PORTS ] = {7 ,7 ,7 }; -void pc_init_ne2k_isa (ISABus *bus,NICInfo *nd) +static void pc_init_ne2k_isa (ISABus *bus,NICInfo *nd) {static int nb_ne2k =0 ;
@@ -926,7 +926,7 @@ static DeviceState *apic_init(void *env, uint8_t apic_id)return dev; } -void pc_acpi_smi_interrupt (void *opaque,int irq,int level) +static void pc_acpi_smi_interrupt (void *opaque,int irq,int level) {CPUX86State *s = opaque;
@@ -960,7 +960,7 @@ static CPUX86State *pc_new_cpu(const char *cpu_model)return env; } -void pc_cpus_init (const char *cpu_model) +static void pc_cpus_init (const char *cpu_model) {int i;
@@ -978,7 +978,7 @@ void pc_cpus_init(const char *cpu_model) } } -void pc_memory_init(MemoryRegion *system_memory, +static void pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename,
@@ -1002,12 +1002,12 @@ void pc_memory_init(MemoryRegion *system_memory, } } -qemu_irq *pc_allocate_cpu_irq (void ) +static qemu_irq *pc_allocate_cpu_irq (void ) {return qemu_allocate_irqs (pic_irq_request,NULL ,1 ); } -DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus) +static DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus) {DeviceState *dev =NULL ;
@@ -1051,7 +1051,7 @@ static void cpu_request_exit(void *opaque, int irq, int level) } } -void pc_basic_device_init (ISABus *isa_bus,qemu_irq *gsi, +static void pc_basic_device_init (ISABus *isa_bus,qemu_irq *gsi,ISADevice **floppy,bool no_vmport) {
@@ -1102,7 +1102,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, *floppy =fdctrl_init_isa (isa_bus, fd); } -void pc_pci_device_init (PCIBus *pci_bus) +static void pc_pci_device_init (PCIBus *pci_bus) {int max_bus;int bus;
hw/pc.h +0 -26
@@ -80,8 +80,6 @@ typedef struct GSIState {qemu_irq ioapic_irq[IOAPIC_NUM_PINS ]; } GSIState; -void gsi_handler (void *opaque,int n,int level); -/* vmport.c */ static inline void vmport_init (ISABus *bus) {
@@ -103,30 +101,6 @@ void i8042_setup_a20_line(ISADevice *dev, qemu_irq *a20_out);/* pc.c */ extern int fd_bootchk; -void pc_register_ferr_irq (qemu_irq irq); -void pc_acpi_smi_interrupt (void *opaque,int irq,int level); - -void pc_cpus_init (const char *cpu_model); -void pc_memory_init (MemoryRegion *system_memory, -const char *kernel_filename, -const char *kernel_cmdline, -const char *initrd_filename, -ram_addr_t below_4g_mem_size, -ram_addr_t above_4g_mem_size, -MemoryRegion *rom_memory, -MemoryRegion **ram_memory); -qemu_irq *pc_allocate_cpu_irq (void ); -DeviceState *pc_vga_init (ISABus *isa_bus,PCIBus *pci_bus); -void pc_basic_device_init (ISABus *isa_bus,qemu_irq *gsi, -ISADevice **floppy, -bool no_vmport); -void pc_init_ne2k_isa (ISABus *bus,NICInfo *nd); -void pc_cmos_init (ram_addr_t ram_size,ram_addr_t above_4g_mem_size, -const char *boot_device, -ISADevice *floppy,BusState *ide0,BusState *ide1, -ISADevice *s); -void pc_pci_device_init (PCIBus *pci_bus); -typedef void (*cpu_set_smm_t )(int smm,void *arg);void cpu_smm_register (cpu_set_smm_t callback,void *arg);
Signature · 1 line
1.7.5.4
Quoted 22 lines · Wanpeng Li
From: Anthony Liguori <[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.
Quoted 7 lines
The two stage initialization of QOM is important here.
instance_init()is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.
While I see the value of the overall direction, I still disagree on making internal data structures of HPET, RTC and 8254 publicly available. That's a wrong step back. I'm sure there are smarter solutions, alse as there were some proposals back then in the original thread.
I'm also sure we will have to refactor the merge significantly again for the introduction of additional chipsets and PC boards. But unless those requirements can already be specified (Isaku?), that might be unavoidable.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 3 lines · Jan Kiszka
I'm also sure we will have to refactor the merge significantly again for the introduction of additional chipsets and PC boards. But unless those requirements can already be specified (Isaku?), that might be unavoidable.
Agreed. At least I'd like pam/smram stuff decoupled from piix. It is difficult to understand why patches of 5, 6 are needed without further patches because they don't show how the code will look like eventually. Anyway I expect some sort of refactor again and am waiting for QOM related stuff stabilizing.
thanks,
Signature · 1 line
yamahata
Quoted 6 lines · Isaku Yamahata
Quoted 3 lines · Jan Kiszka
I'm also sure we will have to refactor the merge significantly again for the introduction of additional chipsets and PC boards. But unless those requirements can already be specified (Isaku?), that might be unavoidable.
Agreed. At least I'd like pam/smram stuff decoupled from piix.
s/piix/i440fx/
PAM/SRAM has nothing do to with the piix. Part of the problem with the current layout is that the distinction between i440fx and piix is not clear. The piix is just a SuperIO chip (and southbridge).
I think the better approach is to have a PCNorthBridge base-class that contains functionality like PAM/SRAM that both I440FX and Q35 inherit from.
Obviously, without getting the I440FX/PIIX3 modeling in shape, we can't look reasonable at how to share code.
Regards,
Anthony Liguori
Quoted 6 lines
It is difficult to understand why patches of 5, 6 are needed without further patches because they don't show how the code will look like eventually. Anyway I expect some sort of refactor again and am waiting for QOM related stuff stabilizing.
thanks,
Quoted 8 lines · Anthony Liguori
Quoted 7 lines · Isaku Yamahata
Quoted 5 lines · Jan Kiszka
I'm also sure we will have to refactor the merge significantly again for
the introduction of additional chipsets and PC boards. But unless those requirements can already be specified (Isaku?), that might be unavoidable.
Quoted 7 lines
Quoted 1 line
Agreed. At least I'd like pam/smram stuff decoupled from piix.
s/piix/i440fx/
PAM/SRAM has nothing do to with the piix. Part of the problem with the current layout is that the distinction between i440fx and piix is not clear. The piix is just a SuperIO chip (and southbridge).
Right.
Quoted 4 lines
I think the better approach is to have a PCNorthBridge base-class that contains functionality like PAM/SRAM that both I440FX and Q35 inherit from.
I hate to transform this into a languagey discussion, but I don't think inheritance is the right thing here. While both 440fx and q35 are north bridges, the similar implementation of PAM/SMRAM is not part of that. It's just a random result of the chips' evolution. I think the code for PAM/SMRAM can be reused if the specs match, but using a has-a instead of an is-a relationship.
As a counterexample, consider a northbridge that implements PAM/SMRAM differently. You'd have to refactor PCNorthBridge into two separate classes. With the other approach the new northbridge simply doesn't include the existing PAM/SMRAM implementation and instead implements its own.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 11 lines · Avi Kivity
Quoted 4 lines
I think the better approach is to have a PCNorthBridge base-class that contains functionality like PAM/SRAM that both I440FX and Q35 inherit from.
I hate to transform this into a languagey discussion, but I don't think inheritance is the right thing here. While both 440fx and q35 are north bridges, the similar implementation of PAM/SMRAM is not part of that. It's just a random result of the chips' evolution. I think the code for PAM/SMRAM can be reused if the specs match, but using a has-a instead of an is-a relationship.
The direction I was heading with the i440fx, the i440fx has-a i440fx-pmc and it was the pmc that actually did PAM/SMRAM.
I don't recall there being significant i440fx specific logic in the i440fx-pmc so it's entirely possible the the i440fx-pmc could be renamed to PCNorthBridge and then both the i440fx and q35 could has-a the same PCNorthBridge (possible with some properties to control certain behaviors.
We really need to push forward with the refactoring to find the right model here.
Regards,
Anthony Liguori
Quoted 7 lines
As a counterexample, consider a northbridge that implements PAM/SMRAM differently. You'd have to refactor PCNorthBridge into two separate classes. With the other approach the new northbridge simply doesn't include the existing PAM/SMRAM implementation and instead implements its own.
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Avi Kivity
Quoted 4 lines
I think the better approach is to have a PCNorthBridge base-class that contains functionality like PAM/SRAM that both I440FX and Q35 inherit from.
I hate to transform this into a languagey discussion, but I don't think inheritance is the right thing here. While both 440fx and q35 are north bridges, the similar implementation of PAM/SMRAM is not part of that. It's just a random result of the chips' evolution. I think the code for PAM/SMRAM can be reused if the specs match, but using a has-a instead of an is-a relationship.
Quoted 9 lines
The direction I was heading with the i440fx, the i440fx has-a i440fx-pmc and it was the pmc that actually did PAM/SMRAM.
I don't recall there being significant i440fx specific logic in the i440fx-pmc so it's entirely possible the the i440fx-pmc could be renamed to PCNorthBridge and then both the i440fx and q35 could has-a the same PCNorthBridge (possible with some properties to control certain behaviors.
Sounds about right.
Quoted 3 lines
We really need to push forward with the refactoring to find the right model here.
Yes. This is opportunistic reuse - we find some sections of both specs that are identical, and we reuse the code there.
In fact code duplication is also justified here. The specs are duplicated, why not the code. Not against deduplication of course, but we need not go out of our way here.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 28 lines · Jan Kiszka
Quoted 27 lines · Wanpeng Li
From: Anthony Liguori <[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.The two stage initialization of QOM is important here. instance_init() is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
Quoted 8 lines
Quoted 2 lines
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.While I see the value of the overall direction, I still disagree on making internal data structures of HPET, RTC and 8254 publicly available. That's a wrong step back. I'm sure there are smarter solutions, alse as there were some proposals back then in the original thread.
Fully agree. At least there should be something like this memory.c line:
/* All fields are private - violators will be prosecuted */
or other C++-ish comments about the fields being private to the class. Device classes should not have friend classes except in exceptional cases like LAPIC/RTC.
Quoted 10 lines
I'm also sure we will have to refactor the merge significantly again for the introduction of additional chipsets and PC boards. But unless those requirements can already be specified (Isaku?), that might be unavoidable.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
Quoted 28 lines · Jan Kiszka
Quoted 27 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.The two stage initialization of QOM is important here.
instance_init()is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
Quoted 8 lines
Quoted 2 lines
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.While I see the value of the overall direction, I still disagree on making internal data structures of HPET, RTC and 8254 publicly available. That's a wrong step back. I'm sure there are smarter solutions, alse as there were some proposals back then in the original thread.
I'm not fully decided myself. A couple things are clear to me though:
1) We must expose type proper types in header files. We need there to be a globally accessible RTCState type and functions that operate on it.
2) We can simplify memory management by knowing the size of the type in the header files too.
Since this is an easily refactorable thing to look at later, I think we should start with extracting the types.
Quoted 4 lines
I'm also sure we will have to refactor the merge significantly again for the introduction of additional chipsets and PC boards. But unless those requirements can already be specified (Isaku?), that might be unavoidable.
We cannot introduce another chipset without properly refactoring the i440fx. The previous refactorings that were oriented around moving code into functions created a nasty spaghetti of reference passing.
Regards,
Anthony Liguori
Quoted 2 lines
Jan
Quoted 38 lines · Anthony Liguori
Quoted 28 lines · Jan Kiszka
Quoted 27 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.The two stage initialization of QOM is important here.
instance_init()is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.Quoted 8 lines
Quoted 2 lines
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.While I see the value of the overall direction, I still disagree on making internal data structures of HPET, RTC and 8254 publicly available. That's a wrong step back. I'm sure there are smarter solutions, alse as there were some proposals back then in the original thread.
Quoted 4 lines
I'm not fully decided myself. A couple things are clear to me though:
1) We must expose type proper types in header files. We need there to be a globally accessible RTCState type and functions that operate on it.
I'm not sure what "proper type" means in this context, but I'm quite sure that there should be no need for poking into the internal of the class outside of mc146818rtc.c. We even abstracted the specifics of the RTC away when it is embedded into a super-IO and interacts with an HPET. If QOM requires such poking, then that requirement should be reassessed.
Quoted 3 lines
2) We can simplify memory management by knowing the size of the type in the header files too.
Is this more than a malloc-free pair?
Quoted 3 lines
Since this is an easily refactorable thing to look at later, I think we should start with extracting the types.
My worry is that those three refactorings set bad examples for others. So I'd like to avoid such back and forth if possible.
Jan
Quoted 39 lines · Jan Kiszka
Quoted 38 lines · Anthony Liguori
Quoted 36 lines · Jan Kiszka
Quoted 22 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.Quoted 7 lines
The two stage initialization of QOM is important here.
instance_init()is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.While I see the value of the overall direction, I still disagree on making internal data structures of HPET, RTC and 8254 publicly available. That's a wrong step back. I'm sure there are smarter solutions, alse as there were some proposals back then in the original thread.
Quoted 8 lines
Quoted 4 lines
I'm not fully decided myself. A couple things are clear to me though:
1) We must expose type proper types in header files. We need there to be a globally accessible RTCState type and functions that operate on it.
I'm not sure what "proper type" means in this context, but I'm quite sure that there should be no need for poking into the internal of the class outside of
mc146818rtc.c.
It needs to be at least a forward reference. So we can avoid stuff like:
int apic_accept_pic_intr(DeviceState *s);
It should be:
int apic_accept_pic_intr(APICState *s);
So we can make use of the lovely type checking provided by the compiler to us.
Quoted 3 lines
We even abstracted the specifics of the
RTC away when it is embedded into a super-IO and interacts with an HPET. If QOM requires such poking, then that requirement should be reassessed.
There are a couple of ways to make types private while still having forward declarations. None of them are straight forward. That's why I suggest we save this for another day.
Quoted 4 lines
Quoted 3 lines
2) We can simplify memory management by knowing the size of the type in the header files too.
Quoted 8 lines
Is this more than a malloc-free pair?
Quoted 3 lines
Since this is an easily refactorable thing to look at later, I think we should start with extracting the types.
My worry is that those three refactorings set bad examples for others. So I'd like to avoid such back and forth if possible.
I'm not really worried about it. It's so easier to refactor this later. Why rush it now?
Regards,
Anthony Liguori
Quoted 1 line
Jan
Quoted 61 lines · Anthony Liguori
Quoted 50 lines · Jan Kiszka
Quoted 49 lines · Anthony Liguori
Quoted 40 lines · Jan Kiszka
Quoted 35 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more
modelled and less ad-hoc. The highlights of this series are:1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled
through composition4)
i440fx_initis trivialized to creating devices and setting
properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion,
we should quickly get to the point wheremachine->initdisappears completely in
favor of just creating a handful of devices.The two stage initialization of QOM is important here.
instance_init()is when
composed devices are created which means that after you've created a device, all
of its children are visible in the device model. This lets you set properties
of the parent and its children.Quoted 3 lines
realize()(which is still calledDeviceState::inittoday) will be called right
before the guest starts up for the first time.Quoted 5 lines
While I see the value of the overall direction, I still disagree on making internal data structures of HPET, RTC and 8254 publicly available. That's a wrong step back. I'm sure there are smarter solutions, alse as there were some proposals back then in the original thread.
I'm not fully decided myself. A couple things are clear to me though:
Quoted 7 lines
Quoted 3 lines
1) We must expose type proper types in header files. We need there to be a
globally accessible RTCState type and functions that operate on it.I'm not sure what "proper type" means in this context, but I'm quite sure that there should be no need for poking into the internal of the class outside of
mc146818rtc.c.It needs to be at least a forward reference. So we can avoid stuff like:
Quoted 8 lines
int
apic_accept_pic_intr(DeviceState *s);It should be:
int
apic_accept_pic_intr(APICState *s);So we can make use of the lovely type checking provided by the compiler to us.
I do not disagree. A pointer is harmless.
Quoted 21 lines
Quoted 4 lines
We even abstracted the specifics of the
RTC away when it is embedded into a super-IO and interacts with an HPET. If QOM requires such poking, then that requirement should be reassessed.There are a couple of ways to make types private while still having forward declarations. None of them are straight forward. That's why I suggest we save this for another day.
Quoted 12 lines
Quoted 4 lines
2) We can simplify memory management by knowing the size of the type in the
header files too.Is this more than a malloc-free pair?
Quoted 4 lines
Since this is an easily refactorable thing to look at later, I think we should
start with extracting the types.
Quoted 5 lines
Quoted 2 lines
My worry is that those three refactorings set bad examples for others. So I'd like to avoid such back and forth if possible.
I'm not really worried about it. It's so easier to refactor this later. Why rush it now?
You rush changing the current layout, not me. :)
Jan
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 4 lines
Quoted 3 lines
Since this is an easily refactorable thing to look at later, I think we should
start with extracting the types.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
My worry is that those three refactorings set bad examples for others. So I'd like to avoid such back and forth if possible.
I'm not really worried about it. It's so easier to refactor this later. Why rush it now?
You rush changing the current layout, not me. :)
No, I'm trying to do incremental changes without boiling the ocean in the process.
I think we all are in violent agreement about where we want to end up (as opaque types as possible). I don't want to hold back additional refactoring on doing this right (and it's not just a matter of malloc/free).
Regards,
Anthony Liguori
Quoted 2 lines
Jan
Quoted 14 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 4 lines
Quoted 3 lines
Since this is an easily refactorable thing to look at later, I think we should
start with extracting the types.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
My worry is that those three refactorings set bad examples for others. So I'd like to avoid such back and forth if possible.
I'm not really worried about it. It's so easier to refactor this later. Why rush it now?
You rush changing the current layout, not me. :)
Quoted 7 lines
No, I'm trying to do incremental changes without boiling the ocean in the process.
I think we all are in violent agreement about where we want to end up (as opaque types as possible). I don't want to hold back additional refactoring on doing this right (and it's not just a matter of malloc/free).
Either I'm missing it in the code shuffling, or it's not part of this
series: Can you point out where more that a forward reference and malloc/free is needed?
Jan
Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 4 lines
Quoted 3 lines
Since this is an easily refactorable thing to look at later, I think we should
start with extracting the types.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
My worry is that those three refactorings set bad examples for others. So I'd like to avoid such back and forth if possible.
I'm not really worried about it. It's so easier to refactor this later. Why rush it now?
You rush changing the current layout, not me. :)
No, I'm trying to do incremental changes without boiling the ocean in the process.
Quoted 8 lines
Quoted 4 lines
I think we all are in violent agreement about where we want to end up (as opaque types as possible). I don't want to hold back additional refactoring on doing this right (and it's not just a matter of malloc/free).
Either I'm missing it in the code shuffling, or it's not part of this
series: Can you point out where more that a forward reference and malloc/free is needed?
QOM is built around the concept that the type size is know (as is GObject). type_initialize() assumes that the pointer passed is an adequate size.
You would either need to move to a model where the memory was completely owned by QOM (which would mean folding type_new into type_initialize) or have a way to query instance size for a given type.
This would also mean that reference counting should be revisited although with how dereferencing a parent affects the child.
It's not rocket science, but it's also something that needs to be done carefully.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Quoted 37 lines · Anthony Liguori
Quoted 19 lines · Jan Kiszka
Quoted 18 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 4 lines
Quoted 3 lines
Since this is an easily refactorable thing to look at later, I think we should
start with extracting the types.Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
My worry is that those three refactorings set bad examples for others.
So I'd like to avoid such back and forth if possible.I'm not really worried about it. It's so easier to refactor this later. Why rush it now?
You rush changing the current layout, not me. :)
No, I'm trying to do incremental changes without boiling the ocean in the process.
Quoted 8 lines
Quoted 4 lines
I think we all are in violent agreement about where we want to end up (as opaque types as possible). I don't want to hold back additional refactoring on doing this right (and it's not just a matter of malloc/free).
Either I'm missing it in the code shuffling, or it's not part of this
series: Can you point out where more that a forward reference and malloc/free is needed?QOM is built around the concept that the type size is know (as is GObject).
type_initialize()assumes that the pointer passed is an adequate size.You would either need to move to a model where the memory was completely owned by QOM (which would mean folding
type_newintotype_initialize) or have a way to query instance size for a given type.
Quoted 5 lines
This would also mean that reference counting should be revisited although with how dereferencing a parent affects the child.
It's not rocket science, but it's also something that needs to be done carefully.
But all this is only a problem for these three here (PIT, RTC, HPET) as their objects shall be embedded into the super-IO. If you only embed an object pointer, it shouldn't be an issue anymore, no?
Also inheritance is not a problem here as we do not derive from the three types in question. If there is a super/sub-class relation, those need to share an internal header, of course.
Jan
Quoted 11 lines · Jan Kiszka
Quoted 6 lines · Anthony Liguori
On 03/26/2012 02:44 PM, Jan Kiszka wrote:
This would also mean that reference counting should be revisited although with how dereferencing a parent affects the child.It's not rocket science, but it's also something that needs to be done carefully.
But all this is only a problem for these three here (PIT, RTC, HPET) as their objects shall be embedded into the super-IO. If you only embed an object pointer, it shouldn't be an issue anymore, no?
The reference counting stuff obviously needs to be looked at even in this case.
Quoted 3 lines
Also inheritance is not a problem here as we do not derive from the three types in question. If there is a super/sub-class relation, those need to share an internal header, of course.
Yes, but then you have two headers for every type. Is that really a good thing?
I think I prefer to just mark fields as /*< private >*/ and scold people if they violate that convention.
Regards,
Anthony Liguori
Quoted 2 lines
Jan
Quoted 9 lines · Anthony Liguori
Quoted 8 lines · Jan Kiszka
Quoted 6 lines · Anthony Liguori
On 03/26/2012 02:44 PM, Jan Kiszka wrote:
This would also mean that reference counting should be revisited although with how dereferencing a parent affects the child.It's not rocket science, but it's also something that needs to be done carefully.
Quoted 6 lines
Quoted 3 lines
But all this is only a problem for these three here (PIT, RTC, HPET) as their objects shall be embedded into the super-IO. If you only embed an object pointer, it shouldn't be an issue anymore, no?
The reference counting stuff obviously needs to be looked at even in this case.
A composite object is owned by its container. So it should go when the container leaves.
Quoted 7 lines
Quoted 4 lines
Also inheritance is not a problem here as we do not derive from the three types in question. If there is a super/sub-class relation, those need to share an internal header, of course.
Yes, but then you have two headers for every type. Is that really a good thing?
It's cleaner and more explicit than tagging members with comments. And it's nothing we will have for each and every type as only a small subset is actually inheriting, the mass is finalizing.
Jan
Quoted 14 lines · Jan Kiszka
Quoted 13 lines · Anthony Liguori
Quoted 11 lines · Jan Kiszka
Quoted 6 lines · Anthony Liguori
On 03/26/2012 02:44 PM, Jan Kiszka wrote:
This would also mean that reference counting should be revisited although with how dereferencing a parent affects the child.It's not rocket science, but it's also something that needs to be done carefully.
But all this is only a problem for these three here (PIT, RTC, HPET) as their objects shall be embedded into the super-IO. If you only embed an object pointer, it shouldn't be an issue anymore, no?
Quoted 5 lines
Quoted 2 lines
The reference counting stuff obviously needs to be looked at even in this case.
A composite object is owned by its container. So it should go when the container leaves.
It's more complicated than that because it's a tree, not a graph. So there may be additional references held beyond the parent.
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Also inheritance is not a problem here as we do not derive from the three types in question. If there is a super/sub-class relation, those need to share an internal header, of course.
Yes, but then you have two headers for every type. Is that really a good thing?
It's cleaner and more explicit than tagging members with comments. And it's nothing we will have for each and every type as only a small subset is actually inheriting, the mass is finalizing.
I don't fundamentally disagree with anything you're saying here. I'm only pointing out that (1) it's not a trivial problem and (2) it's not an urgent problem.
Regards,
Anthony Liguori
Quoted 2 lines
Jan
Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Anthony Liguori
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Anthony Liguori
Quoted 4 lines
Quoted 3 lines
Since this is an easily refactorable thing to look at later, I think we should
start with extracting the types.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
My worry is that those three refactorings set bad examples for others. So I'd like to avoid such back and forth if possible.
I'm not really worried about it. It's so easier to refactor this later. Why rush it now?
You rush changing the current layout, not me. :)
No, I'm trying to do incremental changes without boiling the ocean in the process.
Quoted 8 lines
Quoted 4 lines
I think we all are in violent agreement about where we want to end up (as opaque types as possible). I don't want to hold back additional refactoring on doing this right (and it's not just a matter of malloc/free).
Either I'm missing it in the code shuffling, or it's not part of this
series: Can you point out where more that a forward reference and malloc/free is needed?
Inheritance is the other nasty case.
To inherit from a type, you need to have the type definition. This is a pretty common problem with Object systems and the typical solution is PIMPL[1].
So maybe that's the right thing to do here, but that would have a significant affect on the code. That's what I mean by rushing how to handle this. There are multiple possible solutions and they need to be considered.
The problem is purely aesthetic too, so I don't see a rush to fix it.
[1] http://c2.com/cgi/wiki?PimplIdiom
Regards,
Anthony Liguori
Quoted 2 lines
Jan
Am 26.03.2012 04:06, schrieb Wanpeng Li:
Quoted 1 line
From: Anthony Liguori <[email protected]>
Resending an old cover letter is not a good idea. This looks like a v2, so please mark it as such in the subjects; it's missing a Change Log against Anthony's version. I take it, some patches were dropped?
Quoted 11 lines
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties
Quoted 7 lines
5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.
I agree that machine->init needs to be refactored, however I don't think it'll disappear, just be moved into initfn/realize functions.
Andreas
Quoted 39 lines
The two stage initialization of QOM is important here.
instance_init()is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Wanpeng Li <[email protected]>--- Makefile.target | 3 +- hw/hpet.c | 39 +--- hw/hpet_emul.h | 41 +++ hw/i440fx.c | 431 ++++++++++++++++++++++++++ hw/i440fx.h | 78 +++++ hw/i8254_internal.h | 2 +- hw/mc146818rtc.c | 26 -- hw/mc146818rtc.h | 29 ++ hw/pc.c | 838 +++++++++++++++++++++++++++++++++++++++++++++------ hw/pc.h | 46 +--- hw/pc_piix.c | 762 ---------------------------------------------- hw/pci_host.c | 26 ++ hw/pci_host.h | 5 + hw/piix3.c | 274 +++++++++++++++++ hw/piix3.h | 79 +++++ hw/piix_pci.c | 600 ------------------------------------ memory.c | 94 +++++-- memory.h | 8 + 18 files changed, 1795 insertions(+), 1586 deletions(-) create mode 100644 hw/i440fx.c create mode 100644 hw/i440fx.h delete mode 100644 hw/pc_piix.c create mode 100644 hw/piix3.c create mode 100644 hw/piix3.h delete mode 100644 hw/piix_pci.c--
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 7 lines · Andreas Färber
Am 26.03.2012 04:06, schrieb Wanpeng Li:
Quoted 1 line
From: Anthony Liguori <[email protected]>
Resending an old cover letter is not a good idea. This looks like a v2, so please mark it as such in the subjects; it's missing a Change Log against Anthony's version. I take it, some patches were dropped?
No, I just help him rebase his patches.
Quoted 68 lines
Quoted 11 lines
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting propertiesQuoted 7 lines
5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.I agree that
machine->initneeds to be refactored, however I don't think it'll disappear, just be moved into initfn/realize functions.Andreas
Quoted 39 lines
The two stage initialization of QOM is important here.
instance_init()is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Wanpeng Li <[email protected]>--- Makefile.target | 3 +- hw/hpet.c | 39 +--- hw/hpet_emul.h | 41 +++ hw/i440fx.c | 431 ++++++++++++++++++++++++++ hw/i440fx.h | 78 +++++ hw/i8254_internal.h | 2 +- hw/mc146818rtc.c | 26 -- hw/mc146818rtc.h | 29 ++ hw/pc.c | 838 +++++++++++++++++++++++++++++++++++++++++++++------ hw/pc.h | 46 +--- hw/pc_piix.c | 762 ---------------------------------------------- hw/pci_host.c | 26 ++ hw/pci_host.h | 5 + hw/piix3.c | 274 +++++++++++++++++ hw/piix3.h | 79 +++++ hw/piix_pci.c | 600 ------------------------------------ memory.c | 94 +++++-- memory.h | 8 + 18 files changed, 1795 insertions(+), 1586 deletions(-) create mode 100644 hw/i440fx.c create mode 100644 hw/i440fx.h delete mode 100644 hw/pc_piix.c create mode 100644 hw/piix3.c create mode 100644 hw/piix3.h delete mode 100644 hw/piix_pci.c--
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Signature · 1 line
LTC China, IBM, Shanghai
Quoted 6 lines · Wanpeng Li
From: Anthony Liguori <[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
Please fix coding style while moving.
Quoted 56 lines
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.The two stage initialization of QOM is important here. instance_init() is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.Signed-off-by Anthony Liguori <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---
Makefile.target | 3 +-
hw/hpet.c | 39 +---
hw/hpet_emul.h | 41 +++
hw/i440fx.c | 431 ++++++++++++++++++++++++++
hw/i440fx.h | 78 +++++
hw/i8254_internal.h | 2 +-
hw/mc146818rtc.c | 26 --
hw/mc146818rtc.h | 29 ++
hw/pc.c | 838 +++++++++++++++++++++++++++++++++++++++++++++------hw/pc.h| 46 +---
hw/pc_piix.c | 762 ----------------------------------------------hw/pci_host.c| 26 ++
hw/pci_host.h | 5 +
hw/piix3.c | 274 +++++++++++++++++
hw/piix3.h | 79 +++++
hw/piix_pci.c | 600 ------------------------------------memory.c| 94 +++++--
memory.h | 8 +18 files changed, 1795 insertions(+), 1586 deletions(-)create mode 100644
hw/i440fx.c
create mode 100644hw/i440fx.h
delete mode 100644hw/pc_piix.c
create mode 100644hw/piix3.c
create mode 100644hw/piix3.h
delete mode 100644hw/piix_pci.c
--
Quoted 9 lines · Blue Swirl
Quoted 6 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
Please fix coding style while moving.
I disagree. That makes reviewing the movement and rebasing the movement pretty difficult.
If we were to fix the issues, it should before or after. But in that context, I think it makes it orthogonal to moving the code and should be treated independently.
Regards,
Anthony Liguori
Quoted 13 lines · Anthony Liguori
Quoted 12 lines · Blue Swirl
Quoted 8 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more
modelled and less ad-hoc. The highlights of this series are:
Quoted 5 lines
Quoted 1 line
Please fix coding style while moving.
I disagree. That makes reviewing the movement and rebasing the movement pretty difficult.
Yes, a separate step would be nice.
Quoted 3 lines
If we were to fix the issues, it should before or after. But in that context, I think it makes it orthogonal to moving the code and should be treated independently.
I'd fix the style in the first patch, then perform moves etc. That way no patch would add noncompliant code, only remove.
Quoted 3 lines
Regards,
Anthony Liguori
Quoted 20 lines · Blue Swirl
Quoted 13 lines · Anthony Liguori
Quoted 12 lines · Blue Swirl
Quoted 8 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more
modelled and less ad-hoc. The highlights of this series are:Quoted 5 lines
Quoted 1 line
Please fix coding style while moving.
I disagree. That makes reviewing the movement and rebasing the movement pretty difficult.
Quoted 8 lines
Yes, a separate step would be nice.
Quoted 3 lines
If we were to fix the issues, it should before or after. But in that context, I think it makes it orthogonal to moving the code and should be treated independently.
I'd fix the style in the first patch, then perform moves etc. That way no patch would add noncompliant code, only remove.
Is this something we universally want to do? What would we do about patches to audio?
I'd prefer not to go down this road. Let's keep discussion of fixing CODING_STYLE of existing code separate from rearchitecting/enhancing code.
Regards,
Anthony Liguori
Quoted 4 lines
Quoted 4 lines
Regards,
Anthony Liguori
Quoted 37 lines · Anthony Liguori
Quoted 36 lines · Blue Swirl
Quoted 18 lines · Anthony Liguori
Quoted 16 lines · Blue Swirl
Quoted 9 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more
modelled and less ad-hoc. The highlights of this series are:Quoted 6 lines
Quoted 1 line
Please fix coding style while moving.
I disagree. That makes reviewing the movement and rebasing the movement pretty difficult.
Yes, a separate step would be nice.
Quoted 3 lines
If we were to fix the issues, it should before or after. But in that context, I think it makes it orthogonal to moving the code and should be treated independently.
Quoted 6 lines
Quoted 2 lines
I'd fix the style in the first patch, then perform moves etc. That way no patch would add noncompliant code, only remove.
Is this something we universally want to do? What would we do about patches to audio?
I'd do it in cases when there is code movement, then git blame will not be very useful anyway and other people have to rebase their patches as well.
The audio case has an additional factor, namely maintainer disagreeing with global style and consistency. There are several ways how to handle that case, one of which is to maintain status quo.
Quoted 2 lines
I'd prefer not to go down this road. Let's keep discussion of fixing
CODING_STYLEof existing code separate from rearchitecting/enhancing code.
When code is moved, rearchitected or enhanced, that would be a good point when to fix style too. Though this assumes that just fixing style without those events is evil, but is it? I think you have not been fully consistent in this matter.
Quoted 10 lines
Regards,
Anthony Liguori
Quoted 4 lines
Quoted 4 lines
Regards,
Anthony Liguori
Quoted 14 lines · Blue Swirl
Quoted 4 lines · Anthony Liguori
Is this something we universally want to do? What would we do about patches to audio?
I'd do it in cases when there is code movement, then git blame will not be very useful anyway and other people have to rebase their patches as well.
The audio case has an additional factor, namely maintainer disagreeing with global style and consistency. There are several ways how to handle that case, one of which is to maintain status quo.
Quoted 7 lines
Quoted 2 lines
I'd prefer not to go down this road. Let's keep discussion of fixing
CODING_STYLEof existing code separate from rearchitecting/enhancing code.When code is moved, rearchitected or enhanced, that would be a good point when to fix style too. Though this assumes that just fixing style without those events is evil, but is it? I think you have not been fully consistent in this matter.
I think modifying coding style alone is evil.
But I'm also sick of arguing about coding style. If you take this patch series as an example, this is the beginning of a fundamental refactoring to how we do machines and devices in QEMU--and yet, we're discussing coding style.
I don't see an obvious way to just get past the coding style discussions. If there was a perfect way to automate fixing coding style, at this point, I would say let's do it. But there is no way I want to spend the next two years taking coding style fixup patches.
Regards,
Anthony Liguori
Quoted 10 lines
Quoted 10 lines
Regards,
Anthony Liguori
Quoted 4 lines
Quoted 4 lines
Regards,
Anthony Liguori
Quoted 31 lines · Anthony Liguori
Quoted 24 lines · Blue Swirl
Quoted 6 lines · Anthony Liguori
Is this something we universally want to do? What would we do about patches
to audio?I'd do it in cases when there is code movement, then git blame will not be very useful anyway and other people have to rebase their patches as well.
The audio case has an additional factor, namely maintainer disagreeing with global style and consistency. There are several ways how to handle that case, one of which is to maintain status quo.
Quoted 3 lines
I'd prefer not to go down this road. Let's keep discussion of fixing
CODING_STYLEof existing code separate from rearchitecting/enhancing code.Quoted 4 lines
When code is moved, rearchitected or enhanced, that would be a good point when to fix style too. Though this assumes that just fixing style without those events is evil, but is it? I think you have not been fully consistent in this matter.
Quoted 6 lines
I think modifying coding style alone is evil.
But I'm also sick of arguing about coding style. If you take this patch series as an example, this is the beginning of a fundamental refactoring to how we do machines and devices in QEMU--and yet, we're discussing coding style.
Well, if for example this "fix style in the first patch, then move" would be a widely accepted rule, there would be no discussion. Now we can discuss forever if reformatting is needed or not.
Quoted 4 lines
I don't see an obvious way to just get past the coding style discussions. If there was a perfect way to automate fixing coding style, at this point, I would say let's do it. But there is no way I want to spend the next two years taking coding style fixup patches.
I'd just reformat once, that would reduce fixup patches considerably. I can also volunteer to review and apply all pure style fixup patches if that helps.
Quoted 16 lines
Regards,
Anthony Liguori
Quoted 11 lines
Quoted 11 lines
Regards,
Anthony Liguori
Quoted 4 lines
Quoted 4 lines
Regards,
Anthony Liguori
Quoted 27 lines · Wanpeng Li
From: Anthony Liguori<[email protected]>
This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:
1) Things like -m and -bios-name are now device model properties
2) The i440fx and piix3 are now modelled in a thorough fashion
3) Most of the chipset features of the piix3 are modelled through composition
4)
i440fx_initis trivialized to creating devices and setting properties5) convert MemoryRegion to QOM
6) convert PCI host bridge to QOM
The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where
machine->initdisappears completely in favor of just creating a handful of devices.The two stage initialization of QOM is important here.
instance_init()is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.
Quoted 5 lines
realize()(which is still calledDeviceState::inittoday) will be called right before the guest starts up for the first time.Signed-off-by Anthony Liguori<[email protected]>Signed-off-by Wanpeng Li<[email protected]>
I should add that there's a short term focus on refactoring the i440fx in such a way that we can introduce a new chipset (Q35).
Regards,
Anthony Liguori
Quoted 30 lines
--- Makefile.target | 3 +- hw/hpet.c | 39 +--- hw/hpet_emul.h | 41 +++ hw/i440fx.c | 431 ++++++++++++++++++++++++++ hw/i440fx.h | 78 +++++ hw/i8254_internal.h | 2 +- hw/mc146818rtc.c | 26 -- hw/mc146818rtc.h | 29 ++ hw/pc.c | 838 +++++++++++++++++++++++++++++++++++++++++++++------ hw/pc.h | 46 +--- hw/pc_piix.c | 762 ---------------------------------------------- hw/pci_host.c | 26 ++ hw/pci_host.h | 5 + hw/piix3.c | 274 +++++++++++++++++ hw/piix3.h | 79 +++++ hw/piix_pci.c | 600 ------------------------------------ memory.c | 94 +++++-- memory.h | 8 + 18 files changed, 1795 insertions(+), 1586 deletions(-)create mode 100644
hw/i440fx.c
create mode 100644hw/i440fx.h
delete mode 100644hw/pc_piix.c
create mode 100644hw/piix3.c
create mode 100644hw/piix3.h
delete mode 100644hw/piix_pci.c
--