vmstate: error hint for failed equal checks
PATCH 1/1 vmstate: error hint for failed equal checks
In some cases a failing VMSTATE_*_EQUAL does not mean we detected a bug, but it's actually the best we can do. Especially in these cases a verbose error message is required.
Let's introduce infrastructure for specifying a error hint to be used if equal check fails. Let's do this by adding a parameter to the _EQUAL macros called _err_hint. Also change all current users to pass NULL as last parameter so nothing changes for them.
---
I have already had an RFC series prior to this patch trying to do the
same: https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg01413.html
We decided with the migration maintainers to rather add an parameter than introduce a load of new macros. All the other feedback from there was incorporated too. The RFC also contains the direct motivation for this change, which is vmstate conversion of virtio-ccw, and is intended to happen on top of this.
--- hw/display/virtio-gpu.c | 2 +- hw/nvram/eeprom93xx.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pcie_aer.c | 2 +- include/migration/vmstate.h | 51 +++++++++++++++++++++++++++++++-------------- migration/vmstate-types.c | 15 +++++++++++++ 6 files changed, 54 insertions(+), 20 deletions(-)
hw/display/virtio-gpu.c +1 -1
@@ -962,7 +962,7 @@ static const VMStateDescription vmstate_virtio_gpu_scanouts = { .version_id = 1, .fields = (VMStateField []) { VMSTATE_INT32(enable, struct VirtIOGPU), - VMSTATE_UINT32_EQUAL(conf.max_outputs, struct VirtIOGPU), + VMSTATE_UINT32_EQUAL(conf.max_outputs, struct VirtIOGPU, NULL), VMSTATE_STRUCT_VARRAY_UINT32(scanout, struct VirtIOGPU, conf.max_outputs, 1, vmstate_virtio_gpu_scanout,
hw/nvram/eeprom93xx.c +1 -1
@@ -143,7 +143,7 @@ static const VMStateDescription vmstate_eeprom = {VMSTATE_UINT8 (addrbits, eeprom_t),VMSTATE_UINT16_HACK_TEST (size, eeprom_t, is_old_eeprom_version),VMSTATE_UNUSED_TEST (is_old_eeprom_version,1 ), -VMSTATE_UINT16_EQUAL_V (size, eeprom_t,EEPROM_VERSION ), +VMSTATE_UINT16_EQUAL_V (size, eeprom_t,EEPROM_VERSION ,NULL ),VMSTATE_UINT16 (data, eeprom_t),VMSTATE_VARRAY_UINT16_UNSAFE (contents, eeprom_t, size,0 , vmstate_info_uint16, uint16_t),
hw/pci/pci.c +1 -1
@@ -74,7 +74,7 @@ static const VMStateDescription vmstate_pcibus = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (nirq, PCIBus), +VMSTATE_INT32_EQUAL (nirq, PCIBus,NULL ),VMSTATE_VARRAY_INT32 (irq_count, PCIBus, nirq,0 , vmstate_info_int32, int32_t),
hw/pci/pcie_aer.c +1 -1
@@ -813,7 +813,7 @@ const VMStateDescription vmstate_pcie_aer_log = { .minimum_version_id = 1, .fields = (VMStateField []) {VMSTATE_UINT16 (log_num, PCIEAERLog), -VMSTATE_UINT16_EQUAL (log_max, PCIEAERLog), +VMSTATE_UINT16_EQUAL (log_max, PCIEAERLog,NULL ),VMSTATE_VALIDATE ("log_num <= log_max" , pcie_aer_state_log_num_valid),VMSTATE_STRUCT_VARRAY_POINTER_UINT16 (log, PCIEAERLog, log_num, vmstate_pcie_aer_err, PCIEAERErr),
include/migration/vmstate.h +35 -16
76 lines not on this page · raw message
migration/vmstate-types.c +15 -0
@@ -126,6 +126,9 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%" PRIx32" != %" PRIx32, *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }
@@ -267,6 +270,9 @@ static int get_uint32_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%" PRIx32" != %" PRIx32, *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }
@@ -341,6 +347,9 @@ static int get_uint64_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%" PRIx64" != %" PRIx64, *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }
@@ -364,6 +373,9 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%x != %x" , *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }
@@ -387,6 +399,9 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%x != %x" , *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }
Signature · 1 line
2.11.2
Quoted 10 lines · Halil Pasic
In some cases a failing VMSTATE_*_EQUAL does not mean we detected a bug, but it's actually the best we can do. Especially in these cases a verbose error message is required.
Let's introduce infrastructure for specifying a error hint to be used if equal check fails. Let's do this by adding a parameter to the
_EQUALmacros called_err_hint. Also change all current users to pass NULL as last parameter so nothing changes for them.Signed-off-by Halil Pasic <[email protected]>
Thanks.
Quoted 10 lines · Halil Pasic
In some cases a failing VMSTATE_*_EQUAL does not mean we detected a bug, but it's actually the best we can do. Especially in these cases a verbose error message is required.
Let's introduce infrastructure for specifying a error hint to be used if equal check fails. Let's do this by adding a parameter to the
_EQUALmacros called_err_hint. Also change all current users to pass NULL as last parameter so nothing changes for them.Signed-off-by Halil Pasic <[email protected]>
Hi
I have had to add this to your patch to make it compile.
Later, Juan.
Quoted 1 line
From
74573a4190af8a357054493d5451e2b51c553498Mon Sep 17 00:00:00 2001
From: Juan Quintela <[email protected]>
Date: Wed, 28 Jun 2017 10:19:25 +0200
Subject: [PATCH] fix missing Macro applications
--- hw/block/fdc.c | 2 +- hw/display/qxl.c | 4 ++-- hw/display/vga.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/ide/ahci.c | 2 +- hw/input/vmmouse.c | 2 +- hw/intc/openpic.c | 2 +- hw/intc/xics.c | 2 +- hw/misc/max111x.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/ppc/spapr_pci.c | 4 ++-- hw/ppc/spapr_vio.c | 4 ++-- hw/usb/hcd-uhci.c | 2 +- target/ppc/machine.c | 8 ++++---- 14 files changed, 20 insertions(+), 20 deletions(-)
hw/block/fdc.c +1 -1
@@ -1217,7 +1217,7 @@ static const VMStateDescription vmstate_fdc = {VMSTATE_UINT8 (config, FDCtrl),VMSTATE_UINT8 (lock, FDCtrl),VMSTATE_UINT8 (pwrd, FDCtrl), -VMSTATE_UINT8_EQUAL (num_floppies, FDCtrl), +VMSTATE_UINT8_EQUAL (num_floppies, FDCtrl,NULL ),VMSTATE_STRUCT_ARRAY (drives, FDCtrl,MAX_FD ,1 , vmstate_fdrive, FDrive),VMSTATE_END_OF_LIST ()
hw/display/qxl.c +2 -2
@@ -2373,12 +2373,12 @@ static VMStateDescription qxl_vmstate = {VMSTATE_UINT32 (last_release_offset, PCIQXLDevice),VMSTATE_UINT32 (mode, PCIQXLDevice),VMSTATE_UINT32 (ssd.unique, PCIQXLDevice), -VMSTATE_INT32_EQUAL (num_memslots, PCIQXLDevice), +VMSTATE_INT32_EQUAL (num_memslots, PCIQXLDevice,NULL ),VMSTATE_STRUCT_ARRAY (guest_slots, PCIQXLDevice,NUM_MEMSLOTS ,0 , qxl_memslot, struct guest_slots),VMSTATE_STRUCT (guest_primary.surface, PCIQXLDevice,0 , qxl_surface, QXLSurfaceCreate), -VMSTATE_INT32_EQUAL (ssd.num_surfaces, PCIQXLDevice), +VMSTATE_INT32_EQUAL (ssd.num_surfaces, PCIQXLDevice,NULL ),VMSTATE_VARRAY_INT32 (guest_surfaces.cmds, PCIQXLDevice, ssd.num_surfaces,0 , vmstate_info_uint64, uint64_t),
hw/display/vga.c +1 -1
@@ -2099,7 +2099,7 @@ const VMStateDescription vmstate_vga_common = {VMSTATE_BUFFER (palette, VGACommonState),VMSTATE_INT32 (bank_offset, VGACommonState), -VMSTATE_UINT8_EQUAL (is_vbe_vmstate, VGACommonState), +VMSTATE_UINT8_EQUAL (is_vbe_vmstate, VGACommonState,NULL ),VMSTATE_UINT16 (vbe_index, VGACommonState),VMSTATE_UINT16_ARRAY (vbe_regs, VGACommonState,VBE_DISPI_INDEX_NB ), VMSTATE_UINT32(vbe_start_addr, VGACommonState),
hw/display/vmware_vga.c +1 -1
@@ -1192,7 +1192,7 @@ static const VMStateDescription vmstate_vmware_vga_internal = { .minimum_version_id = 0, .post_load = vmsvga_post_load, .fields = (VMStateField []) { - VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s), + VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s, NULL), VMSTATE_INT32(enable, struct vmsvga_state_s), VMSTATE_INT32(config, struct vmsvga_state_s), VMSTATE_INT32(cursor.id, struct vmsvga_state_s),
hw/ide/ahci.c +1 -1
@@ -1669,7 +1669,7 @@ const VMStateDescription vmstate_ahci = { VMSTATE_UINT32(control_regs.impl, AHCIState), VMSTATE_UINT32(control_regs.version, AHCIState), VMSTATE_UINT32(idp_index, AHCIState), - VMSTATE_INT32_EQUAL(ports, AHCIState), + VMSTATE_INT32_EQUAL(ports, AHCIState, NULL),VMSTATE_END_OF_LIST () }, };
hw/input/vmmouse.c +1 -1
@@ -243,7 +243,7 @@ static const VMStateDescription vmstate_vmmouse = { .minimum_version_id = 0, .post_load = vmmouse_post_load, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (queue_size, VMMouseState), +VMSTATE_INT32_EQUAL (queue_size, VMMouseState,NULL ),VMSTATE_UINT32_ARRAY (queue, VMMouseState,VMMOUSE_QUEUE_SIZE ),VMSTATE_UINT16 (nb_queue, VMMouseState),VMSTATE_UINT16 (status, VMMouseState),
hw/intc/openpic.c +1 -1
@@ -1499,7 +1499,7 @@ static const VMStateDescription vmstate_openpic = {VMSTATE_UINT32 (max_irq, OpenPICState),VMSTATE_STRUCT_VARRAY_UINT32 (src, OpenPICState, max_irq,0 , vmstate_openpic_irqsource, IRQSource), -VMSTATE_UINT32_EQUAL (nb_cpus, OpenPICState), +VMSTATE_UINT32_EQUAL (nb_cpus, OpenPICState,NULL ),VMSTATE_STRUCT_VARRAY_UINT32 (dst, OpenPICState, nb_cpus,0 , vmstate_openpic_irqdest, IRQDest), VMSTATE_STRUCT_ARRAY(timers, OpenPICState, OPENPIC_MAX_TMR, 0,
hw/intc/xics.c +1 -1
@@ -574,7 +574,7 @@ static const VMStateDescription vmstate_ics_simple = { .post_load = ics_simple_dispatch_post_load, .fields = (VMStateField []) {/* Sanity check */ -VMSTATE_UINT32_EQUAL (nr_irqs, ICSState), +VMSTATE_UINT32_EQUAL (nr_irqs, ICSState,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_UINT32(irqs, ICSState, nr_irqs, vmstate_ics_simple_irq,
hw/misc/max111x.c +1 -1
@@ -116,7 +116,7 @@ static const VMStateDescription vmstate_max111x = {VMSTATE_UINT8 (tb1, MAX111xState),VMSTATE_UINT8 (rb2, MAX111xState),VMSTATE_UINT8 (rb3, MAX111xState), -VMSTATE_INT32_EQUAL (inputs, MAX111xState), +VMSTATE_INT32_EQUAL (inputs, MAX111xState,NULL ),VMSTATE_INT32 (com, MAX111xState),VMSTATE_ARRAY_INT32_UNSAFE (input, MAX111xState, inputs, vmstate_info_uint8, uint8_t),
hw/ppc/spapr_iommu.c +1 -1
@@ -231,7 +231,7 @@ static const VMStateDescription vmstate_spapr_tce_table = { .post_load = spapr_tce_table_post_load, .fields = (VMStateField []) {/* Sanity check */ -VMSTATE_UINT32_EQUAL (liobn, sPAPRTCETable), +VMSTATE_UINT32_EQUAL (liobn, sPAPRTCETable,NULL ),/* IOMMU state */ VMSTATE_UINT32 (mig_nb_table, sPAPRTCETable),
hw/ppc/spapr_pci.c +2 -2
@@ -1848,7 +1848,7 @@ static const VMStateDescription vmstate_spapr_pci_lsi = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { - VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi), + VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi, NULL),VMSTATE_END_OF_LIST () },
@@ -1936,7 +1936,7 @@ static const VMStateDescription vmstate_spapr_pci = { .pre_save = spapr_pci_pre_save, .post_load = spapr_pci_post_load, .fields = (VMStateField []) { -VMSTATE_UINT64_EQUAL (buid, sPAPRPHBState), +VMSTATE_UINT64_EQUAL (buid, sPAPRPHBState,NULL ),VMSTATE_UINT32_TEST (mig_liobn, sPAPRPHBState, pre_2_8_migration),VMSTATE_UINT64_TEST (mig_mem_win_addr, sPAPRPHBState, pre_2_8_migration),VMSTATE_UINT64_TEST (mig_mem_win_size, sPAPRPHBState, pre_2_8_migration),
hw/ppc/spapr_vio.c +2 -2
@@ -557,8 +557,8 @@ const VMStateDescription vmstate_spapr_vio = { .minimum_version_id = 1, .fields = (VMStateField []) {/* Sanity check */ -VMSTATE_UINT32_EQUAL (reg, VIOsPAPRDevice), -VMSTATE_UINT32_EQUAL (irq, VIOsPAPRDevice), +VMSTATE_UINT32_EQUAL (reg, VIOsPAPRDevice,NULL ), +VMSTATE_UINT32_EQUAL (irq, VIOsPAPRDevice,NULL ),/* General VIO device state */ VMSTATE_UINT64 (signal_state, VIOsPAPRDevice),
hw/usb/hcd-uhci.c +1 -1
@@ -415,7 +415,7 @@ static const VMStateDescription vmstate_uhci = { .post_load = uhci_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (dev, UHCIState), -VMSTATE_UINT8_EQUAL (num_ports_vmstate, UHCIState), +VMSTATE_UINT8_EQUAL (num_ports_vmstate, UHCIState,NULL ),VMSTATE_STRUCT_ARRAY (ports, UHCIState,NB_PORTS ,1 , vmstate_uhci_port, UHCIPort),VMSTATE_UINT16 (cmd, UHCIState),
target/ppc/machine.c +4 -4
@@ -419,7 +419,7 @@ static const VMStateDescription vmstate_slb = { .needed = slb_needed, .post_load = slb_post_load, .fields = (VMStateField[]) { -VMSTATE_INT32_EQUAL (env.slb_nr, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.slb_nr, PowerPCCPU,NULL ),VMSTATE_SLB_ARRAY (env.slb, PowerPCCPU,MAX_SLB_ENTRIES ),VMSTATE_END_OF_LIST () }
@@ -452,7 +452,7 @@ static const VMStateDescription vmstate_tlb6xx = { .minimum_version_id = 1, .needed = tlb6xx_needed, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlb6, PowerPCCPU, env.nb_tlb, vmstate_tlb6xx_entry,
@@ -510,7 +510,7 @@ static const VMStateDescription vmstate_tlbemb = { .minimum_version_id = 1, .needed = tlbemb_needed, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbe, PowerPCCPU, env.nb_tlb, vmstate_tlbemb_entry,
@@ -551,7 +551,7 @@ static const VMStateDescription vmstate_tlbmas = { .minimum_version_id = 1, .needed = tlbmas_needed, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbm, PowerPCCPU, env.nb_tlb, vmstate_tlbmas_entry,
Signature · 1 line
2.9.4
Quoted 207 lines
---
I have already had an RFC series prior to this patch trying to do the
same: https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg01413.html
We decided with the migration maintainers to rather add an parameter than introduce a load of new macros. All the other feedback from there was incorporated too. The RFC also contains the direct motivation for this change, which is vmstate conversion of virtio-ccw, and is intended to happen on top of this.--- hw/display/virtio-gpu.c | 2 +- hw/nvram/eeprom93xx.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pcie_aer.c | 2 +- include/migration/vmstate.h | 51 +++++++++++++++++++++++++++++++-------------- migration/vmstate-types.c | 15 +++++++++++++ 6 files changed, 54 insertions(+), 20 deletions(-)hw/display/virtio-gpu.c +1
-1@@ -962,7 +962,7 @@ static const VMStateDescription vmstate_virtio_gpu_scanouts = { .version_id = 1, .fields = (VMStateField []) { VMSTATE_INT32(enable, struct VirtIOGPU), - VMSTATE_UINT32_EQUAL(conf.max_outputs, struct VirtIOGPU), + VMSTATE_UINT32_EQUAL(conf.max_outputs, struct VirtIOGPU, NULL), VMSTATE_STRUCT_VARRAY_UINT32(scanout, struct VirtIOGPU, conf.max_outputs, 1, vmstate_virtio_gpu_scanout,hw/nvram/eeprom93xx.c +1
-1@@ -143,7 +143,7 @@ static const VMStateDescription vmstate_eeprom = {VMSTATE_UINT8 (addrbits, eeprom_t),VMSTATE_UINT16_HACK_TEST (size, eeprom_t, is_old_eeprom_version),VMSTATE_UNUSED_TEST (is_old_eeprom_version,1 ), -VMSTATE_UINT16_EQUAL_V (size, eeprom_t,EEPROM_VERSION ), +VMSTATE_UINT16_EQUAL_V (size, eeprom_t,EEPROM_VERSION ,NULL ),VMSTATE_UINT16 (data, eeprom_t),VMSTATE_VARRAY_UINT16_UNSAFE (contents, eeprom_t, size,0 , vmstate_info_uint16, uint16_t),hw/pci/pci.c +1
-1@@ -74,7 +74,7 @@ static const VMStateDescription vmstate_pcibus = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (nirq, PCIBus), +VMSTATE_INT32_EQUAL (nirq, PCIBus,NULL ),VMSTATE_VARRAY_INT32 (irq_count, PCIBus, nirq,0 , vmstate_info_int32, int32_t),hw/pci/pcie_aer.c +1
-1@@ -813,7 +813,7 @@ const VMStateDescription vmstate_pcie_aer_log = { .minimum_version_id = 1, .fields = (VMStateField []) {VMSTATE_UINT16 (log_num, PCIEAERLog), -VMSTATE_UINT16_EQUAL (log_max, PCIEAERLog), +VMSTATE_UINT16_EQUAL (log_max, PCIEAERLog,NULL ),VMSTATE_VALIDATE ("log_num <= log_max" , pcie_aer_state_log_num_valid),VMSTATE_STRUCT_VARRAY_POINTER_UINT16 (log, PCIEAERLog, log_num, vmstate_pcie_aer_err, PCIEAERErr),include/migration/vmstate.h +35
-16@@ -155,6 +155,7 @@ typedef enum {struct VMStateField {const char *name; +const char *err_hint;size_t offset;size_t size;size_t start;@@ -256,6 +257,18 @@ extern const VMStateInfo vmstate_info_qtailq; .offset = vmstate_offset_value(_state, _field, _type), \ } +#define VMSTATE_SINGLE_FULL (_field, _state, _test, _version, _info, \ + _type, _err_hint) { \ + .name = (stringify(_field)), \ + .err_hint = (_err_hint), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size = sizeof(_type), \ + .info = &(_info), \ + .flags = VMS_SINGLE, \ + .offset = vmstate_offset_value(_state, _field, _type), \ +} +/* Validate state using a boolean predicate. */ #define VMSTATE_VALIDATE (_name, _test) { \ .name = (_name), \@@ -762,29 +775,35 @@ extern const VMStateInfo vmstate_info_qtailq;#define VMSTATE_UINT64 (_f, _s) \ VMSTATE_UINT64_V(_f, _s, 0) -#define VMSTATE_UINT8_EQUAL (_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) +#define VMSTATE_UINT8_EQUAL (_f, _s, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ + vmstate_info_uint8_equal, uint8_t, _err_hint) -#define VMSTATE_UINT16_EQUAL (_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t) +#define VMSTATE_UINT16_EQUAL (_f, _s, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ + vmstate_info_uint16_equal, uint16_t, _err_hint) -#define VMSTATE_UINT16_EQUAL_V (_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t) +#define VMSTATE_UINT16_EQUAL_V (_f, _s, _v, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ + vmstate_info_uint16_equal, uint16_t, _err_hint) -#define VMSTATE_INT32_EQUAL (_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) +#define VMSTATE_INT32_EQUAL (_f, _s, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, 0, \ + vmstate_info_int32_equal, int32_t, _err_hint) -#define VMSTATE_UINT32_EQUAL_V (_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32_equal, uint32_t) +#define VMSTATE_UINT32_EQUAL_V (_f, _s, _v, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ + vmstate_info_uint32_equal, uint32_t, _err_hint) -#define VMSTATE_UINT32_EQUAL (_f, _s) \ - VMSTATE_UINT32_EQUAL_V(_f, _s, 0) +#define VMSTATE_UINT32_EQUAL (_f, _s, _err_hint) \ + VMSTATE_UINT32_EQUAL_V(_f, _s, 0, _err_hint) -#define VMSTATE_UINT64_EQUAL_V (_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64_equal, uint64_t) +#define VMSTATE_UINT64_EQUAL_V (_f, _s, _v, _err_hint) \ + VMSTATE_SINGLE_FULL(_f, _s, 0, _v, \ + vmstate_info_uint64_equal, uint64_t, _err_hint) -#define VMSTATE_UINT64_EQUAL (_f, _s) \ - VMSTATE_UINT64_EQUAL_V(_f, _s, 0) +#define VMSTATE_UINT64_EQUAL (_f, _s, _err_hint) \ + VMSTATE_UINT64_EQUAL_V(_f, _s, 0, _err_hint)#define VMSTATE_INT32_POSITIVE_LE (_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t)migration/vmstate-types.c +15
-0@@ -126,6 +126,9 @@ static int get_int32_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%" PRIx32" != %" PRIx32, *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }@@ -267,6 +270,9 @@ static int get_uint32_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%" PRIx32" != %" PRIx32, *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }@@ -341,6 +347,9 @@ static int get_uint64_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%" PRIx64" != %" PRIx64, *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }@@ -364,6 +373,9 @@ static int get_uint8_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%x != %x" , *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }@@ -387,6 +399,9 @@ static int get_uint16_equal(QEMUFile *f, void *pv, size_t size,return 0 ; }error_report ("%x != %x" , *v, v2); +if (field->err_hint) { +error_printf ("%s\n" , field->err_hint); + }return -EINVAL ; }
Quoted 10 lines · Juan Quintela
Quoted 9 lines · Halil Pasic
In some cases a failing VMSTATE_*_EQUAL does not mean we detected a bug, but it's actually the best we can do. Especially in these cases a verbose error message is required.
Let's introduce infrastructure for specifying a error hint to be used if equal check fails. Let's do this by adding a parameter to the
_EQUALmacros called_err_hint. Also change all current users to pass NULL as last parameter so nothing changes for them.
Quoted 8 lines
Quoted 1 line
Signed-off-by Halil Pasic <[email protected]>Hi
I have had to add this to your patch to make it compile.
Later, Juan.
Oops. Seems I have gone by compiler and missed out some targets. Sorry for that! Many thanks!
Halil
Quoted 252 lines
From
74573a4190af8a357054493d5451e2b51c553498Mon Sep 17 00:00:00 2001
From: Juan Quintela <[email protected]>
Date: Wed, 28 Jun 2017 10:19:25 +0200
Subject: [PATCH] fix missing Macro applicationsSigned-off-by Juan Quintela <[email protected]>--- hw/block/fdc.c | 2 +- hw/display/qxl.c | 4 ++-- hw/display/vga.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/ide/ahci.c | 2 +- hw/input/vmmouse.c | 2 +- hw/intc/openpic.c | 2 +- hw/intc/xics.c | 2 +- hw/misc/max111x.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/ppc/spapr_pci.c | 4 ++-- hw/ppc/spapr_vio.c | 4 ++-- hw/usb/hcd-uhci.c | 2 +- target/ppc/machine.c | 8 ++++---- 14 files changed, 20 insertions(+), 20 deletions(-)hw/block/fdc.c +1
-1@@ -1217,7 +1217,7 @@ static const VMStateDescription vmstate_fdc = {VMSTATE_UINT8 (config, FDCtrl),VMSTATE_UINT8 (lock, FDCtrl),VMSTATE_UINT8 (pwrd, FDCtrl), -VMSTATE_UINT8_EQUAL (num_floppies, FDCtrl), +VMSTATE_UINT8_EQUAL (num_floppies, FDCtrl,NULL ),VMSTATE_STRUCT_ARRAY (drives, FDCtrl,MAX_FD ,1 , vmstate_fdrive, FDrive),VMSTATE_END_OF_LIST ()hw/display/qxl.c +2
-2@@ -2373,12 +2373,12 @@ static VMStateDescription qxl_vmstate = {VMSTATE_UINT32 (last_release_offset, PCIQXLDevice),VMSTATE_UINT32 (mode, PCIQXLDevice),VMSTATE_UINT32 (ssd.unique, PCIQXLDevice), -VMSTATE_INT32_EQUAL (num_memslots, PCIQXLDevice), +VMSTATE_INT32_EQUAL (num_memslots, PCIQXLDevice,NULL ),VMSTATE_STRUCT_ARRAY (guest_slots, PCIQXLDevice,NUM_MEMSLOTS ,0 , qxl_memslot, struct guest_slots),VMSTATE_STRUCT (guest_primary.surface, PCIQXLDevice,0 , qxl_surface, QXLSurfaceCreate), -VMSTATE_INT32_EQUAL (ssd.num_surfaces, PCIQXLDevice), +VMSTATE_INT32_EQUAL (ssd.num_surfaces, PCIQXLDevice,NULL ),VMSTATE_VARRAY_INT32 (guest_surfaces.cmds, PCIQXLDevice, ssd.num_surfaces,0 , vmstate_info_uint64, uint64_t),hw/display/vga.c +1
-1@@ -2099,7 +2099,7 @@ const VMStateDescription vmstate_vga_common = {VMSTATE_BUFFER (palette, VGACommonState),VMSTATE_INT32 (bank_offset, VGACommonState), -VMSTATE_UINT8_EQUAL (is_vbe_vmstate, VGACommonState), +VMSTATE_UINT8_EQUAL (is_vbe_vmstate, VGACommonState,NULL ),VMSTATE_UINT16 (vbe_index, VGACommonState),VMSTATE_UINT16_ARRAY (vbe_regs, VGACommonState,VBE_DISPI_INDEX_NB ), VMSTATE_UINT32(vbe_start_addr, VGACommonState),hw/display/vmware_vga.c +1
-1@@ -1192,7 +1192,7 @@ static const VMStateDescription vmstate_vmware_vga_internal = { .minimum_version_id = 0, .post_load = vmsvga_post_load, .fields = (VMStateField []) { - VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s), + VMSTATE_INT32_EQUAL(new_depth, struct vmsvga_state_s, NULL), VMSTATE_INT32(enable, struct vmsvga_state_s), VMSTATE_INT32(config, struct vmsvga_state_s), VMSTATE_INT32(cursor.id, struct vmsvga_state_s),hw/ide/ahci.c +1
-1@@ -1669,7 +1669,7 @@ const VMStateDescription vmstate_ahci = { VMSTATE_UINT32(control_regs.impl, AHCIState), VMSTATE_UINT32(control_regs.version, AHCIState), VMSTATE_UINT32(idp_index, AHCIState), - VMSTATE_INT32_EQUAL(ports, AHCIState), + VMSTATE_INT32_EQUAL(ports, AHCIState, NULL),VMSTATE_END_OF_LIST () }, };hw/input/vmmouse.c +1
-1@@ -243,7 +243,7 @@ static const VMStateDescription vmstate_vmmouse = { .minimum_version_id = 0, .post_load = vmmouse_post_load, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (queue_size, VMMouseState), +VMSTATE_INT32_EQUAL (queue_size, VMMouseState,NULL ),VMSTATE_UINT32_ARRAY (queue, VMMouseState,VMMOUSE_QUEUE_SIZE ),VMSTATE_UINT16 (nb_queue, VMMouseState),VMSTATE_UINT16 (status, VMMouseState),hw/intc/openpic.c +1
-1@@ -1499,7 +1499,7 @@ static const VMStateDescription vmstate_openpic = {VMSTATE_UINT32 (max_irq, OpenPICState),VMSTATE_STRUCT_VARRAY_UINT32 (src, OpenPICState, max_irq,0 , vmstate_openpic_irqsource, IRQSource), -VMSTATE_UINT32_EQUAL (nb_cpus, OpenPICState), +VMSTATE_UINT32_EQUAL (nb_cpus, OpenPICState,NULL ),VMSTATE_STRUCT_VARRAY_UINT32 (dst, OpenPICState, nb_cpus,0 , vmstate_openpic_irqdest, IRQDest), VMSTATE_STRUCT_ARRAY(timers, OpenPICState, OPENPIC_MAX_TMR, 0,hw/intc/xics.c +1
-1@@ -574,7 +574,7 @@ static const VMStateDescription vmstate_ics_simple = { .post_load = ics_simple_dispatch_post_load, .fields = (VMStateField []) {/* Sanity check */ -VMSTATE_UINT32_EQUAL (nr_irqs, ICSState), +VMSTATE_UINT32_EQUAL (nr_irqs, ICSState,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_UINT32(irqs, ICSState, nr_irqs, vmstate_ics_simple_irq,hw/misc/max111x.c +1
-1@@ -116,7 +116,7 @@ static const VMStateDescription vmstate_max111x = {VMSTATE_UINT8 (tb1, MAX111xState),VMSTATE_UINT8 (rb2, MAX111xState),VMSTATE_UINT8 (rb3, MAX111xState), -VMSTATE_INT32_EQUAL (inputs, MAX111xState), +VMSTATE_INT32_EQUAL (inputs, MAX111xState,NULL ),VMSTATE_INT32 (com, MAX111xState),VMSTATE_ARRAY_INT32_UNSAFE (input, MAX111xState, inputs, vmstate_info_uint8, uint8_t),hw/ppc/spapr_iommu.c +1
-1@@ -231,7 +231,7 @@ static const VMStateDescription vmstate_spapr_tce_table = { .post_load = spapr_tce_table_post_load, .fields = (VMStateField []) {/* Sanity check */ -VMSTATE_UINT32_EQUAL (liobn, sPAPRTCETable), +VMSTATE_UINT32_EQUAL (liobn, sPAPRTCETable,NULL ),/* IOMMU state */ VMSTATE_UINT32 (mig_nb_table, sPAPRTCETable),hw/ppc/spapr_pci.c +2
-2@@ -1848,7 +1848,7 @@ static const VMStateDescription vmstate_spapr_pci_lsi = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { - VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi), + VMSTATE_UINT32_EQUAL(irq, struct spapr_pci_lsi, NULL),VMSTATE_END_OF_LIST () },@@ -1936,7 +1936,7 @@ static const VMStateDescription vmstate_spapr_pci = { .pre_save = spapr_pci_pre_save, .post_load = spapr_pci_post_load, .fields = (VMStateField []) { -VMSTATE_UINT64_EQUAL (buid, sPAPRPHBState), +VMSTATE_UINT64_EQUAL (buid, sPAPRPHBState,NULL ),VMSTATE_UINT32_TEST (mig_liobn, sPAPRPHBState, pre_2_8_migration),VMSTATE_UINT64_TEST (mig_mem_win_addr, sPAPRPHBState, pre_2_8_migration),VMSTATE_UINT64_TEST (mig_mem_win_size, sPAPRPHBState, pre_2_8_migration),hw/ppc/spapr_vio.c +2
-2@@ -557,8 +557,8 @@ const VMStateDescription vmstate_spapr_vio = { .minimum_version_id = 1, .fields = (VMStateField []) {/* Sanity check */ -VMSTATE_UINT32_EQUAL (reg, VIOsPAPRDevice), -VMSTATE_UINT32_EQUAL (irq, VIOsPAPRDevice), +VMSTATE_UINT32_EQUAL (reg, VIOsPAPRDevice,NULL ), +VMSTATE_UINT32_EQUAL (irq, VIOsPAPRDevice,NULL ),/* General VIO device state */ VMSTATE_UINT64 (signal_state, VIOsPAPRDevice),hw/usb/hcd-uhci.c +1
-1@@ -415,7 +415,7 @@ static const VMStateDescription vmstate_uhci = { .post_load = uhci_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (dev, UHCIState), -VMSTATE_UINT8_EQUAL (num_ports_vmstate, UHCIState), +VMSTATE_UINT8_EQUAL (num_ports_vmstate, UHCIState,NULL ),VMSTATE_STRUCT_ARRAY (ports, UHCIState,NB_PORTS ,1 , vmstate_uhci_port, UHCIPort),VMSTATE_UINT16 (cmd, UHCIState),target/ppc/machine.c +4
-4@@ -419,7 +419,7 @@ static const VMStateDescription vmstate_slb = { .needed = slb_needed, .post_load = slb_post_load, .fields = (VMStateField[]) { -VMSTATE_INT32_EQUAL (env.slb_nr, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.slb_nr, PowerPCCPU,NULL ),VMSTATE_SLB_ARRAY (env.slb, PowerPCCPU,MAX_SLB_ENTRIES ),VMSTATE_END_OF_LIST () }@@ -452,7 +452,7 @@ static const VMStateDescription vmstate_tlb6xx = { .minimum_version_id = 1, .needed = tlb6xx_needed, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlb6, PowerPCCPU, env.nb_tlb, vmstate_tlb6xx_entry,@@ -510,7 +510,7 @@ static const VMStateDescription vmstate_tlbemb = { .minimum_version_id = 1, .needed = tlbemb_needed, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbe, PowerPCCPU, env.nb_tlb, vmstate_tlbemb_entry,@@ -551,7 +551,7 @@ static const VMStateDescription vmstate_tlbmas = { .minimum_version_id = 1, .needed = tlbmas_needed, .fields = (VMStateField []) { -VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU), +VMSTATE_INT32_EQUAL (env.nb_tlb, PowerPCCPU,NULL ), VMSTATE_STRUCT_VARRAY_POINTER_INT32(env.tlb.tlbm, PowerPCCPU, env.nb_tlb, vmstate_tlbmas_entry,