From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5xZZ-0005De-55 for qemu-devel@nongnu.org; Mon, 07 Dec 2015 10:19:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a5xZV-0003A9-50 for qemu-devel@nongnu.org; Mon, 07 Dec 2015 10:19:29 -0500 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]:37026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a5xZU-0003A3-Tm for qemu-devel@nongnu.org; Mon, 07 Dec 2015 10:19:25 -0500 Received: by wmww144 with SMTP id w144so154451827wmw.0 for ; Mon, 07 Dec 2015 07:19:24 -0800 (PST) References: <1449020831-8414-1-git-send-email-ehabkost@redhat.com> <1449020831-8414-3-git-send-email-ehabkost@redhat.com> From: Marcel Apfelbaum Message-ID: <5665A379.6090209@gmail.com> Date: Mon, 7 Dec 2015 17:19:21 +0200 MIME-Version: 1.0 In-Reply-To: <1449020831-8414-3-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 02/16] pc: Eliminate struct PcGuestInfoState Reply-To: marcel@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Igor Mammedov , "Michael S. Tsirkin" , Marcel Apfelbaum 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 > --- > 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" >