From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XM8wS-000092-HK for qemu-devel@nongnu.org; Tue, 26 Aug 2014 01:05:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XM8wN-0003xN-MR for qemu-devel@nongnu.org; Tue, 26 Aug 2014 01:05:12 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:48423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XM8wM-0003mn-QF for qemu-devel@nongnu.org; Tue, 26 Aug 2014 01:05:07 -0400 Message-ID: <53FC1555.5000804@huawei.com> Date: Tue, 26 Aug 2014 13:04:21 +0800 From: zhanghailiang MIME-Version: 1.0 References: <1408963656-12308-1-git-send-email-zhang.zhanghailiang@huawei.com> <53FC0F79.5080808@redhat.com> In-Reply-To: <53FC0F79.5080808@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V3] net: Fix dealing with packets when runstate changes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: peter.maydell@linaro.org, mst@redhat.com, jan.kiszka@siemens.com, luonengjun@huawei.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com On 2014/8/26 12:39, Jason Wang wrote: > On 08/25/2014 06:47 PM, 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, >> The new dirty RAM related to the packets will be missed, >> And this will lead serious network fault in VM. >> >> To avoid this, we forbid receiving packets in generic net code when >> VM is not running. Also, when the runstate changes back to running, >> we definitely need to flush queues to get packets flowing again. >> >> Here we implement this in the net layer: >> (1) Judge the vm runstate in qemu_can_send_packet >> (2) Add a member 'VMChangeStateEntry *vmstate' to struct NICState, >> Which will listen for VM runstate changes. >> (3) Register a handler function for VMstate change. >> When vm changes back to running, we flush all queues in the callback function. >> (4) Remove checking vm state in virtio_net_can_receive >> >> Signed-off-by: zhanghailiang >> --- >> v3: >> - change the 'vmstate' to 'vm_running' >> >> v2: >> - remove the superfluous check of nc->received_disabled >> --- >> hw/net/virtio-net.c | 4 ---- >> include/net/net.h | 2 ++ >> net/net.c | 31 +++++++++++++++++++++++++++++++ >> 3 files changed, 33 insertions(+), 4 deletions(-) > Hi: > > Have you seen Stefan's replied? We think there's no need to flush the > queued packets or is there anything new issue you found? > Hi Jason, Sorry, maybe i have missed it but i have searched that in internet, And got what happened.;) Hmm, you are right! i will send another patch which removing the unnecessary flush action and also a more clear commit log. Thanks, zhanghailiang