summaryrefslogtreecommitdiffstats
path: root/external/meta-updater/scripts/run-qemu-ota
diff options
context:
space:
mode:
authorToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:24:26 +0900
committerToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp>2020-03-30 09:24:26 +0900
commit5b80bfd7bffd4c20d80b7c70a7130529e9a755dd (patch)
treeb4bb18dcd1487dbf1ea8127e5671b7bb2eded033 /external/meta-updater/scripts/run-qemu-ota
parent706ad73eb02caf8532deaf5d38995bd258725cb8 (diff)
agl-basesystem
Diffstat (limited to 'external/meta-updater/scripts/run-qemu-ota')
-rwxr-xr-xexternal/meta-updater/scripts/run-qemu-ota74
1 files changed, 74 insertions, 0 deletions
diff --git a/external/meta-updater/scripts/run-qemu-ota b/external/meta-updater/scripts/run-qemu-ota
new file mode 100755
index 00000000..de632970
--- /dev/null
+++ b/external/meta-updater/scripts/run-qemu-ota
@@ -0,0 +1,74 @@
+#! /usr/bin/env python
+
+from argparse import ArgumentParser
+from subprocess import Popen
+from os.path import exists
+import sys
+from qemucommand import QemuCommand
+
+DEFAULT_DIR = 'tmp/deploy/images'
+
+
+def main():
+ parser = ArgumentParser(description='Run meta-updater image in qemu')
+ parser.add_argument('imagename', default='core-image-minimal', nargs='?',
+ help="Either the name of the bitbake image target, or a path to the image to run")
+ parser.add_argument('mac', default=None, nargs='?')
+ parser.add_argument('--dir', default=DEFAULT_DIR,
+ help='Path to build directory containing the image and u-boot-qemux86-64.rom')
+ parser.add_argument('--efi',
+ help='Boot using UEFI rather than U-Boot. This requires the image to be built with ' +
+ 'OSTREE_BOOTLOADER = "grub" and OVMF.fd firmware to be installed (try "apt install ovmf")',
+ action='store_true')
+ parser.add_argument('--machine', default=None, help="Target MACHINE")
+ kvm_group = parser.add_argument_group()
+ kvm_group.add_argument('--force-kvm', help='Force use of KVM (default is to autodetect)',
+ dest='kvm', action='store_true', default=None)
+ kvm_group.add_argument('--no-kvm', help='Disable KVM in QEMU',
+ dest='kvm', action='store_false')
+ parser.add_argument('--mem', default=None, help="Amount of memory the machine boots with")
+ parser.add_argument('--no-gui', help='Disable GUI', action='store_true')
+ parser.add_argument('--gdb', help='Export gdbserver port 2159 from the image', action='store_true')
+ parser.add_argument('--pcap', default=None, help='Dump all network traffic')
+ parser.add_argument('-o', '--overlay', type=str, metavar='file.cow',
+ help='Use an overlay storage image file. Will be created if it does not exist. ' +
+ 'This option lets you have a persistent image without modifying the underlying image ' +
+ 'file, permitting multiple different persistent machines.')
+ parser.add_argument('--secondary-network', action='store_true', dest='secondary_network',
+ help='Give the image a second network card connected to a virtual network. ' +
+ 'This can be used to test Uptane Primary/Secondary communication.')
+ parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true')
+ args = parser.parse_args()
+ try:
+ qemu_command = QemuCommand(args)
+ except ValueError as e:
+ print(e.message)
+ sys.exit(1)
+
+ print("Launching %s with mac address %s" % (args.imagename, qemu_command.mac_address))
+ print("To connect via SSH:")
+ print(" ssh -o StrictHostKeyChecking=no root@localhost -p %d" % qemu_command.ssh_port)
+ print("To connect to the serial console:")
+ print(" nc localhost %d" % qemu_command.serial_port)
+
+ cmdline = qemu_command.command_line()
+ if args.overlay and not exists(args.overlay):
+ print("Image file %s does not yet exist, creating." % args.overlay)
+ img_cmdline = qemu_command.img_command_line()
+ if args.dry_run:
+ print(" ".join(img_cmdline))
+ else:
+ Popen(img_cmdline).wait()
+
+ if args.dry_run:
+ print(" ".join(cmdline))
+ else:
+ s = Popen(cmdline)
+ try:
+ s.wait()
+ except KeyboardInterrupt:
+ pass
+
+
+if __name__ == '__main__':
+ main()