[elbe-devel] [PATCH] Port forwarding with newer qemu versions

Manuel Traut manut at linutronix.de
Wed Apr 17 18:06:59 CEST 2019


On 09:23 Fri 12 Apr     , bage at linutronix.de wrote:
> From: Bastian Germann <bage at linutronix.de>
> 
> The -redir flag does not work with QEMU >= 2.9. Replace it with an equivalent
> -netdev flag with hostfwd option. Unfortunately it cannot be connected to the
> libvirt domain's <interface>, so create this also via the qemu namespace.
> 
> This enables the port forwarding on buster, so that elbe can be used on buster
> in general. This fixes #150.
> 
> Signed-off-by: Bastian Germann <bage at linutronix.de>

Reviewed-by: Manuel Traut <manut at linutronix.de>


> ---
>  elbepack/init/libvirt.xml.mako | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/elbepack/init/libvirt.xml.mako b/elbepack/init/libvirt.xml.mako
> index 4174256f..c33609e7 100644
> --- a/elbepack/init/libvirt.xml.mako
> +++ b/elbepack/init/libvirt.xml.mako
> @@ -28,6 +28,10 @@ img = os.path.join(opt.directory, 'buildenv.img')
>  
>  emulator = prj.text('interpreter', default=defs, key='interpreter')
>  nicmac = prj.text('buildimage/NIC/MAC', default=defs, key='nicmac')
> +forward = ''
> +for f in prj.node("portforwarding"):
> +    forward += ',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'>
> @@ -78,17 +82,11 @@ xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
>        <address type='virtio-serial' controller='0' bus='0'
>        port='1' />
>      </channel>
> -    <interface type='user' >
> -      <mac address='${nicmac}'/>
> -      <model type='virtio'/>
> -    </interface>
>    </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='-netdev' />
> +    <qemu:arg value='user,id=user.0${forward}' />
> +    <qemu:arg value='-device' />
> +    <qemu:arg value='virtio-net-pci,netdev=user.0,mac=${nicmac}' />
>    </qemu:commandline>
> -% endif
>  </domain>
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list