mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-05 05:04:44 +02:00
runqemu: respect IMAGE_LINK_NAME
* when searching for qemuboot.conf * don't assume that IMAGE_LINK_NAME is always <rootfs>-<machine> (with <rootfs>-<machine>.qemuboot.conf) * runqemu: use IMAGE_LINK_NAME set by testimage.bbclass or query with bitbake -e * testimage.bbclass was setting DEPLOY_DIR which I don't see used anywhere else, so I assume it was supposed to be DEPLOY_DIR_IMAGE as mentioned in corresponding runqemu code, do the same with IMAGE_LINK_NAME variable * add virtual/kernel as bitbake -e target in run_bitbake_env to make sure IMAGE_LINK_NAME is defined (kernel-artifact-names.bbclass inherits image-artifact-names.bbclass as well) * improve .qemuboot.conf search 1st search for file matching the rootfs and only when not found try again with .rootfs suffix removed [YOCTO #12937] (From OE-Core rev: 82b7a8d5e81d766d0a5c2d0fef0f4c13a8f80c31) Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 716eb55bb963db7b02d985849cb025898aabc855) Signed-off-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
parent
d4e7033be5
commit
bc0bc0504e
|
@ -98,7 +98,7 @@ TESTIMAGELOCK:qemuall = ""
|
|||
|
||||
TESTIMAGE_DUMP_DIR ?= "${LOG_DIR}/runtime-hostdump/"
|
||||
|
||||
TESTIMAGE_UPDATE_VARS ?= "DL_DIR WORKDIR DEPLOY_DIR"
|
||||
TESTIMAGE_UPDATE_VARS ?= "DL_DIR WORKDIR DEPLOY_DIR_IMAGE IMAGE_LINK_NAME"
|
||||
|
||||
testimage_dump_target () {
|
||||
top -bn1
|
||||
|
|
|
@ -381,13 +381,19 @@ class BaseConfig(object):
|
|||
fst = m.group(1)
|
||||
if fst:
|
||||
self.check_arg_fstype(fst)
|
||||
qb = re.sub('\.' + fst + "$", '', self.rootfs)
|
||||
qb = '%s%s' % (re.sub('\.rootfs$', '', qb), '.qemuboot.conf')
|
||||
qb = re.sub('\.' + fst + "$", '.qemuboot.conf', self.rootfs)
|
||||
if os.path.exists(qb):
|
||||
self.qemuboot = qb
|
||||
self.qbconfload = True
|
||||
else:
|
||||
logger.warning("%s doesn't exist" % qb)
|
||||
logger.warning("%s doesn't exist, will try to remove '.rootfs' from filename" % qb)
|
||||
# They to remove .rootfs (IMAGE_NAME_SUFFIX) as well
|
||||
qb = re.sub('\.rootfs.qemuboot.conf$', '.qemuboot.conf', qb)
|
||||
if os.path.exists(qb):
|
||||
self.qemuboot = qb
|
||||
self.qbconfload = True
|
||||
else:
|
||||
logger.warning("%s doesn't exist" % qb)
|
||||
else:
|
||||
raise RunQemuError("Can't find FSTYPE from: %s" % p)
|
||||
|
||||
|
@ -421,6 +427,7 @@ class BaseConfig(object):
|
|||
# are there other scenarios in which we need to support being
|
||||
# invoked by bitbake?
|
||||
deploy = self.get('DEPLOY_DIR_IMAGE')
|
||||
image_link_name = self.get('IMAGE_LINK_NAME')
|
||||
bbchild = deploy and self.get('OE_TMPDIR')
|
||||
if bbchild:
|
||||
self.set_machine_deploy_dir(arg, deploy)
|
||||
|
@ -445,6 +452,12 @@ class BaseConfig(object):
|
|||
else:
|
||||
logger.error("%s not a directory valid DEPLOY_DIR_IMAGE" % deploy_dir_image)
|
||||
self.set("MACHINE", arg)
|
||||
if not image_link_name:
|
||||
s = re.search('^IMAGE_LINK_NAME="(.*)"', self.bitbake_e, re.M)
|
||||
if s:
|
||||
image_link_name = s.group(1)
|
||||
self.set("IMAGE_LINK_NAME", image_link_name)
|
||||
logger.debug('Using IMAGE_LINK_NAME = "%s"' % image_link_name)
|
||||
|
||||
def set_dri_path(self):
|
||||
# As runqemu can be run within bitbake (when using testimage, for example),
|
||||
|
@ -557,11 +570,18 @@ class BaseConfig(object):
|
|||
self.check_arg_machine(unknown_arg)
|
||||
|
||||
if not (self.get('DEPLOY_DIR_IMAGE') or self.qbconfload):
|
||||
self.load_bitbake_env()
|
||||
self.load_bitbake_env(target=self.rootfs)
|
||||
s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M)
|
||||
if s:
|
||||
self.set("DEPLOY_DIR_IMAGE", s.group(1))
|
||||
|
||||
if not self.get('IMAGE_LINK_NAME') and self.rootfs:
|
||||
s = re.search('^IMAGE_LINK_NAME="(.*)"', self.bitbake_e, re.M)
|
||||
if s:
|
||||
image_link_name = s.group(1)
|
||||
self.set("IMAGE_LINK_NAME", image_link_name)
|
||||
logger.debug('Using IMAGE_LINK_NAME = "%s"' % image_link_name)
|
||||
|
||||
def check_kvm(self):
|
||||
"""Check kvm and kvm-host"""
|
||||
if not (self.kvm_enabled or self.vhost_enabled):
|
||||
|
@ -667,8 +687,8 @@ class BaseConfig(object):
|
|||
|
||||
if self.rootfs and not os.path.exists(self.rootfs):
|
||||
# Lazy rootfs
|
||||
self.rootfs = "%s/%s-%s.%s" % (self.get('DEPLOY_DIR_IMAGE'),
|
||||
self.rootfs, self.get('MACHINE'),
|
||||
self.rootfs = "%s/%s.%s" % (self.get('DEPLOY_DIR_IMAGE'),
|
||||
self.get('IMAGE_LINK_NAME'),
|
||||
self.fstype)
|
||||
elif not self.rootfs:
|
||||
cmd_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype)
|
||||
|
@ -872,8 +892,10 @@ class BaseConfig(object):
|
|||
machine = self.get('MACHINE')
|
||||
if not machine:
|
||||
machine = os.path.basename(deploy_dir_image)
|
||||
self.qemuboot = "%s/%s-%s.qemuboot.conf" % (deploy_dir_image,
|
||||
self.rootfs, machine)
|
||||
if not self.get('IMAGE_LINK_NAME'):
|
||||
raise RunQemuError("IMAGE_LINK_NAME wasn't set to find corresponding .qemuboot.conf file")
|
||||
self.qemuboot = "%s/%s.qemuboot.conf" % (deploy_dir_image,
|
||||
self.get('IMAGE_LINK_NAME'))
|
||||
else:
|
||||
cmd = 'ls -t %s/*.qemuboot.conf' % deploy_dir_image
|
||||
logger.debug('Running %s...' % cmd)
|
||||
|
@ -1569,7 +1591,7 @@ class BaseConfig(object):
|
|||
|
||||
self.cleaned = True
|
||||
|
||||
def run_bitbake_env(self, mach=None):
|
||||
def run_bitbake_env(self, mach=None, target=''):
|
||||
bitbake = shutil.which('bitbake')
|
||||
if not bitbake:
|
||||
return
|
||||
|
@ -1582,22 +1604,33 @@ class BaseConfig(object):
|
|||
multiconfig = "mc:%s" % multiconfig
|
||||
|
||||
if mach:
|
||||
cmd = 'MACHINE=%s bitbake -e %s' % (mach, multiconfig)
|
||||
cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target)
|
||||
else:
|
||||
cmd = 'bitbake -e %s' % multiconfig
|
||||
cmd = 'bitbake -e %s %s' % (multiconfig, target)
|
||||
|
||||
logger.info('Running %s...' % cmd)
|
||||
return subprocess.check_output(cmd, shell=True).decode('utf-8')
|
||||
try:
|
||||
return subprocess.check_output(cmd, shell=True).decode('utf-8')
|
||||
except subprocess.CalledProcessError as err:
|
||||
logger.warning("Couldn't run '%s' to gather environment information, maybe the target wasn't an image name, will retry with virtual/kernel as a target:\n%s" % (cmd, err.output.decode('utf-8')))
|
||||
# need something with IMAGE_NAME_SUFFIX/IMAGE_LINK_NAME defined (kernel also inherits image-artifact-names.bbclass)
|
||||
target = 'virtual/kernel'
|
||||
if mach:
|
||||
cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target)
|
||||
else:
|
||||
cmd = 'bitbake -e %s %s' % (multiconfig, target)
|
||||
try:
|
||||
return subprocess.check_output(cmd, shell=True).decode('utf-8')
|
||||
except subprocess.CalledProcessError as err:
|
||||
logger.warning("Couldn't run '%s' to gather environment information, giving up with 'bitbake -e':\n%s" % (cmd, err.output.decode('utf-8')))
|
||||
return ''
|
||||
|
||||
def load_bitbake_env(self, mach=None):
|
||||
|
||||
def load_bitbake_env(self, mach=None, target=None):
|
||||
if self.bitbake_e:
|
||||
return
|
||||
|
||||
try:
|
||||
self.bitbake_e = self.run_bitbake_env(mach=mach)
|
||||
except subprocess.CalledProcessError as err:
|
||||
self.bitbake_e = ''
|
||||
logger.warning("Couldn't run 'bitbake -e' to gather environment information:\n%s" % err.output.decode('utf-8'))
|
||||
self.bitbake_e = self.run_bitbake_env(mach=mach, target=target)
|
||||
|
||||
def validate_combos(self):
|
||||
if (self.fstype in self.vmtypes) and self.kernel:
|
||||
|
|
Loading…
Reference in New Issue
Block a user