diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2020-01-08 13:48:07 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-01-10 21:11:25 +0000 |
commit | 9e7b38c61c6b84b7f137c733ac5da9414025693d (patch) | |
tree | 85d9a5a2539a0d600c2f404680bb363b76bdb297 /scripts | |
parent | 2ce6ef29b9bb4f16ed9d78e166d455b7a6d968bf (diff) | |
download | openembedded-core-contrib-9e7b38c61c6b84b7f137c733ac5da9414025693d.tar.gz |
runqemu: Add network bridge support
Qemu supports attaching the virtual machine to an existing network
bridge interface via the qemu-bridge-helper program (as long as the
system is correctly configured to give the user permissions). Add
support for runqemu to do this also via the "bridge=<INTERFACE>"
argument. Note that for this to work correctly, the host
qemu-bridge-helper must be used, not the one that might have been built
by qemu-native. In order for qemu to correctly find this program, a
qemu-oe-bridge-helper program has been added to qemu-helper-native, and
runqemu will use this helper as the bridge helper. The helper will look
for the host qemu-bridge-helper first by looking in the
QEMU_BRIDGE_HELPER environment variable, then by search common paths
where the helper is installed.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/runqemu | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index c324982e8a..dd0aa4b28f 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -165,6 +165,7 @@ class BaseConfig(object): self.kvm_enabled = False self.vhost_enabled = False self.slirp_enabled = False + self.net_bridge = None self.nfs_instance = 0 self.nfs_running = False self.serialconsole = False @@ -485,6 +486,8 @@ class BaseConfig(object): self.vhost_enabled = True elif arg == 'slirp': self.slirp_enabled = True + elif arg.startswith('bridge='): + self.net_bridge = '%s' % arg[len('bridge='):] elif arg == 'snapshot': self.snapshot = True elif arg == 'publicvnc': @@ -802,7 +805,7 @@ class BaseConfig(object): def check_and_set(self): """Check configs sanity and set when needed""" self.validate_paths() - if not self.slirp_enabled: + if not self.slirp_enabled and not self.net_bridge: check_tun() # Check audio if self.audio_enabled: @@ -1020,6 +1023,10 @@ class BaseConfig(object): self.nfs_running = True + def setup_net_bridge(self): + self.set('NETWORK_CMD', '-netdev bridge,br=%s,id=net0,helper=%s -device virtio-net-pci,netdev=net0 ' % ( + self.net_bridge, os.path.join(self.bindir_native, 'qemu-oe-bridge-helper'))) + def setup_slirp(self): """Setup user networking""" @@ -1161,7 +1168,9 @@ class BaseConfig(object): if sys.stdin.isatty(): self.saved_stty = subprocess.check_output(("stty", "-g")).decode('utf-8').strip() self.network_device = self.get('QB_NETWORK_DEVICE') or self.network_device - if self.slirp_enabled: + if self.net_bridge: + self.setup_net_bridge() + elif self.slirp_enabled: self.setup_slirp() else: self.setup_tap() |