diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/targetcontrol.py | 20 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/commands.py | 13 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 28 |
3 files changed, 43 insertions, 18 deletions
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py index 2f071e0901..ea89538002 100644 --- a/meta/lib/oeqa/targetcontrol.py +++ b/meta/lib/oeqa/targetcontrol.py | |||
@@ -117,10 +117,15 @@ class QemuTarget(BaseTarget): | |||
117 | 117 | ||
118 | super(QemuTarget, self).__init__(d) | 118 | super(QemuTarget, self).__init__(d) |
119 | 119 | ||
120 | self.image_fstype = image_fstype or self.get_image_fstype(d) | 120 | self.rootfs = '' |
121 | self.kernel = '' | ||
122 | self.image_fstype = '' | ||
123 | |||
124 | if d.getVar('FIND_ROOTFS') == '1': | ||
125 | self.image_fstype = image_fstype or self.get_image_fstype(d) | ||
126 | self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("IMAGE_LINK_NAME") + '.' + self.image_fstype) | ||
127 | self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin') | ||
121 | self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) | 128 | self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) |
122 | self.rootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("IMAGE_LINK_NAME") + '.' + self.image_fstype) | ||
123 | self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE"), d.getVar("KERNEL_IMAGETYPE", False) + '-' + d.getVar('MACHINE', False) + '.bin') | ||
124 | dump_target_cmds = d.getVar("testimage_dump_target") | 129 | dump_target_cmds = d.getVar("testimage_dump_target") |
125 | dump_host_cmds = d.getVar("testimage_dump_host") | 130 | dump_host_cmds = d.getVar("testimage_dump_host") |
126 | dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") | 131 | dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") |
@@ -176,8 +181,13 @@ class QemuTarget(BaseTarget): | |||
176 | bb.note("Qemu log file: %s" % self.qemulog) | 181 | bb.note("Qemu log file: %s" % self.qemulog) |
177 | super(QemuTarget, self).deploy() | 182 | super(QemuTarget, self).deploy() |
178 | 183 | ||
179 | def start(self, params=None, ssh=True, extra_bootparams=None, runqemuparams=''): | 184 | def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd=''): |
180 | if self.runner.start(params, get_ip=ssh, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams): | 185 | if launch_cmd: |
186 | start = self.runner.launch(get_ip=ssh, launch_cmd=launch_cmd) | ||
187 | else: | ||
188 | start = self.runner.start(params, get_ip=ssh, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams) | ||
189 | |||
190 | if start: | ||
181 | if ssh: | 191 | if ssh: |
182 | self.ip = self.runner.ip | 192 | self.ip = self.runner.ip |
183 | self.server_ip = self.runner.server_ip | 193 | self.server_ip = self.runner.server_ip |
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 |