Zhang Qian
2009-Aug-05 02:50 UTC
[Libguestfs] How to get information about the guest filesystems by libguestfs
Hi, I am using guestfish to write some files into guest file system of my KVM domain. As you know, I have to mount guest disk at a position in the filesystem before I write any files into it , e.g.: mount /dev/VolGroup00/LogVol00 / But the problem is how I can get guest filesystem info without login guest. Now I have to power on the KVM domain, login the guest, remember which partition(/dev/VolGroup00/LogVol00) is mounted in root directory, then power off the domain, execute the above command in guestfish. Is there any libguestfs API or guestfish command which can be used to get information about the guest filesystems? E.g. which partition is mounted at which directory. It should be very helpful for me. Thanks! Regards, Qian
Charles Duffy
2009-Aug-05 03:24 UTC
[Libguestfs] How to get information about the guest filesystems by libguestfs
I *think* newer libguestfs has support for this built-in -- but personally, I use virt-inspector, which has had such functionality since its inception. On Tue, Aug 4, 2009 at 9:50 PM, Zhang Qian <zhq527725 at gmail.com> wrote:> Hi, > > I am using guestfish to write some files into guest file system of my > KVM domain. As you know, I have to mount guest disk at a position in > the filesystem before I write any files into it , e.g.: > mount /dev/VolGroup00/LogVol00 / > > But the problem is how I can get guest filesystem info without login > guest. Now I have to power on the KVM domain, login the guest, > remember which partition(/dev/VolGroup00/LogVol00) is mounted in root > directory, then power off the domain, execute the above command in > guestfish. > > Is there any libguestfs API or guestfish command which can be used to > get information about the guest filesystems? E.g. which partition is > mounted at which directory. It should be very helpful for me. > Thanks! > > > Regards, > Qian > > _______________________________________________ > Libguestfs mailing list > Libguestfs at redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libguestfs/attachments/20090804/7640cb56/attachment.htm>
Charles Duffy
2009-Aug-05 06:21 UTC
[Libguestfs] How to get information about the guest filesystems by libguestfs
I looked into it -- what exists in newer versions (via "guestfish -i") isn't really built-in as such, but rather calls virt-inspector. There is no C implementation presently, and you would need to rewrite the (fairly complex) Perl code in C to get that functionality independent of it. That's certainly a feasible thing to do -- but why is it so important to you that everything be pure C? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libguestfs/attachments/20090805/f51b2b51/attachment.htm>
Zhang Qian
2009-Aug-05 07:30 UTC
[Libguestfs] How to get information about the guest filesystems by libguestfs
Or I can call guestfs_list_partitions() and guestfs_lvs() to list all partitions and logic volumes in guest disk images, and for each of them call guestfs_exists() to check if the file I want exist, then modify the file. Regards, Qian
Richard W.M. Jones
2009-Aug-05 08:40 UTC
[Libguestfs] How to get information about the guest filesystems by libguestfs
On Wed, Aug 05, 2009 at 04:10:06PM +0800, Zhang Qian wrote:> Thanks Richard! It will be great that I can get an xml representation > of the guest and mountpoints like that. > > Can I install virt-inspector in my RHEL5.3 box? It seems there is not > virt-inspector rpm packages for RHEL5.3. > Or should I build virt-inspector from source? Where can I get its source code?There is unfortunately a missing dependency (perl-Sys-Virt) which prevents us from building virt-inspector in EPEL. The specific problem is that perl-Sys-Virt is going to be added to the next release of RHEL (5.4) in a month, and for this reason we cannot add it to EPEL (for RHEL 5.3) now. Solution is probably to download the source RPM and build from there. There are some parts of the spec file which build virt-inspector that are commented out. If you have a perl-Sys-Virt RPM then you can uncomment those and build it. Our latest source RPM is here: http://kojipkgs.fedoraproject.org/packages/libguestfs/1.0.65/2.el5/src/libguestfs-1.0.65-2.el5.src.rpm (found from http://koji.fedoraproject.org/koji/packageinfo?packageID=8391) perl-Sys-Virt is here: http://search.cpan.org/dist/Sys-Virt/ You should be able to build an RPM using: wget http://search.cpan.org/CPAN/authors/id/D/DA/DANBERR/Sys-Virt-0.2.0.tar.gz rpmbuild -ta Sys-Virt-0.2.0.tar.gz Here is a guide to setting up and using rpmbuild: http://genetikayos.com/code/repos/rpm-tutorial/trunk/rpm-tutorial.html Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
Zhang Qian
2009-Aug-06 01:30 UTC
[Libguestfs] How to get information about the guest filesystems by libguestfs
Thanks Richard. I have downloaded and installed RHEL5.4 Beta which does include KVM, but not libguestfs and virt-inspector. Now I am looking forward to RHEL5.4 release :-) Regards, Qian
Reasonably Related Threads
- Can not build libguestfs from source code
- Can I use libguestfs to pass some parameters into a KVM virtual machine
- DomU stuck in boot
- [PATCH / discussion only] Add kernel and userspace arch detection to virt-inspector
- Can not restore domain from a shared state file