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 6/7] migration: Fix arrays of pointers in JSON writer
Date: Wed, 8 Jan 2025 12:56:18 -0500 [thread overview]
Message-ID: <Z368QjYRk9aqJefd@x1n> (raw)
In-Reply-To: <875xmp447s.fsf@suse.de>
On Wed, Jan 08, 2025 at 02:15:19PM -0300, Fabiano Rosas wrote:
> >> >> else:
> >> >> - self.data[field['name']] = field['data']
> >> >> + # There could be multiple entries for the same field
> >> >> + # name, e.g. when a compressed array was broken in
> >> >> + # more than one piece.
> >> >> + if (field['name'] in self.data and
> >> >> + type(self.data[field['name']]) == list):
> >> >> + self.data[field['name']].append(field['data'])
> >> >> + else:
> >> >> + self.data[field['name']] = field['data']
[...]
> The last nullptr overwrites everything else:
>
> "s390_css (14)": {
> "pending_crws": "00",
> "sei_pending": false,
> "do_crw_mchk": true,
> "crws_lost": false,
> "max_cssid": "0x00",
> "max_ssid": "0x00",
> "chnmon_active": false,
> "chnmon_area": "0x0000000000000000",
> --> "css": "nullptr",
> "default_cssid": "0xfe"
> },
Oh I see what you meant..
Then I am guessing the current change may not always work, e.g. when the
1st entry only contains one element rather than an array, like:
{"name": "css", "type": "uint8", "size": 1},
{"name": "css", "type": "struct", "struct": {"vmsd_name": "s390_css_img", ... }, "size": 768},
{"name": "css", "array_len": 254, "type": "uint8", "size": 1},
Here we may need something like:
name = field['name']
if (name in self.data):
if (type(self.data[name]) is not list):
self.data[name] = [self.data[name]]
self.data[name].append(field['data'])
else:
self.data[name] = field['data']
--
Peter Xu
next prev parent reply other threads:[~2025-01-08 17:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 19:50 [PATCH 0/7] migration: Fix s390 regressions + migration script Fabiano Rosas
2025-01-07 19:50 ` [PATCH 1/7] migration: Add more error handling to analyze-migration.py Fabiano Rosas
2025-01-07 19:50 ` [PATCH 2/7] migration: Remove unused argument in vmsd_desc_field_end Fabiano Rosas
2025-01-07 21:14 ` Peter Xu
2025-01-07 19:50 ` [PATCH 3/7] migration: Document the effect of vmstate_info_nullptr Fabiano Rosas
2025-01-07 21:24 ` Peter Xu
2025-01-08 13:31 ` Fabiano Rosas
2025-01-08 13:48 ` Peter Xu
2025-01-08 14:37 ` Fabiano Rosas
2025-01-07 19:50 ` [PATCH 4/7] migration: Fix parsing of s390 stream Fabiano Rosas
2025-01-07 19:50 ` [PATCH 5/7] migration: Dump correct JSON format for nullptr replacement Fabiano Rosas
2025-01-07 19:50 ` [PATCH 6/7] migration: Fix arrays of pointers in JSON writer Fabiano Rosas
2025-01-07 23:25 ` Peter Xu
2025-01-08 13:52 ` Fabiano Rosas
2025-01-08 16:14 ` Peter Xu
2025-01-08 17:15 ` Fabiano Rosas
2025-01-08 17:56 ` Peter Xu [this message]
2025-01-07 19:50 ` [PATCH 7/7] s390x: Fix CSS migration Fabiano Rosas
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=Z368QjYRk9aqJefd@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 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).