All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 0/6] save/restore on Xen
Date: Mon, 23 Jan 2012 10:54:15 -0600	[thread overview]
Message-ID: <4F1D90B7.4060202@codemonkey.ws> (raw)
In-Reply-To: <alpine.DEB.2.00.1201231623340.3196@kaball-desktop>

On 01/23/2012 10:46 AM, Stefano Stabellini wrote:
> On Mon, 23 Jan 2012, Anthony Liguori wrote:
>> On 01/23/2012 04:47 AM, Stefano Stabellini wrote:
>>> On Fri, 20 Jan 2012, Jan Kiszka wrote:
>>>> On 2012-01-20 18:20, Stefano Stabellini wrote:
>>>>> Hi all,
>>>>> this is the fourth version of the Xen save/restore patch series.
>>>>> We have been discussing this issue for quite a while on #qemu and
>>>>> qemu-devel:
>>>>>
>>>>>
>>>>> http://marc.info/?l=qemu-devel&m=132346828427314&w=2
>>>>> http://marc.info/?l=qemu-devel&m=132377734605464&w=2
>>>>>
>>>>>
>>>>> A few different approaches were proposed to achieve the goal
>>>>> of a working save/restore with upstream Qemu on Xen, however after
>>>>> prototyping some of them I came up with yet another solution, that I
>>>>> think leads to the best results with the less amount of code
>>>>> duplications and ugliness.
>>>>> Far from saying that this patch series is an example of elegance and
>>>>> simplicity, but it is closer to acceptable anything else I have seen so
>>>>> far.
>>>>>
>>>>> What's new is that Qemu is going to keep track of its own physmap on
>>>>> xenstore, so that Xen can be fully aware of the changes Qemu makes to
>>>>> the guest's memory map at any time.
>>>>> This is all handled by Xen or Xen support in Qemu internally and can be
>>>>> used to solve our save/restore framebuffer problem.
>>>>>
>>>>>>  From the Qemu common code POV, we still need to avoid saving the guest's
>>>>> ram when running on Xen, and we need to avoid resetting the videoram on
>>>>> restore (that is a benefit to the generic Qemu case too, because it
>>>>> saves few cpu cycles).
>>>>
>>>> For my understanding: Refraining from the memset is required as the
>>>> already restored vram would then be overwritten?
>>>
>>> Yep
>>>
>>>> Or what is the ordering
>>>> of init, RAM restore, and initial device reset now?
>>>
>>> RAM restore (done by Xen)
>>>
>>> physmap rebuild (done by xen_hvm_init in qemu)
>>> pc_init()
>>> qemu_system_reset()
>>> load_vmstate()
>>
>> That's your problem.  You don't want to do load_vmstate().  You just want to
>> load the device model, not RAM.
>
> True
>
>
>> Why not introduce new Xen specific commands like I suggested on IRC?
>
> Introducing a Xen specific command is not an issue, but I didn't want to
> duplicate all the functionalities currently in savevm.c.

The code is fairly reusable since live migration and savevm use the same 
internal bits.  I think you would just need another version of 
qemu_loadvm_state().  That function is only a hundred lines or so so you 
shouldn't be duplicating much at all.

>> You should have a separate load_device_state() function and mark anything that
>> is RAM as RAM when doing savevm registration.  Better yet, mark devices as
>> devices since that's what you really care about.
>
> I dropped this approach because I thought it causes too much code
> duplication.

Then you're doing it wrong :-)

But even if there is, just refactor out the common code.

> However, following your suggestion, if I add a generic "device" flag in
> SaveStateEntry and implement a generic qemu_save_device_state in
> savevm.c, I believe that the duplication of code would be small.
> And patch #1 could go away.

Yup.

>
>
> However the issue of patch #4, "do not reset videoram on resume", still
> remains: no matter what parameter I pass to Qemu, if qemu_system_reset
> is called on resume the videoram is going to be overwritten by 0xff.

The memset(0xff) looks dubious to me.  My guess is that this could be moved to 
the vgabios-cirrus which would solve your problem.

> In this regard, don't you think it would be advantageous to Qemu in
> general not to reset the videram in resume? It can be pretty large, so
> it is a significant waste of a memset.

It claims to fix a real bug.  Moving the memset to vgabios would do what you 
want to do in a more robust way I think.

Regards,

Anthony Liguori

WARNING: multiple messages have this Message-ID (diff)
From: Anthony Liguori <anthony@codemonkey.ws>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Avi Kivity <avi@redhat.com>
Subject: Re: [PATCH v4 0/6] save/restore on Xen
Date: Mon, 23 Jan 2012 10:54:15 -0600	[thread overview]
Message-ID: <4F1D90B7.4060202@codemonkey.ws> (raw)
In-Reply-To: <alpine.DEB.2.00.1201231623340.3196@kaball-desktop>

On 01/23/2012 10:46 AM, Stefano Stabellini wrote:
> On Mon, 23 Jan 2012, Anthony Liguori wrote:
>> On 01/23/2012 04:47 AM, Stefano Stabellini wrote:
>>> On Fri, 20 Jan 2012, Jan Kiszka wrote:
>>>> On 2012-01-20 18:20, Stefano Stabellini wrote:
>>>>> Hi all,
>>>>> this is the fourth version of the Xen save/restore patch series.
>>>>> We have been discussing this issue for quite a while on #qemu and
>>>>> qemu-devel:
>>>>>
>>>>>
>>>>> http://marc.info/?l=qemu-devel&m=132346828427314&w=2
>>>>> http://marc.info/?l=qemu-devel&m=132377734605464&w=2
>>>>>
>>>>>
>>>>> A few different approaches were proposed to achieve the goal
>>>>> of a working save/restore with upstream Qemu on Xen, however after
>>>>> prototyping some of them I came up with yet another solution, that I
>>>>> think leads to the best results with the less amount of code
>>>>> duplications and ugliness.
>>>>> Far from saying that this patch series is an example of elegance and
>>>>> simplicity, but it is closer to acceptable anything else I have seen so
>>>>> far.
>>>>>
>>>>> What's new is that Qemu is going to keep track of its own physmap on
>>>>> xenstore, so that Xen can be fully aware of the changes Qemu makes to
>>>>> the guest's memory map at any time.
>>>>> This is all handled by Xen or Xen support in Qemu internally and can be
>>>>> used to solve our save/restore framebuffer problem.
>>>>>
>>>>>>  From the Qemu common code POV, we still need to avoid saving the guest's
>>>>> ram when running on Xen, and we need to avoid resetting the videoram on
>>>>> restore (that is a benefit to the generic Qemu case too, because it
>>>>> saves few cpu cycles).
>>>>
>>>> For my understanding: Refraining from the memset is required as the
>>>> already restored vram would then be overwritten?
>>>
>>> Yep
>>>
>>>> Or what is the ordering
>>>> of init, RAM restore, and initial device reset now?
>>>
>>> RAM restore (done by Xen)
>>>
>>> physmap rebuild (done by xen_hvm_init in qemu)
>>> pc_init()
>>> qemu_system_reset()
>>> load_vmstate()
>>
>> That's your problem.  You don't want to do load_vmstate().  You just want to
>> load the device model, not RAM.
>
> True
>
>
>> Why not introduce new Xen specific commands like I suggested on IRC?
>
> Introducing a Xen specific command is not an issue, but I didn't want to
> duplicate all the functionalities currently in savevm.c.

The code is fairly reusable since live migration and savevm use the same 
internal bits.  I think you would just need another version of 
qemu_loadvm_state().  That function is only a hundred lines or so so you 
shouldn't be duplicating much at all.

>> You should have a separate load_device_state() function and mark anything that
>> is RAM as RAM when doing savevm registration.  Better yet, mark devices as
>> devices since that's what you really care about.
>
> I dropped this approach because I thought it causes too much code
> duplication.

Then you're doing it wrong :-)

But even if there is, just refactor out the common code.

> However, following your suggestion, if I add a generic "device" flag in
> SaveStateEntry and implement a generic qemu_save_device_state in
> savevm.c, I believe that the duplication of code would be small.
> And patch #1 could go away.

Yup.

>
>
> However the issue of patch #4, "do not reset videoram on resume", still
> remains: no matter what parameter I pass to Qemu, if qemu_system_reset
> is called on resume the videoram is going to be overwritten by 0xff.

The memset(0xff) looks dubious to me.  My guess is that this could be moved to 
the vgabios-cirrus which would solve your problem.

> In this regard, don't you think it would be advantageous to Qemu in
> general not to reset the videram in resume? It can be pretty large, so
> it is a significant waste of a memset.

It claims to fix a real bug.  Moving the memset to vgabios would do what you 
want to do in a more robust way I think.

Regards,

Anthony Liguori

  reply	other threads:[~2012-01-23 16:54 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20 17:20 [Qemu-devel] [PATCH v4 0/6] save/restore on Xen Stefano Stabellini
2012-01-20 17:20 ` Stefano Stabellini
2012-01-20 17:21 ` [Qemu-devel] [PATCH v4 1/6] vl.c: do not save the RAM state when Xen is enabled Stefano Stabellini
2012-01-20 17:21   ` Stefano Stabellini
2012-01-23 15:58   ` [Qemu-devel] " Anthony Liguori
2012-01-23 15:58     ` Anthony Liguori
2012-01-20 17:21 ` [Qemu-devel] [PATCH v4 2/6] xen mapcache: check if memory region has moved Stefano Stabellini
2012-01-20 17:21   ` Stefano Stabellini
2012-01-20 17:21 ` [Qemu-devel] [PATCH v4 3/6] Set runstate to INMIGRATE earlier Stefano Stabellini
2012-01-20 17:21   ` Stefano Stabellini
2012-01-20 17:21 ` [Qemu-devel] [PATCH v4 4/6] cirrus_vga: do not reset videoram on resume Stefano Stabellini
2012-01-20 17:21   ` Stefano Stabellini
2012-01-20 17:21 ` [Qemu-devel] [PATCH v4 5/6] xen: record physmap changes to xenstore Stefano Stabellini
2012-01-20 17:21   ` Stefano Stabellini
2012-01-20 17:21 ` [Qemu-devel] [PATCH v4 6/6] xen: change memory access behavior during migration Stefano Stabellini
2012-01-20 17:21   ` Stefano Stabellini
2012-01-20 17:59 ` [Qemu-devel] [PATCH v4 0/6] save/restore on Xen Jan Kiszka
2012-01-20 17:59   ` Jan Kiszka
2012-01-23 10:47   ` [Qemu-devel] " Stefano Stabellini
2012-01-23 10:47     ` Stefano Stabellini
2012-01-23 11:50     ` [Qemu-devel] " Jan Kiszka
2012-01-23 11:50       ` Jan Kiszka
2012-01-23 11:59       ` [Qemu-devel] " Stefano Stabellini
2012-01-23 11:59         ` Stefano Stabellini
2012-01-23 12:10         ` [Qemu-devel] " Jan Kiszka
2012-01-23 12:10           ` Jan Kiszka
2012-01-23 14:46           ` [Qemu-devel] " Stefano Stabellini
2012-01-23 14:46             ` Stefano Stabellini
2012-01-23 15:46             ` [Qemu-devel] " Jan Kiszka
2012-01-23 15:46               ` Jan Kiszka
2012-01-23 16:16               ` [Qemu-devel] " Stefano Stabellini
2012-01-23 16:16                 ` Stefano Stabellini
2012-01-23 16:22                 ` [Qemu-devel] " Anthony Liguori
2012-01-23 16:22                   ` Anthony Liguori
2012-01-23 17:13                 ` [Qemu-devel] " Jan Kiszka
2012-01-23 17:13                   ` Jan Kiszka
2012-01-23 17:18                   ` [Qemu-devel] " Anthony Liguori
2012-01-23 17:18                     ` Anthony Liguori
2012-01-23 17:31                     ` [Qemu-devel] " Jan Kiszka
2012-01-23 17:31                       ` Jan Kiszka
2012-01-23 17:36                       ` [Qemu-devel] " Anthony Liguori
2012-01-23 17:36                         ` Anthony Liguori
2012-01-24 10:21                         ` [Qemu-devel] " Gerd Hoffmann
2012-01-24 10:21                           ` Gerd Hoffmann
2012-01-24 11:13                           ` [Qemu-devel] " Avi Kivity
2012-01-24 11:13                             ` Avi Kivity
2012-01-24 12:00                             ` [Qemu-devel] " Stefano Stabellini
2012-01-24 12:00                               ` Stefano Stabellini
2012-01-24 15:39                               ` [Qemu-devel] " Avi Kivity
2012-01-24 15:39                                 ` Avi Kivity
2012-01-24 13:18                             ` [Qemu-devel] " Anthony Liguori
2012-01-24 13:18                               ` Anthony Liguori
2012-01-24 15:43                               ` [Qemu-devel] " Avi Kivity
2012-01-24 15:43                                 ` Avi Kivity
2012-01-24 13:25                           ` [Qemu-devel] " Anthony Liguori
2012-01-24 13:25                             ` Anthony Liguori
2012-01-24 15:47                             ` [Qemu-devel] " Avi Kivity
2012-01-24 15:47                               ` Avi Kivity
2012-01-24 11:10                     ` [Qemu-devel] " Avi Kivity
2012-01-24 11:10                       ` Avi Kivity
2012-01-24 11:27                       ` [Qemu-devel] " Paolo Bonzini
2012-01-24 11:27                         ` Paolo Bonzini
2012-01-24 11:32                         ` [Qemu-devel] " Avi Kivity
2012-01-24 11:32                           ` Avi Kivity
2012-01-24 11:44                           ` [Qemu-devel] " Paolo Bonzini
2012-01-24 11:44                             ` Paolo Bonzini
2012-01-24 15:48                             ` [Qemu-devel] " Avi Kivity
2012-01-24 15:48                               ` Avi Kivity
2012-01-24 11:52                           ` [Qemu-devel] " Stefano Stabellini
2012-01-24 11:52                             ` Stefano Stabellini
2012-01-24 13:15                             ` [Qemu-devel] " Anthony Liguori
2012-01-24 13:15                               ` Anthony Liguori
2012-01-24 13:14                       ` [Qemu-devel] " Anthony Liguori
2012-01-24 13:14                         ` Anthony Liguori
2012-01-24 15:56                         ` [Qemu-devel] " Avi Kivity
2012-01-24 15:56                           ` Avi Kivity
2012-01-24 17:51                           ` [Qemu-devel] " Anthony Liguori
2012-01-24 17:51                             ` Anthony Liguori
2012-01-23 16:00     ` [Qemu-devel] " Anthony Liguori
2012-01-23 16:00       ` Anthony Liguori
2012-01-23 16:46       ` [Qemu-devel] " Stefano Stabellini
2012-01-23 16:46         ` Stefano Stabellini
2012-01-23 16:54         ` Anthony Liguori [this message]
2012-01-23 16:54           ` Anthony Liguori
2012-01-23 17:05           ` [Qemu-devel] " Stefano Stabellini
2012-01-23 17:05             ` Stefano Stabellini
2012-01-23 17:07             ` [Qemu-devel] " Anthony Liguori
2012-01-23 17:07               ` Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2012-01-25 13:04 [Qemu-devel] " Stefano Stabellini
2012-01-31 15:50 ` Stefano Stabellini
2012-02-13 12:20   ` Stefano Stabellini
2012-02-21 10:22     ` Stefano Stabellini

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=4F1D90B7.4060202@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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.