slirp: Fix migration from older versions of QEMU to the current one
While adding the IPv6 support, the commit eae303ff23
("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 <thuth@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
parent
57528a3fef
commit
eaf136f9a2
|
@ -1233,31 +1233,39 @@ static int slirp_sbuf_load(QEMUFile *f, struct sbuf *sbuf)
|
||||||
return 0;
|
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)
|
if (tcp_attach(so) < 0)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
so->so_urgc = qemu_get_be32(f);
|
so->so_urgc = qemu_get_be32(f);
|
||||||
so->so_ffamily = qemu_get_be16(f);
|
if (version_id <= 3) {
|
||||||
switch (so->so_ffamily) {
|
so->so_ffamily = AF_INET;
|
||||||
case AF_INET:
|
|
||||||
so->so_faddr.s_addr = qemu_get_be32(f);
|
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_laddr.s_addr = qemu_get_be32(f);
|
||||||
|
so->so_fport = qemu_get_be16(f);
|
||||||
so->so_lport = qemu_get_be16(f);
|
so->so_lport = qemu_get_be16(f);
|
||||||
break;
|
} else {
|
||||||
default:
|
so->so_ffamily = qemu_get_be16(f);
|
||||||
error_report(
|
switch (so->so_ffamily) {
|
||||||
"so_ffamily unknown, unable to restore so_laddr and so_lport\n");
|
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_iptos = qemu_get_byte(f);
|
||||||
so->so_emu = 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)
|
if (!so)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = slirp_socket_load(f, so);
|
ret = slirp_socket_load(f, so, version_id);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue