Add networking.

This commit is contained in:
Michael Lipp 2023-06-07 15:03:11 +02:00
parent 351c876024
commit 8d08a6adad
3 changed files with 40 additions and 0 deletions

View file

@ -68,6 +68,16 @@
# "rtcBase": "utc"
# "rtcClock": "rt"
# Network settings
# Supported types are "tap" and "user" (for debugging). Type "user"
# supports only the property "net".
# "network":
# - "type": "tap"
# "bridge": "br0"
# "device": "virtio-net"
# "mac": (undefined)
"drives":
- "type": "ide-cd"
"bootindex": (undefined)

View file

@ -70,10 +70,22 @@ class Configuration implements Dto {
public String rtcBase = "utc";
public String rtcClock = "rt";
public int powerdownTimeout = 60;
public Network[] network = { new Network() };
public Drive[] drives;
public Spice spice;
}
/**
* Subsection "network".
*/
public static class Network implements Dto {
public String type = "tap";
public String bridge = "br0";
public String device = "virtio-net";
public String mac;
public String net;
}
/**
* Subsection "drive".
*/

View file

@ -112,6 +112,24 @@
# * Graphics and Audio Card
- [ "-device", "virtio-vga,id=video0,max_outputs=1" ]
- [ "-device", "ich9-intel-hda,id=sound0" ]
# Network
<#assign nwCounter = 0/>
<#list vm.network![] as itf>
<#switch itf.type!"tap">
<#case "tap">
- [ "-netdev", "bridge,id=hostnet${ nwCounter }" ]
- [ "-device", "${ itf.device },netdev=hostnet${ nwCounter }\
<#if itf.mac??>,mac=${ itf.mac }</#if>" ]
<#break>
<#case "user">
- [ "-netdev", "user,id=hostnet${ nwCounter }\
<#if itf.net??>,net=${ itf.net }</#if>" ]
- [ "-device", "${ itf.device },netdev=hostnet${ nwCounter }\
<#if itf.mac??>,mac=${ itf.mac }</#if>" ]
<#break>
</#switch>
<#assign nwCounter += 1/>
</#list>
# Drives
# * CD-Drives
<#assign cdCounter = 0/>