From patchwork Mon Dec 10 14:29:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 204927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7DB482C0223 for ; Tue, 11 Dec 2012 01:31:54 +1100 (EST) Received: from localhost ([::1]:51020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ti4Oe-0002Pi-LR for incoming@patchwork.ozlabs.org; Mon, 10 Dec 2012 09:31:52 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ti4NV-0007rV-AP for qemu-devel@nongnu.org; Mon, 10 Dec 2012 09:30:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ti4NP-00021h-7U for qemu-devel@nongnu.org; Mon, 10 Dec 2012 09:30:41 -0500 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:55039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ti4NO-00021O-Ln for qemu-devel@nongnu.org; Mon, 10 Dec 2012 09:30:35 -0500 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 10 Dec 2012 20:00:07 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 10 Dec 2012 20:00:01 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 9F67A3940050 for ; Mon, 10 Dec 2012 20:00:25 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qBAEUNLa26411090 for ; Mon, 10 Dec 2012 20:00:23 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qBAEUOlE003389 for ; Tue, 11 Dec 2012 01:30:24 +1100 Received: from titi.austin.rr.com (sig-9-77-141-109.mts.ibm.com [9.77.141.109]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id qBAEU0qD000348; Tue, 11 Dec 2012 01:30:12 +1100 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 10 Dec 2012 08:29:50 -0600 Message-Id: <1355149790-8125-5-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1355149790-8125-1-git-send-email-aliguori@us.ibm.com> References: <1355149790-8125-1-git-send-email-aliguori@us.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12121014-2000-0000-0000-00000A33D8EB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.8 Cc: Anthony Liguori , Rusty Russell , David Gibson , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 4/4] virtio: bump migration version number X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org And disable migration on big endian hosts from older versions where endianness of the device state was ambiguous on the wire. Signed-off-by: Anthony Liguori --- hw/virtio-blk.c | 13 +++++++++++-- hw/virtio-serial-bus.c | 9 +++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 7ab174f..837a709 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -566,8 +566,17 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id) VirtIOBlock *s = opaque; int ret; - if (version_id != 2) +#ifdef HOST_WORDS_BIGENDIAN + /* Because of the use of native endianness, we can't reliably handle + * migration below this version on big endian hosts. */ + if (version < 3) { return -EINVAL; + } +#endif + + if (version_id < 2) { + return -EINVAL; + } ret = virtio_load(&s->vdev, f); if (ret) { @@ -633,7 +642,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk) qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); s->qdev = dev; - register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, + register_savevm(dev, "virtio-blk", virtio_blk_id++, 3, virtio_blk_save, virtio_blk_load, s); bdrv_set_dev_ops(s->bs, &virtio_block_ops, s); bdrv_set_buffer_alignment(s->bs, s->conf->logical_block_size); diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index aa1ded0..6aa3b85 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -665,9 +665,14 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id) unsigned int i; int ret; - if (version_id > 3) { +#ifdef HOST_WORDS_BIGENDIAN + /* Because of the use of native endianness, we can't reliably handle + * migration below this version on big endian hosts. */ + + if (version_id < 4) { return -EINVAL; } +#endif /* The virtio device */ ret = virtio_load(&s->vdev, f); @@ -987,7 +992,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf) * Register for the savevm section with the virtio-console name * to preserve backward compat */ - register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save, + register_savevm(dev, "virtio-console", -1, 4, virtio_serial_save, virtio_serial_load, vser); vser->post_load.timer = qemu_new_timer_ns(vm_clock,