diff options
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r-- | meta/lib/oeqa/utils/commands.py | 13 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 28 |
2 files changed, 28 insertions, 13 deletions
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 82c5908e9c..6528a98427 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py | |||
@@ -218,7 +218,10 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec= | |||
218 | 218 | ||
219 | 219 | ||
220 | @contextlib.contextmanager | 220 | @contextlib.contextmanager |
221 | def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None): | 221 | def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None): |
222 | """ | ||
223 | launch_cmd means directly run the command, don't need set rootfs or env vars. | ||
224 | """ | ||
222 | 225 | ||
223 | import bb.tinfoil | 226 | import bb.tinfoil |
224 | import bb.build | 227 | import bb.build |
@@ -230,6 +233,12 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None): | |||
230 | import oeqa.targetcontrol | 233 | import oeqa.targetcontrol |
231 | tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage") | 234 | tinfoil.config_data.setVar("TEST_LOG_DIR", "${WORKDIR}/testimage") |
232 | tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "1000") | 235 | tinfoil.config_data.setVar("TEST_QEMUBOOT_TIMEOUT", "1000") |
236 | # Tell QemuTarget() whether need find rootfs/kernel or not | ||
237 | if launch_cmd: | ||
238 | tinfoil.config_data.setVar("FIND_ROOTFS", '0') | ||
239 | else: | ||
240 | tinfoil.config_data.setVar("FIND_ROOTFS", '1') | ||
241 | |||
233 | recipedata = tinfoil.parse_recipe(pn) | 242 | recipedata = tinfoil.parse_recipe(pn) |
234 | 243 | ||
235 | # The QemuRunner log is saved out, but we need to ensure it is at the right | 244 | # The QemuRunner log is saved out, but we need to ensure it is at the right |
@@ -260,7 +269,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None): | |||
260 | try: | 269 | try: |
261 | qemu.deploy() | 270 | qemu.deploy() |
262 | try: | 271 | try: |
263 | qemu.start(ssh=ssh, runqemuparams=runqemuparams) | 272 | qemu.start(ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd) |
264 | except bb.build.FuncFailed: | 273 | except bb.build.FuncFailed: |
265 | raise Exception('Failed to start QEMU - see the logs in %s' % logdir) | 274 | raise Exception('Failed to start QEMU - see the logs in %s' % logdir) |
266 | 275 | ||
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index c0abb96546..c292b759bc 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -97,7 +97,7 @@ class QemuRunner: | |||
97 | self._dump_host() | 97 | self._dump_host() |
98 | raise SystemExit | 98 | raise SystemExit |
99 | 99 | ||
100 | def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams=''): | 100 | def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None): |
101 | if self.display: | 101 | if self.display: |
102 | os.environ["DISPLAY"] = self.display | 102 | os.environ["DISPLAY"] = self.display |
103 | # Set this flag so that Qemu doesn't do any grabs as SDL grabs | 103 | # Set this flag so that Qemu doesn't do any grabs as SDL grabs |
@@ -117,6 +117,20 @@ class QemuRunner: | |||
117 | else: | 117 | else: |
118 | os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image | 118 | os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image |
119 | 119 | ||
120 | if not launch_cmd: | ||
121 | launch_cmd = 'runqemu snapshot' | ||
122 | if self.use_kvm: | ||
123 | logger.info('Using kvm for runqemu') | ||
124 | launch_cmd += ' kvm' | ||
125 | else: | ||
126 | logger.info('Not using kvm for runqemu') | ||
127 | if not self.display: | ||
128 | launch_cmd += ' nographic' | ||
129 | launch_cmd += ' %s %s' % (self.machine, self.rootfs) | ||
130 | |||
131 | return self.launch(launch_cmd, qemuparams=qemuparams, get_ip=get_ip, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams) | ||
132 | |||
133 | def launch(self, launch_cmd, get_ip = True, qemuparams = None, extra_bootparams = None, runqemuparams=''): | ||
120 | try: | 134 | try: |
121 | threadsock, threadport = self.create_socket() | 135 | threadsock, threadport = self.create_socket() |
122 | self.server_socket, self.serverport = self.create_socket() | 136 | self.server_socket, self.serverport = self.create_socket() |
@@ -124,27 +138,19 @@ class QemuRunner: | |||
124 | logger.error("Failed to create listening socket: %s" % msg[1]) | 138 | logger.error("Failed to create listening socket: %s" % msg[1]) |
125 | return False | 139 | return False |
126 | 140 | ||
127 | |||
128 | bootparams = 'console=tty1 console=ttyS0,115200n8 printk.time=1' | 141 | bootparams = 'console=tty1 console=ttyS0,115200n8 printk.time=1' |
129 | if extra_bootparams: | 142 | if extra_bootparams: |
130 | bootparams = bootparams + ' ' + extra_bootparams | 143 | bootparams = bootparams + ' ' + extra_bootparams |
131 | 144 | ||
132 | self.qemuparams = 'bootparams="{0}" qemuparams="-serial tcp:127.0.0.1:{1}"'.format(bootparams, threadport) | 145 | self.qemuparams = 'bootparams="{0}" qemuparams="-serial tcp:127.0.0.1:{1}"'.format(bootparams, threadport) |
133 | if not self.display: | ||
134 | self.qemuparams = 'nographic ' + self.qemuparams | ||
135 | if qemuparams: | 146 | if qemuparams: |
136 | self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"' | 147 | self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"' |
137 | 148 | ||
149 | launch_cmd += ' tcpserial=%s %s' % (self.serverport, self.qemuparams) | ||
150 | |||
138 | self.origchldhandler = signal.getsignal(signal.SIGCHLD) | 151 | self.origchldhandler = signal.getsignal(signal.SIGCHLD) |
139 | signal.signal(signal.SIGCHLD, self.handleSIGCHLD) | 152 | signal.signal(signal.SIGCHLD, self.handleSIGCHLD) |
140 | 153 | ||
141 | launch_cmd = 'runqemu snapshot %s ' % runqemuparams | ||
142 | if self.use_kvm: | ||
143 | logger.info('Using kvm for runqemu') | ||
144 | launch_cmd += 'kvm ' | ||
145 | else: | ||
146 | logger.info('Not using kvm for runqemu') | ||
147 | launch_cmd += 'tcpserial=%s %s %s %s' % (self.serverport, self.machine, self.rootfs, self.qemuparams) | ||
148 | logger.info('launchcmd=%s'%(launch_cmd)) | 154 | logger.info('launchcmd=%s'%(launch_cmd)) |
149 | 155 | ||
150 | # FIXME: We pass in stdin=subprocess.PIPE here to work around stty | 156 | # FIXME: We pass in stdin=subprocess.PIPE here to work around stty |