diff --git a/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml b/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml index 94abfa8..ef6835b 100644 --- a/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml +++ b/org.jdrupes.vmoperator.runner.qemu/config-sample.yaml @@ -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) diff --git a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java index b2c0d10..127a057 100644 --- a/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java +++ b/org.jdrupes.vmoperator.runner.qemu/src/org/jdrupes/vmoperator/runner/qemu/Configuration.java @@ -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". */ diff --git a/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml b/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml index 9adf4b8..8a5e3fd 100644 --- a/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml +++ b/org.jdrupes.vmoperator.runner.qemu/templates/Standard-VM-latest.ftl.yaml @@ -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 }" ] + <#break> + <#case "user"> + - [ "-netdev", "user,id=hostnet${ nwCounter }\ + <#if itf.net??>,net=${ itf.net }" ] + - [ "-device", "${ itf.device },netdev=hostnet${ nwCounter }\ + <#if itf.mac??>,mac=${ itf.mac }" ] + <#break> + + <#assign nwCounter += 1/> + # Drives # * CD-Drives <#assign cdCounter = 0/>