From patchwork Wed Jun 2 18:02:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 54410 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 D44C0B7D47 for ; Thu, 3 Jun 2010 04:21:25 +1000 (EST) Received: from localhost ([127.0.0.1]:37423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJsUH-0003dz-KI for incoming@patchwork.ozlabs.org; Wed, 02 Jun 2010 14:16:21 -0400 Received: from [140.186.70.92] (port=45193 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJsKr-0000yh-Di for qemu-devel@nongnu.org; Wed, 02 Jun 2010 14:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJsKl-00032r-Ox for qemu-devel@nongnu.org; Wed, 02 Jun 2010 14:06:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41101) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJsKl-000322-Ik for qemu-devel@nongnu.org; Wed, 02 Jun 2010 14:06:31 -0400 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 o52I6TKt012473 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Jun 2010 14:06:30 -0400 Received: from redhat.com (vpn1-4-231.ams2.redhat.com [10.36.4.231]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o52I6Sed020711 for ; Wed, 2 Jun 2010 14:06:29 -0400 Date: Wed, 2 Jun 2010 21:02:18 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20100602180152.GA21861@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) 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. Subject: [Qemu-devel] [PATCHv2] virtio-net: stop vhost backend on vmstop 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 vhost net currently keeps running after vmstop, which causes trouble as qemy does not check for dirty pages anymore. The fix is to simply keep vm and vhost running/stopped status in sync. Tested-by: David L Stevens Signed-off-by: Michael S. Tsirkin --- Changes from v1: Simplify code as suggested by Amit. hw/virtio-net.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 28f26e1..67eebcf 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -877,12 +877,11 @@ static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status) static void virtio_net_vmstate_change(void *opaque, int running, int reason) { VirtIONet *n = opaque; - if (!running) { - return; - } - /* This is called when vm is started, it will start vhost backend if - * appropriate e.g. after migration. */ - virtio_net_set_status(&n->vdev, n->vdev.status); + uint8_t status = running ? n->vdev.status : 0; + /* This is called when vm is started/stopped, + * it will start/stop vhost backend if appropriate + * e.g. after migration. */ + virtio_net_set_status(&n->vdev, status); } VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)