summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcajun-rat <phil@advancedtelematic.com>2017-11-16 17:35:11 +0100
committerGitHub <noreply@github.com>2017-11-16 17:35:11 +0100
commite47cd9155ca2aaab08029b5bd0fd78dc1e3e1c01 (patch)
tree807e338192140cdff21d1f22aa7b5e862cbb9434
parentaf1cc1ef3cf5cdff903249eca9111174aafc5924 (diff)
parent24e5a6d45886365cecce74c2c9aa1cfd8c0da69a (diff)
downloadmeta-updater-e47cd9155ca2aaab08029b5bd0fd78dc1e3e1c01.tar.gz
Merge pull request #178 from advancedtelematic/feat/autodetect-kvm
Autodetect kvm
-rw-r--r--lib/oeqa/selftest/updater.py4
-rw-r--r--scripts/qemucommand.py11
-rwxr-xr-xscripts/run-qemu-ota13
3 files changed, 22 insertions, 6 deletions
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py
index b59eefc..2723b4a 100644
--- a/lib/oeqa/selftest/updater.py
+++ b/lib/oeqa/selftest/updater.py
@@ -119,12 +119,12 @@ class GeneralTests(oeSelfTest):
119 args = type('', (), {})() 119 args = type('', (), {})()
120 args.imagename = 'core-image-minimal' 120 args.imagename = 'core-image-minimal'
121 args.mac = None 121 args.mac = None
122 # Could use DEPLOY_DIR_IMAGE her but it's already in the machine 122 # Could use DEPLOY_DIR_IMAGE here but it's already in the machine
123 # subdirectory. 123 # subdirectory.
124 args.dir = 'tmp/deploy/images' 124 args.dir = 'tmp/deploy/images'
125 args.efi = False 125 args.efi = False
126 args.machine = None 126 args.machine = None
127 args.no_kvm = False 127 args.kvm = None # Autodetect
128 args.no_gui = True 128 args.no_gui = True
129 args.gdb = False 129 args.gdb = False
130 args.pcap = None 130 args.pcap = None
diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py
index a75ffb6..82a9540 100644
--- a/scripts/qemucommand.py
+++ b/scripts/qemucommand.py
@@ -2,6 +2,7 @@ from os.path import exists, join, realpath, abspath
2from os import listdir 2from os import listdir
3import random 3import random
4import socket 4import socket
5from subprocess import check_output, CalledProcessError
5 6
6EXTENSIONS = { 7EXTENSIONS = {
7 'intel-corei7-64': 'wic', 8 'intel-corei7-64': 'wic',
@@ -67,7 +68,15 @@ class QemuCommand(object):
67 self.mac_address = random_mac() 68 self.mac_address = random_mac()
68 self.serial_port = find_local_port(8990) 69 self.serial_port = find_local_port(8990)
69 self.ssh_port = find_local_port(2222) 70 self.ssh_port = find_local_port(2222)
70 self.kvm = not args.no_kvm 71 if args.kvm is None:
72 # Autodetect KVM using 'kvm-ok'
73 try:
74 check_output(['kvm-ok'])
75 self.kvm = True
76 except CalledProcessError:
77 self.kvm = False
78 else:
79 self.kvm = args.kvm
71 self.gui = not args.no_gui 80 self.gui = not args.no_gui
72 self.gdb = args.gdb 81 self.gdb = args.gdb
73 self.pcap = args.pcap 82 self.pcap = args.pcap
diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota
index 5f9cebe..56e4fbc 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, join 5from os.path import exists
6import sys 6import sys
7from qemucommand import QemuCommand 7from qemucommand import QemuCommand
8 8
@@ -21,11 +21,18 @@ def main():
21 'OSTREE_BOOTLOADER = "grub" and OVMF.fd firmware to be installed (try "apt install ovmf")', 21 'OSTREE_BOOTLOADER = "grub" and OVMF.fd firmware to be installed (try "apt install ovmf")',
22 action='store_true') 22 action='store_true')
23 parser.add_argument('--machine', default=None, help="Target MACHINE") 23 parser.add_argument('--machine', default=None, help="Target MACHINE")
24 parser.add_argument('--no-kvm', help='Disable KVM in QEMU', action='store_true') 24 kvm_group = parser.add_argument_group()
25 kvm_group.add_argument('--force-kvm', help='Force use of KVM (default is to autodetect)',
26 dest='kvm', action='store_true', default=None)
27 kvm_group.add_argument('--no-kvm', help='Disable KVM in QEMU',
28 dest='kvm', action='store_false')
25 parser.add_argument('--no-gui', help='Disable GUI', action='store_true') 29 parser.add_argument('--no-gui', help='Disable GUI', action='store_true')
26 parser.add_argument('--gdb', help='Export gdbserver port 2159 from the image', action='store_true') 30 parser.add_argument('--gdb', help='Export gdbserver port 2159 from the image', action='store_true')
27 parser.add_argument('--pcap', default=None, help='Dump all network traffic') 31 parser.add_argument('--pcap', default=None, help='Dump all network traffic')
28 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.') 32 parser.add_argument('-o', '--overlay', type=str, metavar='file.cow',
33 help='Use an overlay storage image file. Will be created if it does not exist. ' +
34 'This option lets you have a persistent image without modifying the underlying image ' +
35 'file, permitting multiple different persistent machines.')
29 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true') 36 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true')
30 args = parser.parse_args() 37 args = parser.parse_args()
31 try: 38 try: