[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] Script to read systemd journal of a guest to find its IP address



On Sat, Jun 14, 2014 at 11:41:03AM +0530, Kashyap Chamarthy wrote:
> g.add_drive (image, format='qcow2')

You must use:

  g.add_drive (image, readonly=1)

otherwise you risk disk corruption if the guest is live (eg. if the
mount command has to replay the journal).

> g.launch ()
> #print g.list_partitions()
> 
> # Set trace
> #g.set_trace (1)
> 
> g.mount_options ("ro", root_filesystem, "/")

What I'd do differently here is to use inspection to detect the root
(and other) filesystems.  You never know if /var is on a separate
partition ...

Here is the example code (see call to "g.inspect_os" and the code with
the comment "Mount up the disks like guestfish -i").

http://libguestfs.org/guestfs-python.3.html#example-2:-inspect-a-virtual-machine-disk-image

> g.sync ()

No need to sync if you've added the drive readonly.

Thanks,

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]