From patchwork Thu Mar 31 14:48:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 8713911 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69CD0C0553 for ; Thu, 31 Mar 2016 14:48:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC36E2028D for ; Thu, 31 Mar 2016 14:48:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 026AC20279 for ; Thu, 31 Mar 2016 14:48:57 +0000 (UTC) Received: from localhost ([::1]:60914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aldu4-00062r-49 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 31 Mar 2016 10:48:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aldtw-00062j-Sr for qemu-devel@nongnu.org; Thu, 31 Mar 2016 10:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aldts-0003XU-Sv for qemu-devel@nongnu.org; Thu, 31 Mar 2016 10:48:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40465) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aldts-0003XG-LC for qemu-devel@nongnu.org; Thu, 31 Mar 2016 10:48:44 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 750407AE9B; Thu, 31 Mar 2016 14:48:43 +0000 (UTC) Received: from thh440s.str.redhat.com. (dhcp-192-192.str.redhat.com [10.33.192.192]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2VEmfCZ020584; Thu, 31 Mar 2016 10:48:42 -0400 From: Thomas Huth To: Samuel Thibault , qemu-devel@nongnu.org Date: Thu, 31 Mar 2016 16:48:41 +0200 Message-Id: <1459435721-21351-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jan Kiszka Subject: [Qemu-devel] [PATCH] slirp: Fix migration from older versions of QEMU to the current one X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While adding the IPv6 support, the commit eae303ff23f51259eddc8856c71453d8 ("slirp: Make Socket structure IPv6 compatible") changed the format of the migration stream, without taking into account that we might still receive an old migration stream layout when upgrading from QEMU version 2.5 (or older) to QEMU 2.6. Currently, QEMU bails out when doing a migration from QEMU 2.5 to the recent master version when it has been started with a "-net user,guestfwd=..." network. So let's fix this by checking the version ID of the migration stream and by using the old behavior if we've detected version 3 or less. Signed-off-by: Thomas Huth Reviewed-by: Samuel Thibault --- slirp/slirp.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 3481fcc..998f278 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -1233,31 +1233,39 @@ static int slirp_sbuf_load(QEMUFile *f, struct sbuf *sbuf) return 0; } -static int slirp_socket_load(QEMUFile *f, struct socket *so) +static int slirp_socket_load(QEMUFile *f, struct socket *so, int version_id) { if (tcp_attach(so) < 0) return -ENOMEM; so->so_urgc = qemu_get_be32(f); - so->so_ffamily = qemu_get_be16(f); - switch (so->so_ffamily) { - case AF_INET: + if (version_id <= 3) { + so->so_ffamily = AF_INET; so->so_faddr.s_addr = qemu_get_be32(f); - so->so_fport = qemu_get_be16(f); - break; - default: - error_report( - "so_ffamily unknown, unable to restore so_faddr and so_lport\n"); - } - so->so_lfamily = qemu_get_be16(f); - switch (so->so_lfamily) { - case AF_INET: so->so_laddr.s_addr = qemu_get_be32(f); + so->so_fport = qemu_get_be16(f); so->so_lport = qemu_get_be16(f); - break; - default: - error_report( - "so_ffamily unknown, unable to restore so_laddr and so_lport\n"); + } else { + so->so_ffamily = qemu_get_be16(f); + switch (so->so_ffamily) { + case AF_INET: + so->so_faddr.s_addr = qemu_get_be32(f); + so->so_fport = qemu_get_be16(f); + break; + default: + error_report( + "so_ffamily unknown, unable to restore so_faddr and so_lport"); + } + so->so_lfamily = qemu_get_be16(f); + switch (so->so_lfamily) { + case AF_INET: + so->so_laddr.s_addr = qemu_get_be32(f); + so->so_lport = qemu_get_be16(f); + break; + default: + error_report( + "so_ffamily unknown, unable to restore so_laddr and so_lport"); + } } so->so_iptos = qemu_get_byte(f); so->so_emu = qemu_get_byte(f); @@ -1294,7 +1302,7 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) if (!so) return -ENOMEM; - ret = slirp_socket_load(f, so); + ret = slirp_socket_load(f, so, version_id); if (ret < 0) return ret;