diff options
| -rw-r--r-- | meta/classes-recipe/testimage.bbclass | 2 | ||||
| -rwxr-xr-x | scripts/runqemu | 69 |
2 files changed, 52 insertions, 19 deletions
diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass index df22bb2344..b48cd96575 100644 --- a/meta/classes-recipe/testimage.bbclass +++ b/meta/classes-recipe/testimage.bbclass | |||
| @@ -98,7 +98,7 @@ TESTIMAGELOCK:qemuall = "" | |||
| 98 | 98 | ||
| 99 | TESTIMAGE_DUMP_DIR ?= "${LOG_DIR}/runtime-hostdump/" | 99 | TESTIMAGE_DUMP_DIR ?= "${LOG_DIR}/runtime-hostdump/" |
| 100 | 100 | ||
| 101 | TESTIMAGE_UPDATE_VARS ?= "DL_DIR WORKDIR DEPLOY_DIR" | 101 | TESTIMAGE_UPDATE_VARS ?= "DL_DIR WORKDIR DEPLOY_DIR_IMAGE IMAGE_LINK_NAME" |
| 102 | 102 | ||
| 103 | testimage_dump_target () { | 103 | testimage_dump_target () { |
| 104 | top -bn1 | 104 | top -bn1 |
diff --git a/scripts/runqemu b/scripts/runqemu index efc135e535..9a3c9d2ce4 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
| @@ -381,13 +381,19 @@ class BaseConfig(object): | |||
| 381 | fst = m.group(1) | 381 | fst = m.group(1) |
| 382 | if fst: | 382 | if fst: |
| 383 | self.check_arg_fstype(fst) | 383 | self.check_arg_fstype(fst) |
| 384 | qb = re.sub('\.' + fst + "$", '', self.rootfs) | 384 | qb = re.sub('\.' + fst + "$", '.qemuboot.conf', self.rootfs) |
| 385 | qb = '%s%s' % (re.sub('\.rootfs$', '', qb), '.qemuboot.conf') | ||
| 386 | if os.path.exists(qb): | 385 | if os.path.exists(qb): |
| 387 | self.qemuboot = qb | 386 | self.qemuboot = qb |
| 388 | self.qbconfload = True | 387 | self.qbconfload = True |
| 389 | else: | 388 | else: |
| 390 | logger.warning("%s doesn't exist" % qb) | 389 | logger.warning("%s doesn't exist, will try to remove '.rootfs' from filename" % qb) |
| 390 | # They to remove .rootfs (IMAGE_NAME_SUFFIX) as well | ||
| 391 | qb = re.sub('\.rootfs.qemuboot.conf$', '.qemuboot.conf', qb) | ||
| 392 | if os.path.exists(qb): | ||
| 393 | self.qemuboot = qb | ||
| 394 | self.qbconfload = True | ||
| 395 | else: | ||
| 396 | logger.warning("%s doesn't exist" % qb) | ||
| 391 | else: | 397 | else: |
| 392 | raise RunQemuError("Can't find FSTYPE from: %s" % p) | 398 | raise RunQemuError("Can't find FSTYPE from: %s" % p) |
| 393 | 399 | ||
| @@ -421,6 +427,7 @@ class BaseConfig(object): | |||
| 421 | # are there other scenarios in which we need to support being | 427 | # are there other scenarios in which we need to support being |
| 422 | # invoked by bitbake? | 428 | # invoked by bitbake? |
| 423 | deploy = self.get('DEPLOY_DIR_IMAGE') | 429 | deploy = self.get('DEPLOY_DIR_IMAGE') |
| 430 | image_link_name = self.get('IMAGE_LINK_NAME') | ||
| 424 | bbchild = deploy and self.get('OE_TMPDIR') | 431 | bbchild = deploy and self.get('OE_TMPDIR') |
| 425 | if bbchild: | 432 | if bbchild: |
| 426 | self.set_machine_deploy_dir(arg, deploy) | 433 | self.set_machine_deploy_dir(arg, deploy) |
| @@ -445,6 +452,12 @@ class BaseConfig(object): | |||
| 445 | else: | 452 | else: |
| 446 | logger.error("%s not a directory valid DEPLOY_DIR_IMAGE" % deploy_dir_image) | 453 | logger.error("%s not a directory valid DEPLOY_DIR_IMAGE" % deploy_dir_image) |
| 447 | self.set("MACHINE", arg) | 454 | self.set("MACHINE", arg) |
| 455 | if not image_link_name: | ||
| 456 | s = re.search('^IMAGE_LINK_NAME="(.*)"', self.bitbake_e, re.M) | ||
| 457 | if s: | ||
| 458 | image_link_name = s.group(1) | ||
| 459 | self.set("IMAGE_LINK_NAME", image_link_name) | ||
| 460 | logger.debug('Using IMAGE_LINK_NAME = "%s"' % image_link_name) | ||
| 448 | 461 | ||
| 449 | def set_dri_path(self): | 462 | def set_dri_path(self): |
| 450 | # As runqemu can be run within bitbake (when using testimage, for example), | 463 | # As runqemu can be run within bitbake (when using testimage, for example), |
| @@ -557,11 +570,18 @@ class BaseConfig(object): | |||
| 557 | self.check_arg_machine(unknown_arg) | 570 | self.check_arg_machine(unknown_arg) |
| 558 | 571 | ||
| 559 | if not (self.get('DEPLOY_DIR_IMAGE') or self.qbconfload): | 572 | if not (self.get('DEPLOY_DIR_IMAGE') or self.qbconfload): |
| 560 | self.load_bitbake_env() | 573 | self.load_bitbake_env(target=self.rootfs) |
| 561 | s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M) | 574 | s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M) |
| 562 | if s: | 575 | if s: |
| 563 | self.set("DEPLOY_DIR_IMAGE", s.group(1)) | 576 | self.set("DEPLOY_DIR_IMAGE", s.group(1)) |
| 564 | 577 | ||
| 578 | if not self.get('IMAGE_LINK_NAME') and self.rootfs: | ||
| 579 | s = re.search('^IMAGE_LINK_NAME="(.*)"', self.bitbake_e, re.M) | ||
| 580 | if s: | ||
| 581 | image_link_name = s.group(1) | ||
| 582 | self.set("IMAGE_LINK_NAME", image_link_name) | ||
| 583 | logger.debug('Using IMAGE_LINK_NAME = "%s"' % image_link_name) | ||
| 584 | |||
| 565 | def check_kvm(self): | 585 | def check_kvm(self): |
| 566 | """Check kvm and kvm-host""" | 586 | """Check kvm and kvm-host""" |
| 567 | if not (self.kvm_enabled or self.vhost_enabled): | 587 | if not (self.kvm_enabled or self.vhost_enabled): |
| @@ -667,8 +687,8 @@ class BaseConfig(object): | |||
| 667 | 687 | ||
| 668 | if self.rootfs and not os.path.exists(self.rootfs): | 688 | if self.rootfs and not os.path.exists(self.rootfs): |
| 669 | # Lazy rootfs | 689 | # Lazy rootfs |
| 670 | self.rootfs = "%s/%s-%s.%s" % (self.get('DEPLOY_DIR_IMAGE'), | 690 | self.rootfs = "%s/%s.%s" % (self.get('DEPLOY_DIR_IMAGE'), |
| 671 | self.rootfs, self.get('MACHINE'), | 691 | self.get('IMAGE_LINK_NAME'), |
| 672 | self.fstype) | 692 | self.fstype) |
| 673 | elif not self.rootfs: | 693 | elif not self.rootfs: |
| 674 | cmd_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype) | 694 | cmd_name = '%s/%s*.%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_NAME'), self.fstype) |
| @@ -872,8 +892,10 @@ class BaseConfig(object): | |||
| 872 | machine = self.get('MACHINE') | 892 | machine = self.get('MACHINE') |
| 873 | if not machine: | 893 | if not machine: |
| 874 | machine = os.path.basename(deploy_dir_image) | 894 | machine = os.path.basename(deploy_dir_image) |
| 875 | self.qemuboot = "%s/%s-%s.qemuboot.conf" % (deploy_dir_image, | 895 | if not self.get('IMAGE_LINK_NAME'): |
| 876 | self.rootfs, machine) | 896 | raise RunQemuError("IMAGE_LINK_NAME wasn't set to find corresponding .qemuboot.conf file") |
| 897 | self.qemuboot = "%s/%s.qemuboot.conf" % (deploy_dir_image, | ||
| 898 | self.get('IMAGE_LINK_NAME')) | ||
| 877 | else: | 899 | else: |
| 878 | cmd = 'ls -t %s/*.qemuboot.conf' % deploy_dir_image | 900 | cmd = 'ls -t %s/*.qemuboot.conf' % deploy_dir_image |
| 879 | logger.debug('Running %s...' % cmd) | 901 | logger.debug('Running %s...' % cmd) |
| @@ -1569,7 +1591,7 @@ class BaseConfig(object): | |||
| 1569 | 1591 | ||
| 1570 | self.cleaned = True | 1592 | self.cleaned = True |
| 1571 | 1593 | ||
| 1572 | def run_bitbake_env(self, mach=None): | 1594 | def run_bitbake_env(self, mach=None, target=''): |
| 1573 | bitbake = shutil.which('bitbake') | 1595 | bitbake = shutil.which('bitbake') |
| 1574 | if not bitbake: | 1596 | if not bitbake: |
| 1575 | return | 1597 | return |
| @@ -1582,22 +1604,33 @@ class BaseConfig(object): | |||
| 1582 | multiconfig = "mc:%s" % multiconfig | 1604 | multiconfig = "mc:%s" % multiconfig |
| 1583 | 1605 | ||
| 1584 | if mach: | 1606 | if mach: |
| 1585 | cmd = 'MACHINE=%s bitbake -e %s' % (mach, multiconfig) | 1607 | cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target) |
| 1586 | else: | 1608 | else: |
| 1587 | cmd = 'bitbake -e %s' % multiconfig | 1609 | cmd = 'bitbake -e %s %s' % (multiconfig, target) |
| 1588 | 1610 | ||
| 1589 | logger.info('Running %s...' % cmd) | 1611 | logger.info('Running %s...' % cmd) |
| 1590 | return subprocess.check_output(cmd, shell=True).decode('utf-8') | 1612 | try: |
| 1613 | return subprocess.check_output(cmd, shell=True).decode('utf-8') | ||
| 1614 | except subprocess.CalledProcessError as err: | ||
| 1615 | 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'))) | ||
| 1616 | # need something with IMAGE_NAME_SUFFIX/IMAGE_LINK_NAME defined (kernel also inherits image-artifact-names.bbclass) | ||
| 1617 | target = 'virtual/kernel' | ||
| 1618 | if mach: | ||
| 1619 | cmd = 'MACHINE=%s bitbake -e %s %s' % (mach, multiconfig, target) | ||
| 1620 | else: | ||
| 1621 | cmd = 'bitbake -e %s %s' % (multiconfig, target) | ||
| 1622 | try: | ||
| 1623 | return subprocess.check_output(cmd, shell=True).decode('utf-8') | ||
| 1624 | except subprocess.CalledProcessError as err: | ||
| 1625 | logger.warning("Couldn't run '%s' to gather environment information, giving up with 'bitbake -e':\n%s" % (cmd, err.output.decode('utf-8'))) | ||
| 1626 | return '' | ||
| 1591 | 1627 | ||
| 1592 | def load_bitbake_env(self, mach=None): | 1628 | |
| 1629 | def load_bitbake_env(self, mach=None, target=None): | ||
| 1593 | if self.bitbake_e: | 1630 | if self.bitbake_e: |
| 1594 | return | 1631 | return |
| 1595 | 1632 | ||
| 1596 | try: | 1633 | self.bitbake_e = self.run_bitbake_env(mach=mach, target=target) |
| 1597 | self.bitbake_e = self.run_bitbake_env(mach=mach) | ||
| 1598 | except subprocess.CalledProcessError as err: | ||
| 1599 | self.bitbake_e = '' | ||
| 1600 | logger.warning("Couldn't run 'bitbake -e' to gather environment information:\n%s" % err.output.decode('utf-8')) | ||
| 1601 | 1634 | ||
| 1602 | def validate_combos(self): | 1635 | def validate_combos(self): |
| 1603 | if (self.fstype in self.vmtypes) and self.kernel: | 1636 | if (self.fstype in self.vmtypes) and self.kernel: |
