qdev: Track runtime machine modifications
Create a trivial interface to track whether the machine has been modified since boot. Adding or removing devices will trigger this to return true. An example usage scenario for such an interface is the rtl8139 driver which includes a cpu_register_io_memory() value in it's migration stream. For the majority of migrations, where no hotplug has occured in the machine, this works correctly. Once the machine is modified, we can use this interface to detect that and include a subsection for the device to prevent migrations to rtl8139 versions with this bug. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
a6a7005d14
commit
0ac8ef7132
10
hw/qdev.c
10
hw/qdev.c
@ -32,6 +32,8 @@
|
|||||||
#include "blockdev.h"
|
#include "blockdev.h"
|
||||||
|
|
||||||
static int qdev_hotplug = 0;
|
static int qdev_hotplug = 0;
|
||||||
|
static bool qdev_hot_added = false;
|
||||||
|
static bool qdev_hot_removed = false;
|
||||||
|
|
||||||
/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
|
/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
|
||||||
static BusState *main_system_bus;
|
static BusState *main_system_bus;
|
||||||
@ -93,6 +95,7 @@ static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
|
|||||||
if (qdev_hotplug) {
|
if (qdev_hotplug) {
|
||||||
assert(bus->allow_hotplug);
|
assert(bus->allow_hotplug);
|
||||||
dev->hotplugged = 1;
|
dev->hotplugged = 1;
|
||||||
|
qdev_hot_added = true;
|
||||||
}
|
}
|
||||||
dev->instance_id_alias = -1;
|
dev->instance_id_alias = -1;
|
||||||
dev->state = DEV_STATE_CREATED;
|
dev->state = DEV_STATE_CREATED;
|
||||||
@ -294,6 +297,8 @@ int qdev_unplug(DeviceState *dev)
|
|||||||
}
|
}
|
||||||
assert(dev->info->unplug != NULL);
|
assert(dev->info->unplug != NULL);
|
||||||
|
|
||||||
|
qdev_hot_removed = true;
|
||||||
|
|
||||||
return dev->info->unplug(dev);
|
return dev->info->unplug(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,6 +400,11 @@ void qdev_machine_creation_done(void)
|
|||||||
qdev_hotplug = 1;
|
qdev_hotplug = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool qdev_machine_modified(void)
|
||||||
|
{
|
||||||
|
return qdev_hot_added || qdev_hot_removed;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get a character (serial) device interface. */
|
/* Get a character (serial) device interface. */
|
||||||
CharDriverState *qdev_init_chardev(DeviceState *dev)
|
CharDriverState *qdev_init_chardev(DeviceState *dev)
|
||||||
{
|
{
|
||||||
|
@ -132,6 +132,7 @@ int qdev_unplug(DeviceState *dev);
|
|||||||
void qdev_free(DeviceState *dev);
|
void qdev_free(DeviceState *dev);
|
||||||
int qdev_simple_unplug_cb(DeviceState *dev);
|
int qdev_simple_unplug_cb(DeviceState *dev);
|
||||||
void qdev_machine_creation_done(void);
|
void qdev_machine_creation_done(void);
|
||||||
|
bool qdev_machine_modified(void);
|
||||||
|
|
||||||
qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
|
qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
|
||||||
void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
|
void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
|
||||||
|
Loading…
Reference in New Issue
Block a user