* [Qemu-devel] [PATCH] net: Flush queued packets when guest resumes
@ 2015-07-01 8:23 Fam Zheng
2015-07-01 8:53 ` Fam Zheng
2015-07-02 13:13 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Fam Zheng @ 2015-07-01 8:23 UTC (permalink / raw)
To: qemu-devel; +Cc: Jason Wang, chao.zhou, Stefan Hajnoczi
Since commit 6e99c63 "net/socket: Drop net_socket_can_send" and friends,
net queues need to be explicitly flushed after qemu_can_send_packet()
returns false, because the netdev side will disable the polling of fd.
This fixes the case of "cont" after "stop" (or migration), i.e.
vm_running changes to true, by listening to vm state changes.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
include/net/net.h | 2 ++
net/net.c | 14 +++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/net/net.h b/include/net/net.h
index 6a6cbef..619a6e1 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
@@ -92,6 +93,7 @@ struct NetClientState {
NetClientDestructor *destructor;
unsigned int queue_index;
unsigned rxfilter_notify_enabled:1;
+ VMChangeStateEntry *vmcse;
};
typedef struct NICState {
diff --git a/net/net.c b/net/net.c
index 6ff7fec..edfa6a0 100644
--- a/net/net.c
+++ b/net/net.c
@@ -43,7 +43,6 @@
#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)
@@ -263,6 +262,16 @@ static void qemu_net_client_destructor(NetClientState *nc)
g_free(nc);
}
+static void qemu_net_client_handle_vmstate(void *opaque,
+ int running,
+ RunState state)
+{
+ NetClientState *nc = opaque;
+ if (running && qemu_can_send_packet(nc) && nc->peer) {
+ qemu_flush_queued_packets(nc->peer);
+ }
+}
+
static void qemu_net_client_setup(NetClientState *nc,
NetClientInfo *info,
NetClientState *peer,
@@ -287,6 +296,8 @@ static void qemu_net_client_setup(NetClientState *nc,
nc->incoming_queue = qemu_new_net_queue(nc);
nc->destructor = destructor;
+ nc->vmcse = qemu_add_vm_change_state_handler(qemu_net_client_handle_vmstate,
+ nc);
}
NetClientState *qemu_new_net_client(NetClientInfo *info,
@@ -395,6 +406,7 @@ void qemu_del_net_client(NetClientState *nc)
MAX_QUEUE_NUM);
assert(queues != 0);
+ qemu_del_vm_change_state_handler(nc->vmcse);
/* If there is a peer NIC, delete and cleanup client, but do not free. */
if (nc->peer && nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
NICState *nic = qemu_get_nic(nc->peer);
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] net: Flush queued packets when guest resumes
2015-07-01 8:23 [Qemu-devel] [PATCH] net: Flush queued packets when guest resumes Fam Zheng
@ 2015-07-01 8:53 ` Fam Zheng
2015-07-02 13:13 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Fam Zheng @ 2015-07-01 8:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Jason Wang, chao.zhou, Stefan Hajnoczi
On Wed, 07/01 16:23, Fam Zheng wrote:
> Since commit 6e99c63 "net/socket: Drop net_socket_can_send" and friends,
> net queues need to be explicitly flushed after qemu_can_send_packet()
> returns false, because the netdev side will disable the polling of fd.
>
> This fixes the case of "cont" after "stop" (or migration), i.e.
> vm_running changes to true, by listening to vm state changes.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
Note that to fix virtio-net, this patch is also needed:
http://lists.nongnu.org/archive/html/qemu-devel/2015-06/msg07377.html
Fam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] net: Flush queued packets when guest resumes
2015-07-01 8:23 [Qemu-devel] [PATCH] net: Flush queued packets when guest resumes Fam Zheng
2015-07-01 8:53 ` Fam Zheng
@ 2015-07-02 13:13 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2015-07-02 13:13 UTC (permalink / raw)
To: Fam Zheng; +Cc: Jason Wang, qemu-devel, chao.zhou
[-- Attachment #1: Type: text/plain, Size: 819 bytes --]
On Wed, Jul 01, 2015 at 04:23:34PM +0800, Fam Zheng wrote:
> Since commit 6e99c63 "net/socket: Drop net_socket_can_send" and friends,
> net queues need to be explicitly flushed after qemu_can_send_packet()
> returns false, because the netdev side will disable the polling of fd.
>
> This fixes the case of "cont" after "stop" (or migration), i.e.
> vm_running changes to true, by listening to vm state changes.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> include/net/net.h | 2 ++
> net/net.c | 14 +++++++++++++-
> 2 files changed, 15 insertions(+), 1 deletion(-)
Please unify this code with:
commit ca77d85e1dbf929ae677a0bac96e9b3edd1704da
Author: Michael S. Tsirkin <mst@redhat.com>
Date: Thu Sep 4 11:39:13 2014 +0300
net: complete all queued packets on VM stop
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-02 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-01 8:23 [Qemu-devel] [PATCH] net: Flush queued packets when guest resumes Fam Zheng
2015-07-01 8:53 ` Fam Zheng
2015-07-02 13:13 ` Stefan Hajnoczi
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).