summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2020-01-14 13:55:32 +0100
committerGitHub <noreply@github.com>2020-01-14 13:55:32 +0100
commite898fd0fb9ffe556c421ace92dd6fe654064f14e (patch)
treedaf91c9267f899b6e87ad2a4a0320bf1aaf6488c
parent2ee5933a5a29b959d08f4f8e9deaa67a293a4840 (diff)
parent16bc3db1644a5fa78bd1c241956144055e4da7c5 (diff)
downloadmeta-updater-e898fd0fb9ffe556c421ace92dd6fe654064f14e.tar.gz
Merge pull request #661 from advancedtelematic/feat/qemu-cmd-args/port-forwarding
QEMU run script option: allowing to pass qemu <hostfwd> as an optiona…
-rw-r--r--scripts/qemucommand.py9
-rwxr-xr-xscripts/run-qemu-ota6
2 files changed, 15 insertions, 0 deletions
diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py
index cef434d..8d3ee0e 100644
--- a/scripts/qemucommand.py
+++ b/scripts/qemucommand.py
@@ -42,6 +42,8 @@ class QemuCommand(object):
42 def __init__(self, args): 42 def __init__(self, args):
43 self.dry_run = args.dry_run 43 self.dry_run = args.dry_run
44 self.overlay = args.overlay 44 self.overlay = args.overlay
45 self.host_fwd = None
46
45 if args.machine: 47 if args.machine:
46 self.machine = args.machine 48 self.machine = args.machine
47 else: 49 else:
@@ -125,10 +127,17 @@ class QemuCommand(object):
125 self.pcap = args.pcap 127 self.pcap = args.pcap
126 self.secondary_network = args.secondary_network 128 self.secondary_network = args.secondary_network
127 129
130 # Append additional port forwarding to QEMU command line.
131 if hasattr(args, 'host_forward'):
132 self.host_fwd = args.host_forward
133
128 def command_line(self): 134 def command_line(self):
129 netuser = 'user,hostfwd=tcp:0.0.0.0:%d-:22,restrict=off' % self.ssh_port 135 netuser = 'user,hostfwd=tcp:0.0.0.0:%d-:22,restrict=off' % self.ssh_port
130 if self.gdb: 136 if self.gdb:
131 netuser += ',hostfwd=tcp:0.0.0.0:2159-:2159' 137 netuser += ',hostfwd=tcp:0.0.0.0:2159-:2159'
138 if self.host_fwd:
139 netuser += ",hostfwd=" + self.host_fwd
140
132 cmdline = [ 141 cmdline = [
133 "qemu-system-x86_64", 142 "qemu-system-x86_64",
134 "-bios", self.bios 143 "-bios", self.bios
diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota
index e2a4103..5652797 100755
--- a/scripts/run-qemu-ota
+++ b/scripts/run-qemu-ota
@@ -39,6 +39,12 @@ def main():
39 help='Give the image a second network card connected to a virtual network. ' + 39 help='Give the image a second network card connected to a virtual network. ' +
40 'This can be used to test Uptane Primary/Secondary communication.') 40 'This can be used to test Uptane Primary/Secondary communication.')
41 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true') 41 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true')
42 parser.add_argument('--host-forward',
43 help='Redirect incoming TCP or UDP connections to the host port. '
44 'Example forwarding guest port 10050 to the host port 10555:'
45 '--host-forward="tcp:0.0.0.0:10556-:10050". '
46 'For more details please refer to QEMU man page, option <hostfwd>. '
47 'https://manpages.debian.org/testing/qemu-system-x86/qemu-system-x86_64.1.en.html')
42 args = parser.parse_args() 48 args = parser.parse_args()
43 49
44 if args.overlay and not exists(args.overlay) and dirname(args.overlay) and not dirname(args.overlay) == '.': 50 if args.overlay and not exists(args.overlay) and dirname(args.overlay) and not dirname(args.overlay) == '.':