On Fri, Dec 23, 2022 at 10:34:36AM +0100, David Hildenbrand wrote: > On 22.12.22 12:02, David Hildenbrand wrote: > > For virtio-mem, we want to have the plugged/unplugged state of memory > > blocks available before migrating any actual RAM content. This > > information is immutable on the migration source while migration is active, > > > > For example, we want to use this information for proper preallocation > > support with migration: currently, we don't preallocate memory on the > > migration target, and especially with hugetlb, we can easily run out of > > hugetlb pages during RAM migration and will crash (SIGBUS) instead of > > catching this gracefully via preallocation. > > > > Migrating device state before we start iterating is currently impossible. > > Introduce and use qemu_savevm_state_start_precopy(), and use > > a new special migration priority -- MIG_PRI_POST_SETUP -- to decide whether > > state will be saved in qemu_savevm_state_start_precopy() or in > > qemu_savevm_state_complete_precopy_*(). > > > > We have to take care of properly including the early device state in the > > vmdesc. Relying on migrate_get_current() to temporarily store the vmdesc is > > a bit sub-optimal, but we use that explicitly or implicitly all over the > > place already, so this barely matters in practice. > > > > Note that only very selected devices (i.e., ones seriously messing with > > RAM setup) are supposed to make use of that. > > > > Signed-off-by: David Hildenbrand <da...@redhat.com> > > [...] > > > if (inactivate_disks) { > > @@ -1427,6 +1474,10 @@ int > > qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, > > qemu_put_buffer(f, (uint8_t *)json_writer_get(vmdesc), > > vmdesc_len); > > } > > + /* Free it now to detect any inconsistencies. */ > > + g_free(vmdesc); > > Missed to convert that to a json_writer_free().
I get it you will post v4? > -- > Thanks, > > David / dhildenb