From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMbsx-0006FX-9R for qemu-devel@nongnu.org; Wed, 27 Aug 2014 07:59:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMbss-000313-Qy for qemu-devel@nongnu.org; Wed, 27 Aug 2014 07:59:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMbss-00030y-Bj for qemu-devel@nongnu.org; Wed, 27 Aug 2014 07:59:26 -0400 Date: Wed, 27 Aug 2014 13:59:49 +0200 From: "Michael S. Tsirkin" Message-ID: <20140827115949.GA17119@redhat.com> References: <1409040377-12088-1-git-send-email-zhang.zhanghailiang@huawei.com> <20140827115321.GB16850@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140827115321.GB16850@redhat.com> Subject: Re: [Qemu-devel] [PATCH V4] net: Forbid dealing with packets when VM is not running List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: aliguori@amazon.com, jasowang@redhat.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, qemu-devel@nongnu.org, stefanha@redhat.com On Wed, Aug 27, 2014 at 01:53:21PM +0200, Michael S. Tsirkin wrote: > On Tue, Aug 26, 2014 at 04:06:17PM +0800, zhanghailiang wrote: > > 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, but > > before the end of the migration, the new receiving packets will possibly dirty > > parts of RAM which has been cached in *iovec*(will be sent asynchronously) and > > dirty parts of new RAM which will be missed. > > This will lead serious network fault in VM. > > > > To avoid this, we forbid receiving packets in generic net code when > > VM is not running. > > > > Bug reproduction steps: > > (1) Start a VM which configured at least one NIC > > (2) In VM, open several Terminal and do *Ping IP -i 0.1* > > (3) Migrate the VM repeatedly between two Hosts > > And the *PING* command in VM will very likely fail with message: > > 'Destination HOST Unreachable', the NIC in VM will stay unavailable unless you > > run 'service network restart' > > > > Signed-off-by: zhanghailiang > > Reviewed-by: Michael S. Tsirkin Please add: Cc: qemu-stable@nongnu.org when applying this. Thanks! > > --- > > v4: > > - The action of flush queued packets is unnecessary, remove this. > > (Thanks for the help of Jason Wang and Stefan). > > > > v3: > > - change the 'vmstate' to 'vm_running' > > > > v2: > > - remove the superfluous check of nc->received_disabled > > --- > > > > net/net.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/net/net.c b/net/net.c > > index 6d930ea..4cb92c0 100644 > > --- a/net/net.c > > +++ b/net/net.c > > @@ -41,6 +41,7 @@ > > #include "qapi-visit.h" > > #include "qapi/opts-visitor.h" > > #include "qapi/dealloc-visitor.h" > > +#include "sysemu/sysemu.h" > > > > /* Net bridge is currently not supported for W32. */ > > #if !defined(_WIN32) > > @@ -452,6 +453,12 @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len) > > > > int qemu_can_send_packet(NetClientState *sender) > > { > > + int vm_running = runstate_is_running(); > > + > > + if (!vm_running) { > > + return 0; > > + } > > + > > if (!sender->peer) { > > return 1; > > } > > -- > > 1.7.12.4 > >