All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] oeqa: more control over qemu
@ 2017-03-27  9:50 Patrick Ohly
  2017-03-27  9:50 ` [PATCH v3 1/3] oeqa: allow extending qemuparams="..." Patrick Ohly
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Patrick Ohly @ 2017-03-27  9:50 UTC (permalink / raw
  To: openembedded-core

I'm currently working on testing an installer image. During that test
I need to:
- boot with two drives attached to the virtual machine (installer image
  and internal disk)
- install to internal disk
- reboot with just the internal disk

There were several problems doing that:
- attaching second disk via qemuparams was not possible
- run_serial() timed out too early during the long-running install command
- writes to the internal disks were discarded
- booting with only the non-standard internal disk instead of the
  recipe's image was not possible

V2: rebased on top of master-next + Robert's "runqemu: add selftest" series,
    no other changes (merge V1 if not taking Robert's patches first)
V3: rebased on top of current master

Patrick Ohly (3):
  oeqa: allow extending qemuparams="..."
  oeqa: allow customizing image used by runqemu()
  oeqa: allow persistent image writes in runqemu()

 meta/lib/oeqa/targetcontrol.py    | 6 +++---
 meta/lib/oeqa/utils/commands.py   | 6 ++++--
 meta/lib/oeqa/utils/qemurunner.py | 4 ++--
 3 files changed, 9 insertions(+), 7 deletions(-)

base-commit: b2a785f19fe25d244179b8672c846925da6d455a
-- 
git-series 0.9.1


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

* [PATCH v3 1/3] oeqa: allow extending qemuparams="..."
  2017-03-27  9:50 [PATCH v3 0/3] oeqa: more control over qemu Patrick Ohly
@ 2017-03-27  9:50 ` Patrick Ohly
  2017-03-27  9:50 ` [PATCH v3 2/3] oeqa: allow customizing image used by runqemu() Patrick Ohly
  2017-03-27  9:50 ` [PATCH v3 3/3] oeqa: allow persistent image writes in runqemu() Patrick Ohly
  2 siblings, 0 replies; 4+ messages in thread
From: Patrick Ohly @ 2017-03-27  9:50 UTC (permalink / raw
  To: openembedded-core

Sometimes it is useful to reconfigure the qemu virtual machine
directly. runqemu has the "qemuparams" parameter for that, and the
underlying start() methods also supported modifying that via their
"params" parameter. Only the runqemu() wrapper function lacked
a way to specify additional parameters.

One potential usage is to attach additional disks.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
 meta/lib/oeqa/utils/commands.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index cd7a5e3..3dfff0f 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -225,7 +225,7 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec=
 
 
 @contextlib.contextmanager
-def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None):
+def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None):
     """
     launch_cmd means directly run the command, don't need set rootfs or env vars.
     """
@@ -276,7 +276,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None):
     try:
         qemu.deploy()
         try:
-            qemu.start(ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd)
+            qemu.start(params=qemuparams, ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd)
         except bb.build.FuncFailed:
             raise Exception('Failed to start QEMU - see the logs in %s' % logdir)
 
-- 
git-series 0.9.1


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

* [PATCH v3 2/3] oeqa: allow customizing image used by runqemu()
  2017-03-27  9:50 [PATCH v3 0/3] oeqa: more control over qemu Patrick Ohly
  2017-03-27  9:50 ` [PATCH v3 1/3] oeqa: allow extending qemuparams="..." Patrick Ohly
@ 2017-03-27  9:50 ` Patrick Ohly
  2017-03-27  9:50 ` [PATCH v3 3/3] oeqa: allow persistent image writes in runqemu() Patrick Ohly
  2 siblings, 0 replies; 4+ messages in thread
From: Patrick Ohly @ 2017-03-27  9:50 UTC (permalink / raw
  To: openembedded-core

runqemu() takes all parameters for the virtual machine from the
variables of the given recipe. By allowing the caller to provide a
hash with variables that get applied locally, the caller gets more
control.

Here's the intended usage:

   <prepare internal-image in self.resultdir>
   overrides = {
        'DEPLOY_DIR_IMAGE': self.resultdir,
        'IMAGE_LINK_NAME': 'internal-image-%s' % self.image_arch,
   }
   with runqemu('refkit-installer-image', ssh=False,
                 overrides=overrides) as qemu:
       ....

This can be used to replace the image completely with something else
or to copy it before allowing runqemu() to write into it.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
 meta/lib/oeqa/utils/commands.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 3dfff0f..88c9bb1 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -225,7 +225,7 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec=
 
 
 @contextlib.contextmanager
-def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None):
+def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}):
     """
     launch_cmd means directly run the command, don't need set rootfs or env vars.
     """
@@ -247,6 +247,8 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, 
             tinfoil.config_data.setVar("FIND_ROOTFS", '1')
 
         recipedata = tinfoil.parse_recipe(pn)
+        for key, value in overrides.items():
+            recipedata.setVar(key, value)
 
         # The QemuRunner log is saved out, but we need to ensure it is at the right
         # log level (and then ensure that since it's a child of the BitBake logger,
-- 
git-series 0.9.1


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

* [PATCH v3 3/3] oeqa: allow persistent image writes in runqemu()
  2017-03-27  9:50 [PATCH v3 0/3] oeqa: more control over qemu Patrick Ohly
  2017-03-27  9:50 ` [PATCH v3 1/3] oeqa: allow extending qemuparams="..." Patrick Ohly
  2017-03-27  9:50 ` [PATCH v3 2/3] oeqa: allow customizing image used by runqemu() Patrick Ohly
@ 2017-03-27  9:50 ` Patrick Ohly
  2 siblings, 0 replies; 4+ messages in thread
From: Patrick Ohly @ 2017-03-27  9:50 UTC (permalink / raw
  To: openembedded-core

By default, runqemu() avoids modifying the image files that it boots
into by enabling the qemu snapshot mode. However, some tests may want
to test changes that must persists across reboots, so this mode
should be optional.

This can be combined by copying the image file to a temporary location
first and then booting with that copy. It's also useful when testing
with additional drives attached to a virtual machine.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
 meta/lib/oeqa/targetcontrol.py    | 6 +++---
 meta/lib/oeqa/utils/commands.py   | 4 ++--
 meta/lib/oeqa/utils/qemurunner.py | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 40a2589..47cfe85 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -182,11 +182,11 @@ class QemuTarget(BaseTarget):
         logger.info("Qemu log file: %s" % self.qemulog)
         super(QemuTarget, self).deploy()
 
-    def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd=''):
+    def start(self, params=None, ssh=True, extra_bootparams='', runqemuparams='', launch_cmd='', discard_writes=True):
         if launch_cmd:
-            start = self.runner.launch(get_ip=ssh, launch_cmd=launch_cmd)
+            start = self.runner.launch(get_ip=ssh, launch_cmd=launch_cmd, discard_writes=discard_writes)
         else:
-            start = self.runner.start(params, get_ip=ssh, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams)
+            start = self.runner.start(params, get_ip=ssh, extra_bootparams=extra_bootparams, runqemuparams=runqemuparams, discard_writes=discard_writes)
 
         if start:
             if ssh:
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index 88c9bb1..2951dfb 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -225,7 +225,7 @@ def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec=
 
 
 @contextlib.contextmanager
-def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}):
+def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, qemuparams=None, overrides={}, discard_writes=True):
     """
     launch_cmd means directly run the command, don't need set rootfs or env vars.
     """
@@ -278,7 +278,7 @@ def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, launch_cmd=None, 
     try:
         qemu.deploy()
         try:
-            qemu.start(params=qemuparams, ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd)
+            qemu.start(params=qemuparams, ssh=ssh, runqemuparams=runqemuparams, launch_cmd=launch_cmd, discard_writes=discard_writes)
         except bb.build.FuncFailed:
             raise Exception('Failed to start QEMU - see the logs in %s' % logdir)
 
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 95f5925..cd79f21 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -97,7 +97,7 @@ class QemuRunner:
                 self._dump_host()
                 raise SystemExit
 
-    def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None):
+    def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True):
         if self.display:
             os.environ["DISPLAY"] = self.display
             # Set this flag so that Qemu doesn't do any grabs as SDL grabs
@@ -118,7 +118,7 @@ class QemuRunner:
             os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image
 
         if not launch_cmd:
-            launch_cmd = 'runqemu snapshot %s' % runqemuparams
+            launch_cmd = 'runqemu %s %s ' % ('snapshot' if discard_writes else '', runqemuparams)
             if self.use_kvm:
                 logger.info('Using kvm for runqemu')
                 launch_cmd += ' kvm'
-- 
git-series 0.9.1


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

end of thread, other threads:[~2017-03-27  9:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-27  9:50 [PATCH v3 0/3] oeqa: more control over qemu Patrick Ohly
2017-03-27  9:50 ` [PATCH v3 1/3] oeqa: allow extending qemuparams="..." Patrick Ohly
2017-03-27  9:50 ` [PATCH v3 2/3] oeqa: allow customizing image used by runqemu() Patrick Ohly
2017-03-27  9:50 ` [PATCH v3 3/3] oeqa: allow persistent image writes in runqemu() Patrick Ohly

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.