All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: Igor Mammedov <imammedo@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel.a@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 02/16] pc: Eliminate struct PcGuestInfoState
Date: Mon, 7 Dec 2015 17:19:21 +0200	[thread overview]
Message-ID: <5665A379.6090209@gmail.com> (raw)
In-Reply-To: <1449020831-8414-3-git-send-email-ehabkost@redhat.com>

On 12/02/2015 03:46 AM, Eduardo Habkost wrote:
> Instead of allocating a new struct just for PcGuestInfo and the
> mchine_done Notifier, place them inside PCMachineState.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>   hw/i386/pc.c         | 27 ++++++++++-----------------
>   include/hw/i386/pc.h |  2 ++
>   2 files changed, 12 insertions(+), 17 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index f32000a..30cdfaf 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1155,18 +1155,12 @@ typedef struct PcRomPciInfo {
>       uint64_t w64_max;
>   } PcRomPciInfo;
>
> -typedef struct PcGuestInfoState {
> -    PcGuestInfo info;
> -    Notifier machine_done;
> -} PcGuestInfoState;
> -
>   static
> -void pc_guest_info_machine_done(Notifier *notifier, void *data)
> +void pc_machine_done(Notifier *notifier, void *data)
>   {
> -    PcGuestInfoState *guest_info_state = container_of(notifier,
> -                                                      PcGuestInfoState,
> -                                                      machine_done);
> -    PCIBus *bus = PC_MACHINE(qdev_get_machine())->bus;
> +    PCMachineState *pcms = container_of(notifier,
> +                                        PCMachineState, machine_done);
> +    PCIBus *bus = pcms->bus;
>
>       if (bus) {
>           int extra_hosts = 0;
> @@ -1177,21 +1171,20 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)
>                   extra_hosts++;
>               }
>           }
> -        if (extra_hosts && guest_info_state->info.fw_cfg) {
> +        if (extra_hosts && pcms->acpi_guest_info.fw_cfg) {
>               uint64_t *val = g_malloc(sizeof(*val));
>               *val = cpu_to_le64(extra_hosts);
> -            fw_cfg_add_file(guest_info_state->info.fw_cfg,
> +            fw_cfg_add_file(pcms->acpi_guest_info.fw_cfg,
>                       "etc/extra-pci-roots", val, sizeof(*val));
>           }
>       }
>
> -    acpi_setup(&guest_info_state->info);
> +    acpi_setup(&pcms->acpi_guest_info);
>   }
>
>   PcGuestInfo *pc_guest_info_init(PCMachineState *pcms)
>   {
> -    PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state);
> -    PcGuestInfo *guest_info = &guest_info_state->info;
> +    PcGuestInfo *guest_info = &pcms->acpi_guest_info;
>       int i, j;
>
>       guest_info->ram_size_below_4g = pcms->below_4g_mem_size;
> @@ -1219,8 +1212,8 @@ PcGuestInfo *pc_guest_info_init(PCMachineState *pcms)
>           }
>       }
>
> -    guest_info_state->machine_done.notify = pc_guest_info_machine_done;
> -    qemu_add_machine_init_done_notifier(&guest_info_state->machine_done);
> +    pcms->machine_done.notify = pc_machine_done;
> +    qemu_add_machine_init_done_notifier(&pcms->machine_done);
>       return guest_info;
>   }
>
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index a74bded..61aa6ee 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -55,6 +55,8 @@ struct PCMachineState {
>       OnOffAuto smm;
>       ram_addr_t below_4g_mem_size, above_4g_mem_size;
>       PCIBus *bus;
> +    PcGuestInfo acpi_guest_info;
> +    Notifier machine_done;

Hi,

Arm's virt machine also has a  machine_done notifier
and a PcGuestInfo like structure (for building the ACPI).

Maybe it worth checking moving machine_done up to Machine
and investigate also the same possibility for a common
acpi guest info ancestor. For the moment all they have in
common is fw_config.

If anybody is looking for an adventure we can make a common
base class for ARM virt and PC machine, something like
ACPI_MACHINE. :)

Just a thought anyway,
Thanks,
Marcel

>   };
>
>   #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
>

  reply	other threads:[~2015-12-07 15:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02  1:46 [Qemu-devel] [PATCH 00/16] pc: Eliminate struct PcGuestInfo Eduardo Habkost
2015-12-02  1:46 ` [Qemu-devel] [PATCH 01/16] pc: Move PcGuestInfo declaration to top of file Eduardo Habkost
2015-12-02  1:46 ` [Qemu-devel] [PATCH 02/16] pc: Eliminate struct PcGuestInfoState Eduardo Habkost
2015-12-07 15:19   ` Marcel Apfelbaum [this message]
2015-12-02  1:46 ` [Qemu-devel] [PATCH 03/16] pc: Remove guest_info parameter from pc_memory_init() Eduardo Habkost
2015-12-02  1:46 ` [Qemu-devel] [PATCH 04/16] acpi: Make acpi_setup() get PCMachineState as argument Eduardo Habkost
2015-12-07 15:24   ` Marcel Apfelbaum
2015-12-08 17:40     ` Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 05/16] acpi: Remove unused build_facs() PcGuestInfo paramter Eduardo Habkost
2015-12-07 15:25   ` Marcel Apfelbaum
2015-12-02  1:47 ` [Qemu-devel] [PATCH 06/16] acpi: Save PCMachineState on AcpiBuildState Eduardo Habkost
2015-12-07 15:39   ` Marcel Apfelbaum
2015-12-08 17:59     ` Eduardo Habkost
2015-12-08 18:44       ` Marcel Apfelbaum
2015-12-09 19:37         ` Igor Mammedov
2015-12-11 14:12           ` Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 07/16] acpi: Make acpi_build() get PCMachineState as argument Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 08/16] acpi: Make build_srat() " Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 09/16] acpi: Remove ram size fields fron PcGuestInfo Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 10/16] pc: Move PcGuestInfo.fw_cfg field to PCMachineState Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 11/16] pc: Simplify signature of xen_load_linux() Eduardo Habkost
2015-12-11 11:40   ` Stefano Stabellini
2015-12-02  1:47 ` [Qemu-devel] [PATCH 12/16] pc: Remove PcGuestInfo.isapc_ram_fw field Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 13/16] q35: Remove MCHPCIState.guest_info field Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 14/16] acpi: Use PCMachineClass fields directly Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 15/16] pc: Move PcGuestInfo.apic_xrupt_override field to PCMachineState Eduardo Habkost
2015-12-02  1:47 ` [Qemu-devel] [PATCH 16/16] pc: Move APIC and NUMA data from PcGuestInfo " Eduardo Habkost
2015-12-07 18:57 ` [Qemu-devel] [PATCH 00/16] pc: Eliminate struct PcGuestInfo Marcel Apfelbaum
2015-12-08 17:53   ` Eduardo Habkost
2015-12-10 11:27     ` Marcel Apfelbaum
2015-12-10 17:45       ` Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5665A379.6090209@gmail.com \
    --to=marcel.apfelbaum@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=marcel.a@redhat.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.