[Libguestfs] Script to read systemd journal of a guest to find its IP address
Kashyap Chamarthy
kchamart at redhat.com
Sat Jun 14 10:13:09 UTC 2014
On Sat, Jun 14, 2014 at 10:37:12AM +0100, Richard W.M. Jones wrote:
> 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).
Ah. I did use 'readonly=1' while testing, but forgot to mention it while
writing this. Thanks for catching.
> > 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.
Noted.
Thanks for these useful review comments, I'll test with these changes.
--
/kashyap
More information about the Libguestfs
mailing list