On Thu, 2 Apr 2020 14:25:30 +0100 Anthony PERARD <anthony.per...@citrix.com> wrote:
> On Thu, Apr 02, 2020 at 02:29:25PM +0200, Igor Mammedov wrote: > > On Mon, 30 Mar 2020 17:52:48 +0100 > > Anthony PERARD <anthony.per...@citrix.com> wrote: > > > > > On Fri, Mar 27, 2020 at 06:48:28AM -0400, Igor Mammedov wrote: > > > > Since bd457782b3b0 ("x86/pc: use memdev for RAM") Xen > > > > machine fails to start with: > > > > qemu-system-i386: xen: failed to populate ram at 0 > > > > > > > > The reason is that xen_ram_alloc() which is called by > > > > memory_region_init_ram(), compares memory region with > > > > statically allocated 'global' ram_memory memory region > > > > that it uses for RAM, and does nothing in case it matches. > > > > > > > > While it's possible feed machine->ram to xen_ram_alloc() > > > > in the same manner to keep that hack working, I'd prefer > > > > not to keep that circular dependency and try to untangle that. > > > > > > > > However it doesn't look trivial to fix, so as temporary > > > > fixup opt out Xen machine from memdev based RAM allocation, > > > > and let xen_ram_alloc() do its trick for now. > > > > > > > > Reported-by: Anthony PERARD <anthony.per...@citrix.com> > > > > Signed-off-by: Igor Mammedov <imamm...@redhat.com> > > > > > > Reviewed-by: Anthony PERARD <anthony.per...@citrix.com> > > > > > > That should work on most configs. But we also sometime use the "pc" > > > machine with accel=xen, to run without the "xen-platform" pci device, > > > but that would be less common. > > > > does following work for you in case of pc machine? > > > > diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c > > index 15650d7f6a..f19c0883ae 100644 > > --- a/hw/xen/xen-common.c > > +++ b/hw/xen/xen-common.c > > @@ -151,6 +151,8 @@ static void xen_setup_post(MachineState *ms, AccelState > > *accel) > > > > static int xen_init(MachineState *ms) > > { > > + MachineClass *mc = MACHINE_GET_CLASS(ms); > > + > > xen_xc = xc_interface_open(0, 0, 0); > > if (xen_xc == NULL) { > > xen_pv_printf(NULL, 0, "can't open xen interface\n"); > > @@ -170,6 +172,10 @@ static int xen_init(MachineState *ms) > > return -1; > > } > > qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); > > + /* > > + * opt out of system RAM being allocated by generic code > > + */ > > + m->default_ram_id = NULL; > > return 0; > > After fixing the build issues, it does work, yes. I've tested both "xenfv" > and "pc,accel=xen". thanks, I'll post a formal patch however it's all workarounds, we need to fix ram allocation properly later on so far I only have questions, hope you can help with clarifying them 1. why xen uses memory_region_init_ram() which does not allocate anything can it use plain memory_region_init() instead? 2. how main ram is allocated? 3. code has /* * Xen does not allocate the memory continuously, it keeps a * hole of the size computed above or passed in. */ block_len = (1ULL << 32) + x86ms->above_4g_mem_size; which fixes up size ram memory region can we allocate 1 memory region of ram_size and then alias lower and upper memory instead of that? 4. how RAM migration works in case of xen? > > Build issue: > - I've added #include "hw/boards.h" > - and s/m->/mc->/ ccccccgndiej> gngfiehlivuil > Thanks!nbchihheikhjlnervve >