This implements support for bridge configs in openvz following the rules
set out in

http://wiki.openvz.org/Virtual_Ethernet_device#Making_a_bridged_veth-device_persistent

This simply requires that the admin has created /etc/vz/vznetctl.conf
containing

  #!/bin/bash
  EXTERNAL_SCRIPT="/usr/sbin/vznetaddbr"


For openvz <= 3.0.22, we have to manually re-write the NETIF line to
add the bridge config parameter.
It is alternative, but more flexible way. It require simple modification of vznetaddbr.
Common scenario is to add VZHOSTBR="<bridge if>" to config.
For newer openvz we can simply pass
the bridge name on the commnand line to --netif_add.

Older openvz also requires that the admin install /usr/sbin/vznetaddbr
since it is not available out of the box

Daniel



+
+    while(1) {
+        if (openvz_readline(fd, line, sizeof(line)) <= 0)
+            break;
+
+        if (!STRPREFIX(line, param)) {
need to check for '='.
Currently, if you will search for 'NETIF', you can find any string with such prefix. example 'NETIFOTHERPARAM'
+            if (safewrite(temp_fd, line, strlen(line)) !=
+                strlen(line))
+                goto error;
+        }
+    }
+
 /*

+
+        if (!(opt = virBufferContentAndReset(&buf)))
+            goto no_memory;
+
         ADD_ARG_LIT(opt) ;
Need to free opt
-    }else if (net->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
+    } else if (net->type == VIR_DOMAIN_NET_TYPE_ETHERNET &&
               net->data.ethernet.ipaddr != NULL) {

+static int
+openvzDomainSetNetworkConfig(virConnectPtr conn,
+                             virDomainDefPtr def)
+{
+    unsigned int i;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    char *param;
+    struct openvz_driver *driver = (struct openvz_driver *) conn->privateData;
+
+    for (i = 0 ; i < def->nnets ; i++) {
+        if (driver->version < VZCTL_BRIDGE_MIN_VERSION && i > 0)
+            virBufferAddLit(&buf, ";");
Need to check that network is bridge.
In other case we will have NETIF='<some params>;;;;'
+
+        if (openvzDomainSetNetwork(conn, def->name, def->nets[i], &buf) < 0) {
+            openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+                        "%s", _("Could not configure network"));
+            goto exit;
+        }
+    }
+

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to