Re: [Qemu-devel] [RFC PATCH v2 04/49] fdc: adding vmstate for save/restore

2014-07-28 Thread Paolo Bonzini
Il 17/07/2014 13:02, Pavel Dovgalyuk ha scritto:
> VMState added by this patch preserves correct
> loading of the FDC device state.
> 
> Signed-off-by: Pavel Dovgalyuk 
> ---
>  hw/block/fdc.c |   11 +--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
> index 490d127..132310a 100644
> --- a/hw/block/fdc.c
> +++ b/hw/block/fdc.c
> @@ -697,12 +697,17 @@ static const VMStateDescription 
> vmstate_fdrive_media_rate = {
>  
>  static const VMStateDescription vmstate_fdrive = {
>  .name = "fdrive",
> -.version_id = 1,
> +.version_id = 2,
>  .minimum_version_id = 1,
>  .fields = (VMStateField[]) {
>  VMSTATE_UINT8(head, FDrive),
>  VMSTATE_UINT8(track, FDrive),
>  VMSTATE_UINT8(sect, FDrive),
> +VMSTATE_UINT8_V(last_sect, FDrive, 2),
> +VMSTATE_UINT8_V(max_track, FDrive, 2),
> +VMSTATE_UINT16_V(bps, FDrive, 2),
> +VMSTATE_UINT8_V(ro, FDrive, 2),
> +VMSTATE_UINT8_V(perpendicular, FDrive, 2),

Perpendicular can be added to a subsection, migrated only if nonzero.
The others can be reconstructed by calling fd_revalidate in
vmstate_fdrive's post_load callback.


>  VMSTATE_END_OF_LIST()
>  },
>  .subsections = (VMStateSubsection[]) {
> @@ -736,7 +741,7 @@ static int fdc_post_load(void *opaque, int version_id)
>  
>  static const VMStateDescription vmstate_fdc = {
>  .name = "fdc",
> -.version_id = 2,
> +.version_id = 3,
>  .minimum_version_id = 2,
>  .pre_save = fdc_pre_save,
>  .post_load = fdc_post_load,
> @@ -769,6 +774,8 @@ static const VMStateDescription vmstate_fdc = {
>  VMSTATE_UINT8_EQUAL(num_floppies, FDCtrl),
>  VMSTATE_STRUCT_ARRAY(drives, FDCtrl, MAX_FD, 1,
>   vmstate_fdrive, FDrive),
> +VMSTATE_INT32_V(reset_sensei, FDCtrl, 3),

Subsection, only migrated if nonzero.

> +VMSTATE_TIMER_V(result_timer, FDCtrl, 3),

Subsection, only migrated if pending.

Paolo

>  VMSTATE_END_OF_LIST()
>  }
>  };
> 
> 
> 




[Qemu-devel] [RFC PATCH v2 04/49] fdc: adding vmstate for save/restore

2014-07-17 Thread Pavel Dovgalyuk
VMState added by this patch preserves correct
loading of the FDC device state.

Signed-off-by: Pavel Dovgalyuk 
---
 hw/block/fdc.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 490d127..132310a 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -697,12 +697,17 @@ static const VMStateDescription vmstate_fdrive_media_rate 
= {
 
 static const VMStateDescription vmstate_fdrive = {
 .name = "fdrive",
-.version_id = 1,
+.version_id = 2,
 .minimum_version_id = 1,
 .fields = (VMStateField[]) {
 VMSTATE_UINT8(head, FDrive),
 VMSTATE_UINT8(track, FDrive),
 VMSTATE_UINT8(sect, FDrive),
+VMSTATE_UINT8_V(last_sect, FDrive, 2),
+VMSTATE_UINT8_V(max_track, FDrive, 2),
+VMSTATE_UINT16_V(bps, FDrive, 2),
+VMSTATE_UINT8_V(ro, FDrive, 2),
+VMSTATE_UINT8_V(perpendicular, FDrive, 2),
 VMSTATE_END_OF_LIST()
 },
 .subsections = (VMStateSubsection[]) {
@@ -736,7 +741,7 @@ static int fdc_post_load(void *opaque, int version_id)
 
 static const VMStateDescription vmstate_fdc = {
 .name = "fdc",
-.version_id = 2,
+.version_id = 3,
 .minimum_version_id = 2,
 .pre_save = fdc_pre_save,
 .post_load = fdc_post_load,
@@ -769,6 +774,8 @@ static const VMStateDescription vmstate_fdc = {
 VMSTATE_UINT8_EQUAL(num_floppies, FDCtrl),
 VMSTATE_STRUCT_ARRAY(drives, FDCtrl, MAX_FD, 1,
  vmstate_fdrive, FDrive),
+VMSTATE_INT32_V(reset_sensei, FDCtrl, 3),
+VMSTATE_TIMER_V(result_timer, FDCtrl, 3),
 VMSTATE_END_OF_LIST()
 }
 };