aboutsummaryrefslogtreecommitdiff
path: root/slirp/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'slirp/state.c')
-rw-r--r--slirp/state.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/slirp/state.c b/slirp/state.c
index 0e5a706e87..f5dd80cdc8 100644
--- a/slirp/state.c
+++ b/slirp/state.c
@@ -21,13 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "qemu/osdep.h"
-
#include "slirp.h"
+#include "vmstate.h"
#include "state.h"
-#include "migration/vmstate.h"
-#include "migration/qemu-file-types.h"
-#include "migration/register.h"
+#include "stream.h"
static int slirp_tcp_post_load(void *opaque, int version)
{
@@ -180,7 +177,7 @@ static int slirp_socket_pre_load(void *opaque)
#else
/* Win uses u_long rather than uint32_t - but it's still 32bits long */
#define VMSTATE_SIN4_ADDR(f, s, t) VMSTATE_SINGLE_TEST(f, s, t, 0, \
- vmstate_info_uint32, u_long)
+ slirp_vmstate_info_uint32, u_long)
#endif
/* The OS provided ss_family field isn't that portable; it's size
@@ -322,10 +319,13 @@ static const VMStateDescription vmstate_slirp = {
}
};
-static void slirp_state_save(QEMUFile *f, void *opaque)
+void slirp_state_save(Slirp *slirp, SlirpWriteCb write_cb, void *opaque)
{
- Slirp *slirp = opaque;
struct gfwd_list *ex_ptr;
+ SlirpOStream f = {
+ .write_cb = write_cb,
+ .opaque = opaque,
+ };
for (ex_ptr = slirp->guestfwd_list; ex_ptr; ex_ptr = ex_ptr->ex_next)
if (ex_ptr->write_cb) {
@@ -336,25 +336,29 @@ static void slirp_state_save(QEMUFile *f, void *opaque)
continue;
}
- qemu_put_byte(f, 42);
- vmstate_save_state(f, &vmstate_slirp_socket, so, NULL);
+ slirp_ostream_write_u8(&f, 42);
+ slirp_vmstate_save_state(&f, &vmstate_slirp_socket, so);
}
- qemu_put_byte(f, 0);
+ slirp_ostream_write_u8(&f, 0);
- vmstate_save_state(f, &vmstate_slirp, slirp, NULL);
+ slirp_vmstate_save_state(&f, &vmstate_slirp, slirp);
}
-static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)
+int slirp_state_load(Slirp *slirp, int version_id,
+ SlirpReadCb read_cb, void *opaque)
{
- Slirp *slirp = opaque;
struct gfwd_list *ex_ptr;
+ SlirpIStream f = {
+ .read_cb = read_cb,
+ .opaque = opaque,
+ };
- while (qemu_get_byte(f)) {
+ while (slirp_istream_read_u8(&f)) {
int ret;
struct socket *so = socreate(slirp);
- ret = vmstate_load_state(f, &vmstate_slirp_socket, so, version_id);
+ ret = slirp_vmstate_load_state(&f, &vmstate_slirp_socket, so, version_id);
if (ret < 0) {
return ret;
}
@@ -375,20 +379,10 @@ static int slirp_state_load(QEMUFile *f, void *opaque, int version_id)
}
}
- return vmstate_load_state(f, &vmstate_slirp, slirp, version_id);
-}
-
-void slirp_state_register(Slirp *slirp)
-{
- static SaveVMHandlers savevm_slirp_state = {
- .save_state = slirp_state_save,
- .load_state = slirp_state_load,
- };
-
- register_savevm_live(NULL, "slirp", 0, 4, &savevm_slirp_state, slirp);
+ return slirp_vmstate_load_state(&f, &vmstate_slirp, slirp, version_id);
}
-void slirp_state_unregister(Slirp *slirp)
+int slirp_state_version(void)
{
- unregister_savevm(NULL, "slirp", slirp);
+ return 4;
}