All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Anthony PERARD <anthony.perard@citrix.com>
Cc: Richard Henderson <richard.henderson@linaro.org>,
	qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: Xen guest broken following "use memdev for RAM" patch
Date: Tue, 24 Mar 2020 13:14:48 +0100	[thread overview]
Message-ID: <20200324131448.05074f3f@redhat.com> (raw)
In-Reply-To: <20200323171039.GI4088@perard.uk.xensource.com>

On Mon, 23 Mar 2020 17:10:39 +0000
Anthony PERARD <anthony.perard@citrix.com> wrote:

> Hi,
> 
> Since bd457782b3b0 ("x86/pc: use memdev for RAM") it isn't possible to
> start Xen guest anymore.
> 
> The error from qemu:
>     qemu-system-i386: xen: failed to populate ram at 0
> that comes from xen_ram_alloc() in hw/i386/xen/xen-hvm.c
> 
> xen_ram_alloc() is used to populate ram for PCI rom devices for example,
> but it is also called for the guest RAM. We try to detect when the call
> is for the ram by comparing the memory region with the one we created
> during initialisation.
> 
> During initialisation of QEMU  for a Xen guest, we create a memory
> region for the RAM by calling memory_region_init_ram() in
> xen_ram_init(). But that memory region isn't used by QEMU anymore (since
> mc->default_ram_id is set).
> 
> For Xen, we don't want QEMU to allocate the RAM, so using the memdev
> won't work.
> 
> Do you have a suggestion on
> - how we can bypass the generic code that allocate ram?
> - keep using something similar to what we have now with
>   memory_region_init_ram()?
> (with accel=xen)

Not that I like it but as a quick fix, does following work for you?

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index e2d98243bc..bbca43bf33 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -953,6 +953,10 @@ static void xenfv_machine_options(MachineClass *m)
     m->desc = "Xen Fully-virtualized PC";
     m->max_cpus = HVM_MAX_VCPUS;
     m->default_machine_opts = "accel=xen";
+    /*
+     * opt out of system RAM being allocated by generic code
+     */
+    m->default_ram_id = NULL;
 }
 
 DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init,


> 
> Maybe we need a new hostmem backend which don't allocate any memory but
> creates a memory region, to be used by Xen?

Maybe, but I don't know about Xen enough so it's hard to make a suggestion,
so lets try to think out of the way to figure out how to approach it.

(In general, I'd prefer to get rid of dependency on 'accel' in memory_region_init_ram())

adapting xen code to use memdev isn't straightforward, since xen_ram_init()
fixes up memory_region size, it could be user provided
  ram_size
or
  4G + ram_size - HVM_BELOW_4G_RAM_END

question is why do you need to use memory_region_init_ram() at all if you are not actually
doing any allocation?
 
> Thanks,
> 



      reply	other threads:[~2020-03-24 12:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23 17:10 Xen guest broken following "use memdev for RAM" patch Anthony PERARD
2020-03-24 12:14 ` Igor Mammedov [this message]

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=20200324131448.05074f3f@redhat.com \
    --to=imammedo@redhat.com \
    --cc=anthony.perard@citrix.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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.