On Mon, Jan 25, 2010 at 05:03:29AM -0500, Michael Goldish wrote:
> 
> ----- "Amos Kong" <[email protected]> wrote:
> 
> > In kvm_vm.py:
> > def get_image_filename(params, root_dir):
> >     ...
> >     ...
> >     image_name = params.get("image_name", "image")
> >     image_format = params.get("image_format", "qcow2")
> >     image_filename = "%s.%s" % (image_name, image_format)
> >     image_filename = kvm_utils.get_path(root_dir, image_filename)
> > 
> > 
> > If assign image_name as "/tmp/img" in configure file, it will be
> > changed to
> > "images//tmp/img" by "image_name.* ?<= images/". Then the second
> > argument of
> > kvm_utils.get_path() will always starts with "images/", this function
> > could not
> > return right "/tmp/img.qcow2". This patch will join root_dir with
> > "images/"
> > first, and analyze whether the rest part is absolute path.
> > 
> > Same problem also exists on ISO name.
> > 
> > Signed-off-by: Amos Kong <[email protected]>
> > ---
> >  client/tests/kvm/kvm_vm.py |   22 +++++++++++++++++++---
> >  1 files changed, 19 insertions(+), 3 deletions(-)
> > 
> > diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> > index 8985f25..5ece6ed 100755
> > --- a/client/tests/kvm/kvm_vm.py
> > +++ b/client/tests/kvm/kvm_vm.py
> > @@ -23,10 +23,26 @@ def get_image_filename(params, root_dir):
> >      image_name = params.get("image_name", "image")
> >      image_format = params.get("image_format", "qcow2")
> >      image_filename = "%s.%s" % (image_name, image_format)
> > -    image_filename = kvm_utils.get_path(root_dir, image_filename)
> > +    n = image_filename.index('/') + 1
> > +    image_filename = kvm_utils.get_path(os.path.join(root_dir,
> > +                                       image_filename[:n]),
> > image_filename[n:])
> >      return image_filename
> >  
> >  
> > +def get_iso_filename(params, root_dir):
> > +    """
> > +    Generate an iso path from params and root_dir.
> > +
> > +    @param params: Dictionary containing the test parameters.
> > +    @param root_dir: Base directory for relative filenames.
> > +    """
> > +    iso = params.get("cdrom")
> > +    n = iso.index('/') + 1
> > +    iso = kvm_utils.get_path(os.path.join(root_dir, iso[:n]),
> > iso[n:])
> > +
> > +    return iso
> > +
> > +
> >  def create_image(params, root_dir):
> >      """
> >      Create an image using qemu_image.
> > @@ -303,7 +319,7 @@ class VM:
> >  
> >          iso = params.get("cdrom")
> >          if iso:
> > -            iso = kvm_utils.get_path(root_dir, iso)
> > +            iso = get_iso_filename(params, root_dir)
> >              qemu_cmd += " -cdrom %s" % iso
> >  
> >          soundhw = params.get("soundcards")
> > @@ -377,7 +393,7 @@ class VM:
> >          # Verify the md5sum of the ISO image
> >          iso = params.get("cdrom")
> >          if iso:
> > -            iso = kvm_utils.get_path(root_dir, iso)
> > +            iso = get_iso_filename(params, root_dir)
> >              if not os.path.exists(iso):
> >                  logging.error("ISO file not found: %s" % iso)
> >                  return False
> 
> This is not the right solution to the problem.  If I understand correctly,
> you're hardcoding a mechanism to deal with the initial 'images/'.  The right
> solution would be to modify the config file to suit your needs.  If you work
> with /tmp, remove the line that pre-pends 'images/' to all image names 
> ("image_name.* ?<= images/") or change that line to "image_name.* ?<= /tmp/".
> The config file is meant to be modified.

Hello Michael,

Your suggestion is good, this problem should be fixed through configure file.
Our default iso files is on '$root_dir/isos/', and I assign this special 'cdrom'
variable below "image_name.* ?<= images/".

--------
 image_name.* ?<= images/
 cdrom.* ?<= isos/
 steps ?<= steps/

+cdrom:
+    cdrom = /tmp/orig.iso
+
--------

thanks.
  Amos 
-- 
Amos Kong
Quality Engineer
Raycom Office(Beijing), Red Hat Inc.
Phone: +86-10-62608183
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to