Richard W.M. Jones
2011-Jun-16 11:27 UTC
[Libguestfs] Comment on libguestfs code in https://bitbucket.org/swamiyeswanth/pyti
Yeswanth, I'm looking at: https://bitbucket.org/swamiyeswanth/pyti/src/2b3a7401eccf/diskhandler.py from this thread: http://librelist.com/browser//pyti/2011/6/13/disk-handler/ (1) I don't think the code you posted will work unless you move line 23 ('launch') up to just after you've added the drive (after line 12). (2) You probably don't want to use 'add_drive'. This deprecated function has a potential vulnerability, although it will only affect you if you are modifying untrusted raw-format guests. The suggested replacement is 'add_drive_opts' (which also has more features). http://libguestfs.org/guestfs.3.html#guestfs_add_drive http://libguestfs.org/guestfs.3.html#guestfs_add_drive_opts https://bugzilla.redhat.com/642934 (3) Instead of using 'mount', use 'mount_options'. The 'mount' call adds some flags to the mountpoint which are not very useful and also make disk writes very slow. http://libguestfs.org/guestfs.3.html#guestfs_mount http://libguestfs.org/guestfs.3.html#guestfs_mount_options http://libguestfs.org/guestfs.3.html#libguestfs_gotchas (4) After line 33 ('umount_all') you should also call 'self.disk_fs.sync()' which causes the libguestfs drive to be fully synced. Alternatively you can delete the handle ('del self.disk_fs') which assuming no other references are being held will do the same thing. HTH, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Richard W.M. Jones
2011-Jun-16 16:02 UTC
[Libguestfs] Comment on libguestfs code in https://bitbucket.org/swamiyeswanth/pyti
On Thu, Jun 16, 2011 at 09:14:14PM +0530, ( [YeSwAnTh] )- wrote:> 1)How do i handle .vdi images in guestfs.We support whatever qemu supports. It turns out that usually *.vdi files "just work": https://rwmj.wordpress.com/2010/10/04/tip-open-virtualbox-vdi-file-using-libguestfs/ If it doesn't work, then it's a qemu problem, so best to contact them. (Or you could use another format like raw instead).> the guestfs_add_drive_opts mentions only qcow2 and raw image > formats.You don't have to set the format parameter - it's optional. If it's not set, then qemu will autodetect it (as happens with 'add_drive'). Autodetection is unsafe if you don't trust your guests. [test plan]> What do you think of this?Sounds perfectly reasonable. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top