On Tue, Aug 29, 2017 at 09:06:48AM -0300, Philippe Mathieu-Daudé wrote: > Hi Fam, > > On 08/28/2017 02:47 PM, Fam Zheng wrote: > > This is the common code to implement a "VM test" to > > > > 1) Download and initialize a pre-defined VM that has necessary > > dependencies to build QEMU and SSH access. > > > > 2) Archive $SRC_PATH to a .tar file. > > > > 3) Boot the VM, and pass the source tar file to the guest. > > > > 4) SSH into the VM, untar the source tarball, build from the source. > > > > Signed-off-by: Fam Zheng <f...@redhat.com> > > --- > > tests/vm/basevm.py | 287 > > +++++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 287 insertions(+) > > create mode 100755 tests/vm/basevm.py > > > > diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py > > new file mode 100755 > > index 0000000000..d0095c5332 > > --- /dev/null > > +++ b/tests/vm/basevm.py
> > + def add_source_dir(self, data_dir): > > + name = "data-" + hashlib.sha1(data_dir).hexdigest()[:5] > > + tarfile = os.path.join(self._tmpdir, name + ".tar") > > + logging.debug("Creating archive %s for data dir: %s", tarfile, > > data_dir) > > + if subprocess.call("type gtar", stdout=self._devnull, > > + stderr=self._devnull, shell=True) == 0: > > + tar_cmd = "gtar" > > + else: > > + tar_cmd = "tar" > > + subprocess.check_call([tar_cmd, > > + "--exclude-vcs", > > + "--exclude=tests/vm/*.img", > > + "--exclude=tests/vm/*.img.*", > > + "--exclude=*.d", > > + "--exclude=*.o", > > + "--exclude=docker-src.*", > > + "-cf", tarfile, '.'], cwd=data_dir, > > I'm not happy with this command :/ > My distrib uses tmpfs for /tmp and suddently the whole X window became > irresponsive until this script failing after filling 8G of /tmp and swap: > > ... > DEBUG:root:Creating archive /tmp/qemu-vm-F7CY9O/data-3a52c.tar for data dir: > . > tar: /tmp/qemu-vm-F7CY9O/data-3a52c.tar: Wrote only 4096 of 10240 bytes > tar: Error is not recoverable: exiting now > Failed to prepare guest environment > > Then I figured out my workdir is full of testing stuff, debug images, > firmwares, coredumps, etc. > > I'll think of another way. Yeah, /tmp should never be used for anything which has significant size. Could go for /var/tmp instead, but IMHO just use the QEMU build dir, as is done for (almost) all other build & test artifacts and thus avoid any global dirs. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|