All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Fabiano Rosas <farosas@suse.de>
Cc: qemu-devel@nongnu.org, Thomas Huth <thuth@redhat.com>
Subject: Re: [PATCH v3 6/7] migration: Fix arrays of pointers in JSON writer
Date: Thu, 9 Jan 2025 14:10:40 -0500	[thread overview]
Message-ID: <Z4AfMFohWV_QNdbP@x1n> (raw)
In-Reply-To: <20250109185249.23952-7-farosas@suse.de>

On Thu, Jan 09, 2025 at 03:52:48PM -0300, Fabiano Rosas wrote:
> Currently, if an array of pointers contains a NULL pointer, that
> pointer will be encoded as '0' in the stream. Since the JSON writer
> doesn't define a "pointer" type, that '0' will now be an uint8, which
> is different from the original type being pointed to, e.g. struct.
> 
> (we're further calling uint8 "nullptr", but that's irrelevant to the
> issue)
> 
> That mixed-type array shouldn't be compressed, otherwise data is lost
> as the code currently makes the whole array have the type of the first
> element:
> 
> css = {NULL, NULL, ..., 0x5555568a7940, NULL};
> 
> {"name": "s390_css", "instance_id": 0, "vmsd_name": "s390_css",
>  "version": 1, "fields": [
>     ...,
>     {"name": "css", "array_len": 256, "type": "nullptr", "size": 1},
>     ...,
> ]}
> 
> In the above, the valid pointer at position 254 got lost among the
> compressed array of nullptr.
> 
> While we could disable the array compression when a NULL pointer is
> found, the JSON part of the stream still makes part of downtime, so we
> should avoid writing unecessary bytes to it.
> 
> Keep the array compression in place, but if NULL and non-NULL pointers
> are mixed break the array into several type-contiguous pieces :
> 
> css = {NULL, NULL, ..., 0x5555568a7940, NULL};
> 
> {"name": "s390_css", "instance_id": 0, "vmsd_name": "s390_css",
>  "version": 1, "fields": [
>      ...,
>      {"name": "css", "array_len": 254, "type": "nullptr", "size": 1},
>      {"name": "css", "type": "struct", "struct": {"vmsd_name": "s390_css_img", ... }, "size": 768},
>      {"name": "css", "type": "nullptr", "size": 1},
>      ...,
> ]}
> 
> Now each type-discontiguous region will become a new JSON entry. The
> reader should interpret this as a concatenation of values, all part of
> the same field.
> 
> Parsing the JSON with analyze-script.py now shows the proper data
> being pointed to at the places where the pointer is valid and
> "nullptr" where there's NULL:
> 
> "s390_css (14)": {
>     ...
>     "css": [
>         "nullptr",
>         "nullptr",
>         ...
>         "nullptr",
>         {
>             "chpids": [
>             {
>                 "in_use": "0x00",
>                 "type": "0x00",
>                 "is_virtual": "0x00"
>             },
>             ...
>             ]
>         },
>         "nullptr",
>     }
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>

Reviewed-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu



  reply	other threads:[~2025-01-09 19:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 18:52 [PATCH v3 0/7] migration: Fix s390 regressions + migration script Fabiano Rosas
2025-01-09 18:52 ` [PATCH v3 1/7] migration: Add more error handling to analyze-migration.py Fabiano Rosas
2025-01-09 18:52 ` [PATCH v3 2/7] migration: Remove unused argument in vmsd_desc_field_end Fabiano Rosas
2025-01-09 18:52 ` [PATCH v3 3/7] migration: Fix parsing of s390 stream Fabiano Rosas
2025-01-12 13:06   ` Michael Tokarev
2025-01-12 14:29     ` Michael Tokarev
2025-01-13  6:39       ` Thomas Huth
2025-01-13  7:51         ` Michael Tokarev
2025-01-13  8:19           ` Thomas Huth
2025-01-13  9:09             ` Michael Tokarev
2025-01-13 13:03               ` Fabiano Rosas
2025-01-13 13:07                 ` Fabiano Rosas
2025-01-13 15:13                 ` Michael Tokarev
2025-01-09 18:52 ` [PATCH v3 4/7] migration: Rename vmstate_info_nullptr Fabiano Rosas
2025-01-09 19:10   ` Peter Xu
2025-01-09 18:52 ` [PATCH v3 5/7] migration: Dump correct JSON format for nullptr replacement Fabiano Rosas
2025-01-09 18:52 ` [PATCH v3 6/7] migration: Fix arrays of pointers in JSON writer Fabiano Rosas
2025-01-09 19:10   ` Peter Xu [this message]
2025-01-09 18:52 ` [PATCH v3 7/7] s390x: Fix CSS migration Fabiano Rosas
2025-01-12 14:34   ` Michael Tokarev
2025-01-13  6:37     ` Thomas Huth
2025-01-12 14:34   ` Michael Tokarev

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=Z4AfMFohWV_QNdbP@x1n \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@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 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.