[01/13] pc: Add PCMachineState::pci_host field
diff mbox

Message ID 1449094978-22986-2-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Dec. 2, 2015, 10:22 p.m. UTC
This will allow us to avoid direct references to piix and q35 in
acpi-build.c.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/i386/pc_q35.c     | 2 ++
 hw/pci-host/piix.c   | 1 +
 include/hw/i386/pc.h | 1 +
 3 files changed, 4 insertions(+)

Comments

Marcel Apfelbaum Dec. 3, 2015, 3:35 p.m. UTC | #1
On 12/03/2015 12:22 AM, Eduardo Habkost wrote:
> This will allow us to avoid direct references to piix and q35 in
> acpi-build.c.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   hw/i386/pc_q35.c     | 2 ++
>   hw/pci-host/piix.c   | 1 +
>   include/hw/i386/pc.h | 1 +
>   3 files changed, 4 insertions(+)
>
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 0907746..317d36a 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -171,6 +171,8 @@ static void pc_q35_init(MachineState *machine)
>       phb = PCI_HOST_BRIDGE(q35_host);
>       host_bus = phb->bus;
>       pcms->bus = phb->bus;
> +    pcms->pci_host = phb;
> +
>       /* create ISA bus */
>       lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
>                                             ICH9_LPC_FUNC), true,
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 715208b..7711e27 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -335,6 +335,7 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,
>                       address_space_io, 0, TYPE_PCI_BUS);
>       s->bus = b;
>       object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), NULL);
> +    PC_MACHINE(qdev_get_machine())->pci_host = s;
>       qdev_init_nofail(dev);
>
>       d = pci_create_simple(b, 0, pci_type);
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 6ff4721..8b184c1 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -38,6 +38,7 @@ struct PCMachineState {
>       OnOffAuto vmport;
>       OnOffAuto smm;
>       ram_addr_t below_4g_mem_size, above_4g_mem_size;
> +    PCIHostState *pci_host;

Having both pci_host and bus as class fields is not needed.
If you have the host, maybe you can get rid of the bus.

Thanks,
Marcel

>       PCIBus *bus;
>       Notifier machine_done;
>       FWCfgState *fw_cfg;
>
Eduardo Habkost Dec. 3, 2015, 4:35 p.m. UTC | #2
On Thu, Dec 03, 2015 at 05:35:03PM +0200, Marcel Apfelbaum wrote:
> On 12/03/2015 12:22 AM, Eduardo Habkost wrote:
> >This will allow us to avoid direct references to piix and q35 in
> >acpi-build.c.
> >
> >Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
[...]
> >diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> >index 6ff4721..8b184c1 100644
> >--- a/include/hw/i386/pc.h
> >+++ b/include/hw/i386/pc.h
> >@@ -38,6 +38,7 @@ struct PCMachineState {
> >      OnOffAuto vmport;
> >      OnOffAuto smm;
> >      ram_addr_t below_4g_mem_size, above_4g_mem_size;
> >+    PCIHostState *pci_host;
> 
> Having both pci_host and bus as class fields is not needed.
> If you have the host, maybe you can get rid of the bus.

Yes, I will send that as folllow-up.

Patch
diff mbox

diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 0907746..317d36a 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -171,6 +171,8 @@  static void pc_q35_init(MachineState *machine)
     phb = PCI_HOST_BRIDGE(q35_host);
     host_bus = phb->bus;
     pcms->bus = phb->bus;
+    pcms->pci_host = phb;
+
     /* create ISA bus */
     lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
                                           ICH9_LPC_FUNC), true,
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 715208b..7711e27 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -335,6 +335,7 @@  PCIBus *i440fx_init(const char *host_type, const char *pci_type,
                     address_space_io, 0, TYPE_PCI_BUS);
     s->bus = b;
     object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev), NULL);
+    PC_MACHINE(qdev_get_machine())->pci_host = s;
     qdev_init_nofail(dev);
 
     d = pci_create_simple(b, 0, pci_type);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 6ff4721..8b184c1 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -38,6 +38,7 @@  struct PCMachineState {
     OnOffAuto vmport;
     OnOffAuto smm;
     ram_addr_t below_4g_mem_size, above_4g_mem_size;
+    PCIHostState *pci_host;
     PCIBus *bus;
     Notifier machine_done;
     FWCfgState *fw_cfg;