qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

migration: Define VMSTATE_INSTANCE_ID_ANY

Define the new macro VMSTATE_INSTANCE_ID_ANY for callers who wants to
auto-generate the vmstate instance ID. Previously it was hard coded
as -1 instead of this macro. It helps to change this default value in
the follow up patches. No functional change.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

authored by

Peter Xu and committed by
Juan Quintela
1df2c9a2 8bba004c

+25 -17
+2 -1
backends/dbus-vmstate.c
··· 412 412 return; 413 413 } 414 414 415 - if (vmstate_register(VMSTATE_IF(self), -1, &dbus_vmstate, self) < 0) { 415 + if (vmstate_register(VMSTATE_IF(self), VMSTATE_INSTANCE_ID_ANY, 416 + &dbus_vmstate, self) < 0) { 416 417 error_setg(errp, "Failed to register vmstate"); 417 418 } 418 419 }
+1 -1
hw/arm/stellaris.c
··· 708 708 memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000); 709 709 memory_region_add_subregion(get_system_memory(), base, &s->iomem); 710 710 ssys_reset(s); 711 - vmstate_register(NULL, -1, &vmstate_stellaris_sys, s); 711 + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_stellaris_sys, s); 712 712 return 0; 713 713 } 714 714
+2 -1
hw/core/qdev.c
··· 879 879 880 880 if (qdev_get_vmsd(dev)) { 881 881 if (vmstate_register_with_alias_id(VMSTATE_IF(dev), 882 - -1, qdev_get_vmsd(dev), dev, 882 + VMSTATE_INSTANCE_ID_ANY, 883 + qdev_get_vmsd(dev), dev, 883 884 dev->instance_id_alias, 884 885 dev->alias_required_for_version, 885 886 &local_err) < 0) {
+1 -1
hw/display/ads7846.c
··· 154 154 155 155 ads7846_int_update(s); 156 156 157 - vmstate_register(NULL, -1, &vmstate_ads7846, s); 157 + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_ads7846, s); 158 158 } 159 159 160 160 static void ads7846_class_init(ObjectClass *klass, void *data)
+1 -1
hw/i2c/core.c
··· 61 61 62 62 bus = I2C_BUS(qbus_create(TYPE_I2C_BUS, parent, name)); 63 63 QLIST_INIT(&bus->current_devs); 64 - vmstate_register(NULL, -1, &vmstate_i2c_bus, bus); 64 + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_i2c_bus, bus); 65 65 return bus; 66 66 } 67 67
+2 -1
hw/input/stellaris_input.c
··· 88 88 } 89 89 s->num_buttons = n; 90 90 qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s); 91 - vmstate_register(NULL, -1, &vmstate_stellaris_gamepad, s); 91 + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, 92 + &vmstate_stellaris_gamepad, s); 92 93 }
+1 -1
hw/intc/apic_common.c
··· 284 284 } 285 285 286 286 if (s->legacy_instance_id) { 287 - instance_id = -1; 287 + instance_id = VMSTATE_INSTANCE_ID_ANY; 288 288 } 289 289 vmstate_register_with_alias_id(NULL, instance_id, &vmstate_apic_common, 290 290 s, -1, 0, NULL);
+2 -1
hw/misc/max111x.c
··· 146 146 s->input[7] = 0x80; 147 147 s->com = 0; 148 148 149 - vmstate_register(VMSTATE_IF(dev), -1, &vmstate_max111x, s); 149 + vmstate_register(VMSTATE_IF(dev), VMSTATE_INSTANCE_ID_ANY, 150 + &vmstate_max111x, s); 150 151 return 0; 151 152 } 152 153
+2 -1
hw/net/eepro100.c
··· 1874 1874 1875 1875 s->vmstate = g_memdup(&vmstate_eepro100, sizeof(vmstate_eepro100)); 1876 1876 s->vmstate->name = qemu_get_queue(s->nic)->model; 1877 - vmstate_register(VMSTATE_IF(&pci_dev->qdev), -1, s->vmstate, s); 1877 + vmstate_register(VMSTATE_IF(&pci_dev->qdev), VMSTATE_INSTANCE_ID_ANY, 1878 + s->vmstate, s); 1878 1879 } 1879 1880 1880 1881 static void eepro100_instance_init(Object *obj)
+1 -1
hw/pci/pci.c
··· 122 122 bus->machine_done.notify = pcibus_machine_done; 123 123 qemu_add_machine_init_done_notifier(&bus->machine_done); 124 124 125 - vmstate_register(NULL, -1, &vmstate_pcibus, bus); 125 + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_pcibus, bus); 126 126 } 127 127 128 128 static void pcie_bus_realize(BusState *qbus, Error **errp)
+1 -1
hw/ppc/spapr.c
··· 2948 2948 * interface, this is a legacy from the sPAPREnvironment structure 2949 2949 * which predated MachineState but had a similar function */ 2950 2950 vmstate_register(NULL, 0, &vmstate_spapr, spapr); 2951 - register_savevm_live("spapr/htab", -1, 1, 2951 + register_savevm_live("spapr/htab", VMSTATE_INSTANCE_ID_ANY, 1, 2952 2952 &savevm_htab_handlers, spapr); 2953 2953 2954 2954 qbus_set_hotplug_handler(sysbus_get_default(), OBJECT(machine),
+1 -1
hw/timer/arm_timer.c
··· 180 180 s->control = TIMER_CTRL_IE; 181 181 182 182 s->timer = ptimer_init(arm_timer_tick, s, PTIMER_POLICY_DEFAULT); 183 - vmstate_register(NULL, -1, &vmstate_arm_timer, s); 183 + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_arm_timer, s); 184 184 return s; 185 185 } 186 186
+2 -1
hw/tpm/tpm_emulator.c
··· 914 914 tpm_emu->cur_locty_number = ~0; 915 915 qemu_mutex_init(&tpm_emu->mutex); 916 916 917 - vmstate_register(NULL, -1, &vmstate_tpm_emulator, obj); 917 + vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, 918 + &vmstate_tpm_emulator, obj); 918 919 } 919 920 920 921 /*
+2
include/migration/vmstate.h
··· 1157 1157 1158 1158 bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque); 1159 1159 1160 + #define VMSTATE_INSTANCE_ID_ANY -1 1161 + 1160 1162 /* Returns: 0 on success, -1 on failure */ 1161 1163 int vmstate_register_with_alias_id(VMStateIf *obj, int instance_id, 1162 1164 const VMStateDescription *vmsd,
+4 -4
migration/savevm.c
··· 775 775 776 776 pstrcat(se->idstr, sizeof(se->idstr), idstr); 777 777 778 - if (instance_id == -1) { 778 + if (instance_id == VMSTATE_INSTANCE_ID_ANY) { 779 779 se->instance_id = calculate_new_instance_id(se->idstr); 780 780 } else { 781 781 se->instance_id = instance_id; ··· 842 842 843 843 se->compat = g_new0(CompatEntry, 1); 844 844 pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name); 845 - se->compat->instance_id = instance_id == -1 ? 845 + se->compat->instance_id = instance_id == VMSTATE_INSTANCE_ID_ANY ? 846 846 calculate_compat_instance_id(vmsd->name) : instance_id; 847 - instance_id = -1; 847 + instance_id = VMSTATE_INSTANCE_ID_ANY; 848 848 } 849 849 } 850 850 pstrcat(se->idstr, sizeof(se->idstr), vmsd->name); 851 851 852 - if (instance_id == -1) { 852 + if (instance_id == VMSTATE_INSTANCE_ID_ANY) { 853 853 se->instance_id = calculate_new_instance_id(se->idstr); 854 854 } else { 855 855 se->instance_id = instance_id;