diff options
| author | Patrick Vacek <patrickvacek@gmail.com> | 2019-09-10 14:10:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-10 14:10:16 +0200 |
| commit | 5348b146054e7b16dff71ceb41697157488867e7 (patch) | |
| tree | 85c10f159169a04e95f247cf4a6ac4874d2a8885 /scripts/run-qemu-ota | |
| parent | f4c7b3d831f232c312b50d52ff296c4678eb475b (diff) | |
| parent | 357c65d44135b560b25e86ec33b1c1efccb0c7fa (diff) | |
| download | meta-updater-5348b146054e7b16dff71ceb41697157488867e7.tar.gz | |
Merge pull request #599 from advancedtelematic/feat/better-overlays
Feat/better overlays
Diffstat (limited to 'scripts/run-qemu-ota')
| -rwxr-xr-x | scripts/run-qemu-ota | 26 |
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 | ||
| 3 | from argparse import ArgumentParser | 3 | from argparse import ArgumentParser |
| 4 | from subprocess import Popen | 4 | from subprocess import Popen |
| 5 | from os.path import exists | 5 | from os.path import exists, dirname |
| 6 | import sys | 6 | import sys |
| 7 | from qemucommand import QemuCommand | 7 | from 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: |
