timers: Createt TimersState and put all timers state there
[qemu] / net.c
diff --git a/net.c b/net.c
index d21f0e9..4510694 100644 (file)
--- a/net.c
+++ b/net.c
@@ -31,6 +31,8 @@
 
 /* Needed early for CONFIG_BSD etc. */
 #include "config-host.h"
+/* Needed early to override system queue definitions on BSD */
+#include "sys-queue.h"
 
 #ifndef _WIN32
 #include <sys/times.h>
@@ -897,8 +899,7 @@ static SlirpState *slirp_lookup(Monitor *mon, const char *vlan,
     }
 }
 
-void net_slirp_hostfwd_remove(Monitor *mon, const char *arg1,
-                              const char *arg2, const char *arg3)
+void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict)
 {
     struct in_addr host_addr = { .s_addr = INADDR_ANY };
     int host_port;
@@ -907,6 +908,9 @@ void net_slirp_hostfwd_remove(Monitor *mon, const char *arg1,
     SlirpState *s;
     int is_udp = 0;
     int err;
+    const char *arg1 = qdict_get_str(qdict, "arg1");
+    const char *arg2 = qdict_get_try_str(qdict, "arg2");
+    const char *arg3 = qdict_get_try_str(qdict, "arg3");
 
     if (arg2) {
         s = slirp_lookup(mon, arg1, arg2);
@@ -1016,11 +1020,13 @@ static void slirp_hostfwd(SlirpState *s, Monitor *mon, const char *redir_str,
     config_error(mon, "invalid host forwarding rule '%s'\n", redir_str);
 }
 
-void net_slirp_hostfwd_add(Monitor *mon, const char *arg1,
-                           const char *arg2, const char *arg3)
+void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict)
 {
     const char *redir_str;
     SlirpState *s;
+    const char *arg1 = qdict_get_str(qdict, "arg1");
+    const char *arg2 = qdict_get_try_str(qdict, "arg2");
+    const char *arg3 = qdict_get_try_str(qdict, "arg3");
 
     if (arg2) {
         s = slirp_lookup(mon, arg1, arg2);
@@ -2248,7 +2254,7 @@ static ssize_t dump_receive(VLANClientState *vc, const uint8_t *buf, size_t size
         return size;
     }
 
-    ts = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec);
+    ts = muldiv64(qemu_get_clock(vm_clock), 1000000, get_ticks_per_sec());
     caplen = size > s->pcap_caplen ? s->pcap_caplen : size;
 
     hdr.ts.tv_sec = ts / 1000000;
@@ -2822,8 +2828,11 @@ static int net_host_check_device(const char *device)
     return 0;
 }
 
-void net_host_device_add(Monitor *mon, const char *device, const char *opts)
+void net_host_device_add(Monitor *mon, const QDict *qdict)
 {
+    const char *device = qdict_get_str(qdict, "device");
+    const char *opts = qdict_get_try_str(qdict, "opts");
+
     if (!net_host_check_device(device)) {
         monitor_printf(mon, "invalid host network device %s\n", device);
         return;
@@ -2833,9 +2842,11 @@ void net_host_device_add(Monitor *mon, const char *device, const char *opts)
     }
 }
 
-void net_host_device_remove(Monitor *mon, int vlan_id, const char *device)
+void net_host_device_remove(Monitor *mon, const QDict *qdict)
 {
     VLANClientState *vc;
+    int vlan_id = qdict_get_int(qdict, "vlan_id");
+    const char *device = qdict_get_str(qdict, "device");
 
     vc = qemu_find_vlan_client_by_name(mon, vlan_id, device);
     if (!vc) {
@@ -2900,10 +2911,12 @@ void do_info_network(Monitor *mon)
     }
 }
 
-void do_set_link(Monitor *mon, const char *name, const char *up_or_down)
+void do_set_link(Monitor *mon, const QDict *qdict)
 {
     VLANState *vlan;
     VLANClientState *vc = NULL;
+    const char *name = qdict_get_str(qdict, "name");
+    const char *up_or_down = qdict_get_str(qdict, "up_or_down");
 
     for (vlan = first_vlan; vlan != NULL; vlan = vlan->next)
         for (vc = vlan->first_client; vc != NULL; vc = vc->next)