aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/qemurunner.py
AgeCommit message (Collapse)Author
2015-09-22oeqa/utils/qemurunner.py: Remove duplicate message on LoggingThread startAníbal Limón
The Starting logging thread message is also executed on run() inside LoggingThread class. Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-22oeqa/utils/qemurunner.py: Fix HIGH CPU usage on LoggingThreadAníbal Limón
LoggingThread is used for receive console output from QEMU over TCP, so add filter to only wake poll on read events, also change the event mask variable name to be more descriptive. This fixes HIGH CPU consume caused by wake on ready to write events. Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-12oeqa: Test failure/cleanup improvementsRichard Purdie
Currently, if qemu segfaults, the tests merrily continue trying to execute which takes time for them to timeout and is a bit silly. Worse, no logs about the segfault are shown to the user, its silent! This patch tries to unravel the tangled web of issues and ensures that we: * install a SIGCHLD handler which tells the user qemu exited * check if qemu is running, if it isn't fail the test outright * don't leave processes behind in sshcontrol which would hold bitbake.lock and block shutdown (From OE-Core rev: 77e9363feba53b72429154be5713c46b007ae0a4) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-09qemurunner: Fix killpg pid usageRichard Purdie
killpg should be being called with a pgid, not a pid. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-09qemurunner: Ensure runqemu doesn't survive SIGKILLRichard Purdie
Currently, we see runqemu and qemu-system-* processes left behind when bitbake is killed by buildbot. This is due to the use of setpgrp() in the runqemu subprocess call. We need the setpgrp call so that all runqemu processes can easily be killed (by killing their process group). This presents a problem if this controlling process itself is killed however since those processes don't notice the death of the parent and merrily continue on. Rather than hack runqemu to deal with this, we add something to qemurunner, at least for now to resolve the issue. Basically we fork off another process which holds an open pipe to the parent and also is setpgrp. If/when the pipe sees EOF from the parent dieing, it kills the process group. This is like pctrl's PDEATHSIG but for a process group rather than a single process. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-07qemurunner: Drop error to a warning to improve user feedbackRichard Purdie
If a task shows an error, the full log is surpressed since bitbake assumes the user has been shown what is wrong. In this code path that isn't the case and its much more helpful to show the user the full error. Therefore show a warning instead to aid usability. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-05oeqa: Test failure/cleanup improvementsRichard Purdie
Currently, if qemu segfaults, the tests merrily continue trying to execute which takes time for them to timeout and is a bit silly. Worse, no logs about the segfault are shown to the user, its silent! This patch tries to unravel the tangled web of issues and ensures that we: * install a SIGCHLD handler which tells the user qemu exited * check if qemu is running, if it isn't fail the test outright * don't leave processes behind in sshcontrol which would hold bitbake.lock and block shutdown Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-02qemurunner: Handle lack of data on run serial gracefullyMariano Lopez
This changes the behavior when data was not received over the serial console when a command is run. With this the socket is no longer closed but it throws and exception that can handled in upper layers. With this the test can continue without throwing errors for not having the socket anymore. [YOCTO #8118] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-01qemurunner: Added host dumps when there are errorsMariano Lopez
This adds an instance of HostDumper to qemurunner, with this instance now is possible to get dumps from the host when there is an error. This adds dump points in the next cases: - runqemu exits before seeing qemu pid - Fail to get qemu process arguments - Not reach login banner before timeout - qemu pid never appears This also modifies the constructors of BaseDumper, HostDumper and TargetDumper, they don't require the datastore anymore, but the feature to replace datastore variables has been lost (never used) [YOCTO #8118] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-29qemurunner: Don't loop on EWOULDBLOCK in logging thread.Randy Witt
EAGAIN/EWOULDBLOCK can be followed by no data. So don't tight loop waiting for data. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-26qemurunner: In the logging thread retry on EAGAIN, EWOULDBLOCKRandy Witt
On a nonblocking socket an exception can be generated for the EAGAIN and EWOULDBLOCK errnos. Since these aren't actually errors make sure to retry rather than bailing out. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-25qemurunner: Shut down logging thread successfully when test failsRandy Witt
Before this change on a test failure an exception would be generated due to runqemu being killed before the logging thread which was on the other end of the socket. The exception was actually correct saying there was no data on a socket marked readable, but this was because the qemu process was killed before the listener thread. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-24runqemu: Add a tcpserial optionRandy Witt
The option was added so that the qemurunner could start a second tcp serial port without adding machine conditional logic to qemurunner. The issue that made this necessary was that when "virt" is passed to qemu-system-aarch64, the normal mechanism for specifying a tcp serial port does not work. This is because the hardware for the "virt" machine is hardcoded in the device tree blob and the addition devices must be virtio devices. So runqemu can specify virtio for qemuarm64 whereas it seems all other qemu machines work with the "-serial tcp*" option. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-24qemurunner: Use two serial ports and log console with a threadRandy Witt
qemu can freeze and stop responding if the socket buffer connected to a tcp serial connection fills up. This happens of course when the reader of the serial data doesn't actually read it. This happened in the qemurunner code, because after checking for the "login:" sentinel, data was never again read from the serial connection. This patch solves the potential freeze by adding a thread to continuously read the data from the console and log it. So it also will give a full log of the console, rather than just up to the login prompt. To simplify this patch, another serial port was also added to use for the sole purpose of watching for the sentinel as well as being the interactive serial port. This will also prevent the possibility of lots of debug data on the console preventing the sentinel value from being seen due to interleaved text. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-08-24qemurunner: Make create_socket() return data and use exceptionsRandy Witt
So that create_socket() can be called more than once to create sockets, it now returns the socket and port rather than setting class variables directly. create_socket() now only uses exceptions for errors, not the return value from the function. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-08-24qemurunner.py: Move some class variables that should only be localRandy Witt
The bootlog and qemusock variables were set in the class as part of the create_socket() routine. However those variables are never used outside of the same function and thus serve no purpose as class variables. This initializes those variables near where they are used. Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-08-16qemurunner.py: Performance improvements in run_serialMariano Lopez
This allow to search for the prompt after a command is run so it can avoid waiting for the timeout. Also corrected identation issues [YOCTO #8118] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-08-16qemurunner.py: Added raw mode in run_serialMariano Lopez
Raw mode allows to send the command without sending 'echo $?' for validation; Also this doesn't remove the command or the prompt from the output returned. In raw mode validation is done if there is output. This raw mode would be useful for validate the prompt when a user logs in. [YOCTO #8118] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-08-16qemurunner.py: Added login to start methodMariano Lopez
This adds the automatic login after the target finished booting. If the automatic login fails it won't stop the target or any test, it would only send a log to the file. [YOCTO #8118] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-08-16qemurunner.py: Add method run_serialMariano Lopez
The only need for the console before this patch was to check if the target has booted. This allows to send commands to the terminal. This new method is based on the method with the same name of the QemuTinyRunner class. The difference here is it will remove the command and the prompt. The other diference is it will send an echo $? to check if the last command was successful. [YOCTO #8118] Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-08-09oeqa/qemurunner: Improve runqemu log output debugRichard Purdie
If runqemu fails, ensure the log output is shown as its invaluable to aid debugging. Its slightly convoluted since we need to ensure we don't block on reading the pipe which may still be executing hence the need for nonblocking IO. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-09qemurunner: Improves checking for server and target IPs on qemus parametersAlejandro Hernandez
Fixes OS hanging infinitely waiting for qemus process to release bitbake.lock Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27oeqa/qemurunner: Fix AttributeError: QemuRunner instance has no attribute ↵Richard Purdie
'server_socket' If start() returns False due to create_socker() failing, stop() may still get called and currently this gives a track back since server_socket doesn't exist. Avoid this. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27qemurunner: Show last 25 line of log, not 5Richard Purdie
For debugging purposes, 5 lines often isn't useful as it doesn't even cover a full backtrace. Show 25 instead. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27oeqa/utils/qemurunner: fix error handling if runqemu exits with an errorPaul Eggleton
* Don't wait for QEMU to start if it's never going to (because runqemu exited with an error) * Don't error out if killing the process fails with "no such process" (we don't care if it's already dead) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27oeqa/utils/qemurunner: avoid blocking on stty when running under oe-selftestPaul Eggleton
runqemu-internal runs stty to return the terminal to its previous state in case QEMU hasn't done that properly (which it at least used to do when it crashed). For some reason I have yet to determine, stty blocks (on tcsetattr() according to gdb) when run within QemuRunner() under oe-selftest, with the result that we always wait until the timeout and then we kill the script, which adds an extra delay after QEMU is stopped. Naturally you would assume that this is something to do with the nature of the terminal under which it is being run; however no amount of playing around with stdin/stdout/stderr seemed to fix the issue, apart from passing in subprocess.PIPE as stdin which makes stty error out with "stty: standard input: Inappropriate ioctl for device". I was also unable to come up with a reliable test for the terminal which we could use inside runqemu-internal to avoid calling stty. For now, go with the stdin=subprocess.PIPE workaround to at least avoid the delay with minimal ill effect. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27oeqa/utils/qemurunner: fix loggingPaul Eggleton
OE-Core commit 519e381278d40bdac79add340e4c0460a9f97e17 unfortunately broke logging in two different ways: 1) it prevented logging to the task log from working within bitbake -c testimage. This is due to the logger object being set up too early which interferes with BitBake's own logging. If we prefix the name with "BitBake." everything works (and we don't need to set the logging level). 2) Additionally because it called the log functions on the logging module and not the logger object it set up, this caused the oe-selftest logging to start printing everything from that point forward. Fix these two issues and return us to the desired behaviour for do_testimage. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-24oeqa/qemurunner: don't assume hostname starts with qemuRoss Burton
It's possible to customise the hostname trivially so don't assume that the hostname hasn't been configured. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-22oeqa/QemuRunner: don't use bb for loggingRoss Burton
Instead of using bb.note() etc for logging use logging.Logger directly, allowing the use of QemuRunner outside of bitbake. Also clean up the logging/errors by moving create_socket() out of __init__()/restart() and into start(). Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-11oeqa/utils/qemurunner: search for login string in the entire boot logStefan Stanacar
If some service is to spammy we might miss the login, so search in the entire log instead of just the last few lines. Use qemu in regex too (to avoid a login string from some service). Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-11oeqa/utils/qemurunner: use the right kill call so we don't send SIGTERM to ↵Stefan Stanacar
bitbake-worker After recent bitbake-worker changes [1] this was killing the bitbake-worker, which isn't what we want and kill(-pid) was the wrong call anyway. runqemu.pid is the right PGID as the process was started with preexec_fn=setpgrp (so no need to do os.getpgid(self.runqemu.pid)) [1] http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=15688798520896690561824b2fdc227c8a365c82 Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-12-03testimage: use the new targetcontrol.py module for running testsStefan Stanacar
This patch makes the necessary changes for using the targetcontrol.py module so that one can run the same tests on a qemu instance or a remote machine based on the value of TEST_TARGET variable: "qemu" or "simpleremote". The default value is "qemu" which starts a qemu instance and it's the with what we currently have. With "simpleremote", the remote machine must be up with network and ssh and you need to set TEST_TARGET_IP with the IP address of the remote machine (it can still be a qemu instance that was manually started). Basically testimage.bbclass now does something along the lines of: - load tests -> deploy (prepare) / start target -> run tests. There were a couple of changes necessary for tests and also some cleanups/renames that were needed to adjust this change. (use ip everywhere when refering to target and server_ip when refering to host/build machine) Also two unnecessary and unsed methods were dropped from sshcontrol. [ YOCTO #5554 ] Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-18qemurunner: disable grabs in automated testingRoss Burton
Use the new QEMU_DONT_GRAB environment variable to disable grabs, finally/hopefully solving the random hangs that the autobuilder has been hitting for a while. [ YOCTO #5131 ] Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-12bitbake.conf: include machine name in DEPLOY_DIR_IMAGEPaul Eggleton
This allows a clean seperation between image outputs from different machines, and makes it possible to have convenience symlinks to make the output ready to deploy. This did require some surgery in runqemu; if explicit paths to the image and kernel are not supplied then DEPLOY_DIR_IMAGE needs to be determined from bitbake or set in the environment. However the script does try to avoid requiring it unless it really is needed. Corresponding changes were made in the automated testing code as well. Based on an RFC patch by Koen Kooi <koen@dominion.thruhere.net> Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-06lib/oeqa/qemurunner: Use a timeout in select() callRichard Purdie
A 0 value to select.select() immediately returns with no timeout. This was pegging the cpu at 100% for the python process which was bad and may be contributing to some of the timeout problems. Profile from -P of a core-image-minimal before: 97526792 function calls (97525652 primitive calls) in 45.189 seconds and after: 50204 function calls (49064 primitive calls) in 17.318 seconds Saving 97.5 million function calls has to be good :) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-30lib/oeqa/utils: qemurunner: fix when runqemu errors outStefan Stanacar
When qemu doesn't start or runqemu errors out (some wrong option passed or sudo needs a password for setting tap) we want to display the output but oe-core commit 9de7fe11967576f4a8b24e653c6b9a02e5f6d85b/ poky commit 51588936d4a8cde3c9bb05800240c0a0f5dedf8d changed the kill method and broke this code, so let's fix it. Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-26lib/oeqa: make it possible to restart the targetStefan Stanacar
Tweak QemuRunner so we can actually restart the qemu target in a test (if we want more memory for example). Also add a restart method to the base test class so that tests can use it. Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-08-26lib/oeqa/utils: qemurunner: save host IP addressMihai Lindner
Save host IP address to host_ip. Read /proc/PID/cmdline on host to look for IPs of target and host; instead of running 'ps'. Also removed some extra empty lines from file. Signed-off-by: Mihai Lindner <mihaix.lindner@linux.intel.com> Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-08-13oeqa/utils/qemurunner: get ip old fashioned way and use tcp serial consoleStefan Stanacar
The way we read data from the serial console was unreliable and blocking (AutoBuilder seems to hit that often), so change the serial console type from unix socket to tcp and reverse the connection - don't let qemu act as server (wait for a connection). So now the serial console is used to save the boot log and make sure that we reached the login prompt. Until a better way is found this should solve some of the AutoBuilder failures (one being YB#4904). Also we need to use the same method as the old qemuimagetest to get the ip (from the qemu process arguments), because that it's more reliable. The first version used here was to log into the target and use the output of "ip addr show eth0" but then systemd decides that it should rename interfaces, so that was changed to get the ip of the interface that has the default gw, but if there is no default gw we'll get the loopback ip and we end up trying to ssh into the host machine (some recent AutoBuilder runs showed that). Changed in V2: - use -ww for ps, as output might get truncated Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-08-05oeqa/utils/qemurunner: fix wrong var in messageStefan Stanacar
If nothing matches we should print the text not the match, else we get a nice traceback. Changed in V2: - commit message Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-08-01oeqa/utils/qemurunner: tweak console bootparam and ip commandStefan Stanacar
Sync serial baud rate with default inittab which should help with apparent boot fails. Also keep a console on tty1. Also we shouldn't assume eth0 it the right interface. (systemd images can rename interfaces to something else). Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-08-01oeqa/utils/qemurunner: add comment and headerStefan Stanacar
One of the files was missing comment/header, unlike the others. Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-07-15classes/testimage.bbclass: use a copy of rootfs for testsStefan Stanacar
Make a copy of the rootfs and test that. We can now drop the snapshot option. Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-07-15testimage.bbclass, lib/oeqa/utils/qemurunner.py: make boot timeout ↵Stefan Stanacar
configurable and increase it On a loaded host (such as an AB setup where multiple builds run) the 200 seconds timeout might not be enough to reach the login prompt. Also make it configurable so we can set it from local.conf/auto.conf Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2013-07-09lib/oeqa/utils/qemurunner.py: class to handle qemu instanceRadu Moisan
Handles qemu instances (launch, kill, restart, serial connection, logging) Launch is blocking until login prompt and returns to the task. A qemu serial connection is used to save the boot log and get the ip from the image. Changed runqemu script not to error out when using custom serial option. Signed-off-by: Radu Moisan <radu.moisan@intel.com> Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>