Message ID | 1412243763-32431-2-git-send-email-aik@ozlabs.ru |
---|---|
State | New |
Headers | show |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 10/02/2014 07:56 PM, Alexey Kardashevskiy wrote: > This extends use of VMS_ALLOC flag from arrays to VBUFFER as well. > > This defines VMSTATE_VBUFFER_ALLOC_UINT32 which makes use of > VMS_ALLOC and uses uint32_t type for a size. Adding Juan to cc:. Please, ack :) > > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- > include/migration/vmstate.h | 11 +++++++++++ vmstate.c > | 13 ++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/include/migration/vmstate.h > b/include/migration/vmstate.h index 9a001bd..e45fc49 100644 --- > a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ > -484,6 +484,17 @@ extern const VMStateInfo vmstate_info_bitmap; .start > = (_start), \ } > > +#define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, _test, > _start, _field_size) { \ + .name = (stringify(_field)), > \ + .version_id = (_version), > \ + .field_exists = (_test), > \ + .size_offset = vmstate_offset_value(_state, _field_size, > uint32_t),\ + .info = &vmstate_info_buffer, > \ + .flags = VMS_VBUFFER|VMS_POINTER|VMS_ALLOC, > \ + .offset = offsetof(_state, _field), > \ + .start = (_start), > \ +} + #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, > _info, _size) { \ .name = (stringify(_field)), > \ .version_id = (_version), \ > diff --git a/vmstate.c b/vmstate.c index ef2f87b..3dde574 100644 --- > a/vmstate.c +++ b/vmstate.c @@ -49,9 +49,16 @@ static void > *vmstate_base_addr(void *opaque, VMStateField *field, bool alloc) > > if (field->flags & VMS_POINTER) { if (alloc && (field->flags & > VMS_ALLOC)) { - int n_elems = vmstate_n_elems(opaque, > field); - if (n_elems) { - gsize size = > n_elems * field->size; + gsize size = 0; + if > (field->flags & VMS_VBUFFER) { + size = > vmstate_size(opaque, field); + } else { + > int n_elems = vmstate_n_elems(opaque, field); + if > (n_elems) { + size = n_elems * field->size; + > } + } + if (size) { *((void **)base_addr + > field->start) = g_malloc(size); } } > - -- Alexey -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJULeLkAAoJEIYTPdgrwSC5r2UP/RSiuKEanpXfhwyhudAB1nGM 9t3NJxrLO5PhkhfIveGgcf/t3hWpGOGu1JiiwpD8//ipjX0nBGt0O8p6Tp6xATtm 2NOid+9F6yUxfhLVB3vGQZ4KocguPt789t37HRgn9oT9YVxsJdeb1ftcDXw+opB7 qM113ZdrOVBPVeH1+vSC0vUwNYokjRQf/kX8IwwFXyJirt9/Rf9FaXf+KuturpJo lp2yYVhuWmBy+MID5HZNlTfqVU5iMmX6ngqVm7rkaFxRA/3Ywlj1OtYGyf9htgya OauFrvwUlM4yh3CiqLqu12Jabadu1Oa8yIeY9r2O5A4JLZt9JS2n3vxM70H8Z67Z XJpQDF2Il26w9jIlmJ10GvVFt7sBaV0Yzu9SfgzNdSO/zteaODulOLj3eciUwnDk DxbFvf8zn1vCuFjIwq3lqPaH1mNHEnLnV+6XlJLYNrD9Vngcc2UN/hXRMKwWovdL rJAtOCObDB8VlilqS5/sFCekZsQasAnY7NckQvrx+0V/I7BJ99I7kKGcNIZF8pAU 84XHrw8j80+jh5W+6byn8M0lKgd7dn11KXcXzE1nuIVAP9KxG7Br5od3zePqhiIl mdJ9meR3aOfNAr6N9iW/El+2g3FvhH3TQaZ+R5ZJMGCTVt9tqIVf1XLuXVbjdV3X /xd/ACb10y32PH2sIEhl =tSNm -----END PGP SIGNATURE-----
On Thu, Oct 02, 2014 at 07:56:02PM +1000, Alexey Kardashevskiy wrote: > This extends use of VMS_ALLOC flag from arrays to VBUFFER as well. > > This defines VMSTATE_VBUFFER_ALLOC_UINT32 which makes use of VMS_ALLOC > and uses uint32_t type for a size. > > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 10/03/2014 09:42 AM, Alexey Kardashevskiy wrote: > On 10/02/2014 07:56 PM, Alexey Kardashevskiy wrote: >> This extends use of VMS_ALLOC flag from arrays to VBUFFER as well. > >> This defines VMSTATE_VBUFFER_ALLOC_UINT32 which makes use of >> VMS_ALLOC and uses uint32_t type for a size. > > > Adding Juan to cc:. Please, ack :) Juan, ping? > > > >> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- >> include/migration/vmstate.h | 11 +++++++++++ vmstate.c | 13 >> ++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) > >> diff --git a/include/migration/vmstate.h >> b/include/migration/vmstate.h index 9a001bd..e45fc49 100644 --- >> a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ >> -484,6 +484,17 @@ extern const VMStateInfo vmstate_info_bitmap; >> .start = (_start), \ } > >> +#define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, >> _test, _start, _field_size) { \ + .name = >> (stringify(_field)), \ + .version_id = (_version), \ + >> .field_exists = (_test), \ + .size_offset = >> vmstate_offset_value(_state, _field_size, uint32_t),\ + .info >> = &vmstate_info_buffer, \ + .flags = >> VMS_VBUFFER|VMS_POINTER|VMS_ALLOC, \ + .offset = >> offsetof(_state, _field), \ + .start = (_start), \ +} + >> #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, >> _size) { \ .name = (stringify(_field)), \ .version_id = >> (_version), \ diff --git >> a/vmstate.c b/vmstate.c index ef2f87b..3dde574 100644 --- >> a/vmstate.c +++ b/vmstate.c @@ -49,9 +49,16 @@ static void >> *vmstate_base_addr(void *opaque, VMStateField *field, bool alloc) > >> if (field->flags & VMS_POINTER) { if (alloc && (field->flags & >> VMS_ALLOC)) { - int n_elems = vmstate_n_elems(opaque, >> field); - if (n_elems) { - gsize size = >> n_elems * field->size; + gsize size = 0; + if >> (field->flags & VMS_VBUFFER) { + size = >> vmstate_size(opaque, field); + } else { + int n_elems = >> vmstate_n_elems(opaque, field); + if (n_elems) { + >> size = n_elems * field->size; + } + } + if >> (size) { *((void **)base_addr + field->start) = g_malloc(size); } } > > > > - -- Alexey -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUNhsTAAoJEIYTPdgrwSC5CzgQAJbQ7C259BGZqPics7P1FhIm wzHhwfUwfEML6nRtaVMeime8qqfbD048VNH43/nCiCoy2MjkvXV/uT+j2f+hLjcG 46Ys004S7SDn+bl+7Z24sFGZ5iqBO3is+kLj79w878IwC5SPM0jH7dfnU+ZSimVE rCug/D95IvU4gOVfxtDbFg5oq6sgGHC+SpLsg9CAo2lBcOje5ylSAwyd5/s3pmnC FMXf3nJI/aAQTcbrVeuB4+khGP4hncqzh2w07IP8olszZcyTzRIzQnyU3eqIbPrM 8nX6HdrauVj0VxtSZJzticaJnzO7qqOl+1TiCZWCV5m7jchbPbKnuvovoRQ1v5cw DSmZ8BULGK6XnuOmqhEY8AMDAYcHP8DvnJ1N+dmAcsfCr6jFIb0HAW6VWsqMJxDG J7G3jIKooOSXCmciFkS+2QMJ0TrAgavF/K2njdcA/7up+nVBDnPsEX+bFnox9N+w KnyBYS8tWqP4NuK+q53BtkZllMXQYSLFQUoi5XgKoCL1dk1xoxlbZg/3rbXzMB3a sWt3W9zxx5PzsNGEUfQyl8mgmR02y+N1cqJRu/6HJfxfXJ2m+LvTPhlp1oWJVuHT YKam971lTrPja0Z7OfNgWjPgv/OOW7NjzMGbq51SV20TDKgn1sJMSGqJ/cdqBkeS HZBj6AVhEzX4V+NDAkrH =JyEK -----END PGP SIGNATURE-----
Alexey Kardashevskiy <aik@ozlabs.ru> wrote: > This extends use of VMS_ALLOC flag from arrays to VBUFFER as well. > > This defines VMSTATE_VBUFFER_ALLOC_UINT32 which makes use of VMS_ALLOC > and uses uint32_t type for a size. > > Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Juan Quintela <quintela@redhat.com>
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 9a001bd..e45fc49 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -484,6 +484,17 @@ extern const VMStateInfo vmstate_info_bitmap; .start = (_start), \ } +#define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, _test, _start, _field_size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ + .info = &vmstate_info_buffer, \ + .flags = VMS_VBUFFER|VMS_POINTER|VMS_ALLOC, \ + .offset = offsetof(_state, _field), \ + .start = (_start), \ +} + #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ diff --git a/vmstate.c b/vmstate.c index ef2f87b..3dde574 100644 --- a/vmstate.c +++ b/vmstate.c @@ -49,9 +49,16 @@ static void *vmstate_base_addr(void *opaque, VMStateField *field, bool alloc) if (field->flags & VMS_POINTER) { if (alloc && (field->flags & VMS_ALLOC)) { - int n_elems = vmstate_n_elems(opaque, field); - if (n_elems) { - gsize size = n_elems * field->size; + gsize size = 0; + if (field->flags & VMS_VBUFFER) { + size = vmstate_size(opaque, field); + } else { + int n_elems = vmstate_n_elems(opaque, field); + if (n_elems) { + size = n_elems * field->size; + } + } + if (size) { *((void **)base_addr + field->start) = g_malloc(size); } }
This extends use of VMS_ALLOC flag from arrays to VBUFFER as well. This defines VMSTATE_VBUFFER_ALLOC_UINT32 which makes use of VMS_ALLOC and uses uint32_t type for a size. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- include/migration/vmstate.h | 11 +++++++++++ vmstate.c | 13 ++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)