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(a)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