From nobody Sun Feb 8 17:48:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491240023372878.1583503405249; Mon, 3 Apr 2017 10:20:23 -0700 (PDT) Received: from localhost ([::1]:60395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv5eQ-0001Ki-3I for importer@patchew.org; Mon, 03 Apr 2017 13:20:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv5cx-0000QA-FD for qemu-devel@nongnu.org; Mon, 03 Apr 2017 13:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv5cu-0003jA-ND for qemu-devel@nongnu.org; Mon, 03 Apr 2017 13:18:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43329) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cv5cu-0003ip-EP for qemu-devel@nongnu.org; Mon, 03 Apr 2017 13:18:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B0DBC00108E; Mon, 3 Apr 2017 17:18:47 +0000 (UTC) Received: from dgilbert-t530.redhat.com (ovpn-117-210.ams2.redhat.com [10.36.117.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 268F8A0A33; Mon, 3 Apr 2017 17:18:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B0DBC00108E Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dgilbert@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6B0DBC00108E From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, samuel.thibault@gnu.org, jan.kiszka@siemens.com Date: Mon, 3 Apr 2017 18:18:39 +0100 Message-Id: <20170403171843.3363-2-dgilbert@redhat.com> In-Reply-To: <20170403171843.3363-1-dgilbert@redhat.com> References: <20170403171843.3363-1-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 03 Apr 2017 17:18:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5 1/5] slirp: VMState conversion; tcpcb X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Convert the migration of the struct tcpcb to use a VMStateDescription, the rest of it will come later. Mostly mechanical, except for conversion of some 'char' to uint8_t to ensure portability. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Samuel Thibault Reviewed-by: Juan Quintela --- slirp/slirp.c | 149 ++++++++++++++++++++--------------------------------= ---- slirp/tcp_var.h | 6 +-- 2 files changed, 57 insertions(+), 98 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 5a94b06..86eefc3 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -1129,53 +1129,62 @@ void slirp_socket_recv(Slirp *slirp, struct in_addr= guest_addr, int guest_port, tcp_output(sototcpcb(so)); } =20 -static void slirp_tcp_save(QEMUFile *f, struct tcpcb *tp) +static int slirp_tcp_post_load(void *opaque, int version) { - int i; + tcp_template((struct tcpcb *)opaque); =20 - qemu_put_sbe16(f, tp->t_state); - for (i =3D 0; i < TCPT_NTIMERS; i++) - qemu_put_sbe16(f, tp->t_timer[i]); - qemu_put_sbe16(f, tp->t_rxtshift); - qemu_put_sbe16(f, tp->t_rxtcur); - qemu_put_sbe16(f, tp->t_dupacks); - qemu_put_be16(f, tp->t_maxseg); - qemu_put_sbyte(f, tp->t_force); - qemu_put_be16(f, tp->t_flags); - qemu_put_be32(f, tp->snd_una); - qemu_put_be32(f, tp->snd_nxt); - qemu_put_be32(f, tp->snd_up); - qemu_put_be32(f, tp->snd_wl1); - qemu_put_be32(f, tp->snd_wl2); - qemu_put_be32(f, tp->iss); - qemu_put_be32(f, tp->snd_wnd); - qemu_put_be32(f, tp->rcv_wnd); - qemu_put_be32(f, tp->rcv_nxt); - qemu_put_be32(f, tp->rcv_up); - qemu_put_be32(f, tp->irs); - qemu_put_be32(f, tp->rcv_adv); - qemu_put_be32(f, tp->snd_max); - qemu_put_be32(f, tp->snd_cwnd); - qemu_put_be32(f, tp->snd_ssthresh); - qemu_put_sbe16(f, tp->t_idle); - qemu_put_sbe16(f, tp->t_rtt); - qemu_put_be32(f, tp->t_rtseq); - qemu_put_sbe16(f, tp->t_srtt); - qemu_put_sbe16(f, tp->t_rttvar); - qemu_put_be16(f, tp->t_rttmin); - qemu_put_be32(f, tp->max_sndwnd); - qemu_put_byte(f, tp->t_oobflags); - qemu_put_byte(f, tp->t_iobc); - qemu_put_sbe16(f, tp->t_softerror); - qemu_put_byte(f, tp->snd_scale); - qemu_put_byte(f, tp->rcv_scale); - qemu_put_byte(f, tp->request_r_scale); - qemu_put_byte(f, tp->requested_s_scale); - qemu_put_be32(f, tp->ts_recent); - qemu_put_be32(f, tp->ts_recent_age); - qemu_put_be32(f, tp->last_ack_sent); + return 0; } =20 +static const VMStateDescription vmstate_slirp_tcp =3D { + .name =3D "slirp-tcp", + .version_id =3D 0, + .post_load =3D slirp_tcp_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_INT16(t_state, struct tcpcb), + VMSTATE_INT16_ARRAY(t_timer, struct tcpcb, TCPT_NTIMERS), + VMSTATE_INT16(t_rxtshift, struct tcpcb), + VMSTATE_INT16(t_rxtcur, struct tcpcb), + VMSTATE_INT16(t_dupacks, struct tcpcb), + VMSTATE_UINT16(t_maxseg, struct tcpcb), + VMSTATE_UINT8(t_force, struct tcpcb), + VMSTATE_UINT16(t_flags, struct tcpcb), + VMSTATE_UINT32(snd_una, struct tcpcb), + VMSTATE_UINT32(snd_nxt, struct tcpcb), + VMSTATE_UINT32(snd_up, struct tcpcb), + VMSTATE_UINT32(snd_wl1, struct tcpcb), + VMSTATE_UINT32(snd_wl2, struct tcpcb), + VMSTATE_UINT32(iss, struct tcpcb), + VMSTATE_UINT32(snd_wnd, struct tcpcb), + VMSTATE_UINT32(rcv_wnd, struct tcpcb), + VMSTATE_UINT32(rcv_nxt, struct tcpcb), + VMSTATE_UINT32(rcv_up, struct tcpcb), + VMSTATE_UINT32(irs, struct tcpcb), + VMSTATE_UINT32(rcv_adv, struct tcpcb), + VMSTATE_UINT32(snd_max, struct tcpcb), + VMSTATE_UINT32(snd_cwnd, struct tcpcb), + VMSTATE_UINT32(snd_ssthresh, struct tcpcb), + VMSTATE_INT16(t_idle, struct tcpcb), + VMSTATE_INT16(t_rtt, struct tcpcb), + VMSTATE_UINT32(t_rtseq, struct tcpcb), + VMSTATE_INT16(t_srtt, struct tcpcb), + VMSTATE_INT16(t_rttvar, struct tcpcb), + VMSTATE_UINT16(t_rttmin, struct tcpcb), + VMSTATE_UINT32(max_sndwnd, struct tcpcb), + VMSTATE_UINT8(t_oobflags, struct tcpcb), + VMSTATE_UINT8(t_iobc, struct tcpcb), + VMSTATE_INT16(t_softerror, struct tcpcb), + VMSTATE_UINT8(snd_scale, struct tcpcb), + VMSTATE_UINT8(rcv_scale, struct tcpcb), + VMSTATE_UINT8(request_r_scale, struct tcpcb), + VMSTATE_UINT8(requested_s_scale, struct tcpcb), + VMSTATE_UINT32(ts_recent, struct tcpcb), + VMSTATE_UINT32(ts_recent_age, struct tcpcb), + VMSTATE_UINT32(last_ack_sent, struct tcpcb), + VMSTATE_END_OF_LIST() + } +}; + static void slirp_sbuf_save(QEMUFile *f, struct sbuf *sbuf) { uint32_t off; @@ -1218,7 +1227,7 @@ static void slirp_socket_save(QEMUFile *f, struct soc= ket *so) qemu_put_be32(f, so->so_state); slirp_sbuf_save(f, &so->so_rcv); slirp_sbuf_save(f, &so->so_snd); - slirp_tcp_save(f, so->so_tcpcb); + vmstate_save_state(f, &vmstate_slirp_tcp, so->so_tcpcb, 0); } =20 static void slirp_bootp_save(QEMUFile *f, Slirp *slirp) @@ -1254,54 +1263,6 @@ static void slirp_state_save(QEMUFile *f, void *opaq= ue) slirp_bootp_save(f, slirp); } =20 -static void slirp_tcp_load(QEMUFile *f, struct tcpcb *tp) -{ - int i; - - tp->t_state =3D qemu_get_sbe16(f); - for (i =3D 0; i < TCPT_NTIMERS; i++) - tp->t_timer[i] =3D qemu_get_sbe16(f); - tp->t_rxtshift =3D qemu_get_sbe16(f); - tp->t_rxtcur =3D qemu_get_sbe16(f); - tp->t_dupacks =3D qemu_get_sbe16(f); - tp->t_maxseg =3D qemu_get_be16(f); - tp->t_force =3D qemu_get_sbyte(f); - tp->t_flags =3D qemu_get_be16(f); - tp->snd_una =3D qemu_get_be32(f); - tp->snd_nxt =3D qemu_get_be32(f); - tp->snd_up =3D qemu_get_be32(f); - tp->snd_wl1 =3D qemu_get_be32(f); - tp->snd_wl2 =3D qemu_get_be32(f); - tp->iss =3D qemu_get_be32(f); - tp->snd_wnd =3D qemu_get_be32(f); - tp->rcv_wnd =3D qemu_get_be32(f); - tp->rcv_nxt =3D qemu_get_be32(f); - tp->rcv_up =3D qemu_get_be32(f); - tp->irs =3D qemu_get_be32(f); - tp->rcv_adv =3D qemu_get_be32(f); - tp->snd_max =3D qemu_get_be32(f); - tp->snd_cwnd =3D qemu_get_be32(f); - tp->snd_ssthresh =3D qemu_get_be32(f); - tp->t_idle =3D qemu_get_sbe16(f); - tp->t_rtt =3D qemu_get_sbe16(f); - tp->t_rtseq =3D qemu_get_be32(f); - tp->t_srtt =3D qemu_get_sbe16(f); - tp->t_rttvar =3D qemu_get_sbe16(f); - tp->t_rttmin =3D qemu_get_be16(f); - tp->max_sndwnd =3D qemu_get_be32(f); - tp->t_oobflags =3D qemu_get_byte(f); - tp->t_iobc =3D qemu_get_byte(f); - tp->t_softerror =3D qemu_get_sbe16(f); - tp->snd_scale =3D qemu_get_byte(f); - tp->rcv_scale =3D qemu_get_byte(f); - tp->request_r_scale =3D qemu_get_byte(f); - tp->requested_s_scale =3D qemu_get_byte(f); - tp->ts_recent =3D qemu_get_be32(f); - tp->ts_recent_age =3D qemu_get_be32(f); - tp->last_ack_sent =3D qemu_get_be32(f); - tcp_template(tp); -} - static int slirp_sbuf_load(QEMUFile *f, struct sbuf *sbuf) { uint32_t off, sb_cc, sb_datalen; @@ -1367,9 +1328,7 @@ static int slirp_socket_load(QEMUFile *f, struct sock= et *so, int version_id) return -ENOMEM; if (slirp_sbuf_load(f, &so->so_snd) < 0) return -ENOMEM; - slirp_tcp_load(f, so->so_tcpcb); - - return 0; + return vmstate_load_state(f, &vmstate_slirp_tcp, so->so_tcpcb, 0); } =20 static void slirp_bootp_load(QEMUFile *f, Slirp *slirp) diff --git a/slirp/tcp_var.h b/slirp/tcp_var.h index 0f8f187..895ef6d 100644 --- a/slirp/tcp_var.h +++ b/slirp/tcp_var.h @@ -48,7 +48,7 @@ struct tcpcb { short t_rxtcur; /* current retransmit value */ short t_dupacks; /* consecutive dup acks recd */ u_short t_maxseg; /* maximum segment size */ - char t_force; /* 1 if forcing out a byte */ + uint8_t t_force; /* 1 if forcing out a byte */ u_short t_flags; #define TF_ACKNOW 0x0001 /* ack peer immediately */ #define TF_DELACK 0x0002 /* ack, but try to delay it */ @@ -109,8 +109,8 @@ struct tcpcb { uint32_t max_sndwnd; /* largest window peer has offered */ =20 /* out-of-band data */ - char t_oobflags; /* have some */ - char t_iobc; /* input character */ + uint8_t t_oobflags; /* have some */ + uint8_t t_iobc; /* input character */ #define TCPOOB_HAVEDATA 0x01 #define TCPOOB_HADDATA 0x02 short t_softerror; /* possible error not yet reported */ --=20 2.9.3