From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPP5a-00082x-Ri for qemu-devel@nongnu.org; Thu, 04 Sep 2014 00:56:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPP5V-0003X6-Py for qemu-devel@nongnu.org; Thu, 04 Sep 2014 00:56:06 -0400 Message-ID: <5407F0CA.1090403@redhat.com> Date: Thu, 04 Sep 2014 12:55:38 +0800 From: Jason Wang MIME-Version: 1.0 References: <1409667790-18015-1-git-send-email-stefanha@redhat.com> In-Reply-To: <1409667790-18015-1-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] net: prevent sending packets while guest is stopped List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, zhang.zhanghailiang@huawei.com, "Michael S. Tsirkin" On 09/02/2014 10:23 PM, Stefan Hajnoczi wrote: > Do not modify guest memory or devices when the guest is stopped. > Currently the netdevs still send packets while the guest is stopped if > their file descriptor was being monitored for write (e.g. the socket > write buffer filled before the guest was stopped). > > Netdevs call qemu_flush_queued_packets() when the file descriptor > becomes writable again. Don't resume packet processing when this > happens. > > Instead we flush queues when the guest resumes. > > Cc: qemu-stable@nongnu.org > Reported-by: Michael S. Tsirkin > Signed-off-by: Stefan Hajnoczi > --- > Note this fixes the transmit side. The receive side was recently fixed in > "net: Forbid dealing with packets when VM is not running". > > net/net.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/net/net.c b/net/net.c > index 6d930ea..74ec07a 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -47,6 +47,7 @@ > # define CONFIG_NET_BRIDGE > #endif > > +static VMChangeStateEntry *net_change_state_entry; > static QTAILQ_HEAD(, NetClientState) net_clients; > > const char *host_net_devices[] = { > @@ -506,6 +507,11 @@ void qemu_purge_queued_packets(NetClientState *nc) > > void qemu_flush_queued_packets(NetClientState *nc) > { > + /* Guest memory and devices must not be modified while stopped */ > + if (!runstate_is_running()) { > + return; > + } > + Consider migration case, this will prevent sent_cb(virtio_net_tx_complete) from being called at source. Since we don't migrate queue and async_tx. This may lead a interrupt lost in destination after migration? (Looks like virtio_net is the only user that uses async sending, not sure why this is needed)