trace:>>> g.inspect_os()
libguestfs: trace: inspect_os
libguestfs: trace: umount_all
libguestfs: trace: umount_all = 0
libguestfs: trace: list_devices
libguestfs: trace: list_devices = ["/dev/vda"]
libguestfs: trace: vfs_type "/dev/vda"
libguestfs: trace: vfs_type = ""
libguestfs: trace: mount_ro "/dev/vda" "/"
libguestfs: trace: mount_ro = -1 (error)
libguestfs: trace: list_partitions
libguestfs: trace: list_partitions = ["/dev/vda1",
"/dev/vda2"]
libguestfs: trace: vfs_type "/dev/vda1"
libguestfs: trace: vfs_type = "ntfs"
libguestfs: trace: mount_ro "/dev/vda1" "/"
libguestfs: trace: mount_ro = -1 (error)
libguestfs: trace: vfs_type "/dev/vda2"
libguestfs: trace: vfs_type = "ntfs"
libguestfs: trace: mount_ro "/dev/vda2" "/"
libguestfs: trace: mount_ro = -1 (error)
libguestfs: trace: list_md_devices
libguestfs: trace: list_md_devices = []
libguestfs: trace: available "lvm2"
libguestfs: trace: available = 0
libguestfs: trace: lvs
libguestfs: trace: lvs = []
libguestfs: trace: inspect_os = []
[]
________________________________________
发件人: Richard W.M. Jones [rjones@redhat.com]
发送时间: 2013年9月5日 16:13
收件人: 徐展聪
Cc: libguestfs@redhat.com
主题: Re: [Libguestfs] python-guestfs
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