summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/qemurunner.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-05 19:15:54 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-06 11:16:24 +0100
commit1140cca023e58af5e20aed9432e4210afd67f0e1 (patch)
treee2e521e8f5c56fb6299edea7f7e2fe07741070f7 /meta/lib/oeqa/utils/qemurunner.py
parente293a3793573ad19f08663fbfcb8f7d9ee828ba4 (diff)
downloadpoky-1140cca023e58af5e20aed9432e4210afd67f0e1.tar.gz
oeqa/qemurunner: Handle path length issues for qmp socket
After the addition of the qmp socket, runqemu started failing: ERROR - Failed to run qemu: qemu-system-aarch64: -qmp unix:/home/yocto/actions-runner-meta-openembedded/_work/meta-openembedded/meta-openembedded/yoe/build/tmp/.3eg5fiid,server,wait: UNIX socket path '/home/yocto/actions-runner-meta-openembedded/_work/meta-openembedded/meta-openembedded/yoe/build/tmp/.3eg5fiid' is too long Path must be less than 108 bytes To avoid this, run qemu within tmpdir and use a relative path to the socket. This avoids having to patch the socket code within qemu. Update the client code to chdir and only use a relative path to the socket to match. (From OE-Core rev: 5c56e72fca18dc942f5c1fd377e98d46ae0126f1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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')