summaryrefslogtreecommitdiffstats
path: root/scripts/run-qemu-ota
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/run-qemu-ota')
-rwxr-xr-xscripts/run-qemu-ota26
1 files changed, 18 insertions, 8 deletions
diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota
index de63297..232ee11 100755
--- a/scripts/run-qemu-ota
+++ b/scripts/run-qemu-ota
@@ -2,7 +2,7 @@
2 2
3from argparse import ArgumentParser 3from argparse import ArgumentParser
4from subprocess import Popen 4from subprocess import Popen
5from os.path import exists 5from os.path import exists, dirname
6import sys 6import sys
7from qemucommand import QemuCommand 7from qemucommand import QemuCommand
8 8
@@ -39,27 +39,37 @@ def main():
39 'This can be used to test Uptane Primary/Secondary communication.') 39 'This can be used to test Uptane Primary/Secondary communication.')
40 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true') 40 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true')
41 args = parser.parse_args() 41 args = parser.parse_args()
42
43 if args.overlay and not exists(args.overlay) and dirname(args.overlay) and not dirname(args.overlay) == '.':
44 print('Error: please provide a file name in the current working directory. ' +
45 'Overlays do not work properly with other directories.')
46 sys.exit(1)
47 if args.overlay and exists(args.overlay) and args.imagename != parser.get_default('imagename'):
48 # qemu-img amend -o <filename> might work, but it has not yet been done
49 # successfully.
50 print('Warning: cannot change backing image of overlay after it has been created.')
51
42 try: 52 try:
43 qemu_command = QemuCommand(args) 53 qemu_command = QemuCommand(args)
44 except ValueError as e: 54 except ValueError as e:
45 print(e.message) 55 print(e.message)
46 sys.exit(1) 56 sys.exit(1)
47 57
48 print("Launching %s with mac address %s" % (args.imagename, qemu_command.mac_address))
49 print("To connect via SSH:")
50 print(" ssh -o StrictHostKeyChecking=no root@localhost -p %d" % qemu_command.ssh_port)
51 print("To connect to the serial console:")
52 print(" nc localhost %d" % qemu_command.serial_port)
53
54 cmdline = qemu_command.command_line() 58 cmdline = qemu_command.command_line()
55 if args.overlay and not exists(args.overlay): 59 if args.overlay and not exists(args.overlay):
56 print("Image file %s does not yet exist, creating." % args.overlay) 60 print("Overlay file %s does not yet exist, creating." % args.overlay)
57 img_cmdline = qemu_command.img_command_line() 61 img_cmdline = qemu_command.img_command_line()
58 if args.dry_run: 62 if args.dry_run:
59 print(" ".join(img_cmdline)) 63 print(" ".join(img_cmdline))
60 else: 64 else:
61 Popen(img_cmdline).wait() 65 Popen(img_cmdline).wait()
62 66
67 print("Launching %s with mac address %s" % (args.imagename, qemu_command.mac_address))
68 print("To connect via SSH:")
69 print(" ssh -o StrictHostKeyChecking=no root@localhost -p %d" % qemu_command.ssh_port)
70 print("To connect to the serial console:")
71 print(" nc localhost %d" % qemu_command.serial_port)
72
63 if args.dry_run: 73 if args.dry_run:
64 print(" ".join(cmdline)) 74 print(" ".join(cmdline))
65 else: 75 else: