qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/7] migration: Fix arrays of pointers in JSON writer


From: Peter Xu
Subject: Re: [PATCH 6/7] migration: Fix arrays of pointers in JSON writer
Date: Wed, 8 Jan 2025 12:56:18 -0500

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]