qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 01/10] qapi: add Visitor interfaces for uint*_t and int*_t
Date: Wed, 21 Dec 2011 13:29:33 +0100	[thread overview]
Message-ID: <4EF1D12D.4070006@redhat.com> (raw)
In-Reply-To: <4EF0EE84.3090509@linux.vnet.ibm.com>

On 12/20/2011 09:22 PM, Michael Roth wrote:
> The main goal is to abstract away data serialization schemes
> (QObject->JSON, C->QEMUFile, etc).

Right.  And the simplest way to abstract the scheme is to provide a 
backend-independent representation of device state.

As a convention, I'll call:

- "device state" the fields in the struct

- "QEMUFile" the serialized output that VMState save produces

- "device state representation" a representation of device state that is 
independent of the actual serialization backend.

- "device configuration" is the parameters that are used to create the 
device (coming from compile-time constants or the command-line)

> In the case of a JSON-based serialization, the visitor interface for
> fixed-with types would end up serializing everything as
> int64_t/double, but QEMUFile requires byte-length affinity to remain
> backward-compatible, so that information must be passed on to the
> Visitor interface when we call it.

When creating the device state representation from either device state 
or QEMUFile, you need the byte length to fetch fields correctly.

When recreating device state from its representation, or saving to 
QEMUFile state, you need the byte length to store fields correctly.

However, you do not need the byte length in the device state 
representation.  In all four cases (from/to device state, from/to 
QEMUFile) the byte length can be fetched from the VMState.

>> As always, you can implement that in many ways. However, I think the
>> point of using Visitors is not to remove QEMUFile. It is to provide a
>> backend-independent representation that backends can transform and that
>> secondarily can be exposed by QOM.
>
> Agreed, it's just a matter of wanting to maintain that information from
> start to finish.

I don't see the point of maintaining the type hints from start to 
finish, as long as you can reconstruct it any time you want it.

>> On top of this the representation he passes to visitors is somewhat
>> redundant. For example, VMState has "equal" fields; they are fields that
>> are serialized but are really fixed at compile- or realize-time. Such
>> fields should not be part of the backend-independent representation.
>> With Michael's approach they are, and that's quite deep in the
>> implementation.
>
> You mean, for instance, put_int32()/get_int32_equal()? If so, I'm not
> sure I follow. In that case we use a Visitor purely to
> serialize/deserialize an int32, vmstate adds the *_equal() interface as
> helper function on top of that, but it's not part of the Visitor
> interfaces.

It should be only in QEMUFile, because it's one of its quirks.  It is a 
separate property that is fixed at compile-time or realize-time, so it's 
part of device configuration; it's not part of device state representation.

>> Yes, this is accurate, but I see the goals differently. We should:
>>
>> (1) First and foremost, provide a backend-independent representation of
>> device state so that we can add other backends later.
>>
>> (2) Serialize this with QEMUFile, both for backwards-compatibility and
>> to ensure that the whole thing works.
>>
>> Whether you do (2) directly with QEMUFile or, like Michael does, with
>> QEMUFile*Visitors is secondary. I don't have big objections to either
>> approach. However, the series is missing (1).
>
> I'll fix up the existing non-QEMUFile Visitor backends with base-class
> implementations for all the new interfaces. Beyond that, is there
> anything else missing to achieve 1)?

I think almost nothing (you need to integrate into the QOM properties, 
and to handle a few special cases such as VMSTATE_EQUAL and 
VMSTATE_UNUSED).  That's quite good.

However, once you do this, you will still be serializing QEMUFile 
directly from device state rather than from device state representation. 
  This is fine, but not what we should do when working on BER 
serialization or similar.

Paolo

  reply	other threads:[~2011-12-21 12:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 17:06 [Qemu-devel] [PATCH v2 00/10] do savevm/migration save/load via Visitor interface Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 01/10] qapi: add Visitor interfaces for uint*_t and int*_t Michael Roth
2011-12-20 11:12   ` Paolo Bonzini
2011-12-20 11:43     ` Paolo Bonzini
2011-12-20 12:00       ` Paolo Bonzini
2011-12-20 13:50     ` Anthony Liguori
2011-12-20 14:30       ` Paolo Bonzini
2011-12-20 20:22         ` Michael Roth
2011-12-21 12:29           ` Paolo Bonzini [this message]
2011-12-20 20:56         ` Anthony Liguori
2011-12-21 12:35           ` Paolo Bonzini
2011-12-21 14:45             ` Anthony Liguori
2011-12-21 15:39               ` Paolo Bonzini
2011-12-21 16:24                 ` Anthony Liguori
2011-12-21 16:52                   ` Paolo Bonzini
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 02/10] qapi: add QemuFileOutputVisitor Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 03/10] qapi: add QemuFileInputVisitor Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 04/10] savevm: move QEMUFile interfaces into qemu-file.c Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 05/10] qapi: test cases for QEMUFile input/output visitors Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 06/10] qemu-file: add QEMUFile<->visitor lookup routines Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 07/10] trace: qemu_(put|get)_(byte|buffer) events Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 08/10] trace: add trace statements for visitor interface Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 09/10] qapi: add trace statements to qapi-visit-core.c Michael Roth
2011-10-27 17:06 ` [Qemu-devel] [PATCH v2 10/10] vmstate: use visitors Michael Roth

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=4EF1D12D.4070006@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).