tangchen | 23 Jul 2012 08:33
Favicon

[libvirt] [PATCH 0/4] Improve netlink to support all protocols.

Now, netlink in libvirt only suport NETLINK_ROUTE protocol.
But we need other netlinks, especially to support cpu and memory hotplug.

These patches did the following things:
    1) Change global variable "server" to an array to store all the netlink sockets,
       and modified all the API prototypes.
    2) Introduce a new API virNetlinkEventServiceStopAll() to stop all netlink servers.
    3) Modify all the function calls.

Tang Chen (4):
  Improve netlink to support all protocol.
  Introduce virNetlinkEventServiceStopAll() to stop all netlink    
    services in libvirt.
  Modify all the function calls for API in virnetlink.c
  DEBUG: print out netlink message.

 daemon/libvirtd.c                |   12 +-
 src/libvirt_private.syms         |    1 +
 src/util/virnetdev.c             |    6 +-
 src/util/virnetdevmacvlan.c      |   12 +-
 src/util/virnetdevvportprofile.c |    7 +-
 src/util/virnetlink.c            |  235 +++++++++++++++++++++++++++++++-------
 src/util/virnetlink.h            |   22 ++--
 7 files changed, 232 insertions(+), 63 deletions(-)

-- 
1.7.10.2

--

-- 
Best Regards,
(Continue reading)

tangchen | 23 Jul 2012 08:39
Favicon

[libvirt] [PATCH 1/4] Improve netlink to support all protocol.

This patch improve all the API in virnetlink.c to support
all kinds of netlink protocols, and make all netlink sockets
be able to join in groups.

Signed-off-by: Tang Chen <tangchen <at> cn.fujitsu.com>
---
 src/util/virnetlink.c |  183 +++++++++++++++++++++++++++++++++++++------------
 src/util/virnetlink.h |   17 +++--
 2 files changed, 150 insertions(+), 50 deletions(-)

diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 222e2fa..c1e198d 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
 <at>  <at>  -33,6 +33,7  <at>  <at> 
 #include <errno.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <sys/socket.h>

 #include "virnetlink.h"
 #include "logging.h"
 <at>  <at>  -93,7 +94,7  <at>  <at>  static int nextWatch = 1;
  records in this multiple */
 # define NETLINK_EVENT_ALLOC_EXTENT 10

-static virNetlinkEventSrvPrivatePtr server = NULL;
+static virNetlinkEventSrvPrivatePtr server[MAX_LINKS] = {NULL};
 static virNetlinkHandle *placeholder_nlhandle = NULL;

(Continue reading)

tangchen | 23 Jul 2012 08:40
Favicon

[libvirt] [PATCH 2/4] Introduce virNetlinkEventServiceStopAll() to stop all netlink services in libvirt.

This patch introduce virNetlinkEventServiceStopAll() to stop
all the monitors to receive netlink messages for libvirtd.

Signed-off-by: Tang Chen <tangchen <at> cn.fujitsu.com>
---
 src/libvirt_private.syms |    1 +
 src/util/virnetlink.c    |   50 ++++++++++++++++++++++++++++++++++++++++++++++
 src/util/virnetlink.h    |    5 +++++
 3 files changed, 56 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 03f7f3e..5880cc4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
 <at>  <at>  -1382,6 +1382,7  <at>  <at>  virNetlinkEventRemoveClient;
 virNetlinkEventServiceIsRunning;
 virNetlinkEventServiceLocalPid;
 virNetlinkEventServiceStop;
+virNetlinkEventServiceStopAll;
 virNetlinkEventServiceStart;
 virNetlinkShutdown;
 virNetlinkStartup;
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index c1e198d..401a8eb 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
 <at>  <at>  -405,6 +405,46  <at>  <at>  virNetlinkEventServiceStop(unsigned int protocol)
 }

 /**
(Continue reading)

tangchen | 23 Jul 2012 08:41
Favicon

[libvirt] [PATCH 3/4] Modify all the function calls for API in virnetlink.c

This patch fixes the function prototype in all the callers
of for API in virnetlink.c

Signed-off-by: Tang Chen <tangchen <at> cn.fujitsu.com>
---
 daemon/libvirtd.c                |   12 +++++++++---
 src/util/virnetdev.c             |    6 ++++--
 src/util/virnetdevmacvlan.c      |   12 +++++++-----
 src/util/virnetdevvportprofile.c |    7 ++++---
 4 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 8c434a0..72ae207 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
 <at>  <at>  -1290,8 +1290,14  <at>  <at>  int main(int argc, char **argv) {
         goto cleanup;
     }

-    /* Register the netlink event service */
-    if (virNetlinkEventServiceStart() < 0) {
+    /* Register the netlink event service for NETLINK_ROUTE */
+    if (virNetlinkEventServiceStart(NETLINK_ROUTE, 0) < 0) {
+        ret = VIR_DAEMON_ERR_NETWORK;
+        goto cleanup;
+    }
+
+    /* Register the netlink event service for NETLINK_KOBJECT_UEVENT */
+    if (virNetlinkEventServiceStart(NETLINK_KOBJECT_UEVENT, 1) < 0) {
         ret = VIR_DAEMON_ERR_NETWORK;
(Continue reading)

tangchen | 23 Jul 2012 08:41
Favicon

[libvirt] [PATCH 4/4] DEBUG: print out netlink message.

Signed-off-by: Tang Chen <tangchen <at> cn.fujitsu.com>
---
 src/util/virnetlink.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 401a8eb..b6c5ded 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
 <at>  <at>  -340,6 +340,8  <at>  <at>  virNetlinkEventCallback(int watch,
         return;
     }

+    VIR_DEBUG("Netlink msg: %s", msg);
+
     virNetlinkEventServerLock(srv);

     VIR_DEBUG("dispatching to max %d clients, called from event watch %d",
--

-- 
1.7.10.2

tangchen | 26 Jul 2012 07:54
Favicon

Re: [libvirt] [PATCH 0/4] Improve netlink to support all protocols.

Hi Viktor, Eric:

Would you please have a look at thest patches ?

If this way is acceptable, I will improve libvirt to support cpu hotplug uevent based on netlink.

Thanks. :)

On 07/23/2012 02:33 PM, tangchen wrote:
> Now, netlink in libvirt only suport NETLINK_ROUTE protocol.
> But we need other netlinks, especially to support cpu and memory hotplug.
> 
> These patches did the following things:
>     1) Change global variable "server" to an array to store all the netlink sockets,
>        and modified all the API prototypes.
>     2) Introduce a new API virNetlinkEventServiceStopAll() to stop all netlink servers.
>     3) Modify all the function calls.
> 
> Tang Chen (4):
>   Improve netlink to support all protocol.
>   Introduce virNetlinkEventServiceStopAll() to stop all netlink    
>     services in libvirt.
>   Modify all the function calls for API in virnetlink.c
>   DEBUG: print out netlink message.
> 
>  daemon/libvirtd.c                |   12 +-
>  src/libvirt_private.syms         |    1 +
>  src/util/virnetdev.c             |    6 +-
>  src/util/virnetdevmacvlan.c      |   12 +-
>  src/util/virnetdevvportprofile.c |    7 +-
(Continue reading)


Gmane