Revision: 457
          http://vde.svn.sourceforge.net/vde/?rev=457&view=rev
Author:   rd235
Date:     2011-01-10 14:41:35 +0000 (Mon, 10 Jan 2011)

Log Message:
-----------
Basic support for libvirt (uml, qemu/kvm)

Modified Paths:
--------------
    trunk/vde-2/src/vde_switch/plugins/iplog.c

Added Paths:
-----------
    trunk/vde-2/libvirt/
    trunk/vde-2/libvirt/README
    trunk/vde-2/libvirt/libvirt-0.8.7.vde.patch

Added: trunk/vde-2/libvirt/README
===================================================================
--- trunk/vde-2/libvirt/README                          (rev 0)
+++ trunk/vde-2/libvirt/README  2011-01-10 14:41:35 UTC (rev 457)
@@ -0,0 +1,22 @@
+This patch defines and manages the syntax:
+
+<domain ....>
+ <device>
+   <interface type='vde'>
+        ...
+               <switch path='/tmp/vde.ctl'/>
+        </interface>
+ </device>
+</domain>
+
+the switch tag can be omitted: vde uses the default switch.
+qemu/kvm support: tested.
+user-mode linux support is included but not tested yet.
+libvirt vde support for virtualbox has not been coded yet.
+
+INSTALL:
+download libvirt-0.8.7
+..../libvirt-0.8.7$ patch -p 1 < libvirt-0.8.7.vde.patch
+..../libvirt-0.8.7$ configure
+..../libvirt-0.8.7$ make
+..../libvirt-0.8.7$ sudo make install

Added: trunk/vde-2/libvirt/libvirt-0.8.7.vde.patch
===================================================================
--- trunk/vde-2/libvirt/libvirt-0.8.7.vde.patch                         (rev 0)
+++ trunk/vde-2/libvirt/libvirt-0.8.7.vde.patch 2011-01-10 14:41:35 UTC (rev 
457)
@@ -0,0 +1,140 @@
+--- a/src/lxc/lxc_driver.c  2011-01-10 11:49:49.000000000 +0100
++++ b/src/lxc/lxc_driver.c  2011-01-10 11:50:03.000000000 +0100
+@@ -1083,6 +1083,7 @@
+         case VIR_DOMAIN_NET_TYPE_INTERNAL:
+         case VIR_DOMAIN_NET_TYPE_DIRECT:
+         case VIR_DOMAIN_NET_TYPE_LAST:
++        case VIR_DOMAIN_NET_TYPE_VDE:
+             break;
+         }
+ 
+--- a/src/uml/uml_conf.c  2011-01-10 12:03:54.000000000 +0100
++++ b/src/uml/uml_conf.c  2011-01-10 13:26:08.000000000 +0100
+@@ -269,6 +269,14 @@
+         virBufferVSprintf(&buf, "tuntap,%s", def->ifname);
+         break;
+ 
++    case VIR_DOMAIN_NET_TYPE_VDE:
++        /* ethNNN=vde,vde_switch,macaddr,port,group,mode,description */
++        if (def->data.vde.vdeswitch) {
++          virBufferVSprintf(&buf, "vde,%s", def->data.vde.vdeswitch);
++        } else
++          virBufferAddLit(&buf, "vde");
++        break;
++
+     case VIR_DOMAIN_NET_TYPE_INTERNAL:
+         umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                        _("internal networking type not supported"));
+--- a/src/conf/domain_conf.h  2011-01-10 11:41:07.000000000 +0100
++++ b/src/conf/domain_conf.h  2011-01-10 13:21:08.000000000 +0100
+@@ -288,6 +288,7 @@
+     VIR_DOMAIN_NET_TYPE_BRIDGE,
+     VIR_DOMAIN_NET_TYPE_INTERNAL,
+     VIR_DOMAIN_NET_TYPE_DIRECT,
++    VIR_DOMAIN_NET_TYPE_VDE,
+ 
+     VIR_DOMAIN_NET_TYPE_LAST,
+ };
+@@ -336,6 +337,9 @@
+             int mode;
+             virVirtualPortProfileParams virtPortProfile;
+         } direct;
++        struct {
++          char *vdeswitch;
++        } vde;
+     } data;
+     char *ifname;
+     virDomainDeviceInfo info;
+--- a/src/conf/domain_conf.c  2011-01-10 11:42:04.000000000 +0100
++++ b/src/conf/domain_conf.c  2011-01-10 14:49:46.000000000 +0100
+@@ -182,7 +182,8 @@
+               "network",
+               "bridge",
+               "internal",
+-              "direct")
++              "direct",
++              "vde")
+ 
+ VIR_ENUM_IMPL(virDomainChrChannelTarget,
+               VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
+@@ -598,6 +599,10 @@
+         VIR_FREE(def->data.direct.linkdev);
+         break;
+ 
++    case VIR_DOMAIN_NET_TYPE_VDE:
++        VIR_FREE(def->data.vde.vdeswitch);
++        break;
++
+     case VIR_DOMAIN_NET_TYPE_USER:
+     case VIR_DOMAIN_NET_TYPE_LAST:
+         break;
+@@ -2293,6 +2298,7 @@
+     char *internal = NULL;
+     char *devaddr = NULL;
+     char *mode = NULL;
++    char *vdeswitch = NULL;
+     virNWFilterHashTablePtr filterparams = NULL;
+     virVirtualPortProfileParams virtPort;
+     bool virtPortParsed = false;
+@@ -2379,7 +2385,11 @@
+                        xmlStrEqual(cur->name, BAD_CAST "state")) {
+                 /* Legacy back-compat. Don't add any more attributes here */
+                 devaddr = virXMLPropString(cur, "devaddr");
+-            }
++            } else if ((vdeswitch == NULL) &&
++                def->type == VIR_DOMAIN_NET_TYPE_VDE &&
++                xmlStrEqual(cur->name, BAD_CAST "switch")) {
++              vdeswitch = virXMLPropString(cur, "path");
++            }
+         }
+         cur = cur->next;
+     }
+@@ -2529,6 +2539,11 @@
+ 
+         break;
+ 
++    case VIR_DOMAIN_NET_TYPE_VDE:
++        def->data.vde.vdeswitch = vdeswitch;
++        vdeswitch = NULL;
++        break;
++
+     case VIR_DOMAIN_NET_TYPE_USER:
+     case VIR_DOMAIN_NET_TYPE_LAST:
+         break;
+@@ -6263,6 +6278,12 @@
+                                     "      ");
+         break;
+ 
++    case VIR_DOMAIN_NET_TYPE_VDE:
++        if (def->data.vde.vdeswitch)
++          virBufferEscapeString(buf, "      <switch path='%s'/>\n",
++              def->data.vde.vdeswitch);
++        break;
++
+     case VIR_DOMAIN_NET_TYPE_USER:
+     case VIR_DOMAIN_NET_TYPE_LAST:
+         break;
+--- a/src/qemu/qemu_command.c  2011-01-10 13:11:17.000000000 +0100
++++ b/src/qemu/qemu_command.c  2011-01-10 13:26:28.000000000 +0100
+@@ -1602,12 +1602,21 @@
+         case VIR_DOMAIN_NET_TYPE_BRIDGE:
+         case VIR_DOMAIN_NET_TYPE_INTERNAL:
+         case VIR_DOMAIN_NET_TYPE_DIRECT:
++        case VIR_DOMAIN_NET_TYPE_VDE:
+         case VIR_DOMAIN_NET_TYPE_LAST:
+             break;
+         }
+         type_sep = ',';
+         break;
+ 
++    case VIR_DOMAIN_NET_TYPE_VDE:
++        virBufferAddLit(&buf, "vde");
++        if (net->data.vde.vdeswitch)
++          virBufferVSprintf(&buf, "%csock=%s",
++              type_sep,
++              net->data.vde.vdeswitch);
++        break;
++
+     case VIR_DOMAIN_NET_TYPE_USER:
+     default:
+         virBufferAddLit(&buf, "user");

Modified: trunk/vde-2/src/vde_switch/plugins/iplog.c
===================================================================
--- trunk/vde-2/src/vde_switch/plugins/iplog.c  2010-12-05 09:06:18 UTC (rev 
456)
+++ trunk/vde-2/src/vde_switch/plugins/iplog.c  2011-01-10 14:41:35 UTC (rev 
457)
@@ -183,12 +183,14 @@
        } 
        now=qtime();
        e->last_seen = now;
-       if(e->port != port) {
+       if(e->port != port || e->vlan != vlan) {
                e->port=port;
+               e->vlan = vlan;
                char hostname[100];
                char msg[256];
                char lf[]="\n";
-               struct iovec iov[]={{msg,0},{lf,1}};
+               char stime[26];
+               struct iovec iov[]={{stime+4,16},{msg,0},{lf,1}};
 
                if ((len==4 && ip42string((uint32_t 
*)addr,hostname,sizeof(hostname))==0) ||
                                (len==16 && ip62string((uint32_t 
*)addr,hostname,sizeof(hostname))==0)) {
@@ -198,11 +200,13 @@
                                username="(none)";
                        else
                                username=pwd->pw_name;
-                       iov[0].iov_len=snprintf(msg,sizeof(msg),"ipv%d %s 
port=%d user=%s",
-                                       (len==4)?4:6, hostname, port, username);
-                       if (logfilefd >= 0)
-                               writev(logfilefd,iov,2);
-                       else if (logfilefd != -1) 
+                       iov[1].iov_len=snprintf(msg,sizeof(msg),"ipv%d %s 
port=%d vlan=%d user=%s",
+                                       (len==4)?4:6, hostname, port, vlan, 
username);
+                       if (logfilefd >= 0) {
+                               time_t ntime=time(&ntime);
+                               ctime_r(&ntime,stime);
+                               writev(logfilefd,iov,3);
+                       } else if (logfilefd != -1) 
                                syslog(LOG_INFO, msg);
                        DBGOUT(D_LOGIP_NEWIP,"%s",msg);
                }
@@ -254,14 +258,6 @@
        ip_for_all_hash(ip_gc, &t);
 }
 
-/* delete all ip address on a specific port (when the port is closed) */
-static void port_gc(struct ip_hash_entry *e, void *arg)
-{
-       int *port=arg;
-       if(*port == e->port)
-               delete_hash_entry(e);
-}
-
 /* upcall from vde: new incomping packet */
 #define UINT32(X) (((uint32_t *)&(X)))
 static int iplog_pktin(struct dbgcl *event,void *arg,va_list v)
@@ -321,6 +317,14 @@
        return 0;
 }
 
+/* delete all ip address on a specific port (when the port is closed) */
+static void port_gc(struct ip_hash_entry *e, void *arg)
+{
+       int *port=arg;
+       if(*port == e->port)
+               delete_hash_entry(e);
+}
+
 /* upcall from vde: a port has been closed */
 static int iplog_port_minus(struct dbgcl *event,void *arg,va_list v)
 {
@@ -329,7 +333,7 @@
        return 0;
 }
 
-/*user interface: chowinfo */
+/*user interface: showinfo */
 static int ipshowinfo(FILE *fd)
 {
        printoutc(fd,"iplog: ip/port/user loggin plugin");
@@ -473,7 +477,7 @@
                out[i]=*(((uint32_t *)m)+i);
 }
 
-/* cumpute the number of bits from a mask */
+/* compute the number of bits from a mask */
 static int mask2n(int len, void *addr)
 {
        char *m=addr;
@@ -700,7 +704,7 @@
                struct sockaddr_in6 *ip6addr=(struct sockaddr_in6 *) 
ai->ai_addr;
                iplog_ipsearch_item(16, ip6addr->sin6_addr.s6_addr , fd);
        } else 
-               return rv=EINVAL;
+               rv=EINVAL;
        freeaddrinfo(ai);
        return rv;
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
vde-users mailing list
vde-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vde-users

Reply via email to