mirror of
https://github.com/unraid/webgui.git
synced 2026-04-28 13:59:21 -05:00
New vhost network for both containers and VMs
User can enable / disable bridging to change network behavior. Containers and VMs are automatically updated to the new network settings
This commit is contained in:
@@ -661,23 +661,36 @@
|
||||
$netmodel = $nic['model'] ?: 'virtio-net';
|
||||
|
||||
$net_res =$this->libvirt_get_net_res($this->conn, $nic['network']);
|
||||
exec("brctl show | cut -f1| awk NF | sed -n '1!p'", $br);
|
||||
|
||||
$vhost = file_exists("/boot/config/network.cfg") && exec("grep -Po '^BRNICS\[0\]=\"\K[^\"]+' /boot/config/network.cfg")=='';
|
||||
if ($vhost) {
|
||||
exec("ip -br a|grep -Po '^vhost[0-9][^@]*'",$br);
|
||||
} else {
|
||||
exec("brctl show | cut -f1| awk NF | sed -n '1!p'", $br);
|
||||
}
|
||||
if ($nic["boot"] != NULL) $nicboot = "<boot order='".$nic["boot"]."'/>" ; else $nicboot = "" ;
|
||||
if($net_res) {
|
||||
$netstr .= "<interface type='network'>
|
||||
$netstr .= "<interface type='network'>
|
||||
<mac address='{$nic['mac']}'/>
|
||||
<source network='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "'/>
|
||||
<model type='$netmodel'/>
|
||||
$nicboot
|
||||
</interface>" ;
|
||||
</interface>";
|
||||
} elseif(in_array($nic['network'], $br)) {
|
||||
$netstr .= "<interface type='bridge'>
|
||||
if ($vhost) {
|
||||
$netstr .= "<interface type='direct'>
|
||||
<mac address='{$nic['mac']}'/>
|
||||
<source dev='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "' mode='bridge'/>
|
||||
<model type='$netmodel'/>
|
||||
$nicboot
|
||||
</interface>";
|
||||
} else {
|
||||
$netstr .= "<interface type='bridge'>
|
||||
<mac address='{$nic['mac']}'/>
|
||||
<source bridge='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "'/>
|
||||
<model type='$netmodel'/>
|
||||
$nicboot
|
||||
</interface>";
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user