From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHoJc-0001gx-5H for qemu-devel@nongnu.org; Thu, 14 Aug 2014 02:15:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHoJW-0006yJ-2o for qemu-devel@nongnu.org; Thu, 14 Aug 2014 02:15:12 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:9596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHoJV-0006ow-8w for qemu-devel@nongnu.org; Thu, 14 Aug 2014 02:15:06 -0400 From: zhanghailiang Date: Thu, 14 Aug 2014 14:13:56 +0800 Message-ID: <1407996838-10212-2-git-send-email-zhang.zhanghailiang@huawei.com> In-Reply-To: <1407996838-10212-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1407996838-10212-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH 1/3] net: Forbid dealing with packets when VM is not running List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, stefanha@redhat.com, mst@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, aliguori@amazon.com, akong@redhat.com, zhanghailiang For all NICs(except virtio-net) emulated by qemu, Such as e1000, rtl8139, pcnet and ne2k_pci, Qemu can still receive packets when VM is not running. If this happened in *migration's* last PAUSE VM stage, The new dirty RAM related to the packets will be missed, And this will lead serious network fault in VM. To avoid this, do things like virtio-net, and forbid receiving packets in generic net code when VM is not running. Signed-off-by: zhanghailiang --- include/net/net.h | 1 + net/net.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index ed594f9..312f728 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -8,6 +8,7 @@ #include "net/queue.h" #include "migration/vmstate.h" #include "qapi-types.h" +#include "sysemu/sysemu.h" #define MAX_QUEUE_NUM 1024 diff --git a/net/net.c b/net/net.c index 6d930ea..5bb2821 100644 --- a/net/net.c +++ b/net/net.c @@ -452,6 +452,12 @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len) int qemu_can_send_packet(NetClientState *sender) { + int vmstat = runstate_is_running(); + + if (!vmstat) { + return 0; + } + if (!sender->peer) { return 1; } -- 1.7.12.4