diff options
| author | Martin Jansa <Martin.Jansa@gmail.com> | 2023-03-31 01:27:24 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-04-04 13:11:49 +0100 |
| commit | 3f0acc2a6133bf8cd3cb2c5046cf6f7e8943283c (patch) | |
| tree | 547cea7dee6a7dd341e2bed27f6212e23b74cd52 /scripts | |
| parent | 658728a67871f4ee10369308f166577053478300 (diff) | |
| download | poky-3f0acc2a6133bf8cd3cb2c5046cf6f7e8943283c.tar.gz | |
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: 716eb55bb963db7b02d985849cb025898aabc855)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/runqemu | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index 09b0ad5ed5..4c06cefbff 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
| @@ -384,13 +384,19 @@ class BaseConfig(object): | |||
| 384 | fst = m.group(1) | 384 | fst = m.group(1) |
| 385 | if fst: | 385 | if fst: |
| 386 | self.check_arg_fstype(fst) | 386 | self.check_arg_fstype(fst) |
| 387 | qb = re.sub('\.' + fst + "$", '', self.rootfs) | 387 | qb = re.sub('\.' + fst + "$", '.qemuboot.conf', self.rootfs) |
| 388 | qb = '%s%s' % (re.sub('\.rootfs$', '', qb), '.qemuboot.conf') | ||
| 389 | if os.path.exists(qb): | 388 | if os.path.exists(qb): |
| 390 | self.qemuboot = qb | 389 | self.qemuboot = qb |
| 391 | self.qbconfload = True | 390 | self.qbconfload = True |
| 392 | else: | 391 | else: |
| 393 | logger.warning("%s doesn't exist" % qb) | 392 | logger.warning("%s doesn't exist, will try to remove '.rootfs' from filename" % qb) |
| 393 | # They to remove .rootfs (IMAGE_NAME_SUFFIX) as well | ||
| 394 | qb = re.sub('\.rootfs.qemuboot.conf$', '.qemuboot.conf', qb) | ||
| 395 | if os.path.exists(qb): | ||
| 396 | self.qemuboot = qb | ||
| 397 | self.qbconfload = True | ||
| 398 | else: | ||
| 399 | logger.warning("%s doesn't exist" % qb) | ||
| 394 | else: | 400 | else: |
| 395 | raise RunQemuError("Can't find FSTYPE from: %s" % p) | 401 | raise RunQemuError("Can't find FSTYPE from: %s" % p) |
| 396 | 402 | ||
| @@ -424,6 +430,7 @@ class BaseConfig(object): | |||
| 424 | # are there other scenarios in which we need to support being | 430 | # are there other scenarios in which we need to support being |
| 425 | # invoked by bitbake? | 431 | # invoked by bitbake? |
| 426 | deploy = self.get('DEPLOY_DIR_IMAGE') | 432 | deploy = self.get('DEPLOY_DIR_IMAGE') |
| 433 | image_link_name = self.get('IMAGE_LINK_NAME') | ||
| 427 | bbchild = deploy and self.get('OE_TMPDIR') | 434 | bbchild = deploy and self.get('OE_TMPDIR') |
| 428 | if bbchild: | 435 | if bbchild: |
| 429 | self.set_machine_deploy_dir(arg, deploy) | 436 | self.set_machine_deploy_dir(arg, deploy) |
| @@ -448,6 +455,12 @@ class BaseConfig(object): | |||
| 448 | else: | 455 | else: |
| 449 | logger.error("%s not a directory valid DEPLOY_DIR_IMAGE" % deploy_dir_image) | 456 | logger.error("%s not a directory valid DEPLOY_DIR_IMAGE" % deploy_dir_image) |
| 450 | self.set("MACHINE", arg) | 457 | self.set("MACHINE", arg) |
| 458 | if not image_link_name: | ||
| 459 | s = re.search('^IMAGE_LINK_NAME="(.*)"', self.bitbake_e, re.M) | ||
| 460 | if s: | ||
| 461 | image_link_name = s.group(1) | ||
| 462 | self.set("IMAGE_LINK_NAME", image_link_name) | ||
| 463 | logger.debug('Using IMAGE_LINK_NAME = "%s"' % image_link_name) | ||
| 451 | 464 | ||
| 452 | def set_dri_path(self): | 465 | def set_dri_path(self): |
| 453 | drivers_path = os.path.join(self.bindir_native, '../lib/dri') | 466 | drivers_path = os.path.join(self.bindir_native, '../lib/dri') |
| @@ -550,11 +563,18 @@ to your build configuration. | |||
| 550 | self.check_arg_machine(unknown_arg) | 563 | self.check_arg_machine(unknown_arg) |
| 551 | 564 | ||
| 552 | if not (self.get('DEPLOY_DIR_IMAGE') or self.qbconfload): | 565 | if not (self.get('DEPLOY_DIR_IMAGE') or self.qbconfload): |
| 553 | self.load_bitbake_env() | 566 | self.load_bitbake_env(target=self.rootfs) |
| 554 | s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M) | 567 | s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M) |
| 555 | if s: | 568 | if s: |
| 556 | self.set("DEPLOY_DIR_IMAGE", s.group(1)) | 569 | self.set("DEPLOY_DIR_IMAGE", s.group(1)) |
| 557 | 570 | ||
| 571 | if not self.get('IMAGE_LINK_NAME') and self.rootfs: | ||
| 572 | s = re.search('^IMAGE_LINK_NAME="(.*)"', self.bitbake_e, re.M) | ||
| 573 | if s: | ||
| 574 | image_link_name = s.group(1) | ||
| 575 | self.set("IMAGE_LINK_NAME", image_link_name) | ||
| 576 | logger.debug('Using IMAGE_LINK_NAME = "%s"' % image_link_name) | ||
| 577 | |||
| 558 | def check_kvm(self): | 578 | def check_kvm(self): |
| 559 | """Check kvm and kvm-host""" | 579 | """Check kvm and kvm-host""" |
| 560 | if not (self.kvm_enabled or self.vhost_enabled): | 580 | if not (self.kvm_enabled or self.vhost_enabled): |
| @@ -660,8 +680,8 @@ to your build configuration. | |||
| 660 | 680 | ||
| 661 | if self.rootfs and not os.path.exists(self.rootfs): | 681 | if self.rootfs and not os.path.exists(self.rootfs): |
| 662 | # Lazy rootfs | 682 | # Lazy rootfs |
| 663 | self.rootfs = "%s/%s-%s.%s" % (self.get('DEPLOY_DIR_IMAGE'), | 683 | self.rootfs = "%s/%s.%s" % (self.get('DEPLOY_DIR_IMAGE'), |
| 664 | self.rootfs, self.get('MACHINE'), | 684 | self.get('IMAGE_LINK_NAME'), |
| 665 | self.fstype) | 685 | self.fstype) |
| 666 | elif not self.rootfs: | 686 | elif not self.rootfs: |
| 667 | glob_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype) | 687 | glob_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype) |
| @@ -865,8 +885,10 @@ to your build configuration. | |||
| 865 | machine = self.get('MACHINE') | 885 | machine = self.get('MACHINE') |
| 866 | if not machine: | 886 | if not machine: |
| 867 | machine = os.path.basename(deploy_dir_image) | 887 | machine = os.path.basename(deploy_dir_image) |
| 868 | self.qemuboot = "%s/%s-%s.qemuboot.conf" % (deploy_dir_image, | 888 | if not self.get('IMAGE_LINK_NAME'): |
| 869 | self.rootfs, machine) | 889 | raise RunQemuError("IMAGE_LINK_NAME wasn't set to find corresponding .qemuboot.conf file") |
| 890 | self.qemuboot = "%s/%s.qemuboot.conf" % (deploy_dir_image, | ||
| 891 | self.get('IMAGE_LINK_NAME')) | ||
| 870 | else: | 892 | else: |
| 871 | cmd = 'ls -t %s/*.qemuboot.conf' % deploy_dir_image | 893 | cmd = 'ls -t %s/*.qemuboot.conf' % deploy_dir_image |
| 872 | logger.debug('Running %s...' % cmd) | 894 | logger.debug('Running %s...' % cmd) |
| @@ -1600,7 +1622,7 @@ to your build configuration. | |||
| 1600 | 1622 | ||
| 1601 | self.cleaned = True | 1623 | self.cleaned = True |
| 1602 | 1624 | ||
| 1603 | def run_bitbake_env(self, mach=None): | 1625 | def run_bitbake_env(self, mach=None, target=''): |
| 1604 | bitbake = shutil.which('bitbake') | 1626 | bitbake = shutil.which('bitbake') |
| 1605 | if not bitbake: | 1627 | if not bitbake: |
| 1606 | return | 1628 | return |
| @@ -1613,22 +1635,33 @@ to your build configuration. | |||
| 1613 | multiconfig = "mc:%s" % multiconfig | 1635 | multiconfig = "mc:%s" % multiconfig |
| 1614 | 1636 | ||
| 1615 | if mach: | 1637 | if mach: |
| 1616 | cmd = 'MACHINE=%s bitbake -e %s' % (mach, multiconfig) | 1638 | cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target) |
| 1617 | else: | 1639 | else: |
| 1618 | cmd = 'bitbake -e %s' % multiconfig | 1640 | cmd = 'bitbake -e %s %s' % (multiconfig, target) |
| 1619 | 1641 | ||
| 1620 | logger.info('Running %s...' % cmd) | 1642 | logger.info('Running %s...' % cmd) |
| 1621 | return subprocess.check_output(cmd, shell=True).decode('utf-8') | 1643 | try: |
| 1644 | return subprocess.check_output(cmd, shell=True).decode('utf-8') | ||
| 1645 | except subprocess.CalledProcessError as err: | ||
| 1646 | 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'))) | ||
| 1647 | # need something with IMAGE_NAME_SUFFIX/IMAGE_LINK_NAME defined (kernel also inherits image-artifact-names.bbclass) | ||
| 1648 | target = 'virtual/kernel' | ||
| 1649 | if mach: | ||
| 1650 | cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target) | ||
| 1651 | else: | ||
| 1652 | cmd = 'bitbake -e %s %s' % (multiconfig, target) | ||
| 1653 | try: | ||
| 1654 | return subprocess.check_output(cmd, shell=True).decode('utf-8') | ||
| 1655 | except subprocess.CalledProcessError as err: | ||
| 1656 | logger.warning("Couldn't run '%s' to gather environment information, giving up with 'bitbake -e':\n%s" % (cmd, err.output.decode('utf-8'))) | ||
| 1657 | return '' | ||
| 1622 | 1658 | ||
| 1623 | def load_bitbake_env(self, mach=None): | 1659 | |
| 1660 | def load_bitbake_env(self, mach=None, target=None): | ||
| 1624 | if self.bitbake_e: | 1661 | if self.bitbake_e: |
| 1625 | return | 1662 | return |
| 1626 | 1663 | ||
| 1627 | try: | 1664 | self.bitbake_e = self.run_bitbake_env(mach=mach, target=target) |
| 1628 | self.bitbake_e = self.run_bitbake_env(mach=mach) | ||
| 1629 | except subprocess.CalledProcessError as err: | ||
| 1630 | self.bitbake_e = '' | ||
| 1631 | logger.warning("Couldn't run 'bitbake -e' to gather environment information:\n%s" % err.output.decode('utf-8')) | ||
| 1632 | 1665 | ||
| 1633 | def validate_combos(self): | 1666 | def validate_combos(self): |
| 1634 | if (self.fstype in self.vmtypes) and self.kernel: | 1667 | if (self.fstype in self.vmtypes) and self.kernel: |
