* [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
@ 2012-03-26 9:05 Wanpeng Li
0 siblings, 0 replies; 6+ messages in thread
From: Wanpeng Li @ 2012-03-26 9:05 UTC (permalink / raw)
To: qemu-devel; +Cc: Wanpeng Li, Anthony Liguori, Avi Kivity, Gavin Shan
From: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
---
hw/pci_host.c | 26 ++++++++++++++++++++++++++
hw/pci_host.h | 5 +++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/hw/pci_host.c b/hw/pci_host.c
index 44c6c20..44d7e55 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -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);
diff --git a/hw/pci_host.h b/hw/pci_host.h
index 359e38f..084e15c 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -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;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
@ 2012-03-26 8:34 y
0 siblings, 0 replies; 6+ messages in thread
From: y @ 2012-03-26 8:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Wanpeng Li, Anthony Liguori, Avi Kivity, Gavin Shan
From: Wanpeng Li <liwp@linux.vnet.ibm.com>
From: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
---
hw/pci_host.c | 26 ++++++++++++++++++++++++++
hw/pci_host.h | 5 +++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/hw/pci_host.c b/hw/pci_host.c
index 44c6c20..44d7e55 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -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);
diff --git a/hw/pci_host.h b/hw/pci_host.h
index 359e38f..084e15c 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -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;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 0/6] refactor PC machine, i440fx and piix3 to take advantage of QOM
@ 2012-03-26 2:06 Wanpeng Li
2012-03-26 2:06 ` [Qemu-devel] [PATCH 3/6] convert pci-host to QOM Wanpeng Li
0 siblings, 1 reply; 6+ messages in thread
From: Wanpeng Li @ 2012-03-26 2:06 UTC (permalink / raw)
To: qemu-devel; +Cc: Wanpeng Li, Anthony Liguori, Avi Kivity, Gavin Shan
From: Anthony Liguori <aliguori@us.ibm.com>
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.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
---
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
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
2012-03-26 2:06 [Qemu-devel] [PATCH 0/6] refactor PC machine, i440fx and piix3 to take advantage of QOM Wanpeng Li
@ 2012-03-26 2:06 ` Wanpeng Li
2012-03-26 7:32 ` Stefan Hajnoczi
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Wanpeng Li @ 2012-03-26 2:06 UTC (permalink / raw)
To: qemu-devel; +Cc: Wanpeng Li, Anthony Liguori, Avi Kivity, Gavin Shan
From: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
---
hw/pci_host.c | 26 ++++++++++++++++++++++++++
hw/pci_host.h | 5 +++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/hw/pci_host.c b/hw/pci_host.c
index 44c6c20..44d7e55 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -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);
diff --git a/hw/pci_host.h b/hw/pci_host.h
index 359e38f..084e15c 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -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;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
2012-03-26 2:06 ` [Qemu-devel] [PATCH 3/6] convert pci-host to QOM Wanpeng Li
@ 2012-03-26 7:32 ` Stefan Hajnoczi
2012-03-26 9:22 ` Wanpeng Li
2012-03-26 14:25 ` Andreas Färber
2 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2012-03-26 7:32 UTC (permalink / raw)
To: Wanpeng Li; +Cc: Gavin Shan, Anthony Liguori, qemu-devel, Avi Kivity
On Mon, Mar 26, 2012 at 10:06:45AM +0800, Wanpeng Li wrote:
> diff --git a/hw/pci_host.c b/hw/pci_host.c
> index 44c6c20..44d7e55 100644
> --- a/hw/pci_host.c
> +++ b/hw/pci_host.c
> @@ -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);
This patch has tabs instead of 4-space indent.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
2012-03-26 2:06 ` [Qemu-devel] [PATCH 3/6] convert pci-host to QOM Wanpeng Li
2012-03-26 7:32 ` Stefan Hajnoczi
@ 2012-03-26 9:22 ` Wanpeng Li
2012-03-26 14:25 ` Andreas Färber
2 siblings, 0 replies; 6+ messages in thread
From: Wanpeng Li @ 2012-03-26 9:22 UTC (permalink / raw)
To: qemu-devel; +Cc: Gavin Shan, Stefan Hajnoczi, Anthony Liguori, Avi Kivity, liwp
[-- Attachment #1: Type: text/plain, Size: 2077 bytes --]
On Mon, Mar 26, 2012 at 10:06:45AM +0800, Wanpeng Li wrote:
>
>From: Anthony Liguori <aliguori@us.ibm.com>
>
>
>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
>
>---
> hw/pci_host.c | 26 ++++++++++++++++++++++++++
> hw/pci_host.h | 5 +++++
> 2 files changed, 31 insertions(+), 0 deletions(-)
>
>diff --git a/hw/pci_host.c b/hw/pci_host.c
>index 44c6c20..44d7e55 100644
>--- a/hw/pci_host.c
>+++ b/hw/pci_host.c
>@@ -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);
>
>diff --git a/hw/pci_host.h b/hw/pci_host.h
>index 359e38f..084e15c 100644
>--- a/hw/pci_host.h
>+++ b/hw/pci_host.h
>@@ -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;
>--
>1.7.5.4
>
[-- Attachment #2: 0003.patch --]
[-- Type: text/x-diff, Size: 2161 bytes --]
>From 72bc193e6e25cb393437317843a701b82a9b9233 Mon Sep 17 00:00:00 2001
From: Wanpeng Li <liwp@linux.vnet.ibm.com>
Date: Thu, 22 Mar 2012 17:57:30 +0800
Subject: [PATCH 3/6] convert pci-host to QOM
From: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
---
hw/pci_host.c | 26 ++++++++++++++++++++++++++
hw/pci_host.h | 5 +++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/hw/pci_host.c b/hw/pci_host.c
index 44c6c20..44d7e55 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -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);
diff --git a/hw/pci_host.h b/hw/pci_host.h
index 359e38f..084e15c 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -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;
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 3/6] convert pci-host to QOM
2012-03-26 2:06 ` [Qemu-devel] [PATCH 3/6] convert pci-host to QOM Wanpeng Li
2012-03-26 7:32 ` Stefan Hajnoczi
2012-03-26 9:22 ` Wanpeng Li
@ 2012-03-26 14:25 ` Andreas Färber
2 siblings, 0 replies; 6+ messages in thread
From: Andreas Färber @ 2012-03-26 14:25 UTC (permalink / raw)
To: Wanpeng Li; +Cc: Gavin Shan, Anthony Liguori, qemu-devel, Avi Kivity
Am 26.03.2012 04:06, schrieb Wanpeng Li:
> From: Anthony Liguori <aliguori@us.ibm.com>
>
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Wanpeng Li <liwp@linux.vnet.ibm.com>
Some minor formal comments inline, otherwise looks okay.
> ---
> hw/pci_host.c | 26 ++++++++++++++++++++++++++
> hw/pci_host.h | 5 +++++
> 2 files changed, 31 insertions(+), 0 deletions(-)
>
> diff --git a/hw/pci_host.c b/hw/pci_host.c
> index 44c6c20..44d7e55 100644
> --- a/hw/pci_host.c
> +++ b/hw/pci_host.c
> @@ -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 = {
I thought the convention was ..._type_info (in case we ever need to do a
mass conversion again). And please make it static const.
> + .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.
> +{
> + 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
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-26 14:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-26 9:05 [Qemu-devel] [PATCH 3/6] convert pci-host to QOM Wanpeng Li
-- strict thread matches above, loose matches on Subject: below --
2012-03-26 8:34 y
2012-03-26 2:06 [Qemu-devel] [PATCH 0/6] refactor PC machine, i440fx and piix3 to take advantage of QOM Wanpeng Li
2012-03-26 2:06 ` [Qemu-devel] [PATCH 3/6] convert pci-host to QOM Wanpeng Li
2012-03-26 7:32 ` Stefan Hajnoczi
2012-03-26 9:22 ` Wanpeng Li
2012-03-26 14:25 ` Andreas Färber
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).