All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liran Alon <liran.alon@oracle.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Idan Brown <idan.brown@oracle.com>,
	ehabkost@redhat.com, kvm list <kvm@vger.kernel.org>,
	mtosatti@redhat.com, qemu-devel@nongnu.org, rth@twiddle.net,
	Jim Mattson <jmattson@google.com>
Subject: Re: [PATCH 2/2] KVM: i386: Add support for save and restore nested state
Date: Sat, 15 Sep 2018 23:57:52 +0300	[thread overview]
Message-ID: <F16E888D-8C0D-4758-A605-040C12CBB05C@oracle.com> (raw)
In-Reply-To: <6F9299DE-58CA-4CC9-8779-2FE2C4B7C2CE@oracle.com>



> On 15 Sep 2018, at 23:48, Liran Alon <liran.alon@oracle.com> wrote:
> 
> 
> 
>> On 14 Sep 2018, at 18:08, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> 
>> On 14/09/2018 16:31, Liran Alon wrote:
>>>> There is still a problem, however, in that the same input stream would
>>>> be parsed differently depending on the kernel version.  In particular,
>>>> if in the future the maximum nested state size grows, you break all
>>>> existing save files.
>>> 
>>> I’m not sure I agree with this.
>>> 1) Newer kernels should change struct only by utilizing unused fields in current struct
>>> or enlarging it with extra fields. It should not change the meaning of existing fields.
>> 
>> Newer kernels will return a larger size, which is stored in
>> env->nested_state_len, and the file format depends on it:
>> 
>>> +        VMSTATE_VBUFFER_UINT32(env.nested_state, X86CPU, 
>>> +                               0, NULL, 
>>> +                               env.nested_state_len), 
>> 
> 
> Oh. I thought that QEMU will just receive to dest buffer only what was sent from source buffer.
> I didn’t know that it also enforces that the sizes of the source and dest buffer are equal.
> (I thought that dest_buffer_size only needed to be >= src_buffer_size).
> 
> Anyway, my intention here was that QEMU will only enforce (dest_buffer_size >= source_buffer_size)
> and if so, receive source buffer into destination buffer.
> Is there a simple way to do this in QEMU’s VMSTATE framework without implementing custom save/load callbacks?
> 

One possible, but not so elegant, way to do so is to put env.nested_state_len as part of VMState
and change env.nested_state to be declared in VMState as VMSTATE_VBUFFER_ALLOC_UINT32().
Then, make nested_state_post_load() to realloc env.nested_state in size specified by kvm_nested_state_length().
To guarantee that env.nested_state is always at max size that local kernel supports.

-Liran

WARNING: multiple messages have this Message-ID (diff)
From: Liran Alon <liran.alon@oracle.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, rth@twiddle.net, ehabkost@redhat.com,
	mtosatti@redhat.com, kvm list <kvm@vger.kernel.org>,
	Jim Mattson <jmattson@google.com>,
	Idan Brown <idan.brown@oracle.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] KVM: i386: Add support for save and restore nested state
Date: Sat, 15 Sep 2018 23:57:52 +0300	[thread overview]
Message-ID: <F16E888D-8C0D-4758-A605-040C12CBB05C@oracle.com> (raw)
In-Reply-To: <6F9299DE-58CA-4CC9-8779-2FE2C4B7C2CE@oracle.com>



> On 15 Sep 2018, at 23:48, Liran Alon <liran.alon@oracle.com> wrote:
> 
> 
> 
>> On 14 Sep 2018, at 18:08, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> 
>> On 14/09/2018 16:31, Liran Alon wrote:
>>>> There is still a problem, however, in that the same input stream would
>>>> be parsed differently depending on the kernel version.  In particular,
>>>> if in the future the maximum nested state size grows, you break all
>>>> existing save files.
>>> 
>>> I’m not sure I agree with this.
>>> 1) Newer kernels should change struct only by utilizing unused fields in current struct
>>> or enlarging it with extra fields. It should not change the meaning of existing fields.
>> 
>> Newer kernels will return a larger size, which is stored in
>> env->nested_state_len, and the file format depends on it:
>> 
>>> +        VMSTATE_VBUFFER_UINT32(env.nested_state, X86CPU, 
>>> +                               0, NULL, 
>>> +                               env.nested_state_len), 
>> 
> 
> Oh. I thought that QEMU will just receive to dest buffer only what was sent from source buffer.
> I didn’t know that it also enforces that the sizes of the source and dest buffer are equal.
> (I thought that dest_buffer_size only needed to be >= src_buffer_size).
> 
> Anyway, my intention here was that QEMU will only enforce (dest_buffer_size >= source_buffer_size)
> and if so, receive source buffer into destination buffer.
> Is there a simple way to do this in QEMU’s VMSTATE framework without implementing custom save/load callbacks?
> 

One possible, but not so elegant, way to do so is to put env.nested_state_len as part of VMState
and change env.nested_state to be declared in VMState as VMSTATE_VBUFFER_ALLOC_UINT32().
Then, make nested_state_post_load() to realloc env.nested_state in size specified by kvm_nested_state_length().
To guarantee that env.nested_state is always at max size that local kernel supports.

-Liran

  reply	other threads:[~2018-09-15 20:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14  9:54 [PATCH 2/2] KVM: i386: Add support for save and restore nested state Liran Alon
2018-09-14  9:54 ` [Qemu-devel] " Liran Alon
2018-09-14 10:59 ` Paolo Bonzini
2018-09-14 10:59   ` [Qemu-devel] " Paolo Bonzini
2018-09-14 14:31   ` Liran Alon
2018-09-14 14:31     ` [Qemu-devel] " Liran Alon
2018-09-14 15:08     ` Paolo Bonzini
2018-09-14 15:08       ` [Qemu-devel] " Paolo Bonzini
2018-09-15 20:48       ` Liran Alon
2018-09-15 20:48         ` [Qemu-devel] " Liran Alon
2018-09-15 20:57         ` Liran Alon [this message]
2018-09-15 20:57           ` Liran Alon
2018-09-17 14:35         ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2018-09-14  0:38 [PATCH 0/2]: " Liran Alon
2018-09-14  0:38 ` [PATCH 2/2] " Liran Alon
2018-09-14  7:16   ` Paolo Bonzini

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=F16E888D-8C0D-4758-A605-040C12CBB05C@oracle.com \
    --to=liran.alon@oracle.com \
    --cc=ehabkost@redhat.com \
    --cc=idan.brown@oracle.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.