Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Randy Witt <randy.e.witt@linux.intel.com>
To: Robert Yang <liezhi.yang@windriver.com>,
	openembedded-core@lists.openembedded.org
Subject: Re: [PATCH V2 5/6] runqemu: fixes for slirp, network device and hostfwd
Date: Wed, 7 Dec 2016 09:58:54 -0800	[thread overview]
Message-ID: <4f79b40c-e1a8-3e62-0cbb-ea4c9d4176e4@linux.intel.com> (raw)
In-Reply-To: <2ecbdf8cca844fb9b76df48f80b0762811dd1b04.1481014270.git.liezhi.yang@windriver.com>


>      def setup_slirp(self):
>          """Setup user networking"""
>
>          if self.fstype == 'nfs':
>              self.setup_nfs()
>          self.kernel_cmdline_script += ' ip=dhcp'
> -        self.set('NETWORK_CMD', self.get('QB_SLIRP_OPT'))
> +        # Port mapping
> +        hostfwd = ",hostfwd=tcp::2222-:22,hostfwd=tcp::2323-:23"
> +        qb_slirp_opt_default = "-netdev user,id=net0%s" % hostfwd
> +        qb_slirp_opt = self.get('QB_SLIRP_OPT') or qb_slirp_opt_default
> +        # Figure out the port
> +        ports = re.findall('hostfwd=[^-]*:([0-9]+)-[^,-]*', qb_slirp_opt)
> +        ports = [int(i) for i in ports]
> +        mac = 2
> +        # Find a free port to avoid conflicts
> +        for p in ports[:]:
> +            p_new = p
> +            while not check_free_port('localhost', p_new):
> +                p_new += 1
> +                mac += 1
> +                while p_new in ports:
> +                        p_new += 1
> +                        mac += 1
> +            if p != p_new:
> +                ports.append(p_new)
> +                qb_slirp_opt = re.sub(':%s-' % p, ':%s-' % p_new, qb_slirp_opt)
> +                logger.info("Port forward changed: %s -> %s" % (p, p_new))
Regardless if the port is changed or not, so that things like tests have an 
easier time of figuring out the port mappings, would it be good add a flag that 
prints out the entire list of ports used, or always do it? i.e. "Port forwarding 
2222:22 2333:23.... It's not necessary of course, you can  always look at the 
command line and then check to see if anything is remapped. But that's a bit 
more work.

> +        mac = "%s%02x" % (self.mac_slirp, mac)
> +        self.set('NETWORK_CMD', '%s %s' % (self.network_device.replace('@MAC@', mac), qb_slirp_opt))



  reply	other threads:[~2016-12-07 17:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06  8:55 [PATCH V2 0/6] runqemu: fix for slirp, network device and hostfwd Robert Yang
2016-12-06  8:55 ` [PATCH V2 1/6] scripts/runqemu: fix checking for <file>.cpio.gz Robert Yang
2016-12-06  8:55 ` [PATCH V2 2/6] qemuboot.bbclass: use IMGDEPLOYDIR Robert Yang
2016-12-06  8:55 ` [PATCH V2 3/6] runqemu-export-rootfs: fix inconsistent var names Robert Yang
2016-12-06  8:55 ` [PATCH V2 4/6] runqemu: support mutiple qemus running when nfs Robert Yang
2016-12-14  9:45   ` Robert Yang
2016-12-06  8:55 ` [PATCH V2 5/6] runqemu: fixes for slirp, network device and hostfwd Robert Yang
2016-12-07 17:58   ` Randy Witt [this message]
2016-12-12  3:31     ` Robert Yang
2016-12-06  8:55 ` [PATCH V2 6/6] qemuboot.bbclass: add blank lines in comments Robert Yang
2016-12-06  9:01 ` [PATCH V2 0/6] runqemu: fix for slirp, network device and hostfwd Robert Yang
2016-12-07 16:50   ` Nathan Rossi
2016-12-21  6:24 ` Robert Yang
2017-01-11  1:47   ` Robert Yang
2017-01-17 13:14     ` Burton, Ross
2017-01-18  9:25       ` Robert Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f79b40c-e1a8-3e62-0cbb-ea4c9d4176e4@linux.intel.com \
    --to=randy.e.witt@linux.intel.com \
    --cc=liezhi.yang@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox