From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHqLg-0005Fq-Oe for qemu-devel@nongnu.org; Thu, 14 Aug 2014 04:25:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHqLb-0001gH-4q for qemu-devel@nongnu.org; Thu, 14 Aug 2014 04:25:28 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:22493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHqLa-0001fT-6a for qemu-devel@nongnu.org; Thu, 14 Aug 2014 04:25:23 -0400 Message-ID: <53EC7246.6030300@huawei.com> Date: Thu, 14 Aug 2014 16:24:38 +0800 From: zhanghailiang MIME-Version: 1.0 References: <1407996838-10212-1-git-send-email-zhang.zhanghailiang@huawei.com> <1407996838-10212-3-git-send-email-zhang.zhanghailiang@huawei.com> <33183CC9F5247A488A2544077AF1902086C3622C@SZXEMA503-MBS.china.huawei.com> In-Reply-To: <33183CC9F5247A488A2544077AF1902086C3622C@SZXEMA503-MBS.china.huawei.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/3] net: Flush queues when runstate changes back to running List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: "peter.maydell@linaro.org" , "aliguori@amazon.com" , "mst@redhat.com" , Luonengjun , "Huangpeng (Peter)" , "qemu-devel@nongnu.org" , "stefanha@redhat.com" , "akong@redhat.com" On 2014/8/14 15:12, Gonglei (Arei) wrote: > Hi, > >> Subject: [Qemu-devel] [PATCH 2/3] net: Flush queues when runstate changes >> back to running >> >> 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) add a member 'VMChangeStateEntry *vmstate' to struct NICState, >> Which will listen for VM runstate changes. > > Does this change will block migration during with different QEMU versions? > No, I have tested migration between qemu-1.5.1 with new qemu which has merged this patches, everything seems ok! >> (2) Register a handler function for VMstate change. >> When vm changes back to running, we flush all queues in the callback function. >> >> Signed-off-by: zhanghailiang >> --- >> include/net/net.h | 1 + >> net/net.c | 26 ++++++++++++++++++++++++++ >> 2 files changed, 27 insertions(+) >> >> diff --git a/include/net/net.h b/include/net/net.h >> index 312f728..a294277 100644 >> --- a/include/net/net.h >> +++ b/include/net/net.h >> @@ -97,6 +97,7 @@ typedef struct NICState { >> NICConf *conf; >> void *opaque; >> bool peer_deleted; >> + VMChangeStateEntry *vmstate; >> } NICState; >> >> NetClientState *qemu_find_netdev(const char *id); >> diff --git a/net/net.c b/net/net.c >> index 5bb2821..506e58f 100644 >> --- a/net/net.c >> +++ b/net/net.c >> @@ -242,6 +242,29 @@ NetClientState *qemu_new_net_client(NetClientInfo >> *info, >> return nc; >> } >> >> +static void nic_vmstate_change_handler(void *opaque, >> + int running, >> + RunState state) >> +{ >> + NICState *nic = opaque; >> + NetClientState *nc; >> + int i, queues; >> + >> + if (!running) { >> + return; >> + } >> + >> + queues = MAX(1, nic->conf->peers.queues); > ^ > A superfluous space. > Yes, Good catch, i will modify this. Thanks.