summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/qemurunner.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/utils/qemurunner.py')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py56
1 files changed, 32 insertions, 24 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index cb0be5603c..3d3213d3d3 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -186,8 +186,10 @@ class QemuRunner:
186 except: 186 except:
187 self.logger.error("qemurunner: qmp.py missing, please ensure it's installed") 187 self.logger.error("qemurunner: qmp.py missing, please ensure it's installed")
188 return False 188 return False
189 qmp_port = self.tmpdir + "/." + next(tempfile._get_candidate_names()) 189 # Path relative to tmpdir used as cwd for qemu below to avoid unix socket path length issues
190 qmp_param = ' -S -qmp unix:%s,server,wait' % (qmp_port) 190 qmp_file = "." + next(tempfile._get_candidate_names())
191 qmp_param = ' -S -qmp unix:./%s,server,wait' % (qmp_file)
192 qmp_port = self.tmpdir + "/" + qmp_file
191 193
192 try: 194 try:
193 if self.serial_ports >= 2: 195 if self.serial_ports >= 2:
@@ -224,7 +226,7 @@ class QemuRunner:
224 # blocking at the end of the runqemu script when using this within 226 # blocking at the end of the runqemu script when using this within
225 # oe-selftest (this makes stty error out immediately). There ought 227 # oe-selftest (this makes stty error out immediately). There ought
226 # to be a proper fix but this will suffice for now. 228 # to be a proper fix but this will suffice for now.
227 self.runqemu = subprocess.Popen(launch_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, preexec_fn=os.setpgrp, env=env) 229 self.runqemu = subprocess.Popen(launch_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, preexec_fn=os.setpgrp, env=env, cwd=self.tmpdir)
228 output = self.runqemu.stdout 230 output = self.runqemu.stdout
229 231
230 # 232 #
@@ -287,31 +289,37 @@ class QemuRunner:
287 # This will allow us to read status from Qemu if the the process 289 # This will allow us to read status from Qemu if the the process
288 # is still alive 290 # is still alive
289 self.logger.debug("QMP Initializing to %s" % (qmp_port)) 291 self.logger.debug("QMP Initializing to %s" % (qmp_port))
292 # chdir dance for path length issues with unix sockets
293 origpath = os.getcwd()
290 try: 294 try:
291 self.qmp = qmp.QEMUMonitorProtocol(qmp_port) 295 os.chdir(os.path.dirname(qmp_port))
292 except OSError as msg: 296 try:
293 self.logger.warning("Failed to initialize qemu monitor socket: %s File: %s" % (msg, msg.filename)) 297 self.qmp = qmp.QEMUMonitorProtocol(os.path.basename(qmp_port))
294 return False 298 except OSError as msg:
299 self.logger.warning("Failed to initialize qemu monitor socket: %s File: %s" % (msg, msg.filename))
300 return False
295 301
296 self.logger.debug("QMP Connecting to %s" % (qmp_port)) 302 self.logger.debug("QMP Connecting to %s" % (qmp_port))
297 if not os.path.exists(qmp_port) and self.is_alive():
298 self.logger.debug("QMP Port does not exist waiting for it to be created")
299 endtime = time.time() + self.runqemutime
300 while not os.path.exists(qmp_port) and self.is_alive() and time.time() < endtime:
301 self.logger.warning("QMP port does not exist yet!")
302 time.sleep(0.5)
303 if not os.path.exists(qmp_port) and self.is_alive(): 303 if not os.path.exists(qmp_port) and self.is_alive():
304 self.logger.warning("QMP Port still does not exist but QEMU is alive") 304 self.logger.debug("QMP Port does not exist waiting for it to be created")
305 return False 305 endtime = time.time() + self.runqemutime
306 while not os.path.exists(qmp_port) and self.is_alive() and time.time() < endtime:
307 self.logger.warning("QMP port does not exist yet!")
308 time.sleep(0.5)
309 if not os.path.exists(qmp_port) and self.is_alive():
310 self.logger.warning("QMP Port still does not exist but QEMU is alive")
311 return False
306 312
307 try: 313 try:
308 self.qmp.connect() 314 self.qmp.connect()
309 except OSError as msg: 315 except OSError as msg:
310 self.logger.warning("Failed to connect qemu monitor socket: %s File: %s" % (msg, msg.filename)) 316 self.logger.warning("Failed to connect qemu monitor socket: %s File: %s" % (msg, msg.filename))
311 return False 317 return False
312 except qmp.QMPConnectError as msg: 318 except qmp.QMPConnectError as msg:
313 self.logger.warning("Failed to communicate with qemu monitor: %s" % (msg)) 319 self.logger.warning("Failed to communicate with qemu monitor: %s" % (msg))
314 return False 320 return False
321 finally:
322 os.chdir(origpath)
315 323
316 # Release the qemu porcess to continue running 324 # Release the qemu porcess to continue running
317 self.run_monitor('cont') 325 self.run_monitor('cont')