runqemu: explicitly set image format

QEMU produces a warning if drive format is not specified:
  WARNING: Image format was not specified for
  'tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.wic'
   and probing guessed raw.
   Automatically detecting the format is dangerous for raw images,
   write operations on block 0 will be restricted.
   Specify the 'raw' format explicitly to remove the restrictions.

Set image format to 'vmdk', 'qcow2' or 'vdi' for correspondent image
types. Set it to 'raw' for the rest of image types.

(From OE-Core rev: 5100bb36502ef7c81220a3c4809eb1b3ac83801f)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ed Bartosh 2016-09-28 12:16:14 +03:00 committed by Richard Purdie
parent b8f5fdacae
commit 5753147ea2
1 changed files with 7 additions and 4 deletions

View File

@ -817,11 +817,13 @@ class BaseConfig(object):
else: else:
self.setup_tap() self.setup_tap()
rootfs_format = self.fstype if self.fstype in ('vmdk', 'qcow2', 'vdi') else 'raw'
qb_rootfs_opt = self.get('QB_ROOTFS_OPT') qb_rootfs_opt = self.get('QB_ROOTFS_OPT')
if qb_rootfs_opt: if qb_rootfs_opt:
self.rootfs_options = qb_rootfs_opt.replace('@ROOTFS@', self.rootfs) self.rootfs_options = qb_rootfs_opt.replace('@ROOTFS@', self.rootfs)
else: else:
self.rootfs_options = '-drive file=%s,if=virtio,format=raw' % self.rootfs self.rootfs_options = '-drive file=%s,if=virtio,format=%s' % (self.rootfs, rootfs_format)
if self.fstype in ('cpio.gz', 'cpio'): if self.fstype in ('cpio.gz', 'cpio'):
self.kernel_cmdline = 'root=/dev/ram0 rw debugshell' self.kernel_cmdline = 'root=/dev/ram0 rw debugshell'
@ -835,14 +837,15 @@ class BaseConfig(object):
cmd2 = "grep -q 'root=/dev/hd' %s" % self.rootfs cmd2 = "grep -q 'root=/dev/hd' %s" % self.rootfs
if subprocess.call(cmd1, shell=True) == 0: if subprocess.call(cmd1, shell=True) == 0:
logger.info('Using scsi drive') logger.info('Using scsi drive')
vm_drive = '-drive if=none,id=hd,file=%s -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd' % self.rootfs 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 subprocess.call(cmd2, shell=True) == 0:
logger.info('Using scsi drive') logger.info('Using scsi drive')
vm_drive = self.rootfs vm_drive = "%s,format=%s" % (self.rootfs, rootfs_format)
else: else:
logger.warn("Can't detect drive type %s" % self.rootfs) logger.warn("Can't detect drive type %s" % self.rootfs)
logger.warn('Tring to use virtio block drive') logger.warn('Tring to use virtio block drive')
vm_drive = '-drive if=virtio,file=%s' % self.rootfs vm_drive = '-drive if=virtio,file=%s,format=%s' % (self.rootfs, rootfs_format)
self.rootfs_options = '%s -no-reboot' % vm_drive self.rootfs_options = '%s -no-reboot' % vm_drive
self.kernel_cmdline = 'root=%s rw highres=off' % (self.get('QB_KERNEL_ROOT')) self.kernel_cmdline = 'root=%s rw highres=off' % (self.get('QB_KERNEL_ROOT'))