Received: from eggs.gnu.org ([2001:4830:134:3::10]:55188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZArS9-0001oh-4W for qemu-devel@nongnu.org; Thu, 02 Jul 2015 23:15:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZArS5-0000fm-MF for qemu-devel@nongnu.org; Thu, 02 Jul 2015 23:15:49 -0400 Received: from indium.canonical.com ([91.189.90.7]:58856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZArS5-0000eH-DN for qemu-devel@nongnu.org; Thu, 02 Jul 2015 23:15:45 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.76 #1 (Debian)) id 1ZArS4-0006Wz-EH for ; Fri, 03 Jul 2015 03:15:44 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 68ECE2E80C2 for ; Fri, 3 Jul 2015 03:15:44 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Fri, 03 Jul 2015 03:10:04 -0000 From: chao zhou Sender: bounces@canonical.com References: <20150630034055.10614.7558.malonedeb@soybean.canonical.com> Message-Id: <20150703031004.9567.54144.malone@gac.canonical.com> Errors-To: bounces@canonical.com Subject: [Qemu-devel] [Bug 1469946] Re: guest can't get IP when create guest with bridge. Reply-To: Bug 1469946 <1469946@bugs.launchpad.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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 1= 00644 --- 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 =3D 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 =3D qemu_new_net_queue(nc); nc->destructor =3D destructor; + nc->vmcse =3D 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 !=3D 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 =3D=3D NET_CLIENT_OPTIONS_KIND_NI= C) { NICState *nic =3D qemu_get_nic(nc->peer); -- 2.4.3 after try this patch and http://lists.nongnu.org/archive/html/qemu-devel/20= 15-06/msg07377.html with qemu.git d2966f804d70a244f5dde395fc5d22a50ed3e74e after save/retore or live migration, the guest is alive, ping or ssh gues= t's IP , it is fine -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1469946 Title: guest can't get IP when create guest with bridge. Status in QEMU: New Bug description: Environment: ------------ Host OS (ia32/ia32e/IA64):ia32e Guest OS (ia32/ia32e/IA64):ia32e Guest OS Type (Linux/Windows):linux kvm.git Commit:aefbef10e3ae6e2c6e3c54f906f10b34c73a2c66 qemu.git Commit:dc1e1350f8061021df765b396295329797d66933 Host Kernel Version:4.1.0 Hardware:Ivytown_EP, Haswell_EP = Bug detailed description: -------------------------- when create guest with bridge, the guest can not get ip. note: 1. fail rate: 3/5 2. this is a qemu bug: kvm + qemu =3D result aefbef10 + dc1e1350 =3D bad = aefbef10 + a4ef02fd =3D good Reproduce steps: ---------------- 1. create guest: qemu-system-x86_64 -enable-kvm -m 2G -smp 4 -device virtio-net-pci,netdev= =3Dnet0,mac=3D$random_mac -netdev tap,id=3Dnet0,script=3D/etc/kvm/qemu-ifup= rhel6u5.qcow Current result: ---------------- guest can't get IP Expected result: ---------------- guest can get ip Basic root-causing log: ---------------------- To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1469946/+subscriptions