|
|
ddf19c |
From 2659af9267586fb626f543773bf3f844727e473b Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Peter Xu <peterx@redhat.com>
|
|
|
ddf19c |
Date: Fri, 31 Jan 2020 17:12:55 +0000
|
|
|
ddf19c |
Subject: [PATCH 13/15] migration: Define VMSTATE_INSTANCE_ID_ANY
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Peter Xu <peterx@redhat.com>
|
|
|
ddf19c |
Message-id: <20200131171257.1066593-2-peterx@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 93630
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/3] migration: Define VMSTATE_INSTANCE_ID_ANY
|
|
|
ddf19c |
Bugzilla: 1529231
|
|
|
ddf19c |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Juan Quintela <quintela@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Define the new macro VMSTATE_INSTANCE_ID_ANY for callers who wants to
|
|
|
ddf19c |
auto-generate the vmstate instance ID. Previously it was hard coded
|
|
|
ddf19c |
as -1 instead of this macro. It helps to change this default value in
|
|
|
ddf19c |
the follow up patches. No functional change.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Juan Quintela <quintela@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Juan Quintela <quintela@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 1df2c9a26fcb2fa32d099f8e9adcdae4207872e3)
|
|
|
ddf19c |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Conflicts:
|
|
|
ddf19c |
backends/dbus-vmstate.c
|
|
|
ddf19c |
File deleted
|
|
|
ddf19c |
hw/core/qdev.c
|
|
|
ddf19c |
hw/misc/max111x.c
|
|
|
ddf19c |
hw/net/eepro100.c
|
|
|
ddf19c |
Due to missing commit 3cad405bab ("vmstate: replace
|
|
|
ddf19c |
DeviceState with VMStateIf", 2020-01-06)
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
hw/arm/stellaris.c | 2 +-
|
|
|
ddf19c |
hw/core/qdev.c | 3 ++-
|
|
|
ddf19c |
hw/display/ads7846.c | 2 +-
|
|
|
ddf19c |
hw/i2c/core.c | 2 +-
|
|
|
ddf19c |
hw/input/stellaris_input.c | 3 ++-
|
|
|
ddf19c |
hw/intc/apic_common.c | 2 +-
|
|
|
ddf19c |
hw/misc/max111x.c | 2 +-
|
|
|
ddf19c |
hw/net/eepro100.c | 2 +-
|
|
|
ddf19c |
hw/pci/pci.c | 2 +-
|
|
|
ddf19c |
hw/ppc/spapr.c | 2 +-
|
|
|
ddf19c |
hw/timer/arm_timer.c | 2 +-
|
|
|
ddf19c |
hw/tpm/tpm_emulator.c | 3 ++-
|
|
|
ddf19c |
include/migration/vmstate.h | 2 ++
|
|
|
ddf19c |
migration/savevm.c | 8 ++++----
|
|
|
ddf19c |
14 files changed, 21 insertions(+), 16 deletions(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
|
|
|
ddf19c |
index b198066..bb025e0 100644
|
|
|
ddf19c |
--- a/hw/arm/stellaris.c
|
|
|
ddf19c |
+++ b/hw/arm/stellaris.c
|
|
|
ddf19c |
@@ -708,7 +708,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq,
|
|
|
ddf19c |
memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000);
|
|
|
ddf19c |
memory_region_add_subregion(get_system_memory(), base, &s->iomem);
|
|
|
ddf19c |
ssys_reset(s);
|
|
|
ddf19c |
- vmstate_register(NULL, -1, &vmstate_stellaris_sys, s);
|
|
|
ddf19c |
+ vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_stellaris_sys, s);
|
|
|
ddf19c |
return 0;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
|
|
|
ddf19c |
index cf1ba28..40f6b2b 100644
|
|
|
ddf19c |
--- a/hw/core/qdev.c
|
|
|
ddf19c |
+++ b/hw/core/qdev.c
|
|
|
ddf19c |
@@ -890,7 +890,8 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
|
|
|
ddf19c |
dev->canonical_path = object_get_canonical_path(OBJECT(dev));
|
|
|
ddf19c |
|
|
|
ddf19c |
if (qdev_get_vmsd(dev)) {
|
|
|
ddf19c |
- if (vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
|
|
|
ddf19c |
+ if (vmstate_register_with_alias_id(dev, VMSTATE_INSTANCE_ID_ANY,
|
|
|
ddf19c |
+ qdev_get_vmsd(dev), dev,
|
|
|
ddf19c |
dev->instance_id_alias,
|
|
|
ddf19c |
dev->alias_required_for_version,
|
|
|
ddf19c |
&local_err) < 0) {
|
|
|
ddf19c |
diff --git a/hw/display/ads7846.c b/hw/display/ads7846.c
|
|
|
ddf19c |
index c12272a..9228b40 100644
|
|
|
ddf19c |
--- a/hw/display/ads7846.c
|
|
|
ddf19c |
+++ b/hw/display/ads7846.c
|
|
|
ddf19c |
@@ -154,7 +154,7 @@ static void ads7846_realize(SSISlave *d, Error **errp)
|
|
|
ddf19c |
|
|
|
ddf19c |
ads7846_int_update(s);
|
|
|
ddf19c |
|
|
|
ddf19c |
- vmstate_register(NULL, -1, &vmstate_ads7846, s);
|
|
|
ddf19c |
+ vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_ads7846, s);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
static void ads7846_class_init(ObjectClass *klass, void *data)
|
|
|
ddf19c |
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
|
|
|
ddf19c |
index 92cd489..d770035 100644
|
|
|
ddf19c |
--- a/hw/i2c/core.c
|
|
|
ddf19c |
+++ b/hw/i2c/core.c
|
|
|
ddf19c |
@@ -61,7 +61,7 @@ I2CBus *i2c_init_bus(DeviceState *parent, const char *name)
|
|
|
ddf19c |
|
|
|
ddf19c |
bus = I2C_BUS(qbus_create(TYPE_I2C_BUS, parent, name));
|
|
|
ddf19c |
QLIST_INIT(&bus->current_devs);
|
|
|
ddf19c |
- vmstate_register(NULL, -1, &vmstate_i2c_bus, bus);
|
|
|
ddf19c |
+ vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_i2c_bus, bus);
|
|
|
ddf19c |
return bus;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
|
|
|
ddf19c |
index 59892b0..e6ee5e1 100644
|
|
|
ddf19c |
--- a/hw/input/stellaris_input.c
|
|
|
ddf19c |
+++ b/hw/input/stellaris_input.c
|
|
|
ddf19c |
@@ -88,5 +88,6 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode)
|
|
|
ddf19c |
}
|
|
|
ddf19c |
s->num_buttons = n;
|
|
|
ddf19c |
qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s);
|
|
|
ddf19c |
- vmstate_register(NULL, -1, &vmstate_stellaris_gamepad, s);
|
|
|
ddf19c |
+ vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY,
|
|
|
ddf19c |
+ &vmstate_stellaris_gamepad, s);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
|
|
|
ddf19c |
index 375cb6a..f2c3a7f 100644
|
|
|
ddf19c |
--- a/hw/intc/apic_common.c
|
|
|
ddf19c |
+++ b/hw/intc/apic_common.c
|
|
|
ddf19c |
@@ -284,7 +284,7 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
if (s->legacy_instance_id) {
|
|
|
ddf19c |
- instance_id = -1;
|
|
|
ddf19c |
+ instance_id = VMSTATE_INSTANCE_ID_ANY;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
vmstate_register_with_alias_id(NULL, instance_id, &vmstate_apic_common,
|
|
|
ddf19c |
s, -1, 0, NULL);
|
|
|
ddf19c |
diff --git a/hw/misc/max111x.c b/hw/misc/max111x.c
|
|
|
ddf19c |
index a713149..81ee73e 100644
|
|
|
ddf19c |
--- a/hw/misc/max111x.c
|
|
|
ddf19c |
+++ b/hw/misc/max111x.c
|
|
|
ddf19c |
@@ -146,7 +146,7 @@ static int max111x_init(SSISlave *d, int inputs)
|
|
|
ddf19c |
s->input[7] = 0x80;
|
|
|
ddf19c |
s->com = 0;
|
|
|
ddf19c |
|
|
|
ddf19c |
- vmstate_register(dev, -1, &vmstate_max111x, s);
|
|
|
ddf19c |
+ vmstate_register(dev, VMSTATE_INSTANCE_ID_ANY, &vmstate_max111x, s);
|
|
|
ddf19c |
return 0;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
|
|
|
ddf19c |
index cc2dd8b..39920c6 100644
|
|
|
ddf19c |
--- a/hw/net/eepro100.c
|
|
|
ddf19c |
+++ b/hw/net/eepro100.c
|
|
|
ddf19c |
@@ -1874,7 +1874,7 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp)
|
|
|
ddf19c |
|
|
|
ddf19c |
s->vmstate = g_memdup(&vmstate_eepro100, sizeof(vmstate_eepro100));
|
|
|
ddf19c |
s->vmstate->name = qemu_get_queue(s->nic)->model;
|
|
|
ddf19c |
- vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
|
|
|
ddf19c |
+ vmstate_register(&pci_dev->qdev, VMSTATE_INSTANCE_ID_ANY, s->vmstate, s);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
static void eepro100_instance_init(Object *obj)
|
|
|
ddf19c |
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
|
|
|
ddf19c |
index cbc7a32..fed019d 100644
|
|
|
ddf19c |
--- a/hw/pci/pci.c
|
|
|
ddf19c |
+++ b/hw/pci/pci.c
|
|
|
ddf19c |
@@ -124,7 +124,7 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
|
|
|
ddf19c |
bus->machine_done.notify = pcibus_machine_done;
|
|
|
ddf19c |
qemu_add_machine_init_done_notifier(&bus->machine_done);
|
|
|
ddf19c |
|
|
|
ddf19c |
- vmstate_register(NULL, -1, &vmstate_pcibus, bus);
|
|
|
ddf19c |
+ vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_pcibus, bus);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
static void pcie_bus_realize(BusState *qbus, Error **errp)
|
|
|
ddf19c |
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
|
|
|
ddf19c |
index 8749c72..c12862d 100644
|
|
|
ddf19c |
--- a/hw/ppc/spapr.c
|
|
|
ddf19c |
+++ b/hw/ppc/spapr.c
|
|
|
ddf19c |
@@ -3028,7 +3028,7 @@ static void spapr_machine_init(MachineState *machine)
|
|
|
ddf19c |
* interface, this is a legacy from the sPAPREnvironment structure
|
|
|
ddf19c |
* which predated MachineState but had a similar function */
|
|
|
ddf19c |
vmstate_register(NULL, 0, &vmstate_spapr, spapr);
|
|
|
ddf19c |
- register_savevm_live("spapr/htab", -1, 1,
|
|
|
ddf19c |
+ register_savevm_live("spapr/htab", VMSTATE_INSTANCE_ID_ANY, 1,
|
|
|
ddf19c |
&savevm_htab_handlers, spapr);
|
|
|
ddf19c |
|
|
|
ddf19c |
qbus_set_hotplug_handler(sysbus_get_default(), OBJECT(machine),
|
|
|
ddf19c |
diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
|
|
|
ddf19c |
index af524fa..beaa285 100644
|
|
|
ddf19c |
--- a/hw/timer/arm_timer.c
|
|
|
ddf19c |
+++ b/hw/timer/arm_timer.c
|
|
|
ddf19c |
@@ -180,7 +180,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq)
|
|
|
ddf19c |
s->control = TIMER_CTRL_IE;
|
|
|
ddf19c |
|
|
|
ddf19c |
s->timer = ptimer_init(arm_timer_tick, s, PTIMER_POLICY_DEFAULT);
|
|
|
ddf19c |
- vmstate_register(NULL, -1, &vmstate_arm_timer, s);
|
|
|
ddf19c |
+ vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, &vmstate_arm_timer, s);
|
|
|
ddf19c |
return s;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
|
|
|
ddf19c |
index 22f9113..da7b490 100644
|
|
|
ddf19c |
--- a/hw/tpm/tpm_emulator.c
|
|
|
ddf19c |
+++ b/hw/tpm/tpm_emulator.c
|
|
|
ddf19c |
@@ -914,7 +914,8 @@ static void tpm_emulator_inst_init(Object *obj)
|
|
|
ddf19c |
tpm_emu->cur_locty_number = ~0;
|
|
|
ddf19c |
qemu_mutex_init(&tpm_emu->mutex);
|
|
|
ddf19c |
|
|
|
ddf19c |
- vmstate_register(NULL, -1, &vmstate_tpm_emulator, obj);
|
|
|
ddf19c |
+ vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY,
|
|
|
ddf19c |
+ &vmstate_tpm_emulator, obj);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
/*
|
|
|
ddf19c |
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
|
|
|
ddf19c |
index ac4f46a..883f1cf 100644
|
|
|
ddf19c |
--- a/include/migration/vmstate.h
|
|
|
ddf19c |
+++ b/include/migration/vmstate.h
|
|
|
ddf19c |
@@ -1155,6 +1155,8 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDescription *vmsd,
|
|
|
ddf19c |
|
|
|
ddf19c |
bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque);
|
|
|
ddf19c |
|
|
|
ddf19c |
+#define VMSTATE_INSTANCE_ID_ANY -1
|
|
|
ddf19c |
+
|
|
|
ddf19c |
/* Returns: 0 on success, -1 on failure */
|
|
|
ddf19c |
int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
|
|
|
ddf19c |
const VMStateDescription *vmsd,
|
|
|
ddf19c |
diff --git a/migration/savevm.c b/migration/savevm.c
|
|
|
ddf19c |
index a71b930..e2e8e0a 100644
|
|
|
ddf19c |
--- a/migration/savevm.c
|
|
|
ddf19c |
+++ b/migration/savevm.c
|
|
|
ddf19c |
@@ -750,7 +750,7 @@ int register_savevm_live(const char *idstr,
|
|
|
ddf19c |
|
|
|
ddf19c |
pstrcat(se->idstr, sizeof(se->idstr), idstr);
|
|
|
ddf19c |
|
|
|
ddf19c |
- if (instance_id == -1) {
|
|
|
ddf19c |
+ if (instance_id == VMSTATE_INSTANCE_ID_ANY) {
|
|
|
ddf19c |
se->instance_id = calculate_new_instance_id(se->idstr);
|
|
|
ddf19c |
} else {
|
|
|
ddf19c |
se->instance_id = instance_id;
|
|
|
ddf19c |
@@ -817,14 +817,14 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
|
|
|
ddf19c |
|
|
|
ddf19c |
se->compat = g_new0(CompatEntry, 1);
|
|
|
ddf19c |
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
|
|
|
ddf19c |
- se->compat->instance_id = instance_id == -1 ?
|
|
|
ddf19c |
+ se->compat->instance_id = instance_id == VMSTATE_INSTANCE_ID_ANY ?
|
|
|
ddf19c |
calculate_compat_instance_id(vmsd->name) : instance_id;
|
|
|
ddf19c |
- instance_id = -1;
|
|
|
ddf19c |
+ instance_id = VMSTATE_INSTANCE_ID_ANY;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
}
|
|
|
ddf19c |
pstrcat(se->idstr, sizeof(se->idstr), vmsd->name);
|
|
|
ddf19c |
|
|
|
ddf19c |
- if (instance_id == -1) {
|
|
|
ddf19c |
+ if (instance_id == VMSTATE_INSTANCE_ID_ANY) {
|
|
|
ddf19c |
se->instance_id = calculate_new_instance_id(se->idstr);
|
|
|
ddf19c |
} else {
|
|
|
ddf19c |
se->instance_id = instance_id;
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|