[elbe-devel] [PATCH] init libvirt.xml.mako: dont use deprecate option -redir for ports

Torben Hohn torben.hohn at linutronix.de
Fri Oct 12 11:14:36 CEST 2018


the option -redir is deprecated in qemu since version 2.6.0
(see https://qemu.weilnetz.de/doc/qemu-doc.html#Deprecated-features)
qemu needs the following commandline options now:
-------------------------------------------------------------------------
-device virtio-net-pci,netdev=user.0
-netdev user,ipv4,id=user.0,hostfwd=tcp::5022-:22,hostfwd=tcp::7587-:7588
-------------------------------------------------------------------------

the -device and -netdev options are generated by libvirt, though. And
libvirt does not support hostfwd= in any way.

in order to be able to specify hostfwd, remove the libvirt generated
network interface, and then create it via <qemu:arg>. This hides the
network interface from libvirt. The only bad thing seems to be, that
virt-manager does not show the network interface and the trafic graph
is not showing any traffic.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/init/libvirt.xml.mako | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/elbepack/init/libvirt.xml.mako b/elbepack/init/libvirt.xml.mako
index 1260c55f..bf3c893f 100644
--- a/elbepack/init/libvirt.xml.mako
+++ b/elbepack/init/libvirt.xml.mako
@@ -28,6 +28,12 @@ img = os.path.join(opt.directory, 'buildenv.img')
 
 emulator = prj.text('interpreter', default=defs, key='interpreter')
 
+fwd = ""
+if prj.has("portforwarding"):
+    for f in prj.node("portforwarding"):
+        fwd += ",hostfwd=%s::%s-:%s" % (f.text("proto"),
+		                        f.text("host"),
+                                        f.text("buildenv"))
 %><domain type='kvm'
 xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
 <name>${name}</name>
@@ -72,14 +78,13 @@ xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
       <address type='virtio-serial' controller='0' bus='0'
       port='1' />
     </channel>
-    <interface type='user' />
   </devices>
 %if prj.has("portforwarding"):
   <qemu:commandline>
-  %for f in prj.node('portforwarding'):
-    <qemu:arg value='-redir' />
-    <qemu:arg value='${f.text("proto")}:${f.text("host")}::${f.text("buildenv")}' />
-  %endfor
+  <qemu:arg value='-device' />
+  <qemu:arg value='virtio-net-pci,netdev=user.0' />
+  <qemu:arg value='-netdev' />
+  <qemu:arg value='user,ipv4,id=user.0${fwd}' />
   </qemu:commandline>
 % endif
 </domain>
-- 
2.11.0




More information about the elbe-devel mailing list