mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 18:49:32 +02:00
runqemu: Ensure we cleanup snapshot files after image run
We need to cleanup snapshot files if we make a copy of them to ensure the tmpfs doesn't run out of space. There is already NFS code needing this so make it a generic code path. (From OE-Core rev: a3e0eec5a4785a0c4859455eb10b43aa832e606d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -145,7 +145,6 @@ class BaseConfig(object):
|
|||||||
self.qemu_opt = ''
|
self.qemu_opt = ''
|
||||||
self.qemu_opt_script = ''
|
self.qemu_opt_script = ''
|
||||||
self.qemuparams = ''
|
self.qemuparams = ''
|
||||||
self.clean_nfs_dir = False
|
|
||||||
self.nfs_server = ''
|
self.nfs_server = ''
|
||||||
self.rootfs = ''
|
self.rootfs = ''
|
||||||
# File name(s) of a OVMF firmware file or variable store,
|
# File name(s) of a OVMF firmware file or variable store,
|
||||||
@@ -210,6 +209,8 @@ class BaseConfig(object):
|
|||||||
self.qemupid = None
|
self.qemupid = None
|
||||||
# avoid cleanup twice
|
# avoid cleanup twice
|
||||||
self.cleaned = False
|
self.cleaned = False
|
||||||
|
# Files to cleanup after run
|
||||||
|
self.cleanup_files = []
|
||||||
|
|
||||||
def acquire_taplock(self, error=True):
|
def acquire_taplock(self, error=True):
|
||||||
logger.debug("Acquiring lockfile %s..." % self.taplock)
|
logger.debug("Acquiring lockfile %s..." % self.taplock)
|
||||||
@@ -1020,8 +1021,9 @@ class BaseConfig(object):
|
|||||||
logger.info('Running %s...' % str(cmd))
|
logger.info('Running %s...' % str(cmd))
|
||||||
if subprocess.call(cmd) != 0:
|
if subprocess.call(cmd) != 0:
|
||||||
raise RunQemuError('Failed to run %s' % cmd)
|
raise RunQemuError('Failed to run %s' % cmd)
|
||||||
self.clean_nfs_dir = True
|
|
||||||
self.rootfs = dest
|
self.rootfs = dest
|
||||||
|
self.cleanup_files.append(self.rootfs)
|
||||||
|
self.cleanup_files.append('%s.pseudo_state' % self.rootfs)
|
||||||
|
|
||||||
# Start the userspace NFS server
|
# Start the userspace NFS server
|
||||||
cmd = ('runqemu-export-rootfs', 'start', self.rootfs)
|
cmd = ('runqemu-export-rootfs', 'start', self.rootfs)
|
||||||
@@ -1204,6 +1206,7 @@ class BaseConfig(object):
|
|||||||
self.rootfs = newrootfs
|
self.rootfs = newrootfs
|
||||||
# Don't need a second copy now!
|
# Don't need a second copy now!
|
||||||
self.snapshot = False
|
self.snapshot = False
|
||||||
|
self.cleanup_files.append(newrootfs)
|
||||||
|
|
||||||
qb_rootfs_opt = self.get('QB_ROOTFS_OPT')
|
qb_rootfs_opt = self.get('QB_ROOTFS_OPT')
|
||||||
if qb_rootfs_opt:
|
if qb_rootfs_opt:
|
||||||
@@ -1476,10 +1479,13 @@ class BaseConfig(object):
|
|||||||
if self.saved_stty:
|
if self.saved_stty:
|
||||||
subprocess.check_call(("stty", self.saved_stty))
|
subprocess.check_call(("stty", self.saved_stty))
|
||||||
|
|
||||||
if self.clean_nfs_dir:
|
if self.cleanup_files:
|
||||||
logger.info('Removing %s' % self.rootfs)
|
for ent in self.cleanup_files:
|
||||||
shutil.rmtree(self.rootfs)
|
logger.info('Removing %s' % ent)
|
||||||
shutil.rmtree('%s.pseudo_state' % self.rootfs)
|
if os.path.isfile(ent):
|
||||||
|
os.remove(ent)
|
||||||
|
else:
|
||||||
|
shutil.rmtree(ent)
|
||||||
|
|
||||||
self.cleaned = True
|
self.cleaned = True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user