summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2017-04-11 02:21:28 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-04-11 18:10:49 +0100
commita99deb30a0138594147ae28aab016fe4b74b8959 (patch)
tree4009cda8006d0110552d36688d03b6feba40b6b1
parent9ebcb2b6f41420ae3686afad03bb26a68cfacf95 (diff)
downloadopenembedded-core-a99deb30a0138594147ae28aab016fe4b74b8959.tar.gz
openembedded-core-a99deb30a0138594147ae28aab016fe4b74b8959.tar.bz2
openembedded-core-a99deb30a0138594147ae28aab016fe4b74b8959.zip
runqemu: do not rely on grepping images
Fixed when the image is large and not enough memory: grep: memory exhausted Aborted [YOCTO #11073] Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/qemuboot.bbclass3
-rwxr-xr-xscripts/runqemu19
2 files changed, 14 insertions, 8 deletions
diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index 3ca97cad4c..2870388dfb 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -64,6 +64,9 @@ QB_DEFAULT_FSTYPE ?= "ext4"
QB_OPT_APPEND ?= "-show-cursor"
QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@"
+# This should be kept align with ROOT_VM
+QB_DRIVE_TYPE ?= "/dev/sd"
+
# Create qemuboot.conf
addtask do_write_qemuboot_conf after do_rootfs before do_image
IMGDEPLOYDIR ?= "${WORKDIR}/deploy-${PN}-image-complete"
diff --git a/scripts/runqemu b/scripts/runqemu
index 51ed9de22c..803b205690 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -980,23 +980,26 @@ class BaseConfig(object):
self.kernel_cmdline = 'root=/dev/ram0 rw debugshell'
self.rootfs_options = '-initrd %s' % self.rootfs
else:
+ vm_drive = ''
if self.fstype in self.vmtypes:
if self.fstype == 'iso':
vm_drive = '-cdrom %s' % self.rootfs
- else:
- cmd1 = "grep -q 'root=/dev/sd' %s" % self.rootfs
- cmd2 = "grep -q 'root=/dev/hd' %s" % self.rootfs
- if subprocess.call(cmd1, shell=True) == 0:
+ elif self.get('QB_DRIVE_TYPE'):
+ drive_type = self.get('QB_DRIVE_TYPE')
+ if drive_type.startswith("/dev/sd"):
logger.info('Using scsi drive')
vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd' \
% (self.rootfs, rootfs_format)
- elif subprocess.call(cmd2, shell=True) == 0:
+ elif drive_type.startswith("/dev/hd"):
logger.info('Using ide drive')
vm_drive = "%s,format=%s" % (self.rootfs, rootfs_format)
else:
- logger.warn("Can't detect drive type %s" % self.rootfs)
- logger.warn('Trying to use virtio block drive')
- vm_drive = '-drive if=virtio,file=%s,format=%s' % (self.rootfs, rootfs_format)
+ logger.warn("Unknown QB_DRIVE_TYPE: %s" % drive_type)
+
+ if not vm_drive:
+ logger.warn("Failed to figure out drive type, consider define or fix QB_DRIVE_TYPE")
+ logger.warn('Trying to use virtio block drive')
+ vm_drive = '-drive if=virtio,file=%s,format=%s' % (self.rootfs, rootfs_format)
self.rootfs_options = '%s -no-reboot' % vm_drive
self.kernel_cmdline = 'root=%s rw highres=off' % (self.get('QB_KERNEL_ROOT'))