From: zhanghailiang <zhang.zhanghailiang@huawei.com>
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 <zhang.zhanghailiang@huawei.com>
Subject: [Qemu-devel] [PATCH 1/3] net: Forbid dealing with packets when VM is not running
Date: Thu, 14 Aug 2014 14:13:56 +0800 [thread overview]
Message-ID: <1407996838-10212-2-git-send-email-zhang.zhanghailiang@huawei.com> (raw)
In-Reply-To: <1407996838-10212-1-git-send-email-zhang.zhanghailiang@huawei.com>
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 <zhang.zhanghailiang@huawei.com>
---
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
next prev parent reply other threads:[~2014-08-14 6:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-14 6:13 [Qemu-devel] [PATCH 0/3] forbid dealing with net packets when VM is not running zhanghailiang
2014-08-14 6:13 ` zhanghailiang [this message]
2014-08-14 6:13 ` [Qemu-devel] [PATCH 2/3] net: Flush queues when runstate changes back to running zhanghailiang
2014-08-14 7:12 ` Gonglei (Arei)
2014-08-14 8:24 ` zhanghailiang
2014-08-14 10:05 ` Michael S. Tsirkin
2014-08-18 0:45 ` zhanghailiang
2014-08-14 10:09 ` Michael S. Tsirkin
2014-08-18 0:46 ` zhanghailiang
2014-08-14 6:13 ` [Qemu-devel] [PATCH 3/3] virtio-net: Remove checking vm state in virtio_net_can_receive zhanghailiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407996838-10212-2-git-send-email-zhang.zhanghailiang@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=akong@redhat.com \
--cc=aliguori@amazon.com \
--cc=luonengjun@huawei.com \
--cc=mst@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).