On Thu, 11 Apr 2019 09:32:11 +0800 Wei Yang <richardw.y...@linux.intel.com> wrote:
> On Wed, Apr 10, 2019 at 05:01:50PM +0200, Igor Mammedov wrote: > >On Wed, 10 Apr 2019 22:27:56 +0800 > >Wei Yang <richardw.y...@linux.intel.com> wrote: > > > >[...] > >> >@@ -2411,19 +2410,7 @@ build_mcfg_q35(GArray *table_data, BIOSLinker > >> >*linker, AcpiMcfgInfo *info) > >> > mcfg->allocation[0].start_bus_number = 0; > >> > mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size > >> > - 1); > >> > > >> >- /* MCFG is used for ECAM which can be enabled or disabled by guest. > >> > > >> > >> I want to cnfirm what is "enabled or disabled by guest" here. > > > >Firmware theoretically during PCI initialization may disable ECAM support > >and that's when we do no need MCFG. In practice that's not happening > >(SeaBIOS or UEFI) but we in case there is out there a firmware that does > >disable ECAM we do not generate MCFG. > > > >Note: > >ACPI tables generated twice, 1st when QEMU starts and the second time > >when firmware accesses fwcfg to read blobs for the 1st time. > >The later happens after PCI subsystem was initialized by firmware. > >At that time we know if ECAM was enabled or not. > > > > That's much clear, thanks :-) > > So this is the guest BIOS instead of guest kernel who may disable/enable it. > > >> If we don't reserve mcfg and "guest" enable mcfg during running, the ACPI > >> table size changed. But the destination still has the original table size, > >> since destination "guest" keep sleep during this period. > >> > >> Now the migration would face table size difference > > > >with commit a1666142db we do not care as all the tables created on > >source will be migrated to destination as is overwriting whatever blobs > >destination created on startup. > > > >> and break migration? > >nope, > > > >to help you figure out why it works > >look at what following git commits did: > > git log c8d6f66ae7..a1666142db > >and pay attention to 'used_length' > > > > To be honest, this is what I feel confused in your previous reply. > > First I want to confirm both fields in RAMBlock affects the migration: > > * used_length > * max_length > > Both of them should be the same on both source/destination, otherwise the > migration would fail. well, it works fine for me. Where do you see max_length being used during migration? > Then I thought the migration would be broken if source/destination has > different knowledge about acpi table size. Because this will introduce > different value of used_length, even we have resizable MemoryRegion. > > The 1st time ACPI generation flow: > > acpi_add_rom_blob > rom_add_blob > rom_set_mr > memory_region_init_resizable_ram > qemu_ram_alloc_resizable > new_block->used_length = size > new_block->max_length = max_size > > The 2nd time ACPI generation flow: > > acpi_ram_update > memory_regioin_ram_resize > qemu_ram_resize > block->used_length = new_size > > The max_length is always the same, while used_length would be changed to the > actual table_blob size. > > In case source/destination has different knowledge about acpi table size, the > table_blob size(even after aligned) could be different. > > This is why I thought there is still some chance to break migration after > resizable MemoryRegion. > > Do I miss something? yes, you did, max_length does not influence migration stream. see what above mentioned commits and ram_load() -> "if (length != block->used_length)" do.