[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH COLO-Frame v15 33/38] net: Add notifier/callback for
From: |
zhanghailiang |
Subject: |
[Qemu-devel] [PATCH COLO-Frame v15 33/38] net: Add notifier/callback for netdev init |
Date: |
Mon, 22 Feb 2016 10:40:27 +0800 |
We can register some callback for this notifier,
this will be used by COLO to register a callback which
will add each netdev a buffer filter.
Signed-off-by: zhanghailiang <address@hidden>
Cc: Jason Wang <address@hidden>
Cc: Yang Hongyang <address@hidden>
---
v14:
- New patch
---
include/net/net.h | 4 ++++
net/net.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/net/net.h b/include/net/net.h
index 73e4c46..f6f0194 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -176,6 +176,10 @@ struct NICInfo {
int nvectors;
};
+typedef struct netdev_init_entry NetdevInitEntry;
+typedef void NetdevInitHandler(const char *netdev_id, void *opaque);
+NetdevInitEntry *netdev_init_add_handler(NetdevInitHandler *cb, void *opaque);
+
extern int nb_nics;
extern NICInfo nd_table[MAX_NICS];
extern int default_net;
diff --git a/net/net.c b/net/net.c
index aebf753..bdd3e7b 100644
--- a/net/net.c
+++ b/net/net.c
@@ -55,6 +55,14 @@
static VMChangeStateEntry *net_change_state_entry;
static QTAILQ_HEAD(, NetClientState) net_clients;
+struct netdev_init_entry {
+ NetdevInitHandler *cb;
+ void *opaque;
+ QLIST_ENTRY(netdev_init_entry) entries;
+};
+
+static QLIST_HEAD(netdev_init_head, netdev_init_entry)netdev_init_head;
+
const char *host_net_devices[] = {
"tap",
"socket",
@@ -953,6 +961,26 @@ static int net_init_nic(const NetClientOptions *opts,
const char *name,
return idx;
}
+NetdevInitEntry *netdev_init_add_handler(NetdevInitHandler *cb, void *opaque)
+{
+ NetdevInitEntry *e;
+
+ e = g_malloc0(sizeof(*e));
+
+ e->cb = cb;
+ e->opaque = opaque;
+ QLIST_INSERT_HEAD(&netdev_init_head, e, entries);
+ return e;
+}
+
+static void netdev_init_notify(const char *netdev_id)
+{
+ NetdevInitEntry *e, *next;
+
+ QLIST_FOREACH_SAFE(e, &netdev_init_head, entries, next) {
+ e->cb(netdev_id, e->opaque);
+ }
+}
static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND__MAX])(
const NetClientOptions *opts,
@@ -1039,6 +1067,11 @@ static int net_client_init1(const void *object, int
is_netdev, Error **errp)
}
return -1;
}
+ if (is_netdev) {
+ const Netdev *netdev = object;
+
+ netdev_init_notify(netdev->id);
+ }
return 0;
}
--
1.8.3.1
- [Qemu-devel] [PATCH COLO-Frame v15 14/38] COLO: Flush PVM's cached RAM into SVM's memory, (continued)
- [Qemu-devel] [PATCH COLO-Frame v15 14/38] COLO: Flush PVM's cached RAM into SVM's memory, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 23/38] COLO failover: Don't do failover during loading VM's state, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 17/38] COLO failover: Introduce a new command to trigger a failover, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 25/38] COLO: Update the global runstate after going into colo state, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 30/38] COLO: Split qemu_savevm_state_begin out of checkpoint process, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 18/38] COLO failover: Introduce state to record failover process, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 24/38] COLO: Process shutdown command for VM in COLO state, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 29/38] COLO: Separate the process of saving/loading ram and device state, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 33/38] net: Add notifier/callback for netdev init,
zhanghailiang <=
- [Qemu-devel] [PATCH COLO-Frame v15 13/38] COLO: Load VMState into qsb before restore it, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 32/38] filter-buffer: Accept zero interval, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 35/38] COLO: manage the status of buffer filters for PVM, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 26/38] savevm: Introduce two helper functions for save/find loadvm_handlers entry, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 34/38] COLO/filter: add each netdev a buffer filter, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 21/38] qmp event: Add COLO_EXIT event to notify users while exited from COLO, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 31/38] net/filter: Add a 'status' property for filter object, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 38/38] COLO: Add block replication into colo process, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 22/38] COLO failover: Shutdown related socket fd when do failover, zhanghailiang, 2016/02/21
- [Qemu-devel] [PATCH COLO-Frame v15 36/38] filter-buffer: make filter_buffer_flush() public, zhanghailiang, 2016/02/21