From 6390530ee45abff5069e83d0788a7abd4f662d83 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Thu, 6 Jan 2011 18:17:35 -0200 Subject: [PATCH 39/48] rtl8139: Use subsection to restrict migration after hotplug RH-Author: Alex Williamson Message-id: <20110106181723.5924.2329.stgit@s20.home> Patchwork-id: 15930 O-Subject: [RHEL6.1 qemu-kvm PATCH 2/2] rtl8139: Use subsection to restrict migration after hotplug Bugzilla: 653591 RH-Acked-by: Juan Quintela RH-Acked-by: Michael S. Tsirkin RH-Acked-by: Jes Sorensen Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=653591 Upstream commit: c574ba5a4ce0faee6a687412804d6045ef815327 (mst's tree) Notes: RHEL6 doesn't include the pre_save function, which was added by 05447803. We don't need the rest of that commit, so I included just the pre_save here to stay consistent with upstream. rtl8139 includes a cpu_register_io_memory acquired value in it's migration data. This is not only unecessary, but we should treat these values as unique to the VM instances since the value depends on call order. In most cases, this miraculously still works. However, if devices are added or removed from the system, it may represent an ordering change, which could cause the target rtl8139 device to make use of another device's cpu_register_io_memory value. If we detect that a hot-add/remove has occured, include a subsection to restrict migrations only to driver versions known to include this fix. Signed-off-by: Alex Williamson Acked-by: Michael S. Tsirkin Acked-by: Juan Quintela Signed-off-by: Michael S. Tsirkin --- hw/rtl8139.c | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) Signed-off-by: Luiz Capitulino --- hw/rtl8139.c | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) diff --git a/hw/rtl8139.c b/hw/rtl8139.c index fcdcd1d..6f52ca1 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -492,6 +492,8 @@ typedef struct RTL8139State { /* PCI interrupt timer */ QEMUTimer *timer; + /* Support migration to/from old versions */ + int rtl8139_mmio_io_addr_dummy; } RTL8139State; static void prom9346_decode_command(EEprom9346 *eeprom, uint8_t command) @@ -3107,12 +3109,34 @@ static int rtl8139_post_load(void *opaque, int version_id) return 0; } +static bool rtl8139_hotplug_ready_needed(void *opaque) +{ + return qdev_machine_modified(); +} + +static const VMStateDescription vmstate_rtl8139_hotplug_ready ={ + .name = "rtl8139/hotplug_ready", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_END_OF_LIST() + } +}; + +static void rtl8139_pre_save(void *opaque) +{ + RTL8139State* s = opaque; + s->rtl8139_mmio_io_addr_dummy = s->rtl8139_mmio_io_addr; +} + static const VMStateDescription vmstate_rtl8139 = { .name = "rtl8139", .version_id = 4, .minimum_version_id = 3, .minimum_version_id_old = 3, .post_load = rtl8139_post_load, + .pre_save = rtl8139_pre_save, .fields = (VMStateField []) { VMSTATE_PCI_DEVICE(dev, RTL8139State), VMSTATE_PARTIAL_BUFFER(phys, RTL8139State, 6), @@ -3156,7 +3180,7 @@ static const VMStateDescription vmstate_rtl8139 = { VMSTATE_UNUSED(4), VMSTATE_MACADDR(conf.macaddr, RTL8139State), - VMSTATE_INT32(rtl8139_mmio_io_addr, RTL8139State), + VMSTATE_INT32(rtl8139_mmio_io_addr_dummy, RTL8139State), VMSTATE_UINT32(currTxDesc, RTL8139State), VMSTATE_UINT32(currCPlusRxDesc, RTL8139State), @@ -3185,6 +3209,14 @@ static const VMStateDescription vmstate_rtl8139 = { VMSTATE_UINT32_V(cplus_enabled, RTL8139State, 4), VMSTATE_END_OF_LIST() + }, + .subsections = (VMStateSubsection []) { + { + .vmsd = &vmstate_rtl8139_hotplug_ready, + .needed = rtl8139_hotplug_ready_needed, + }, { + /* empty */ + } } }; -- 1.7.4.rc1.16.gd2f15e