提交 9ebeed0c 编写于 作者: E Eduardo Habkost 提交者: Michael S. Tsirkin

pc: Eliminate struct PcGuestInfoState

Instead of allocating a new struct just for PcGuestInfo and the
mchine_done Notifier, place them inside PCMachineState.
Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: NMarcel Apfelbaum <marcel@redhat.com>
上级 281b1047
...@@ -1156,18 +1156,12 @@ typedef struct PcRomPciInfo { ...@@ -1156,18 +1156,12 @@ typedef struct PcRomPciInfo {
uint64_t w64_max; uint64_t w64_max;
} PcRomPciInfo; } PcRomPciInfo;
typedef struct PcGuestInfoState {
PcGuestInfo info;
Notifier machine_done;
} PcGuestInfoState;
static 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, PCMachineState *pcms = container_of(notifier,
PcGuestInfoState, PCMachineState, machine_done);
machine_done); PCIBus *bus = pcms->bus;
PCIBus *bus = PC_MACHINE(qdev_get_machine())->bus;
if (bus) { if (bus) {
int extra_hosts = 0; int extra_hosts = 0;
...@@ -1178,21 +1172,20 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data) ...@@ -1178,21 +1172,20 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)
extra_hosts++; 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)); uint64_t *val = g_malloc(sizeof(*val));
*val = cpu_to_le64(extra_hosts); *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)); "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) PcGuestInfo *pc_guest_info_init(PCMachineState *pcms)
{ {
PcGuestInfoState *guest_info_state = g_malloc0(sizeof *guest_info_state); PcGuestInfo *guest_info = &pcms->acpi_guest_info;
PcGuestInfo *guest_info = &guest_info_state->info;
int i, j; int i, j;
guest_info->ram_size_below_4g = pcms->below_4g_mem_size; guest_info->ram_size_below_4g = pcms->below_4g_mem_size;
...@@ -1220,8 +1213,8 @@ PcGuestInfo *pc_guest_info_init(PCMachineState *pcms) ...@@ -1220,8 +1213,8 @@ PcGuestInfo *pc_guest_info_init(PCMachineState *pcms)
} }
} }
guest_info_state->machine_done.notify = pc_guest_info_machine_done; pcms->machine_done.notify = pc_machine_done;
qemu_add_machine_init_done_notifier(&guest_info_state->machine_done); qemu_add_machine_init_done_notifier(&pcms->machine_done);
return guest_info; return guest_info;
} }
......
...@@ -61,6 +61,8 @@ struct PCMachineState { ...@@ -61,6 +61,8 @@ struct PCMachineState {
/* State for other subsystems/APIs: */ /* State for other subsystems/APIs: */
MemoryHotplugState hotplug_memory; MemoryHotplugState hotplug_memory;
PcGuestInfo acpi_guest_info;
Notifier machine_done;
/* Pointers to devices and objects: */ /* Pointers to devices and objects: */
HotplugHandler *acpi_dev; HotplugHandler *acpi_dev;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册