From patchwork Thu Mar 31 22:21:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 8718951 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 50C6F9F39A for ; Thu, 31 Mar 2016 22:22:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D6592034B for ; Thu, 31 Mar 2016 22:21:59 +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 B4C4E202FF for ; Thu, 31 Mar 2016 22:21:58 +0000 (UTC) Received: from localhost ([::1]:34775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alkyU-0005Ke-1n for patchwork-qemu-devel@patchwork.kernel.org; Thu, 31 Mar 2016 18:21:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alkyG-0005Id-4K for qemu-devel@nongnu.org; Thu, 31 Mar 2016 18:21:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alkyB-0005I5-OM for qemu-devel@nongnu.org; Thu, 31 Mar 2016 18:21:44 -0400 Received: from domu-toccata.ens-lyon.fr ([140.77.166.138]:39071 helo=sonata.ens-lyon.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alkyB-0005GI-HF for qemu-devel@nongnu.org; Thu, 31 Mar 2016 18:21:39 -0400 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id C9C8120140; Fri, 1 Apr 2016 00:21:37 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dnafwpTRqxSa; Fri, 1 Apr 2016 00:21:37 +0200 (CEST) Received: from var.youpi.perso.aquilenet.fr (LFbn-1-6757-94.w90-120.abo.wanadoo.fr [90.120.189.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 5DB802013D; Fri, 1 Apr 2016 00:21:37 +0200 (CEST) Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.87) (envelope-from ) id 1alky8-0001yP-M5; Fri, 01 Apr 2016 00:21:36 +0200 From: Samuel Thibault To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 1 Apr 2016 00:21:36 +0200 Message-Id: <1459462896-7415-2-git-send-email-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1459462896-7415-1-git-send-email-samuel.thibault@ens-lyon.org> References: <1459462896-7415-1-git-send-email-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 140.77.166.138 Cc: jan.kiszka@siemens.com, Thomas Huth , Samuel Thibault Subject: [Qemu-devel] [PULL] 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 From: Thomas Huth 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 Signed-off-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;