On Wed, Sep 04, 2013 at 02:31:08AM +0000, 徐展聪 wrote:
I use python-guestfs to mount windows image it have some problems
.Here is my code:
[root@mfsdata1 ~]# python
Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license"
for more information.
>>> import os
>>> sheepfs_dir="/tmp/sheepfs"
>>> os.system("umount " + sheepfs_dir)
0
>>> os.system("sheepfs -n " + sheepfs_dir)
0
>>> vdi_name = "vm1935028.nbregion.ec2.cloudkc.cn"
>>> os.system("echo " + vdi_name + ">" + sheepfs_dir +
"/vdi/mount")
0
>>> import guestfs
>>> g=guestfs.GuestFS()
>>> imgfile=sheepfs_dir + "/volume/" + vdi_name
>>> g.add_drive_opts(imgfile, format="raw", readonly=0)
>>> g.launch()
>>> root = g.inspect_os()
>>> print root
[]
So libguestfs can't find any guest(s) in the disk image. I suggest
calling g.set_trace(1) after opening the handle, then looking at the
trace output. If you can't see what is wrong, then post the full
trace output on this list.
>>> g.list_filesystems()
[('/dev/vda1', 'ntfs'), ('/dev/vda2', 'ntfs')]
You can also just mount filesystems directly.
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://people.redhat.com/~rjones/virt-top