aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTang Chen <tangchen@cn.fujitsu.com>2012-08-22 12:10:24 +0800
committerDaniel Veillard <veillard@redhat.com>2012-08-22 18:23:58 +0800
commit15a71e60592afbb9200d1b9c3adcffb532ba7890 (patch)
treedf4bc5de515c4b8f3659d3b314c75c2996c658ca
parentImprove netlink to support all protocol. (diff)
downloadlibvirt-15a71e60592afbb9200d1b9c3adcffb532ba7890.tar.gz
libvirt-15a71e60592afbb9200d1b9c3adcffb532ba7890.tar.bz2
libvirt-15a71e60592afbb9200d1b9c3adcffb532ba7890.zip
Introduce virNetlinkEventServiceStopAll() to stop all netlink services.
This patch introduce virNetlinkEventServiceStopAll() to stop all the monitors to receive netlink messages for libvirtd. Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
-rw-r--r--daemon/libvirtd.c2
-rw-r--r--src/libvirt_private.syms1
-rw-r--r--src/util/virnetlink.c50
-rw-r--r--src/util/virnetlink.h5
4 files changed, 57 insertions, 1 deletions
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 96c8dddf2..c7f8d3b74 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1327,7 +1327,7 @@ int main(int argc, char **argv) {
0, "shutdown", NULL, NULL);
cleanup:
- virNetlinkEventServiceStop(NETLINK_ROUTE);
+ virNetlinkEventServiceStopAll();
virObjectUnref(remoteProgram);
virObjectUnref(qemuProgram);
virNetServerClose(srv);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8962de2ed..d91f492cc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1483,6 +1483,7 @@ virNetlinkEventRemoveClient;
virNetlinkEventServiceIsRunning;
virNetlinkEventServiceLocalPid;
virNetlinkEventServiceStop;
+virNetlinkEventServiceStopAll;
virNetlinkEventServiceStart;
virNetlinkShutdown;
virNetlinkStartup;
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 19619f5ed..2c5e9f315 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -405,6 +405,46 @@ virNetlinkEventServiceStop(unsigned int protocol)
}
/**
+ * virNetlinkEventServiceStopAll:
+ *
+ * Stop all the monitors to receive netlink messages for libvirtd.
+ *
+ * Returns -1 if any monitor cannot be unregistered, 0 upon success
+ */
+int
+virNetlinkEventServiceStopAll(void)
+{
+ unsigned int i, j;
+ virNetlinkEventSrvPrivatePtr srv = NULL;
+
+ VIR_INFO("stopping all netlink event services");
+
+ for (i = 0; i < MAX_LINKS; i++) {
+ srv = server[i];
+ if (!srv)
+ continue;
+
+ virNetlinkEventServerLock(srv);
+ nl_close(srv->netlinknh);
+ virNetlinkFree(srv->netlinknh);
+ virEventRemoveHandle(srv->eventwatch);
+
+ for (j = 0; j < srv->handlesCount; j++) {
+ if (srv->handles[j].deleted == VIR_NETLINK_HANDLE_VALID)
+ virNetlinkEventRemoveClientPrimitive(j, i);
+ }
+
+ server[i] = NULL;
+ virNetlinkEventServerUnlock(srv);
+
+ virMutexDestroy(&srv->lock);
+ VIR_FREE(srv);
+ }
+
+ return 0;
+}
+
+/**
* virNetlinkEventServiceIsRunning:
*
* Returns if the netlink event service is running.
@@ -732,6 +772,16 @@ int virNetlinkEventServiceStop(unsigned int protocol ATTRIBUTE_UNUSED)
}
/**
+ * stopNetlinkEventServerAll: stop all the monitors to receive netlink
+ * messages for libvirtd
+ */
+int virNetlinkEventServiceStopAll(void)
+{
+ VIR_DEBUG("%s", _(unsupported));
+ return 0;
+}
+
+/**
* startNetlinkEventServer: start a monitor to receive netlink
* messages for libvirtd
*/
diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h
index 2e18af403..1982dae5b 100644
--- a/src/util/virnetlink.h
+++ b/src/util/virnetlink.h
@@ -54,6 +54,11 @@ typedef void (*virNetlinkEventRemoveCallback)(int watch, const virMacAddrPtr mac
int virNetlinkEventServiceStop(unsigned int protocol);
/**
+ * stopNetlinkEventServerAll: stop all the monitors to receive netlink messages for libvirtd
+ */
+int virNetlinkEventServiceStopAll(void);
+
+/**
* startNetlinkEventServer: start a monitor to receive netlink messages for libvirtd
*/
int virNetlinkEventServiceStart(unsigned int protocol, unsigned int groups);