All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again)
@ 2016-06-20 17:53 David Vrabel
  2016-06-21  1:44 ` Jason Wang
  0 siblings, 1 reply; 6+ messages in thread
From: David Vrabel @ 2016-06-20 17:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Vrabel, Jason Wang

Commit 9d29cdeaaca3a0383af764000b71492c4fc67c6e (rtl8139: port
TallyCounters to vmstate) introduced in incompatibility in the v4
format as it omitted the RxOkMul counter.

There are presumably no users that were impacted by the v4 to v4'
breakage, so increase the save version to 5 and re-add the field,
keeping backward compatibility with v4'.

We can't have a field conditional on the section version in
vmstate_tally_counters since this version checked would not be the
section version (but the version defined in this structure).  So, move
all the fields into the main state structure.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
Cc: Jason Wang <jasowang@redhat.com>
---
 hw/net/rtl8139.c | 40 ++++++++++++++--------------------------
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 562c1fd..8ccd1d3 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -1352,29 +1352,6 @@ static void RTL8139TallyCounters_dma_write(RTL8139State *s, dma_addr_t tc_addr)
     pci_dma_write(d, tc_addr + 62,    (uint8_t *)&val16, 2);
 }
 
-/* Loads values of tally counters from VM state file */
-
-static const VMStateDescription vmstate_tally_counters = {
-    .name = "tally_counters",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_UINT64(TxOk, RTL8139TallyCounters),
-        VMSTATE_UINT64(RxOk, RTL8139TallyCounters),
-        VMSTATE_UINT64(TxERR, RTL8139TallyCounters),
-        VMSTATE_UINT32(RxERR, RTL8139TallyCounters),
-        VMSTATE_UINT16(MissPkt, RTL8139TallyCounters),
-        VMSTATE_UINT16(FAE, RTL8139TallyCounters),
-        VMSTATE_UINT32(Tx1Col, RTL8139TallyCounters),
-        VMSTATE_UINT32(TxMCol, RTL8139TallyCounters),
-        VMSTATE_UINT64(RxOkPhy, RTL8139TallyCounters),
-        VMSTATE_UINT64(RxOkBrd, RTL8139TallyCounters),
-        VMSTATE_UINT16(TxAbt, RTL8139TallyCounters),
-        VMSTATE_UINT16(TxUndrn, RTL8139TallyCounters),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
 static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val)
 {
     DeviceState *d = DEVICE(s);
@@ -3222,7 +3199,7 @@ static void rtl8139_pre_save(void *opaque)
 
 static const VMStateDescription vmstate_rtl8139 = {
     .name = "rtl8139",
-    .version_id = 4,
+    .version_id = 5,
     .minimum_version_id = 3,
     .post_load = rtl8139_post_load,
     .pre_save  = rtl8139_pre_save,
@@ -3293,8 +3270,19 @@ static const VMStateDescription vmstate_rtl8139 = {
         VMSTATE_UINT32(TimerInt, RTL8139State),
         VMSTATE_INT64(TCTR_base, RTL8139State),
 
-        VMSTATE_STRUCT(tally_counters, RTL8139State, 0,
-                       vmstate_tally_counters, RTL8139TallyCounters),
+        VMSTATE_UINT64(tally_counters.TxOk, RTL8139State),
+        VMSTATE_UINT64(tally_counters.RxOk, RTL8139State),
+        VMSTATE_UINT64(tally_counters.TxERR, RTL8139State),
+        VMSTATE_UINT32(tally_counters.RxERR, RTL8139State),
+        VMSTATE_UINT16(tally_counters.MissPkt, RTL8139State),
+        VMSTATE_UINT16(tally_counters.FAE, RTL8139State),
+        VMSTATE_UINT32(tally_counters.Tx1Col, RTL8139State),
+        VMSTATE_UINT32(tally_counters.TxMCol, RTL8139State),
+        VMSTATE_UINT64(tally_counters.RxOkPhy, RTL8139State),
+        VMSTATE_UINT64(tally_counters.RxOkBrd, RTL8139State),
+        VMSTATE_UINT32_V(tally_counters.RxOkMul, RTL8139State, 5),
+        VMSTATE_UINT16(tally_counters.TxAbt, RTL8139State),
+        VMSTATE_UINT16(tally_counters.TxUndrn, RTL8139State),
 
         VMSTATE_UINT32_V(cplus_enabled, RTL8139State, 4),
         VMSTATE_END_OF_LIST()
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again)
  2016-06-20 17:53 [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again) David Vrabel
@ 2016-06-21  1:44 ` Jason Wang
  2016-06-21  7:35   ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2016-06-21  1:44 UTC (permalink / raw)
  To: David Vrabel, qemu-devel



On 2016年06月21日 01:53, David Vrabel wrote:
> Commit 9d29cdeaaca3a0383af764000b71492c4fc67c6e (rtl8139: port
> TallyCounters to vmstate) introduced in incompatibility in the v4
> format as it omitted the RxOkMul counter.
>
> There are presumably no users that were impacted by the v4 to v4'
> breakage, so increase the save version to 5 and re-add the field,
> keeping backward compatibility with v4'.
>
> We can't have a field conditional on the section version in
> vmstate_tally_counters since this version checked would not be the
> section version (but the version defined in this structure).  So, move
> all the fields into the main state structure.
>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>

Migration to old version is important for the user and this patch seems 
to break this. How about something like:

- introduce a subsection for RXOKMul
- only migrate it for new version (e.g >= 2.7)

Thanks

> ---
> Cc: Jason Wang <jasowang@redhat.com>
> ---
>   hw/net/rtl8139.c | 40 ++++++++++++++--------------------------
>   1 file changed, 14 insertions(+), 26 deletions(-)
>
> diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
> index 562c1fd..8ccd1d3 100644
> --- a/hw/net/rtl8139.c
> +++ b/hw/net/rtl8139.c
> @@ -1352,29 +1352,6 @@ static void RTL8139TallyCounters_dma_write(RTL8139State *s, dma_addr_t tc_addr)
>       pci_dma_write(d, tc_addr + 62,    (uint8_t *)&val16, 2);
>   }
>   
> -/* Loads values of tally counters from VM state file */
> -
> -static const VMStateDescription vmstate_tally_counters = {
> -    .name = "tally_counters",
> -    .version_id = 1,
> -    .minimum_version_id = 1,
> -    .fields = (VMStateField[]) {
> -        VMSTATE_UINT64(TxOk, RTL8139TallyCounters),
> -        VMSTATE_UINT64(RxOk, RTL8139TallyCounters),
> -        VMSTATE_UINT64(TxERR, RTL8139TallyCounters),
> -        VMSTATE_UINT32(RxERR, RTL8139TallyCounters),
> -        VMSTATE_UINT16(MissPkt, RTL8139TallyCounters),
> -        VMSTATE_UINT16(FAE, RTL8139TallyCounters),
> -        VMSTATE_UINT32(Tx1Col, RTL8139TallyCounters),
> -        VMSTATE_UINT32(TxMCol, RTL8139TallyCounters),
> -        VMSTATE_UINT64(RxOkPhy, RTL8139TallyCounters),
> -        VMSTATE_UINT64(RxOkBrd, RTL8139TallyCounters),
> -        VMSTATE_UINT16(TxAbt, RTL8139TallyCounters),
> -        VMSTATE_UINT16(TxUndrn, RTL8139TallyCounters),
> -        VMSTATE_END_OF_LIST()
> -    }
> -};
> -
>   static void rtl8139_ChipCmd_write(RTL8139State *s, uint32_t val)
>   {
>       DeviceState *d = DEVICE(s);
> @@ -3222,7 +3199,7 @@ static void rtl8139_pre_save(void *opaque)
>   
>   static const VMStateDescription vmstate_rtl8139 = {
>       .name = "rtl8139",
> -    .version_id = 4,
> +    .version_id = 5,
>       .minimum_version_id = 3,
>       .post_load = rtl8139_post_load,
>       .pre_save  = rtl8139_pre_save,
> @@ -3293,8 +3270,19 @@ static const VMStateDescription vmstate_rtl8139 = {
>           VMSTATE_UINT32(TimerInt, RTL8139State),
>           VMSTATE_INT64(TCTR_base, RTL8139State),
>   
> -        VMSTATE_STRUCT(tally_counters, RTL8139State, 0,
> -                       vmstate_tally_counters, RTL8139TallyCounters),
> +        VMSTATE_UINT64(tally_counters.TxOk, RTL8139State),
> +        VMSTATE_UINT64(tally_counters.RxOk, RTL8139State),
> +        VMSTATE_UINT64(tally_counters.TxERR, RTL8139State),
> +        VMSTATE_UINT32(tally_counters.RxERR, RTL8139State),
> +        VMSTATE_UINT16(tally_counters.MissPkt, RTL8139State),
> +        VMSTATE_UINT16(tally_counters.FAE, RTL8139State),
> +        VMSTATE_UINT32(tally_counters.Tx1Col, RTL8139State),
> +        VMSTATE_UINT32(tally_counters.TxMCol, RTL8139State),
> +        VMSTATE_UINT64(tally_counters.RxOkPhy, RTL8139State),
> +        VMSTATE_UINT64(tally_counters.RxOkBrd, RTL8139State),
> +        VMSTATE_UINT32_V(tally_counters.RxOkMul, RTL8139State, 5),
> +        VMSTATE_UINT16(tally_counters.TxAbt, RTL8139State),
> +        VMSTATE_UINT16(tally_counters.TxUndrn, RTL8139State),
>   
>           VMSTATE_UINT32_V(cplus_enabled, RTL8139State, 4),
>           VMSTATE_END_OF_LIST()

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again)
  2016-06-21  1:44 ` Jason Wang
@ 2016-06-21  7:35   ` Paolo Bonzini
  2016-06-21  9:36     ` David Vrabel
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2016-06-21  7:35 UTC (permalink / raw)
  To: Jason Wang, David Vrabel, qemu-devel



On 21/06/2016 03:44, Jason Wang wrote:
> 
> 
> On 2016年06月21日 01:53, David Vrabel wrote:
>> Commit 9d29cdeaaca3a0383af764000b71492c4fc67c6e (rtl8139: port
>> TallyCounters to vmstate) introduced in incompatibility in the v4
>> format as it omitted the RxOkMul counter.
>>
>> There are presumably no users that were impacted by the v4 to v4'
>> breakage, so increase the save version to 5 and re-add the field,
>> keeping backward compatibility with v4'.
>>
>> We can't have a field conditional on the section version in
>> vmstate_tally_counters since this version checked would not be the
>> section version (but the version defined in this structure).  So, move
>> all the fields into the main state structure.
>>
>> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> 
> Migration to old version is important for the user and this patch seems
> to break this. How about something like:
> 
> - introduce a subsection for RXOKMul
> - only migrate it for new version (e.g >= 2.7)

Introducing a subsection is not really necessary if the value is going
to be migrated always, and upstream generally does not have "migrate it
only in some version" checks.  This is left for downstreams to implement
if they care.  We just don't have the manpower to ensure that migration
to older versions works between all releases of QEMU.

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again)
  2016-06-21  7:35   ` Paolo Bonzini
@ 2016-06-21  9:36     ` David Vrabel
  2016-06-21 10:11       ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: David Vrabel @ 2016-06-21  9:36 UTC (permalink / raw)
  To: Paolo Bonzini, Jason Wang, qemu-devel

On 21/06/16 08:35, Paolo Bonzini wrote:
> 
> 
> On 21/06/2016 03:44, Jason Wang wrote:
>>
>>
>> On 2016年06月21日 01:53, David Vrabel wrote:
>>> Commit 9d29cdeaaca3a0383af764000b71492c4fc67c6e (rtl8139: port
>>> TallyCounters to vmstate) introduced in incompatibility in the v4
>>> format as it omitted the RxOkMul counter.
>>>
>>> There are presumably no users that were impacted by the v4 to v4'
>>> breakage, so increase the save version to 5 and re-add the field,
>>> keeping backward compatibility with v4'.
>>>
>>> We can't have a field conditional on the section version in
>>> vmstate_tally_counters since this version checked would not be the
>>> section version (but the version defined in this structure).  So, move
>>> all the fields into the main state structure.
>>>
>>> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
>>
>> Migration to old version is important for the user and this patch seems
>> to break this. How about something like:
>>
>> - introduce a subsection for RXOKMul
>> - only migrate it for new version (e.g >= 2.7)

I don't see how this can work with snapshots where the QEMU version that
is going to restore the snapshot is not known in advance.

> Introducing a subsection is not really necessary if the value is going
> to be migrated always, and upstream generally does not have "migrate it
> only in some version" checks.  This is left for downstreams to implement
> if they care.  We just don't have the manpower to ensure that migration
> to older versions works between all releases of QEMU.

So is this patch acceptable as is?

David

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again)
  2016-06-21  9:36     ` David Vrabel
@ 2016-06-21 10:11       ` Paolo Bonzini
  2016-06-22  5:51         ` Jason Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2016-06-21 10:11 UTC (permalink / raw)
  To: David Vrabel, Jason Wang, qemu-devel



On 21/06/2016 11:36, David Vrabel wrote:
> On 21/06/16 08:35, Paolo Bonzini wrote:
>>
>>
>> On 21/06/2016 03:44, Jason Wang wrote:
>>>
>>>
>>> On 2016年06月21日 01:53, David Vrabel wrote:
>>>> Commit 9d29cdeaaca3a0383af764000b71492c4fc67c6e (rtl8139: port
>>>> TallyCounters to vmstate) introduced in incompatibility in the v4
>>>> format as it omitted the RxOkMul counter.
>>>>
>>>> There are presumably no users that were impacted by the v4 to v4'
>>>> breakage, so increase the save version to 5 and re-add the field,
>>>> keeping backward compatibility with v4'.
>>>>
>>>> We can't have a field conditional on the section version in
>>>> vmstate_tally_counters since this version checked would not be the
>>>> section version (but the version defined in this structure).  So, move
>>>> all the fields into the main state structure.
>>>>
>>>> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
>>>
>>> Migration to old version is important for the user and this patch seems
>>> to break this. How about something like:
>>>
>>> - introduce a subsection for RXOKMul
>>> - only migrate it for new version (e.g >= 2.7)
> 
> I don't see how this can work with snapshots where the QEMU version that
> is going to restore the snapshot is not known in advance.

By "new version" he meant the versioned machine types, e.g.
pc-i440fx-2.6 and older wouldn't migrate it.

>> Introducing a subsection is not really necessary if the value is going
>> to be migrated always, and upstream generally does not have "migrate it
>> only in some version" checks.  This is left for downstreams to implement
>> if they care.  We just don't have the manpower to ensure that migration
>> to older versions works between all releases of QEMU.
> 
> So is this patch acceptable as is?

I think it is.

Paolo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again)
  2016-06-21 10:11       ` Paolo Bonzini
@ 2016-06-22  5:51         ` Jason Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2016-06-22  5:51 UTC (permalink / raw)
  To: Paolo Bonzini, David Vrabel, qemu-devel



On 2016年06月21日 18:11, Paolo Bonzini wrote:
> On 21/06/2016 11:36, David Vrabel wrote:
>> >On 21/06/16 08:35, Paolo Bonzini wrote:
>>> >>
>>> >>
>>> >>On 21/06/2016 03:44, Jason Wang wrote:
>>>> >>>
>>>> >>>
>>>> >>>On 2016年06月21日 01:53, David Vrabel wrote:
>>>>> >>>>Commit 9d29cdeaaca3a0383af764000b71492c4fc67c6e (rtl8139: port
>>>>> >>>>TallyCounters to vmstate) introduced in incompatibility in the v4
>>>>> >>>>format as it omitted the RxOkMul counter.
>>>>> >>>>
>>>>> >>>>There are presumably no users that were impacted by the v4 to v4'
>>>>> >>>>breakage, so increase the save version to 5 and re-add the field,
>>>>> >>>>keeping backward compatibility with v4'.
>>>>> >>>>
>>>>> >>>>We can't have a field conditional on the section version in
>>>>> >>>>vmstate_tally_counters since this version checked would not be the
>>>>> >>>>section version (but the version defined in this structure).  So, move
>>>>> >>>>all the fields into the main state structure.
>>>>> >>>>
>>>>> >>>>Signed-off-by: David Vrabel<david.vrabel@citrix.com>
>>>> >>>
>>>> >>>Migration to old version is important for the user and this patch seems
>>>> >>>to break this. How about something like:
>>>> >>>
>>>> >>>- introduce a subsection for RXOKMul
>>>> >>>- only migrate it for new version (e.g >= 2.7)
>> >
>> >I don't see how this can work with snapshots where the QEMU version that
>> >is going to restore the snapshot is not known in advance.
> By "new version" he meant the versioned machine types, e.g.
> pc-i440fx-2.6 and older wouldn't migrate it.
>
>>> >>Introducing a subsection is not really necessary if the value is going
>>> >>to be migrated always, and upstream generally does not have "migrate it
>>> >>only in some version" checks.  This is left for downstreams to implement
>>> >>if they care.  We just don't have the manpower to ensure that migration
>>> >>to older versions works between all releases of QEMU.
>> >
>> >So is this patch acceptable as is?
> I think it is.
>
> Paolo

Applied to -net.

Thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-22  5:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20 17:53 [Qemu-devel] [PATCHv2] rtl8139: save/load RxMulOk counter (again) David Vrabel
2016-06-21  1:44 ` Jason Wang
2016-06-21  7:35   ` Paolo Bonzini
2016-06-21  9:36     ` David Vrabel
2016-06-21 10:11       ` Paolo Bonzini
2016-06-22  5:51         ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.