Hi, I tried to run the guestfs-examples from http://libguestfs.org/guestfs-examples.3.html, but they gave the following warnings and errors- #warning: Unable to get device geometry for /var/tmp/guestfs.JVxEUn/root #libguestfs: error: guestfs_launch failed, see earlier error messages What I did from the beginning- I boot my debian linux (2.6.32-5-686) inside VirtualBox and then install following packages there- #apt-get install qemu libguestfs-dev libguestfs-tools Then I created an image and install debian using qemu (inside my linux in VirtualBox, i.e. host)- #qemu-img create -f qcow2 deb.img 4G #qemu -m 256 -hda deb.img -cdrom debian-6.0.7-i386-netinst.iso -boot d Then I ran the vm using qemu in one terminal (inside my linux in VirtualBox, i.e. host)- #qemu -m 256 -hda deb.img -boot d In another terminal, I did- #gcc -Wall inspect_vm.c -o prog -lguestfs (without any warnings) #./prog deb.img Then the above warnings and errors were generated. Also I shutdown the vm, and tried to inspect the offline VM image (./prog deb.img), but it gaves the error- #libguestfs: error: guestfs_launch failed, see earlier error messages I tried to run the "EXAMPLE: DISPLAY THE OPERATING SYSTEM ICON OF A GUEST", but it gaves the same error- #libguestfs: error: guestfs_launch failed, see earlier error messages What is the problem here? Thank you. Best regards, Wahid
On Mon, Mar 04, 2013 at 05:50:27PM +0100, Khan Ferdous Wahid wrote:
Hi, I tried to run the guestfs-examples from http://libguestfs.org/guestfs-examples.3.html, but they gave the following warnings and errors- #warning: Unable to get device geometry for /var/tmp/guestfs.JVxEUn/root
You can just ignore this. However:
#libguestfs: error: guestfs_launch failed, see earlier error messages
you need to run 'libguestfs-test-tool' and post the complete, unedited output. However:
What I did from the beginning- I boot my debian linux (2.6.32-5-686) inside VirtualBox and then install following packages there- #apt-get install qemu libguestfs-dev libguestfs-tools
Your problem is that this kernel is too old. You have to use at least 2.6.36. 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
Hi, I have upgraded my kernel as you mentioned and everything is fine now. I wrote the following code to check the integrity of /boot directory in guest image. Now my question is- how could I check the integrity of files that are modified in last 10 minutes inside /boot directory? I use boot directory as an example directory. /*check a disk image for integrity */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <guestfs.h> int main (int argc, char *argv[]) { guestfs_h *g; const char *disk; char **roots; if (argc != 2) { fprintf (stderr, "usage: checkvm disk.img\n"); exit (EXIT_FAILURE); } disk = argv[1]; g = guestfs_create (); if (g == NULL) { perror ("failed to create libguestfs handle"); exit (EXIT_FAILURE); } /* Attach the disk image read-only to libguestfs. */ if (guestfs_add_drive_opts (g, disk, /* GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw", */ GUESTFS_ADD_DRIVE_OPTS_READONLY, 1, -1) /* this marks end of optional arguments */ == -1) exit (EXIT_FAILURE); /* Run the libguestfs back-end. */ if (guestfs_launch (g) == -1) exit (EXIT_FAILURE); /* Ask libguestfs to inspect for operating systems. */ roots = guestfs_inspect_os (g); if (roots == NULL) exit (EXIT_FAILURE); if (roots[0] == NULL) { fprintf (stderr, "checkvm: no operating systems found\n"); exit (EXIT_FAILURE); } printf ("start check\n"); guestfs_mount (g, "/dev/sda1", "/"); int chkrt; chkrt=guestfs_checksums_out (g, "sha1", "/boot", "chkvm.log"); printf ("\nend check\n"); guestfs_umount (g, "/"); if (!chkrt) exit (EXIT_FAILURE); /* Unmount everything. */ if (guestfs_umount_all (g) == -1) exit (EXIT_FAILURE); free (roots); guestfs_close (g); exit (EXIT_SUCCESS); } Thank you. .... Wahid On Mon, Mar 4, 2013 at 6:27 PM, Richard W.M. Jones <rjones@redhat.com>wrote:
On Mon, Mar 04, 2013 at 05:50:27PM +0100, Khan Ferdous Wahid wrote:
Hi, I tried to run the guestfs-examples from http://libguestfs.org/guestfs-examples.3.html, but they gave the following warnings and errors- #warning: Unable to get device geometry for /var/tmp/guestfs.JVxEUn/root
You can just ignore this. However:
#libguestfs: error: guestfs_launch failed, see earlier error messages
you need to run 'libguestfs-test-tool' and post the complete, unedited output. However:
What I did from the beginning- I boot my debian linux (2.6.32-5-686) inside VirtualBox and then install following packages there- #apt-get install qemu libguestfs-dev libguestfs-tools
Your problem is that this kernel is too old. You have to use at least 2.6.36.
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
On Tue, Mar 05, 2013 at 05:04:05PM +0100, Khan Ferdous Wahid wrote:
I have upgraded my kernel as you mentioned and everything is fine now. I wrote the following code to check the integrity of /boot directory in guest image. Now my question is- how could I check the integrity of files that are modified in last 10 minutes inside /boot directory? I use boot directory as an example directory.
AIUI you want to display the checksums of files in /boot which have been modified within the last 10 minutes? Recursively or just to /boot directory without subdirectories? The easiest way is: virt-ls -lR -a disk --checksum --time-relative /boot | awk '$6 <= 10*60' If you want to do that in C instead of using virt-ls, then take a look at the source of virt-ls -- it is written in C. A good place to start would be here: https://github.com/libguestfs/libguestfs/blob/master/cat/virt-ls.c#L443 especially the functions 'visit', 'show_file' and 'do_ls_lR'. I would caution you that the 'visit' function shown above would have trouble with very large directories *if* using libguestfs < 1.20. These bugs were fixed in libguestfs 1.20 and above. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Hi, Sorry for the late reply. Yes, I want to display the checksums of files in /boot which have been modified within the last 10 minutes, and I want to do that in C. Thank you very much for pointing me to the right direction, and thank you for always be so helpful. Best regards, Wahid On Tue, Mar 5, 2013 at 6:25 PM, Richard W.M. Jones <rjones@redhat.com>wrote:
On Tue, Mar 05, 2013 at 05:04:05PM +0100, Khan Ferdous Wahid wrote:
I have upgraded my kernel as you mentioned and everything is fine now. I wrote the following code to check the integrity of /boot directory in guest image. Now my question is- how could I check the integrity of files that are modified in last 10 minutes inside /boot directory? I use boot directory as an example directory.
AIUI you want to display the checksums of files in /boot which have been modified within the last 10 minutes? Recursively or just to /boot directory without subdirectories?
The easiest way is:
virt-ls -lR -a disk --checksum --time-relative /boot | awk '$6 <= 10*60'
If you want to do that in C instead of using virt-ls, then take a look at the source of virt-ls -- it is written in C. A good place to start would be here:
https://github.com/libguestfs/libguestfs/blob/master/cat/virt-ls.c#L443
especially the functions 'visit', 'show_file' and 'do_ls_lR'.
I would caution you that the 'visit' function shown above would have trouble with very large directories *if* using libguestfs < 1.20. These bugs were fixed in libguestfs 1.20 and above.
Rich.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
participants (2)
-
Khan Ferdous Wahid -
Richard W.M. Jones