[et-mgmt-tools] [PATCH]: Print a better error message if the disk path doesn't exist

Chris Lalancette clalance at redhat.com
Thu Oct 4 17:53:49 UTC 2007


All,
     Currently with virt-install, if you specify a path for the disk image, and
the subdirectories don't exist, like so:

virt-install -n chris -r 512 -f /var/lib/xen/images/foo/x.img -s 1 --nonsparse
--nographics -p -l nfs:server:/path/to/tree

(where /var/lib/xen/images/foo subdir doesn't exist), you get a traceback like so:

Starting install...
Creating storage file...  100% |=========================| 1.0 GB    00:00
Traceback (most recent call last):
  File "/usr/sbin/virt-install", line 633, in ?
    main()
  File "/usr/sbin/virt-install", line 578, in main
    dom = guest.start_install(conscb,progresscb)
  File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 649, in
start_install
    return self._do_install(consolecb, meter)
  File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 662, in
_do_install
    self._create_devices(meter)
  File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 557, in
_create_devices
    disk.setup(progresscb)
  File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 104, in setup
    fd = os.open(self.path, os.O_WRONLY | os.O_CREAT)
OSError: [Errno 2] No such file or directory: '/var/lib/xen/images/foo/x.img'

The attached patch fixes this by adding a try..except inside of the try..finally
block to catch the exception and throw a RuntimeError instead.  Note that I went
the route of nested try..except inside of try..finally to be compatible with
python 2.4.  Also note that the patch as posted is against the RHEL-5.1 version
of virt-install, but should apply pretty easily to upstream virt-install.

Comments?

Thanks,
Chris Lalancette
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python-virtinst-file-image-traceback.patch
Type: text/x-patch
Size: 1672 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/et-mgmt-tools/attachments/20071004/54f12c3b/attachment.bin>


More information about the et-mgmt-tools mailing list