<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<div>I do not undesrtand how it will simplify parsing: the iterator<br>
in parsing is an interface name, not bridge name. I attached a patch, so<br>
you will see how I do think about it :) (this patch includes all<br>
discussed changes)<br>
</div></blockquote>
My point of view is to use small count common methods to manipulate config parameters. That is don't use array of differend methods for different types of data. In current case we can transform format to be used common functions.<br>



<br>
For example:<br>
if we will use format<br>
#BRIDGE-ifname=<><br>
we can drop openvzGetDefinedBridge and use one existing method<br>
openvzReadConfigParam(veid, "#BRIDGE-ifname", value, sizeof(value));<br>
<br>
openvzSetDefinedBridge can be simplified if create<br>
openvzAppendParamToConfig<br>
<br>
openvzSetDefinedBridge() {<br>
openvzReadConfigParam()<br>
if not found<br>
        openvzAppendParamToConfig()<br>
return<br>
}</blockquote><div> </div><div>I done the following:<br></div><div>- Add function openvzAppendConfigParam(veid, param, value)<br>  This function simply appends a string `param="value"` to config file.<br>- Rewrite functions openvz{Get,Set}DefinedBridge to use that function<br>


<br>I think, we need to rewrite {Get,Set}UUID functions in the same manner.<br><br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
+        case VIR_DOMAIN_NET_TYPE_BRIDGE:<br>
+            veth = net->ifname;<br>
+            bridge = net->data.bridge.brname;<br>
+            if (rc = brAddInterface(brctl, bridge, veth)) {<br>
+                openvzError(conn, VIR_ERR_INTERNAL_ERROR,<br>
+                         _("failed to add %s device to %s: %s"),<br>
+                         veth, bridge, strerror(rc));<br>
+                goto exit;<br>
+            }<br>
+            break;<br>
It will be good to check veth & bridge for NULL. Potentially it may happens when config is broken.</blockquote><div>Done. If veth or bridge is NULL, then openvzError is raised<br>and one iteration of loop is passed.<br>

<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
@@ -602,6 +713,12 @@ openvzDomainCreate(virDomainPtr dom)<br>
         return -1;<br>
     }<br>
<br>
+    if (openvzSetBridges(dom->conn, vm->def->name, vm->def->nets) < 0) {<br>
+        openvzError(dom->conn, VIR_ERR_INTERNAL_ERROR,<br>
+                _("Could not configure bridges"));<br>
+        return -1;<br>
+    }<br>
+<br>
Also, we need to set bridges in openvzDomainReboot method.</blockquote><div>Done.<br><br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

+    if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {<br>
+        static int vnetNo = 0;<br>
<br>
Libvirt may be use as library in applications. If some will call create 2 containers, then first container will have eth0...ethN<br>
second will have ethN+1...<br>
</blockquote><div><br></div></div>Write function openvzGenerateContainerVethName.<br>When called, it will search for interface names in $veid.conf.<br>If there are ethN,...,ethM, it will return name "ethL",<br>

where L = 1+max(N,...,M)</div></div></div>