qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: samuel.thibault@ens-lyon.org, thuth@redhat.com,
	dbuono@linux.vnet.ibm.com
Subject: [RFC PATCH 1/4] net: slirp: introduce a wrapper struct for QemuTimer
Date: Tue, 12 Apr 2022 14:13:34 +0200	[thread overview]
Message-ID: <20220412121337.207203-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20220412121337.207203-1-pbonzini@redhat.com>

This struct will be extended in the next few patches to support the
new slirp_handle_timer() call.  For that we need to store an additional
"int" for each SLIRP timer, in addition to the cb_opaque.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 net/slirp.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index bc5e9e4f77..f1e25d741f 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -184,23 +184,32 @@ static int64_t net_slirp_clock_get_ns(void *opaque)
     return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
 }
 
+struct SlirpTimer {
+    QEMUTimer timer;
+}
+
 static void *net_slirp_timer_new(SlirpTimerCb cb,
                                  void *cb_opaque, void *opaque)
 {
-    return timer_new_full(NULL, QEMU_CLOCK_VIRTUAL,
-                          SCALE_MS, QEMU_TIMER_ATTR_EXTERNAL,
-                          cb, cb_opaque);
+    SlirpTimer *t = g_new(SlirpTimer, 1);
+    timer_init_full(&t->timer, NULL, QEMU_CLOCK_VIRTUAL,
+                    SCALE_MS, QEMU_TIMER_ATTR_EXTERNAL,
+                    cb, cb_opaque);
+    return t;
 }
 
 static void net_slirp_timer_free(void *timer, void *opaque)
 {
-    timer_free(timer);
+    SlirpTimer *t = timer;
+    timer_del(&t->timer);
+    g_free(t);
 }
 
 static void net_slirp_timer_mod(void *timer, int64_t expire_timer,
                                 void *opaque)
 {
-    timer_mod(timer, expire_timer);
+    SlirpTimer *t = timer;
+    timer_mod(&t->timer, expire_timer);
 }
 
 static void net_slirp_register_poll_fd(int fd, void *opaque)
-- 
2.35.1




  reply	other threads:[~2022-04-12 12:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 12:13 [RFC PATCH 0/4] net: support for CFI with libslirp >= 4.7 Paolo Bonzini
2022-04-12 12:13 ` Paolo Bonzini [this message]
2022-04-26 23:11   ` [RFC PATCH 1/4] net: slirp: introduce a wrapper struct for QemuTimer Samuel Thibault
2022-04-12 12:13 ` [RFC PATCH 2/4] net: slirp: switch to slirp_new Paolo Bonzini
2022-04-26 23:12   ` Samuel Thibault
2022-04-12 12:13 ` [RFC PATCH 3/4] net: slirp: add support for CFI-friendly timer API Paolo Bonzini
2022-04-26 23:15   ` Samuel Thibault
2022-04-12 12:13 ` [RFC PATCH 4/4] net: slirp: allow CFI with libslirp >= 4.7 Paolo Bonzini
2022-04-26 23:19   ` Samuel Thibault

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=20220412121337.207203-2-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dbuono@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=thuth@redhat.com \
    /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).