diff options
author | Dr. David Alan Gilbert <dgilbert@redhat.com> | 2017-04-03 18:18:43 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2017-04-29 18:44:16 +0200 |
commit | eb5d4f5329df83ea15244b47f7fbca21adaae41b (patch) | |
tree | 590f4682bc0bc894c92b5b4dcee2f1e34ff391ea /slirp | |
parent | 14650df4020c60be6c498f05622ac07338cebb09 (diff) |
slirp: VMStatify remaining except for loop
This converts the remaining components, except for the top level
loop, to VMState.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/slirp.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/slirp/slirp.c b/slirp/slirp.c index c3426648e5..2f2ec2c1b3 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -1402,15 +1402,25 @@ static const VMStateDescription vmstate_slirp_socket = { } }; -static void slirp_bootp_save(QEMUFile *f, Slirp *slirp) -{ - int i; +static const VMStateDescription vmstate_slirp_bootp_client = { + .name = "slirp_bootpclient", + .fields = (VMStateField[]) { + VMSTATE_UINT16(allocated, BOOTPClient), + VMSTATE_BUFFER(macaddr, BOOTPClient), + VMSTATE_END_OF_LIST() + } +}; - for (i = 0; i < NB_BOOTP_CLIENTS; i++) { - qemu_put_be16(f, slirp->bootp_clients[i].allocated); - qemu_put_buffer(f, slirp->bootp_clients[i].macaddr, 6); +static const VMStateDescription vmstate_slirp = { + .name = "slirp", + .version_id = 4, + .fields = (VMStateField[]) { + VMSTATE_UINT16_V(ip_id, Slirp, 2), + VMSTATE_STRUCT_ARRAY(bootp_clients, Slirp, NB_BOOTP_CLIENTS, 3, + vmstate_slirp_bootp_client, BOOTPClient), + VMSTATE_END_OF_LIST() } -} +}; static void slirp_state_save(QEMUFile *f, void *opaque) { @@ -1430,22 +1440,10 @@ static void slirp_state_save(QEMUFile *f, void *opaque) } qemu_put_byte(f, 0); - qemu_put_be16(f, slirp->ip_id); - - slirp_bootp_save(f, slirp); + vmstate_save_state(f, &vmstate_slirp, slirp, NULL); } -static void slirp_bootp_load(QEMUFile *f, Slirp *slirp) -{ - int i; - - for (i = 0; i < NB_BOOTP_CLIENTS; i++) { - slirp->bootp_clients[i].allocated = qemu_get_be16(f); - qemu_get_buffer(f, slirp->bootp_clients[i].macaddr, 6); - } -} - static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) { Slirp *slirp = opaque; @@ -1480,13 +1478,5 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id) so->extra = (void *)ex_ptr->ex_exec; } - if (version_id >= 2) { - slirp->ip_id = qemu_get_be16(f); - } - - if (version_id >= 3) { - slirp_bootp_load(f, slirp); - } - - return 0; + return vmstate_load_state(f, &vmstate_slirp, slirp, version_id); } |