On 10/25/2016 12:13 PM, Dr. David Alan Gilbert wrote: > * Halil Pasic (pa...@linux.vnet.ibm.com) wrote: >> > Make VMS_ARRAY_OF_POINTER cope with null pointers. Previously the reward >> > for trying to migrate an array with some null pointers in it was an >> > illegal memory access, that is a swift and painless death of the >> > process. Let's make vmstate cope with this scenario at least for >> > pointers to structs. The general approach is when we encounter a null >> > pointer (element) instead of following the pointer to save/load the data >> > behind it we save/load a placeholder. This way we can detect if we >> > expected a null pointer at the load side but not null data was saved >> > instead. Sadly all other error scenarios are not detected by this scheme >> > (and would require the usage of the JSON meta data). >> > >> > Limitations: Does not work for pointers to primitives. > Hmm is this needed - I mean could you do this just by giving the vmsd > that defines the children of the array a '.needed' that tests if their > pointer is NULL? > >
I do not think so: .needed is basically for subsections (also used in migration/savevm.c via the exported vmstate_save_needed function), and .field_exists is also no use for this (AFAIU). Have also tried just to be sure, it did not work for me. If I did not convince you, a bit of a code proving me wrong would be highly appreciated. Thanks for the comment! Halil