Patchwork [V2,1/7] targetcontrol.py: make possible dynamical determination of rootfs type

login
register
mail settings
Submitter Corneliu Stoicescu
Date June 6, 2014, 7:14 p.m.
Message ID <1402082078-10826-2-git-send-email-corneliux.stoicescu@intel.com>
Download mbox | patch
Permalink /patch/73439/
State Accepted
Commit af384220175dc548d8eb0b94209c49c937292d91
Headers show

Comments

Corneliu Stoicescu - June 6, 2014, 7:14 p.m.
YB: #6375

Added a new method get_image_fstype() that autodetermines what fstype to use for the rootfs file.
This method uses a new list variable 'supported_image_fstypes' that contains image fstypes supported by the target controller.

This method is also a classmethod which means outside scripts can get the image fstype.

Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com>
---
 meta/lib/oeqa/targetcontrol.py | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
Stefan Stanacar - June 7, 2014, 11:38 a.m.
Hi Corneliu,

On Fri, Jun 6, 2014 at 10:14 PM, Corneliu Stoicescu
<corneliux.stoicescu@intel.com> wrote:
> YB: #6375
>
> Added a new method get_image_fstype() that autodetermines what fstype to use for the rootfs file.
> This method uses a new list variable 'supported_image_fstypes' that contains image fstypes supported by the target controller.
>
> This method is also a classmethod which means outside scripts can get the image fstype.
>
> Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com>
> ---
>  meta/lib/oeqa/targetcontrol.py | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
> index ff1bb89..866c414 100644
> --- a/meta/lib/oeqa/targetcontrol.py
> +++ b/meta/lib/oeqa/targetcontrol.py
> @@ -44,6 +44,8 @@ class BaseTarget(object):
>
>      __metaclass__ = ABCMeta
>
> +    supported_image_fstypes = []
> +
>      def __init__(self, d):
>          self.connection = None
>          self.ip = None
> @@ -70,6 +72,16 @@ class BaseTarget(object):
>      def stop(self):
>          pass
>
> +    @classmethod
> +    def get_image_fstype(self, d, image_fstypes=None):

You made this a static method so you can call it from an external
script? Hmm.. But then you wouldn't be able to pass d, so what's the
point? Adding support for more fs is nice, but you should do that for
testimage, ie make it configurable and let the use choose from
local.conf (with a reasonable default). Right now you are configuring
the test bits from outside...

Cheers,
Stefan

> +        if not image_fstypes:
> +            image_fstypes = d.getVar('IMAGE_FSTYPES', True).split(' ')
> +        possible_image_fstypes = [fstype for fstype in self.supported_image_fstypes if fstype in image_fstypes]
> +        if possible_image_fstypes:
> +            return possible_image_fstypes[0]
> +        else:
> +            bb.fatal("no possible image_fstype could not be determined. IMAGE_FSTYPES=\"%s\" and supported_image_fstypes=\"%s\": " % (', '.join(map(str, image_fstypes)), ', '.join(map(str, self.supported_image_fstypes))))
> +
>      def restart(self, params=None):
>          self.stop()
>          self.start(params)
> @@ -87,13 +99,16 @@ class BaseTarget(object):
>
>  class QemuTarget(BaseTarget):
>
> +    supported_image_fstypes = ['ext3']
> +
>      def __init__(self, d):
>
>          super(QemuTarget, self).__init__(d)
>
> +        self.image_fstype = self.get_image_fstype(d)
>          self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime)
> -        self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),  d.getVar("IMAGE_LINK_NAME", True) + '.ext3')
> -        self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.ext3')
> +        self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),  d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype)
> +        self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.' + self.image_fstype)
>
>          self.runner = QemuRunner(machine=d.getVar("MACHINE", True),
>                          rootfs=self.rootfs,
> --
> 1.8.3.2
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Corneliu Stoicescu - June 8, 2014, 7:19 p.m.
> -----Original Message-----
> From: Stefan Stanacar [mailto:sstncr@gmail.com]
> Sent: Saturday, June 07, 2014 2:38 PM
> To: Stoicescu, CorneliuX
> Cc: openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCH V2 1/7] targetcontrol.py: make possible
> dynamical determination of rootfs type
> 
> Hi Corneliu,
> 
> On Fri, Jun 6, 2014 at 10:14 PM, Corneliu Stoicescu
> <corneliux.stoicescu@intel.com> wrote:
> > YB: #6375
> >
> > Added a new method get_image_fstype() that autodetermines what fstype
> to use for the rootfs file.
> > This method uses a new list variable 'supported_image_fstypes' that
> contains image fstypes supported by the target controller.
> >
> > This method is also a classmethod which means outside scripts can get the
> image fstype.
> >
> > Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com>
> > ---
> >  meta/lib/oeqa/targetcontrol.py | 19 +++++++++++++++++--
> >  1 file changed, 17 insertions(+), 2 deletions(-)
> >
> > diff --git a/meta/lib/oeqa/targetcontrol.py
> > b/meta/lib/oeqa/targetcontrol.py index ff1bb89..866c414 100644
> > --- a/meta/lib/oeqa/targetcontrol.py
> > +++ b/meta/lib/oeqa/targetcontrol.py
> > @@ -44,6 +44,8 @@ class BaseTarget(object):
> >
> >      __metaclass__ = ABCMeta
> >
> > +    supported_image_fstypes = []
> > +
> >      def __init__(self, d):
> >          self.connection = None
> >          self.ip = None
> > @@ -70,6 +72,16 @@ class BaseTarget(object):
> >      def stop(self):
> >          pass
> >
> > +    @classmethod
> > +    def get_image_fstype(self, d, image_fstypes=None):
> 
> You made this a static method so you can call it from an external script?
> Hmm.. But then you wouldn't be able to pass d, so what's the point? Adding
> support for more fs is nice, but you should do that for testimage, ie make it
> configurable and let the use choose from local.conf (with a reasonable
> default). Right now you are configuring the test bits from outside...
> 
> Cheers,
> Stefan

This method can use d to get the IMAGE_FSTYPES value or it can be directly given that value and bypass d. See in the test-remote-image script how we used it.
Again, these patches are made with the possibility of using the target controllers to get as much information, both internally and externally, in mind. We try to process the information (like image fstype used) in one place and get if rom there wherever we need it.
Also we would like to keep the user configurable variables to a minimum and automatically determine as much as we can(I should have included this in the cover letter). And where can we do this better than in the target controllers themselves?

I hope I this is a little more clear now. 

Regards,
Corneliu

Patch

diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index ff1bb89..866c414 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -44,6 +44,8 @@  class BaseTarget(object):
 
     __metaclass__ = ABCMeta
 
+    supported_image_fstypes = []
+
     def __init__(self, d):
         self.connection = None
         self.ip = None
@@ -70,6 +72,16 @@  class BaseTarget(object):
     def stop(self):
         pass
 
+    @classmethod
+    def get_image_fstype(self, d, image_fstypes=None):
+        if not image_fstypes:
+            image_fstypes = d.getVar('IMAGE_FSTYPES', True).split(' ')
+        possible_image_fstypes = [fstype for fstype in self.supported_image_fstypes if fstype in image_fstypes]
+        if possible_image_fstypes:
+            return possible_image_fstypes[0]
+        else:
+            bb.fatal("no possible image_fstype could not be determined. IMAGE_FSTYPES=\"%s\" and supported_image_fstypes=\"%s\": " % (', '.join(map(str, image_fstypes)), ', '.join(map(str, self.supported_image_fstypes))))
+
     def restart(self, params=None):
         self.stop()
         self.start(params)
@@ -87,13 +99,16 @@  class BaseTarget(object):
 
 class QemuTarget(BaseTarget):
 
+    supported_image_fstypes = ['ext3']
+
     def __init__(self, d):
 
         super(QemuTarget, self).__init__(d)
 
+        self.image_fstype = self.get_image_fstype(d)
         self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime)
-        self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),  d.getVar("IMAGE_LINK_NAME", True) + '.ext3')
-        self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.ext3')
+        self.origrootfs = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True),  d.getVar("IMAGE_LINK_NAME", True) + '.' + self.image_fstype)
+        self.rootfs = os.path.join(self.testdir, d.getVar("IMAGE_LINK_NAME", True) + '-testimage.' + self.image_fstype)
 
         self.runner = QemuRunner(machine=d.getVar("MACHINE", True),
                         rootfs=self.rootfs,