summaryrefslogtreecommitdiffstats
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-12 15:09:57 +0100
commitf57393b386499c607e01ce1b3f1503b2cdca73d9 (patch)
tree0e30e8a57c7dbc941551e27411bf46343cb62f92
parentf2c09f786704568c0c40726cdc3fef760e941d92 (diff)
downloadpoky-f57393b386499c607e01ce1b3f1503b2cdca73d9.tar.gz
runqemu: do not rely on grepping images
Fixed when the image is large and not enough memory: grep: memory exhausted Aborted [YOCTO #11073] (From OE-Core rev: a99deb30a0138594147ae28aab016fe4b74b8959) 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"
64QB_OPT_APPEND ?= "-show-cursor" 64QB_OPT_APPEND ?= "-show-cursor"
65QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@" 65QB_NETWORK_DEVICE ?= "-device virtio-net-pci,netdev=net0,mac=@MAC@"
66 66
67# This should be kept align with ROOT_VM
68QB_DRIVE_TYPE ?= "/dev/sd"
69
67# Create qemuboot.conf 70# Create qemuboot.conf
68addtask do_write_qemuboot_conf after do_rootfs before do_image 71addtask do_write_qemuboot_conf after do_rootfs before do_image
69IMGDEPLOYDIR ?= "${WORKDIR}/deploy-${PN}-image-complete" 72IMGDEPLOYDIR ?= "${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):
980 self.kernel_cmdline = 'root=/dev/ram0 rw debugshell' 980 self.kernel_cmdline = 'root=/dev/ram0 rw debugshell'
981 self.rootfs_options = '-initrd %s' % self.rootfs 981 self.rootfs_options = '-initrd %s' % self.rootfs
982 else: 982 else:
983 vm_drive = ''
983 if self.fstype in self.vmtypes: 984 if self.fstype in self.vmtypes:
984 if self.fstype == 'iso': 985 if self.fstype == 'iso':
985 vm_drive = '-cdrom %s' % self.rootfs 986 vm_drive = '-cdrom %s' % self.rootfs
986 else: 987 elif self.get('QB_DRIVE_TYPE'):
987 cmd1 = "grep -q 'root=/dev/sd' %s" % self.rootfs 988 drive_type = self.get('QB_DRIVE_TYPE')
988 cmd2 = "grep -q 'root=/dev/hd' %s" % self.rootfs 989 if drive_type.startswith("/dev/sd"):
989 if subprocess.call(cmd1, shell=True) == 0:
990 logger.info('Using scsi drive') 990 logger.info('Using scsi drive')
991 vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd' \ 991 vm_drive = '-drive if=none,id=hd,file=%s,format=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd' \
992 % (self.rootfs, rootfs_format) 992 % (self.rootfs, rootfs_format)
993 elif subprocess.call(cmd2, shell=True) == 0: 993 elif drive_type.startswith("/dev/hd"):
994 logger.info('Using ide drive') 994 logger.info('Using ide drive')
995 vm_drive = "%s,format=%s" % (self.rootfs, rootfs_format) 995 vm_drive = "%s,format=%s" % (self.rootfs, rootfs_format)
996 else: 996 else:
997 logger.warn("Can't detect drive type %s" % self.rootfs) 997 logger.warn("Unknown QB_DRIVE_TYPE: %s" % drive_type)
998 logger.warn('Trying to use virtio block drive') 998
999 vm_drive = '-drive if=virtio,file=%s,format=%s' % (self.rootfs, rootfs_format) 999 if not vm_drive:
1000 logger.warn("Failed to figure out drive type, consider define or fix QB_DRIVE_TYPE")
1001 logger.warn('Trying to use virtio block drive')
1002 vm_drive = '-drive if=virtio,file=%s,format=%s' % (self.rootfs, rootfs_format)
1000 self.rootfs_options = '%s -no-reboot' % vm_drive 1003 self.rootfs_options = '%s -no-reboot' % vm_drive
1001 self.kernel_cmdline = 'root=%s rw highres=off' % (self.get('QB_KERNEL_ROOT')) 1004 self.kernel_cmdline = 'root=%s rw highres=off' % (self.get('QB_KERNEL_ROOT'))
1002 1005