qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, samuel.thibault@ens-lyon.org,
	jan.kiszka@siemens.com
Cc: quintela@redhat.com
Subject: [Qemu-devel] [PATCH v4 5/5] slirp: VMStatify remaining except for loop
Date: Mon, 20 Feb 2017 18:50:20 +0000	[thread overview]
Message-ID: <20170220185020.774-6-dgilbert@redhat.com> (raw)
In-Reply-To: <20170220185020.774-1-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

This converts the remaining components, except for the top level
loop, to VMState.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 slirp/slirp.c | 48 +++++++++++++++++++-----------------------------
 1 file changed, 19 insertions(+), 29 deletions(-)

diff --git a/slirp/slirp.c b/slirp/slirp.c
index 6583de8..f8ee7f9 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -1343,15 +1343,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)
 {
@@ -1371,22 +1381,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;
@@ -1421,13 +1419,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);
 }
-- 
2.9.3

  parent reply	other threads:[~2017-02-20 18:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20 18:50 [Qemu-devel] [PATCH v4 0/5] SLIRP VMStatification Dr. David Alan Gilbert (git)
2017-02-20 18:50 ` [Qemu-devel] [PATCH v4 1/5] slirp: VMState conversion; tcpcb Dr. David Alan Gilbert (git)
2017-02-20 18:50 ` [Qemu-devel] [PATCH v4 2/5] slirp: VMStatify sbuf Dr. David Alan Gilbert (git)
2017-02-20 18:50 ` [Qemu-devel] [PATCH v4 3/5] slirp: Common lhost/fhost union Dr. David Alan Gilbert (git)
2017-02-20 21:02   ` Philippe Mathieu-Daudé
2017-02-21 13:55   ` Juan Quintela
2017-02-20 18:50 ` [Qemu-devel] [PATCH v4 4/5] slirp: VMStatify socket level Dr. David Alan Gilbert (git)
2017-02-21 14:03   ` Juan Quintela
2017-02-21 14:08     ` Dr. David Alan Gilbert
2017-02-23 10:51     ` Dr. David Alan Gilbert
2017-02-23 11:04       ` Daniel P. Berrange
2017-02-23 11:40         ` Dr. David Alan Gilbert
2017-02-26 20:34           ` Samuel Thibault
2017-02-26 22:59             ` Samuel Thibault
2017-02-28 16:54             ` Dr. David Alan Gilbert
2017-02-28 16:57               ` Samuel Thibault
2017-02-28 17:00                 ` Dr. David Alan Gilbert
2017-02-28 17:02                   ` Samuel Thibault
2017-02-28 17:09                     ` Dr. David Alan Gilbert
2017-02-28 17:12                       ` Samuel Thibault
2017-02-28 17:40                         ` Dr. David Alan Gilbert
2017-02-28 22:09                           ` Samuel Thibault
2017-02-20 18:50 ` Dr. David Alan Gilbert (git) [this message]
2017-02-21 13:57   ` [Qemu-devel] [PATCH v4 5/5] slirp: VMStatify remaining except for loop Juan Quintela
2017-02-20 19:02 ` [Qemu-devel] [PATCH v4 0/5] SLIRP VMStatification no-reply

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=20170220185020.774-6-dgilbert@redhat.com \
    --to=dgilbert@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).