From patchwork Tue Jan 4 19:38:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 77526 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C4AF3B6EDF for ; Wed, 5 Jan 2011 07:18:31 +1100 (EST) Received: from localhost ([127.0.0.1]:34661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PaCrU-0006wq-Ef for incoming@patchwork.ozlabs.org; Tue, 04 Jan 2011 14:48:04 -0500 Received: from [140.186.70.92] (port=59330 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PaChp-0000Qp-Tp for qemu-devel@nongnu.org; Tue, 04 Jan 2011 14:38:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PaCho-0004Zm-NV for qemu-devel@nongnu.org; Tue, 04 Jan 2011 14:38:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PaCho-0004ZV-G4 for qemu-devel@nongnu.org; Tue, 04 Jan 2011 14:38:04 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p04Jc3AU000972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Jan 2011 14:38:03 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p04Jc2Uk025104; Tue, 4 Jan 2011 14:38:03 -0500 From: Alex Williamson To: qemu-devel@nongnu.org Date: Tue, 04 Jan 2011 12:38:02 -0700 Message-ID: <20110104193756.1909.39285.stgit@s20.home> In-Reply-To: <20110104192739.1909.73162.stgit@s20.home> References: <20110104192739.1909.73162.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com, mst@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [RESEND PATCH 2/2] rtl8139: Use subsection to restrict migration after hotplug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- hw/rtl8139.c | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) diff --git a/hw/rtl8139.c b/hw/rtl8139.c index a8aed89..a22530c 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -495,6 +495,8 @@ typedef struct RTL8139State { QEMUTimer *timer; int64_t TimerExpire; + /* Support migration to/from old versions */ + int rtl8139_mmio_io_addr_dummy; } RTL8139State; static void rtl8139_set_next_tctr_time(RTL8139State *s, int64_t current_time); @@ -3162,6 +3164,21 @@ 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; @@ -3171,6 +3188,7 @@ static void rtl8139_pre_save(void *opaque) rtl8139_set_next_tctr_time(s, current_time); s->TCTR = muldiv64(current_time - s->TCTR_base, PCI_FREQUENCY, get_ticks_per_sec()); + s->rtl8139_mmio_io_addr_dummy = s->rtl8139_mmio_io_addr; } static const VMStateDescription vmstate_rtl8139 = { @@ -3223,7 +3241,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), @@ -3252,6 +3270,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 */ + } } };