From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, quintela@redhat.com, amit.shah@redhat.com,
samuel.thibault@ens-lyon.org, jan.kiszka@siemens.com
Cc: duanj@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH 5/8] slirp: VMState conversion; tcpcb
Date: Thu, 27 Oct 2016 16:32:14 +0100 [thread overview]
Message-ID: <20161027153217.16984-6-dgilbert@redhat.com> (raw)
In-Reply-To: <20161027153217.16984-1-dgilbert@redhat.com>
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
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 <dgilbert@redhat.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
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 6e2b4e5..6276315 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));
}
-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);
- qemu_put_sbe16(f, tp->t_state);
- for (i = 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;
}
+static const VMStateDescription vmstate_slirp_tcp = {
+ .name = "slirp-tcp",
+ .version_id = 0,
+ .post_load = slirp_tcp_post_load,
+ .fields = (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 socket *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);
}
static void slirp_bootp_save(QEMUFile *f, Slirp *slirp)
@@ -1254,54 +1263,6 @@ static void slirp_state_save(QEMUFile *f, void *opaque)
slirp_bootp_save(f, slirp);
}
-static void slirp_tcp_load(QEMUFile *f, struct tcpcb *tp)
-{
- int i;
-
- tp->t_state = qemu_get_sbe16(f);
- for (i = 0; i < TCPT_NTIMERS; i++)
- tp->t_timer[i] = qemu_get_sbe16(f);
- tp->t_rxtshift = qemu_get_sbe16(f);
- tp->t_rxtcur = qemu_get_sbe16(f);
- tp->t_dupacks = qemu_get_sbe16(f);
- tp->t_maxseg = qemu_get_be16(f);
- tp->t_force = qemu_get_sbyte(f);
- tp->t_flags = qemu_get_be16(f);
- tp->snd_una = qemu_get_be32(f);
- tp->snd_nxt = qemu_get_be32(f);
- tp->snd_up = qemu_get_be32(f);
- tp->snd_wl1 = qemu_get_be32(f);
- tp->snd_wl2 = qemu_get_be32(f);
- tp->iss = qemu_get_be32(f);
- tp->snd_wnd = qemu_get_be32(f);
- tp->rcv_wnd = qemu_get_be32(f);
- tp->rcv_nxt = qemu_get_be32(f);
- tp->rcv_up = qemu_get_be32(f);
- tp->irs = qemu_get_be32(f);
- tp->rcv_adv = qemu_get_be32(f);
- tp->snd_max = qemu_get_be32(f);
- tp->snd_cwnd = qemu_get_be32(f);
- tp->snd_ssthresh = qemu_get_be32(f);
- tp->t_idle = qemu_get_sbe16(f);
- tp->t_rtt = qemu_get_sbe16(f);
- tp->t_rtseq = qemu_get_be32(f);
- tp->t_srtt = qemu_get_sbe16(f);
- tp->t_rttvar = qemu_get_sbe16(f);
- tp->t_rttmin = qemu_get_be16(f);
- tp->max_sndwnd = qemu_get_be32(f);
- tp->t_oobflags = qemu_get_byte(f);
- tp->t_iobc = qemu_get_byte(f);
- tp->t_softerror = qemu_get_sbe16(f);
- tp->snd_scale = qemu_get_byte(f);
- tp->rcv_scale = qemu_get_byte(f);
- tp->request_r_scale = qemu_get_byte(f);
- tp->requested_s_scale = qemu_get_byte(f);
- tp->ts_recent = qemu_get_be32(f);
- tp->ts_recent_age = qemu_get_be32(f);
- tp->last_ack_sent = 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 socket *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);
}
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 */
/* 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 */
--
2.9.3
next prev parent reply other threads:[~2016-10-27 15:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-27 15:32 [Qemu-devel] [PATCH 0/8] VMSTATE_WITH_TMP and it's use in SLIRP Dr. David Alan Gilbert (git)
2016-10-27 15:32 ` [Qemu-devel] [PATCH 1/8] migration: extend VMStateInfo Dr. David Alan Gilbert (git)
2017-02-13 12:02 ` Juan Quintela
2016-10-27 15:32 ` [Qemu-devel] [PATCH 2/8] add QEMU_BUILD_BUG_EXPR Dr. David Alan Gilbert (git)
2017-02-13 12:02 ` Juan Quintela
2016-10-27 15:32 ` [Qemu-devel] [PATCH 3/8] migration: Add VMSTATE_WITH_TMP Dr. David Alan Gilbert (git)
2017-02-13 12:04 ` Juan Quintela
2016-10-27 15:32 ` [Qemu-devel] [PATCH 4/8] tests/migration: Add test for VMSTATE_WITH_TMP Dr. David Alan Gilbert (git)
2017-02-13 12:06 ` Juan Quintela
2016-10-27 15:32 ` Dr. David Alan Gilbert (git) [this message]
2017-02-13 12:06 ` [Qemu-devel] [PATCH 5/8] slirp: VMState conversion; tcpcb Juan Quintela
2016-10-27 15:32 ` [Qemu-devel] [PATCH 6/8] slirp: VMStatify sbuf Dr. David Alan Gilbert (git)
2016-10-30 14:40 ` Samuel Thibault
2017-02-13 12:07 ` Juan Quintela
2016-10-27 15:32 ` [Qemu-devel] [PATCH 7/8] slirp: VMStatify socket level Dr. David Alan Gilbert (git)
2016-10-30 14:47 ` Samuel Thibault
2016-11-07 19:55 ` Dr. David Alan Gilbert
2017-02-13 12:13 ` Juan Quintela
2016-10-27 15:32 ` [Qemu-devel] [PATCH 8/8] slirp: VMStatify remaining except for loop Dr. David Alan Gilbert (git)
2016-10-30 14:51 ` Samuel Thibault
2016-11-07 19:30 ` Dr. David Alan Gilbert
2017-02-13 12:09 ` Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161027153217.16984-6-dgilbert@redhat.com \
--to=dgilbert@redhat.com \
--cc=amit.shah@redhat.com \
--cc=duanj@linux.vnet.ibm.com \
--cc=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=samuel.thibault@ens-lyon.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.