All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7 V3] fixes for runqemu
@ 2017-04-11  9:21 Robert Yang
  2017-04-11  9:21 ` [PATCH 1/7] runqemu: support env vars explicitly Robert Yang
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

* V3:
  - Fixed wic's test cases.
  - Remove Qi's patch since it was broken, and there are other solutions in the
    mailing list:
    http://lists.openembedded.org/pipermail/openembedded-core/2017-April/135464.html

* V2:
  - Fixed "ERROR - name 'p' is not defined"
  - Add Qi's patch.

// Robert

The following changes since commit ec2931852b2a097c9c8cb0d7288f5ca1d79f401c:

  Revert "staging: Fix sysroot problem with populate_sysroot dependencies on do_fetch" (2017-04-11 00:56:58 +0100)

are available in the git repository at:

  git://git.openembedded.org/openembedded-core-contrib rbt/qemu
  http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/qemu

Robert Yang (7):
  runqemu: support env vars explicitly
  runqemu: use self.rootfs to replace self.nfs_dir
  runqemu: run without arguments
  runqemu: do not rely on grepping images
  selftest/wic.py: vda -> sda
  wic-image-minimal.wks: vda -> sda
  qemux86-directdisk.wks: vda -> sda

 .../recipes-test/images/wic-image-minimal.wks      |   8 +-
 meta/classes/qemuboot.bbclass                      |   3 +
 meta/lib/oeqa/selftest/wic.py                      |   6 +-
 scripts/lib/wic/canned-wks/qemux86-directdisk.wks  |   2 +-
 scripts/runqemu                                    | 122 ++++++++++++---------
 5 files changed, 79 insertions(+), 62 deletions(-)

-- 
2.11.0.rc2.dirty



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/7] runqemu: support env vars explicitly
  2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
@ 2017-04-11  9:21 ` Robert Yang
  2017-04-11  9:21 ` [PATCH 2/7] runqemu: use self.rootfs to replace self.nfs_dir Robert Yang
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

Use self.env_vars to support get vars from environment explicity. The
MACHINE, ROOTFS and KERNEL was supported by shell based runqemu, and
the help text says support them from env vars, so add them back.

[YOCTO #11141]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 scripts/runqemu | 71 ++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 42 insertions(+), 29 deletions(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index b696202871..6234e811a7 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -163,12 +163,18 @@ def check_free_port(host, port):
 
 class BaseConfig(object):
     def __init__(self):
-        # Vars can be merged with .qemuboot.conf, use a dict to manage them.
-        self.d = {
-            'MACHINE': '',
-            'DEPLOY_DIR_IMAGE': '',
-            'QB_KERNEL_ROOT': '/dev/vda',
-        }
+        # The self.d saved vars from self.set(), part of them are from qemuboot.conf
+        self.d = {'QB_KERNEL_ROOT': '/dev/vda'}
+
+        # Supported env vars, add it here if a var can be got from env,
+        # and don't use os.getenv in the code.
+        self.env_vars = ('MACHINE',
+                        'ROOTFS',
+                        'KERNEL',
+                        'DEPLOY_DIR_IMAGE',
+                        'OE_TMPDIR',
+                        'OECORE_NATIVE_SYSROOT',
+                        )
 
         self.qemu_opt = ''
         self.qemu_opt_script = ''
@@ -238,6 +244,8 @@ class BaseConfig(object):
     def get(self, key):
         if key in self.d:
             return self.d.get(key)
+        elif os.getenv(key):
+            return os.getenv(key)
         else:
             return ''
 
@@ -338,10 +346,13 @@ class BaseConfig(object):
 
     def check_arg_machine(self, arg):
         """Check whether it is a machine"""
-        if self.get('MACHINE') and self.get('MACHINE') != arg or re.search('/', arg):
-            raise Exception("Unknown arg: %s" % arg)
-        elif self.get('MACHINE') == arg:
+        if self.get('MACHINE') == arg:
             return
+        elif self.get('MACHINE') and self.get('MACHINE') != arg:
+            raise Exception("Maybe conflicted MACHINE: %s vs %s" % (self.get('MACHINE'), arg))
+        elif re.search('/', arg):
+            raise Exception("Unknown arg: %s" % arg)
+
         logger.info('Assuming MACHINE = %s' % arg)
 
         # if we're running under testimage, or similarly as a child
@@ -350,14 +361,14 @@ class BaseConfig(object):
         # FIXME: testimage.bbclass exports these two variables into env,
         # are there other scenarios in which we need to support being
         # invoked by bitbake?
-        deploy = os.environ.get('DEPLOY_DIR_IMAGE')
-        bbchild = deploy and os.environ.get('OE_TMPDIR')
+        deploy = self.get('DEPLOY_DIR_IMAGE')
+        bbchild = deploy and self.get('OE_TMPDIR')
         if bbchild:
             self.set_machine_deploy_dir(arg, deploy)
             return
         # also check whether we're running under a sourced toolchain
         # environment file
-        if os.environ.get('OECORE_NATIVE_SYSROOT'):
+        if self.get('OECORE_NATIVE_SYSROOT'):
             self.set("MACHINE", arg)
             return
 
@@ -430,20 +441,15 @@ class BaseConfig(object):
         if unknown_arg:
             if self.get('MACHINE') == unknown_arg:
                 return
-            if not self.get('DEPLOY_DIR_IMAGE'):
-                # Trying to get DEPLOY_DIR_IMAGE from env.
-                p = os.getenv('DEPLOY_DIR_IMAGE')
-                if p and self.is_deploy_dir_image(p):
-                    machine = os.path.basename(p)
-                    if unknown_arg == machine:
-                        self.set_machine_deploy_dir(machine, p)
-                        return
-                    else:
-                        logger.info('DEPLOY_DIR_IMAGE: %s' % p)
-                        self.set("DEPLOY_DIR_IMAGE", p)
+            if self.get('DEPLOY_DIR_IMAGE'):
+                machine = os.path.basename(self.get('DEPLOY_DIR_IMAGE'))
+                if unknown_arg == machine:
+                    self.set("MACHINE", machine)
+                    return
+
             self.check_arg_machine(unknown_arg)
 
-        if not (self.get('MACHINE') or self.get('DEPLOY_DIR_IMAGE')):
+        if not self.get('DEPLOY_DIR_IMAGE'):
             self.load_bitbake_env()
             s = re.search('^DEPLOY_DIR_IMAGE="(.*)"', self.bitbake_e, re.M)
             if s:
@@ -505,7 +511,16 @@ class BaseConfig(object):
     def check_rootfs(self):
         """Check and set rootfs"""
 
-        if self.fstype == 'nfs' or self.fstype == "none":
+        if self.fstype == "none":
+            return
+
+        if self.get('ROOTFS'):
+            if not self.rootfs:
+                self.rootfs = self.get('ROOTFS')
+            elif self.get('ROOTFS') != self.rootfs:
+                raise Exception("Maybe conflicted ROOTFS: %s vs %s" % (self.get('ROOTFS'), self.rootfs))
+
+        if self.fstype == 'nfs':
             return
 
         if self.rootfs and not os.path.exists(self.rootfs):
@@ -642,8 +657,6 @@ class BaseConfig(object):
         if not self.qemuboot:
             if self.get('DEPLOY_DIR_IMAGE'):
                 deploy_dir_image = self.get('DEPLOY_DIR_IMAGE')
-            elif os.getenv('DEPLOY_DIR_IMAGE'):
-                deploy_dir_image = os.getenv('DEPLOY_DIR_IMAGE')
             else:
                 logger.info("Can't find qemuboot conf file, DEPLOY_DIR_IMAGE is NULL!")
                 return
@@ -720,8 +733,8 @@ class BaseConfig(object):
                 # be able to call `bitbake -e`, then try:
                 # - get OE_TMPDIR from environment and guess paths based on it
                 # - get OECORE_NATIVE_SYSROOT from environment (for sdk)
-                tmpdir = os.environ.get('OE_TMPDIR', None)
-                oecore_native_sysroot = os.environ.get('OECORE_NATIVE_SYSROOT', None)
+                tmpdir = self.get('OE_TMPDIR', None)
+                oecore_native_sysroot = self.get('OECORE_NATIVE_SYSROOT', None)
                 if tmpdir:
                     logger.info('Setting STAGING_DIR_NATIVE and STAGING_BINDIR_NATIVE relative to OE_TMPDIR (%s)' % tmpdir)
                     hostos, _, _, _, machine = os.uname()
-- 
2.11.0.rc2.dirty



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/7] runqemu: use self.rootfs to replace self.nfs_dir
  2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
  2017-04-11  9:21 ` [PATCH 1/7] runqemu: support env vars explicitly Robert Yang
@ 2017-04-11  9:21 ` Robert Yang
  2017-04-11  9:21 ` [PATCH 3/7] runqemu: run without arguments Robert Yang
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

We can use self.rootfs as self.nfs_dir when self.fstype is nfs, this can
reduce the code's complexity and we can re-use the code of checking
ROOTFS conflictions.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 scripts/runqemu | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index 6234e811a7..4594173db7 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -178,7 +178,6 @@ class BaseConfig(object):
 
         self.qemu_opt = ''
         self.qemu_opt_script = ''
-        self.nfs_dir = ''
         self.clean_nfs_dir = False
         self.nfs_server = ''
         self.rootfs = ''
@@ -284,12 +283,11 @@ class BaseConfig(object):
 
     def check_arg_nfs(self, p):
         if os.path.isdir(p):
-            self.nfs_dir = p
+            self.rootfs = p
         else:
             m = re.match('(.*):(.*)', p)
             self.nfs_server = m.group(1)
-            self.nfs_dir = m.group(2)
-        self.rootfs = ""
+            self.rootfs = m.group(2)
         self.check_arg_fstype('nfs')
 
     def check_arg_path(self, p):
@@ -759,7 +757,7 @@ class BaseConfig(object):
         print('MACHINE: [%s]' % self.get('MACHINE'))
         print('FSTYPE: [%s]' % self.fstype)
         if self.fstype  == 'nfs':
-            print('NFS_DIR: [%s]' % self.nfs_dir)
+            print('NFS_DIR: [%s]' % self.rootfs)
         else:
             print('ROOTFS: [%s]' % self.rootfs)
         if self.ovmf_bios:
@@ -804,13 +802,13 @@ class BaseConfig(object):
 
         self.unfs_opts="nfsvers=3,port=%s,mountprog=%s,nfsprog=%s,udp,mountport=%s" % (nfsd_port, mountd_rpcport, nfsd_rpcport, mountd_port)
 
-        # Extract .tar.bz2 or .tar.bz if no self.nfs_dir
-        if not self.nfs_dir:
+        # Extract .tar.bz2 or .tar.bz if no nfs dir
+        if not (self.rootfs and os.path.isdir(self.rootfs)):
             src_prefix = '%s/%s' % (self.get('DEPLOY_DIR_IMAGE'), self.get('IMAGE_LINK_NAME'))
             dest = "%s-nfsroot" % src_prefix
             if os.path.exists('%s.pseudo_state' % dest):
                 logger.info('Use %s as NFS_DIR' % dest)
-                self.nfs_dir = dest
+                self.rootfs = dest
             else:
                 src = ""
                 src1 = '%s.tar.bz2' % src_prefix
@@ -827,10 +825,10 @@ class BaseConfig(object):
                 if subprocess.call(cmd, shell=True) != 0:
                     raise Exception('Failed to run %s' % cmd)
                 self.clean_nfs_dir = True
-                self.nfs_dir = dest
+                self.rootfs = dest
 
         # Start the userspace NFS server
-        cmd = 'runqemu-export-rootfs start %s' % self.nfs_dir
+        cmd = 'runqemu-export-rootfs start %s' % self.rootfs
         logger.info('Running %s...' % cmd)
         if subprocess.call(cmd, shell=True) != 0:
             raise Exception('Failed to run %s' % cmd)
@@ -1001,7 +999,7 @@ class BaseConfig(object):
 
         if self.fstype == 'nfs':
             self.rootfs_options = ''
-            k_root = '/dev/nfs nfsroot=%s:%s,%s' % (self.nfs_server, self.nfs_dir, self.unfs_opts)
+            k_root = '/dev/nfs nfsroot=%s:%s,%s' % (self.nfs_server, self.rootfs, self.unfs_opts)
             self.kernel_cmdline = 'root=%s rw highres=off' % k_root
 
         if self.fstype == 'none':
@@ -1147,7 +1145,7 @@ class BaseConfig(object):
 
         if self.nfs_running:
             logger.info("Shutting down the userspace NFS server...")
-            cmd = "runqemu-export-rootfs stop %s" % self.nfs_dir
+            cmd = "runqemu-export-rootfs stop %s" % self.rootfs
             logger.info('Running %s' % cmd)
             subprocess.call(cmd, shell=True)
 
@@ -1156,9 +1154,9 @@ class BaseConfig(object):
             subprocess.call(cmd, shell=True)
 
         if self.clean_nfs_dir:
-            logger.info('Removing %s' % self.nfs_dir)
-            shutil.rmtree(self.nfs_dir)
-            shutil.rmtree('%s.pseudo_state' % self.nfs_dir)
+            logger.info('Removing %s' % self.rootfs)
+            shutil.rmtree(self.rootfs)
+            shutil.rmtree('%s.pseudo_state' % self.rootfs)
 
     def load_bitbake_env(self, mach=None):
         if self.bitbake_e:
-- 
2.11.0.rc2.dirty



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/7] runqemu: run without arguments
  2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
  2017-04-11  9:21 ` [PATCH 1/7] runqemu: support env vars explicitly Robert Yang
  2017-04-11  9:21 ` [PATCH 2/7] runqemu: use self.rootfs to replace self.nfs_dir Robert Yang
@ 2017-04-11  9:21 ` Robert Yang
  2017-04-11  9:21 ` [PATCH 4/7] runqemu: do not rely on grepping images Robert Yang
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

Since we can get MACHINE and others from env vars and "bitbake -e",
"runqemu" can work without any arguments.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 scripts/runqemu | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/runqemu b/scripts/runqemu
index 4594173db7..a4036ae091 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -83,6 +83,7 @@ of the following environment variables (in any order):
   help, -h, --help: print this text
 
 Examples:
+  runqemu
   runqemu qemuarm
   runqemu tmp/deploy/images/qemuarm
   runqemu tmp/deploy/images/qemux86/<qemuboot.conf>
@@ -1182,8 +1183,7 @@ class BaseConfig(object):
             logger.warn("Couldn't run 'bitbake -e' to gather environment information:\n%s" % err.output.decode('utf-8'))
 
 def main():
-    if len(sys.argv) == 1 or "help" in sys.argv or \
-            '-h' in sys.argv or '--help' in sys.argv:
+    if "help" in sys.argv or '-h' in sys.argv or '--help' in sys.argv:
         print_usage()
         return 0
     config = BaseConfig()
-- 
2.11.0.rc2.dirty



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/7] runqemu: do not rely on grepping images
  2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
                   ` (2 preceding siblings ...)
  2017-04-11  9:21 ` [PATCH 3/7] runqemu: run without arguments Robert Yang
@ 2017-04-11  9:21 ` Robert Yang
  2017-04-13  8:46   ` Patrick Ohly
  2017-04-11  9:21 ` [PATCH 5/7] selftest/wic.py: vda -> sda Robert Yang
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

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>
---
 meta/classes/qemuboot.bbclass |  3 +++
 scripts/runqemu               | 19 +++++++++++--------
 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 a4036ae091..5b5d56b9ef 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -978,23 +978,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'))
 
-- 
2.11.0.rc2.dirty



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/7] selftest/wic.py: vda -> sda
  2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
                   ` (3 preceding siblings ...)
  2017-04-11  9:21 ` [PATCH 4/7] runqemu: do not rely on grepping images Robert Yang
@ 2017-04-11  9:21 ` Robert Yang
  2017-04-11  9:21 ` [PATCH 6/7] wic-image-minimal.wks: " Robert Yang
  2017-04-11  9:21 ` [PATCH 7/7] qemux86-directdisk.wks: " Robert Yang
  6 siblings, 0 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

Previously, runqemu grep root=/dev/sd or root=/dev/hd on the image, and
would use vda if no grep result, now we have set QB_DRIVE_TYPE to
"/dev/sd" by default, and the device will be /dev/sda, so use sda to
replace vda in the test case.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/lib/oeqa/selftest/wic.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py
index 8030c35117..34de6808c4 100644
--- a/meta/lib/oeqa/selftest/wic.py
+++ b/meta/lib/oeqa/selftest/wic.py
@@ -613,7 +613,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             cmd = "mount |grep '^/dev/' | cut -f1,3 -d ' '"
             status, output = qemu.run_serial(cmd)
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
-            self.assertEqual(output, '/dev/root /\r\n/dev/vda3 /mnt')
+            self.assertEqual(output, '/dev/root /\r\n/dev/sda3 /mnt')
 
     @only_for_arch(['i586', 'i686', 'x86_64'])
     def test_qemu_efi(self):
@@ -625,7 +625,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
 
         with runqemu('core-image-minimal', ssh=False,
                      runqemuparams='ovmf', image_fstype='wic') as qemu:
-            cmd = "grep vda. /proc/partitions  |wc -l"
+            cmd = "grep sda. /proc/partitions  |wc -l"
             status, output = qemu.run_serial(cmd)
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '3')
@@ -700,7 +700,7 @@ part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --r
             self.remove_config(config)
 
         with runqemu('core-image-minimal', ssh=False, image_fstype='wic') as qemu:
-            cmd = "grep vda. /proc/partitions  |wc -l"
+            cmd = "grep sda. /proc/partitions  |wc -l"
             status, output = qemu.run_serial(cmd)
             self.assertEqual(1, status, 'Failed to run command "%s": %s' % (cmd, output))
             self.assertEqual(output, '2')
-- 
2.11.0.rc2.dirty



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/7] wic-image-minimal.wks: vda -> sda
  2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
                   ` (4 preceding siblings ...)
  2017-04-11  9:21 ` [PATCH 5/7] selftest/wic.py: vda -> sda Robert Yang
@ 2017-04-11  9:21 ` Robert Yang
  2017-04-11  9:21 ` [PATCH 7/7] qemux86-directdisk.wks: " Robert Yang
  6 siblings, 0 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

Previously, runqemu grep root=/dev/sd or root=/dev/hd on the image, and
would use vda if no grep result, now we have set QB_DRIVE_TYPE to
"/dev/sd" by default, and the device will be /dev/sda, so use sda to
replace vda in the test case.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta-selftest/recipes-test/images/wic-image-minimal.wks | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/meta-selftest/recipes-test/images/wic-image-minimal.wks b/meta-selftest/recipes-test/images/wic-image-minimal.wks
index d55075d503..3e08cf4e43 100644
--- a/meta-selftest/recipes-test/images/wic-image-minimal.wks
+++ b/meta-selftest/recipes-test/images/wic-image-minimal.wks
@@ -2,9 +2,9 @@
 # long-description: This image contains boot partition and 3 rootfs partitions
 # created from core-image-minimal and wic-image-minimal image recipes.
 
-part /boot --source bootimg-pcbios --ondisk vda --label boot --active --align 1024
-part / --source rootfs --ondisk vda --fstype=ext4 --label platform --align 1024 --use-uuid
-part /mnt --source rootfs --rootfs-dir=core-image-minimal --ondisk vda --fstype=ext4 --label core --align 1024
-part backup --source rootfs --rootfs-dir=wic-image-minimal --ondisk vda --fstype=ext4 --label backup --align 1024
+part /boot --source bootimg-pcbios --ondisk sda --label boot --active --align 1024
+part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid
+part /mnt --source rootfs --rootfs-dir=core-image-minimal --ondisk sda --fstype=ext4 --label core --align 1024
+part backup --source rootfs --rootfs-dir=wic-image-minimal --ondisk sda --fstype=ext4 --label backup --align 1024
 
 bootloader --ptable gpt --timeout=0  --append="rootwait console=tty0"
-- 
2.11.0.rc2.dirty



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/7] qemux86-directdisk.wks: vda -> sda
  2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
                   ` (5 preceding siblings ...)
  2017-04-11  9:21 ` [PATCH 6/7] wic-image-minimal.wks: " Robert Yang
@ 2017-04-11  9:21 ` Robert Yang
  6 siblings, 0 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-11  9:21 UTC (permalink / raw)
  To: openembedded-core

Previously, runqemu grep root=/dev/sd or root=/dev/hd on the image, and
would use vda if no grep result, now we have set QB_DRIVE_TYPE to
"/dev/sd" by default, and the device will be /dev/sda, so use sda to
replace vda in the test case.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 scripts/lib/wic/canned-wks/qemux86-directdisk.wks | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/lib/wic/canned-wks/qemux86-directdisk.wks b/scripts/lib/wic/canned-wks/qemux86-directdisk.wks
index a6518a0f45..db30bbced0 100644
--- a/scripts/lib/wic/canned-wks/qemux86-directdisk.wks
+++ b/scripts/lib/wic/canned-wks/qemux86-directdisk.wks
@@ -4,5 +4,5 @@
 
 include common.wks.inc
 
-bootloader  --timeout=0  --append="vga=0 uvesafb.mode_option=640x480-32 root=/dev/vda2 rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 rootfstype=ext4 "
+bootloader  --timeout=0  --append="vga=0 uvesafb.mode_option=640x480-32 root=/dev/sda2 rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 rootfstype=ext4 "
 
-- 
2.11.0.rc2.dirty



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/7] runqemu: do not rely on grepping images
  2017-04-11  9:21 ` [PATCH 4/7] runqemu: do not rely on grepping images Robert Yang
@ 2017-04-13  8:46   ` Patrick Ohly
  2017-04-13  8:59     ` Robert Yang
  2017-04-13  8:59     ` Robert Yang
  0 siblings, 2 replies; 12+ messages in thread
From: Patrick Ohly @ 2017-04-13  8:46 UTC (permalink / raw)
  To: Robert Yang; +Cc: openembedded-core

On Tue, 2017-04-11 at 02:21 -0700, Robert Yang wrote:
> 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>
> ---
>  meta/classes/qemuboot.bbclass |  3 +++
>  scripts/runqemu               | 19 +++++++++++--------
>  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"

Now that I am faced with the problem of selecting virtio I'm starting to
wonder how to do that.

Our refkit image doesn't expect the image on a particular drive, using
PARTUUID instead to find it. But when running under qemu, it would be
nice to use virtio for performance reasons... if the kernel supports it.
But that's not something that the image recipe or even the distro should
make assumptions about.

It seems safer to let the machine configuration which chooses the kernel
also set QB_DRIVE_TYPE, but with ?= so that it can still be changed
elsewhere. In that case, we would need:

qemuboot.bbclass: QB_DRIVE_TYPE ??= "/dev/sd"
qemuboot-intel.inc (from meta-intel): QB_DRIVE_TYPE ?= "/dev/vd"
distro, local or image (optional): QB_DRIVE_TYPE = "/dev/..."

> +                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)

Here "/dev/sd" should be treated as an explicit selection of virtio,
without triggering warnings.

I'll send a patch for both if there are no objections.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/7] runqemu: do not rely on grepping images
  2017-04-13  8:46   ` Patrick Ohly
@ 2017-04-13  8:59     ` Robert Yang
  2017-04-13  9:13       ` Patrick Ohly
  2017-04-13  8:59     ` Robert Yang
  1 sibling, 1 reply; 12+ messages in thread
From: Robert Yang @ 2017-04-13  8:59 UTC (permalink / raw)
  To: Patrick Ohly; +Cc: openembedded-core

Hi Patrick,

On 04/13/2017 04:46 PM, Patrick Ohly wrote:
> On Tue, 2017-04-11 at 02:21 -0700, Robert Yang wrote:
>> 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>
>> ---
>>  meta/classes/qemuboot.bbclass |  3 +++
>>  scripts/runqemu               | 19 +++++++++++--------
>>  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"
>
> Now that I am faced with the problem of selecting virtio I'm starting to
> wonder how to do that.
>
> Our refkit image doesn't expect the image on a particular drive, using
> PARTUUID instead to find it. But when running under qemu, it would be
> nice to use virtio for performance reasons... if the kernel supports it.
> But that's not something that the image recipe or even the distro should
> make assumptions about.
>
> It seems safer to let the machine configuration which chooses the kernel
> also set QB_DRIVE_TYPE, but with ?= so that it can still be changed
> elsewhere. In that case, we would need:
>
> qemuboot.bbclass: QB_DRIVE_TYPE ??= "/dev/sd"
> qemuboot-intel.inc (from meta-intel): QB_DRIVE_TYPE ?= "/dev/vd"
> distro, local or image (optional): QB_DRIVE_TYPE = "/dev/..."

The "??=" is not needed, just "?=" in qemuboot.bbclass is OK, we have
"?=" in other bbclass, too, and they can be overrided as expected.
For example:

qemuboot-intel.inc (from meta-intel): QB_DRIVE_TYPE ?= "/dev/vd"

Then it would be vd, and if you set = /dev/hd in local.conf, the it would
be /dev/hd.

// Robert

>
>> +                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)
>
> Here "/dev/sd" should be treated as an explicit selection of virtio,
> without triggering warnings.

Did you mean /dev/vd ? If yes, I'm fine with that.

// Robert

>
> I'll send a patch for both if there are no objections.
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/7] runqemu: do not rely on grepping images
  2017-04-13  8:46   ` Patrick Ohly
  2017-04-13  8:59     ` Robert Yang
@ 2017-04-13  8:59     ` Robert Yang
  1 sibling, 0 replies; 12+ messages in thread
From: Robert Yang @ 2017-04-13  8:59 UTC (permalink / raw)
  To: Patrick Ohly; +Cc: openembedded-core

Hi Patrick,

On 04/13/2017 04:46 PM, Patrick Ohly wrote:
> On Tue, 2017-04-11 at 02:21 -0700, Robert Yang wrote:
>> 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>
>> ---
>>  meta/classes/qemuboot.bbclass |  3 +++
>>  scripts/runqemu               | 19 +++++++++++--------
>>  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"
>
> Now that I am faced with the problem of selecting virtio I'm starting to
> wonder how to do that.
>
> Our refkit image doesn't expect the image on a particular drive, using
> PARTUUID instead to find it. But when running under qemu, it would be
> nice to use virtio for performance reasons... if the kernel supports it.
> But that's not something that the image recipe or even the distro should
> make assumptions about.
>
> It seems safer to let the machine configuration which chooses the kernel
> also set QB_DRIVE_TYPE, but with ?= so that it can still be changed
> elsewhere. In that case, we would need:
>
> qemuboot.bbclass: QB_DRIVE_TYPE ??= "/dev/sd"
> qemuboot-intel.inc (from meta-intel): QB_DRIVE_TYPE ?= "/dev/vd"
> distro, local or image (optional): QB_DRIVE_TYPE = "/dev/..."

The "??=" is not needed, just "?=" in qemuboot.bbclass is OK, we have
"?=" in other bbclass, too, and they can be overrided as expected.
For example:

qemuboot-intel.inc (from meta-intel): QB_DRIVE_TYPE ?= "/dev/vd"

Then it would be vd, and if you set = /dev/hd in local.conf, the it would
be /dev/hd.

>
>> +                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)
>
> Here "/dev/sd" should be treated as an explicit selection of virtio,
> without triggering warnings.

Did you mean /dev/vd ? If yes, I'm fine with that.

// Robert

>
> I'll send a patch for both if there are no objections.
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/7] runqemu: do not rely on grepping images
  2017-04-13  8:59     ` Robert Yang
@ 2017-04-13  9:13       ` Patrick Ohly
  0 siblings, 0 replies; 12+ messages in thread
From: Patrick Ohly @ 2017-04-13  9:13 UTC (permalink / raw)
  To: Robert Yang; +Cc: openembedded-core

On Thu, 2017-04-13 at 16:59 +0800, Robert Yang wrote:
> Hi Patrick,
> 
> On 04/13/2017 04:46 PM, Patrick Ohly wrote:
> > On Tue, 2017-04-11 at 02:21 -0700, Robert Yang wrote:
> >> 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>
> >> ---
> >>  meta/classes/qemuboot.bbclass |  3 +++
> >>  scripts/runqemu               | 19 +++++++++++--------
> >>  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"
> >
> > Now that I am faced with the problem of selecting virtio I'm starting to
> > wonder how to do that.
> >
> > Our refkit image doesn't expect the image on a particular drive, using
> > PARTUUID instead to find it. But when running under qemu, it would be
> > nice to use virtio for performance reasons... if the kernel supports it.
> > But that's not something that the image recipe or even the distro should
> > make assumptions about.
> >
> > It seems safer to let the machine configuration which chooses the kernel
> > also set QB_DRIVE_TYPE, but with ?= so that it can still be changed
> > elsewhere. In that case, we would need:
> >
> > qemuboot.bbclass: QB_DRIVE_TYPE ??= "/dev/sd"
> > qemuboot-intel.inc (from meta-intel): QB_DRIVE_TYPE ?= "/dev/vd"
> > distro, local or image (optional): QB_DRIVE_TYPE = "/dev/..."
> 
> The "??=" is not needed, just "?=" in qemuboot.bbclass is OK, we have
> "?=" in other bbclass, too, and they can be overrided as expected.

Other classes might depend on a different order of setting values.

> For example:
> 
> qemuboot-intel.inc (from meta-intel): QB_DRIVE_TYPE ?= "/dev/vd"

But you right, that works, because although that default gets set first,
it does not get overwritten by the latter default from qemuboot.bbclass.

I thought defaults worked the same way as normal assignments, i.e.
  foo ?= "a"
  foo ?= "b"
would result in foo == "b". That's not the case.

> >> +                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)
> >
> > Here "/dev/sd" should be treated as an explicit selection of virtio,
> > without triggering warnings.
> 
> Did you mean /dev/vd ? If yes, I'm fine with that.

Yes.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-04-13  9:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11  9:21 [PATCH 0/7 V3] fixes for runqemu Robert Yang
2017-04-11  9:21 ` [PATCH 1/7] runqemu: support env vars explicitly Robert Yang
2017-04-11  9:21 ` [PATCH 2/7] runqemu: use self.rootfs to replace self.nfs_dir Robert Yang
2017-04-11  9:21 ` [PATCH 3/7] runqemu: run without arguments Robert Yang
2017-04-11  9:21 ` [PATCH 4/7] runqemu: do not rely on grepping images Robert Yang
2017-04-13  8:46   ` Patrick Ohly
2017-04-13  8:59     ` Robert Yang
2017-04-13  9:13       ` Patrick Ohly
2017-04-13  8:59     ` Robert Yang
2017-04-11  9:21 ` [PATCH 5/7] selftest/wic.py: vda -> sda Robert Yang
2017-04-11  9:21 ` [PATCH 6/7] wic-image-minimal.wks: " Robert Yang
2017-04-11  9:21 ` [PATCH 7/7] qemux86-directdisk.wks: " Robert Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.