From patchwork Mon Oct 25 10:32:43 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: 69085 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 D6ED5B70AF for ; Mon, 25 Oct 2010 21:43:12 +1100 (EST) Received: from localhost ([127.0.0.1]:51425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAKWC-0001Ob-5j for incoming@patchwork.ozlabs.org; Mon, 25 Oct 2010 06:43:08 -0400 Received: from [140.186.70.92] (port=58624 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAKSh-0000Gu-9c for qemu-devel@nongnu.org; Mon, 25 Oct 2010 06:39:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAKSZ-0008TA-Qn for qemu-devel@nongnu.org; Mon, 25 Oct 2010 06:39:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAKSZ-0008St-EI for qemu-devel@nongnu.org; Mon, 25 Oct 2010 06:39:23 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9PAdMhG003892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 25 Oct 2010 06:39:22 -0400 Received: from redhat.com (vpn-6-113.tlv.redhat.com [10.35.6.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id o9PAdK6T011232 for ; Mon, 25 Oct 2010 06:39:21 -0400 Date: Mon, 25 Oct 2010 12:32:43 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20101025081859.GA5619@redhat.com> MIME-Version: 1.0 Content-Disposition: inline Received: from mail.corp.redhat.com [10.5.5.51] by tuck.tlv.redhat.com with IMAP (fetchmail-6.3.17 polling redhat account mtsirkin folder Copy) for (single-drop); Mon, 25 Oct 2010 10:19:11 +0200 (IST) Received: from zmta02.collab.prod.int.phx2.redhat.com (LHLO zmta02.collab.prod.int.phx2.redhat.com) (10.5.5.32) by mail01.corp.redhat.com with LMTP; Mon, 25 Oct 2010 04:25:38 -0400 (EDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zmta02.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 178699E8A2 for ; Mon, 25 Oct 2010 04:25:38 -0400 (EDT) Received: from zmta02.collab.prod.int.phx2.redhat.com ([127.0.0.1]) by localhost (zmta02.collab.prod.int.phx2.redhat.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sIbZPqyHQ44F for ; Mon, 25 Oct 2010 04:25:38 -0400 (EDT) Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by zmta02.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 069759D901 for ; Mon, 25 Oct 2010 04:25:38 -0400 (EDT) Received: from redhat.com (vpn-6-113.tlv.redhat.com [10.35.6.113]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o9P8Paa7013716 for ; Mon, 25 Oct 2010 04:25:37 -0400 User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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] [PATCH RFC] virtio-net: don't dma while vm is stopped 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 DMA into memory while VM is stopped makes it hard to debug migration (consequitive saves result in different files). Sending while vm is stopped has an even worse effect as it confuses the bridges so that they do not know where to send packets. Fixing this completely is a large effort, this patch does this for virtio-net since that already tracks vm state. Signed-off-by: Michael S. Tsirkin --- hw/virtio-net.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 7e1688c..90010e6 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -424,6 +424,9 @@ static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq) static int virtio_net_can_receive(VLANClientState *nc) { VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque; + if (!n->vm_running) { + return 0; + } if (!virtio_queue_ready(n->rx_vq) || !(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) @@ -673,11 +676,14 @@ static int32_t virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq) { VirtQueueElement elem; int32_t num_packets = 0; - if (!(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) { return num_packets; } + if (!n->vm_running) { + return 0; + } + if (n->async_tx.elem.out_num) { virtio_queue_set_notification(n->tx_vq, 0); return num_packets;