Commit 0a1f851eb7f3eee5f980a0bdb6687eeee1b60a71
Committed by
Anthony Liguori
1 parent
b1c99fcd
slirp: Save/restore bootp client states
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
27 additions
and
1 deletions
slirp/slirp.c
@@ -222,7 +222,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, | @@ -222,7 +222,7 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, | ||
222 | 222 | ||
223 | slirp->opaque = opaque; | 223 | slirp->opaque = opaque; |
224 | 224 | ||
225 | - register_savevm("slirp", 0, 2, slirp_state_save, slirp_state_load, slirp); | 225 | + register_savevm("slirp", 0, 3, slirp_state_save, slirp_state_load, slirp); |
226 | 226 | ||
227 | TAILQ_INSERT_TAIL(&slirp_instances, slirp, entry); | 227 | TAILQ_INSERT_TAIL(&slirp_instances, slirp, entry); |
228 | 228 | ||
@@ -942,6 +942,16 @@ static void slirp_socket_save(QEMUFile *f, struct socket *so) | @@ -942,6 +942,16 @@ static void slirp_socket_save(QEMUFile *f, struct socket *so) | ||
942 | slirp_tcp_save(f, so->so_tcpcb); | 942 | slirp_tcp_save(f, so->so_tcpcb); |
943 | } | 943 | } |
944 | 944 | ||
945 | +static void slirp_bootp_save(QEMUFile *f, Slirp *slirp) | ||
946 | +{ | ||
947 | + int i; | ||
948 | + | ||
949 | + for (i = 0; i < NB_BOOTP_CLIENTS; i++) { | ||
950 | + qemu_put_be16(f, slirp->bootp_clients[i].allocated); | ||
951 | + qemu_put_buffer(f, slirp->bootp_clients[i].macaddr, 6); | ||
952 | + } | ||
953 | +} | ||
954 | + | ||
945 | static void slirp_state_save(QEMUFile *f, void *opaque) | 955 | static void slirp_state_save(QEMUFile *f, void *opaque) |
946 | { | 956 | { |
947 | Slirp *slirp = opaque; | 957 | Slirp *slirp = opaque; |
@@ -961,6 +971,8 @@ static void slirp_state_save(QEMUFile *f, void *opaque) | @@ -961,6 +971,8 @@ static void slirp_state_save(QEMUFile *f, void *opaque) | ||
961 | qemu_put_byte(f, 0); | 971 | qemu_put_byte(f, 0); |
962 | 972 | ||
963 | qemu_put_be16(f, slirp->ip_id); | 973 | qemu_put_be16(f, slirp->ip_id); |
974 | + | ||
975 | + slirp_bootp_save(f, slirp); | ||
964 | } | 976 | } |
965 | 977 | ||
966 | static void slirp_tcp_load(QEMUFile *f, struct tcpcb *tp) | 978 | static void slirp_tcp_load(QEMUFile *f, struct tcpcb *tp) |
@@ -1057,6 +1069,16 @@ static int slirp_socket_load(QEMUFile *f, struct socket *so) | @@ -1057,6 +1069,16 @@ static int slirp_socket_load(QEMUFile *f, struct socket *so) | ||
1057 | return 0; | 1069 | return 0; |
1058 | } | 1070 | } |
1059 | 1071 | ||
1072 | +static void slirp_bootp_load(QEMUFile *f, Slirp *slirp) | ||
1073 | +{ | ||
1074 | + int i; | ||
1075 | + | ||
1076 | + for (i = 0; i < NB_BOOTP_CLIENTS; i++) { | ||
1077 | + slirp->bootp_clients[i].allocated = qemu_get_be16(f); | ||
1078 | + qemu_get_buffer(f, slirp->bootp_clients[i].macaddr, 6); | ||
1079 | + } | ||
1080 | +} | ||
1081 | + | ||
1060 | static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) | 1082 | static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) |
1061 | { | 1083 | { |
1062 | Slirp *slirp = opaque; | 1084 | Slirp *slirp = opaque; |
@@ -1096,5 +1118,9 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) | @@ -1096,5 +1118,9 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) | ||
1096 | slirp->ip_id = qemu_get_be16(f); | 1118 | slirp->ip_id = qemu_get_be16(f); |
1097 | } | 1119 | } |
1098 | 1120 | ||
1121 | + if (version_id >= 3) { | ||
1122 | + slirp_bootp_load(f, slirp); | ||
1123 | + } | ||
1124 | + | ||
1099 | return 0; | 1125 | return 0; |
1100 | } | 1126 | } |