From patchwork Wed Jan 7 10:23:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 1123 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n07AKCUs028632 for ; Wed, 7 Jan 2009 02:20:12 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751014AbZAGKXp (ORCPT ); Wed, 7 Jan 2009 05:23:45 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751311AbZAGKXp (ORCPT ); Wed, 7 Jan 2009 05:23:45 -0500 Received: from mx2.redhat.com ([66.187.237.31]:50320 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751014AbZAGKXo (ORCPT ); Wed, 7 Jan 2009 05:23:44 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n07ANhPG023177 for ; Wed, 7 Jan 2009 05:23:43 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n07ANh9n009621; Wed, 7 Jan 2009 05:23:43 -0500 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n07ANg0h013520; Wed, 7 Jan 2009 05:23:42 -0500 Subject: Re: [PATCH 1/1] kvm: qemu: virtio-net: migration fixes From: Mark McLoughlin Reply-To: Mark McLoughlin To: Avi Kivity Cc: kvm@vger.kernel.org In-Reply-To: <1231242498-3191-1-git-send-email-markmc@redhat.com> References: <1231242498-3191-1-git-send-email-markmc@redhat.com> Date: Wed, 07 Jan 2009 10:23:40 +0000 Message-Id: <1231323820.5050.10.camel@localhost.localdomain> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Avi, A new version, with Anthony's suggested savevm version number bump. Cheers, Mark. From: Mark McLoughlin Subject: [PATCH] kvm: qemu: virtio-net: migration fixes We were failing to save two important pieces of state: 1) Whether the guest will supply us rx buffers using the new mergeable format; this caused the migrated guest to crash with "virtio-net header not in first element" 2) Whether the tx/rx buffers we exchange with the tap code should include a virtio_net_hdr header; this caused the migrated guest to receive garbage packets because the tap code was stripping away the header and virtio_net was interpreting packet data as the virtio_net header With these fixes a guest using mergeable rx buffers and GSO passes a simple "ping while migrating" test. Bump the savevm version number and refuse to load v1 saves just to be on the safe side. Signed-off-by: Mark McLoughlin --- qemu/hw/virtio-net.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c index ef8f591..dfe370a 100644 --- a/qemu/hw/virtio-net.c +++ b/qemu/hw/virtio-net.c @@ -360,19 +360,30 @@ static void virtio_net_save(QEMUFile *f, void *opaque) qemu_put_buffer(f, n->mac, 6); qemu_put_be32(f, n->tx_timer_active); + qemu_put_be32(f, n->mergeable_rx_bufs); + +#ifdef TAP_VNET_HDR + qemu_put_be32(f, tap_has_vnet_hdr(n->vc->vlan->first_client)); +#endif } static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) { VirtIONet *n = opaque; - if (version_id != 1) + if (version_id != 2) return -EINVAL; virtio_load(&n->vdev, f); qemu_get_buffer(f, n->mac, 6); n->tx_timer_active = qemu_get_be32(f); + n->mergeable_rx_bufs = qemu_get_be32(f); + +#ifdef TAP_VNET_HDR + if (qemu_get_be32(f)) + tap_using_vnet_hdr(n->vc->vlan->first_client, 1); +#endif if (n->tx_timer_active) { qemu_mod_timer(n->tx_timer, @@ -407,7 +418,7 @@ PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn) n->tx_timer_active = 0; n->mergeable_rx_bufs = 0; - register_savevm("virtio-net", virtio_net_id++, 1, + register_savevm("virtio-net", virtio_net_id++, 2, virtio_net_save, virtio_net_load, n); return (PCIDevice *)n;