mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
contrib: Update introduction to libguestfs.
This commit is contained in:
@@ -179,16 +179,28 @@ get_blkid_tag (const char *device, const char *tag)
|
||||
</object>
|
||||
|
||||
<table>
|
||||
<tr><td valign="top" style="padding-bottom: 1.5em;">
|
||||
<tr><td valign="top" style="padding-bottom: 1.5em;" colspan="2">
|
||||
<pre>
|
||||
<b>guestfish -N fs -m /dev/sda1 <<EOF</b>
|
||||
<font style="color: green;">mkdir /etc
|
||||
upload /etc/resolv.conf /etc/resolv.conf
|
||||
write /etc/hostname "test01.redhat.com"</font>
|
||||
<b>guestfish -N bootrootlv:/dev/VG/LV:ext4:ext4:10G:256M <<EOF</b>
|
||||
<font style="color: green;">mount-options "" /dev/VG/LV /
|
||||
mkdir /boot
|
||||
mount-options "" /dev/sda1 /boot
|
||||
txz-in filesystem.tar.xz /
|
||||
write /etc/HOSTNAME "test01.example.com\n"
|
||||
upload /etc/resolv.conf /etc/resolv.conf</font>
|
||||
<b>EOF</b>
|
||||
<b>guestmount -a test1.img -i mnt/</b>
|
||||
<b>ls mnt</b>
|
||||
bin dev home lib mnt proc sbin tmp var
|
||||
boot etc initrd.img lost+found old-root root sys usr vmlinuz
|
||||
<b>cat mnt/etc/HOSTNAME</b>
|
||||
test01.example.com
|
||||
<b>fusermount -u mnt</b>
|
||||
</pre>
|
||||
<p class="sourcelnk"><a href="http://libguestfs.org/guestfish.1.html">manual ...</a></p>
|
||||
</td><td valign="top">
|
||||
<p class="sourcelnk"><a href="http://libguestfs.org/guestfish.1.html">manual for guestfish ...</a> <br/>
|
||||
<a href="http://libguestfs.org/guestmount.1.html">manual for guestmount ...</a></p>
|
||||
</td></tr>
|
||||
<tr><td valign="top" style="padding-bottom: 1.5em;">
|
||||
<pre>
|
||||
<b>virt-df -a /dev/vg/F15x32 -h</b>
|
||||
Filesystem Size Used Available Use%
|
||||
@@ -196,14 +208,30 @@ F15x32:/dev/sda1 484M 31M 428M 7%
|
||||
F15x32:/dev/vg_f15x32/lv_root 5.5G 3.4G 1.8G 63%
|
||||
</pre>
|
||||
<p class="sourcelnk"><a href="http://libguestfs.org/virt-df.1.html">manual ...</a></p>
|
||||
</td>
|
||||
<td valign="top" style="padding-bottom: 1.5em;">
|
||||
<pre>
|
||||
<b>virt-cat -c qemu:///system -d WinXP 'c:\boot.ini'</b>
|
||||
[boot loader]
|
||||
timeout=30
|
||||
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
|
||||
[operating systems]
|
||||
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS=
|
||||
"Microsoft Windows XP Professional" /noexecute=optin
|
||||
/fastdetect
|
||||
</pre>
|
||||
<p class="sourcelnk"><a href="http://libguestfs.org/virt-cat.1.html">manual ...</a></p>
|
||||
</td></tr>
|
||||
<tr><td valign="top">
|
||||
<tr><td valign="top" style="padding-bottom: 1.5em;">
|
||||
<pre>
|
||||
<b>virt-edit -c qemu:///system -d F15x32 /etc/passwd</b>
|
||||
<i>(launches editor)</i>
|
||||
<i>(launches text editor to edit guest /etc/passwd)</i>
|
||||
|
||||
<b>virt-edit -c qemu:///system -d F15x32 /etc/passwd \
|
||||
-e 's/^root:.*?:/root::/'</b>
|
||||
</pre>
|
||||
<p class="sourcelnk"><a href="http://libguestfs.org/virt-edit.1.html">manual ...</a></p>
|
||||
</td><td valign="top">
|
||||
</td><td valign="top" style="padding-bottom: 1.5em;">
|
||||
<pre>
|
||||
<b>virt-win-reg -c qemu:///system --unsafe-printable-strings \
|
||||
Win7x32 'HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters' \
|
||||
@@ -217,8 +245,20 @@ F15x32:/dev/vg_f15x32/lv_root 5.5G 3.4G 1.8G 63%
|
||||
<h2>Inspection</h2>
|
||||
|
||||
<pre>
|
||||
$ <b>virt-inspector -c qemu:///system -d Win7x32</b>
|
||||
$ <b>virt-filesystems -c qemu:///system -d Win7x32 --all --long -h --uuid</b>
|
||||
Name Type VFS Label MBR Size Parent UUID
|
||||
/dev/sda1 filesystem ntfs System Reserved - 100M - F81C92571C92112C
|
||||
/dev/sda2 filesystem ntfs - - 20G - F2E8996AE8992E3B
|
||||
/dev/sda1 partition - - 07 100M /dev/sda -
|
||||
/dev/sda2 partition - - 07 20G /dev/sda -
|
||||
/dev/sda device - - - 20G - -
|
||||
</pre>
|
||||
<p class="sourcelnk">
|
||||
<a href="http://libguestfs.org/virt-filesystems.1.html">manual ...</a>
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
$ <b>virt-inspector -c qemu:///system -d Win7x32</b>
|
||||
<font style="color: #888;"><?xml version="1.0"?></font>
|
||||
<font style="color: #888;"><operatingsystems></font>
|
||||
<font style="color: #888;"><operatingsystem></font>
|
||||
@@ -235,18 +275,10 @@ $ <b>virt-inspector -c qemu:///system -d Win7x32</b>
|
||||
<font style="color: #888;"><hostname></font>win7x32<font style="color: #888;"></hostname></font>
|
||||
<i>... etc ...</i>
|
||||
</pre>
|
||||
<p class="sourcelnk"><a href="win7.xml">full XML ...</a></p>
|
||||
|
||||
<table>
|
||||
<tr><td colspan="2" align="middle">
|
||||
<small><i>Click to enlarge the images</i></small>
|
||||
</td></tr>
|
||||
<tr><td width="50%">
|
||||
<a href="virt-manager.png"><img src="virt-manager-t.png"></a>
|
||||
</td><td width="50%" align="middle" valign="top">
|
||||
<a href="vmm-icons.png"><img src="vmm-icons-t.png"></a>
|
||||
</td></tr>
|
||||
</table>
|
||||
<p class="sourcelnk">
|
||||
<a href="win7.xml">full XML ...</a> <br/>
|
||||
<a href="http://libguestfs.org/virt-inspector.1.html">manual ...</a>
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
char **roots;
|
||||
@@ -290,15 +322,47 @@ $ <b>virt-inspector -c qemu:///system -d Win7x32</b>
|
||||
</pre>
|
||||
<p class="sourcelnk"><a href="http://git.annexia.org/?p=libguestfs.git;a=blob;f=rescue/virt-rescue.c;h=0c0036460434f1365d9591d6b2b805d999b07056;hb=HEAD#l351">full source ...</a></p>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>V2V & P2V</h2>
|
||||
<table>
|
||||
<tr><td colspan="2" align="middle">
|
||||
<small><i>Click to enlarge the images</i></small>
|
||||
</td></tr>
|
||||
<tr><td width="50%">
|
||||
<a href="virt-manager.png"><img src="virt-manager-t.png"></a>
|
||||
</td><td width="50%" align="middle" valign="top">
|
||||
<a href="vmm-icons.png"><img src="vmm-icons-t.png"></a>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Read more ...</h2>
|
||||
<h2>Graphical browsers</h2>
|
||||
|
||||
<p>
|
||||
<img src="https://rwmj.files.wordpress.com/2011/07/guestfs-browser1.png?w=438&h=450"/>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img src="https://rwmj.files.wordpress.com/2011/07/guestfs-browser2.png?w=438&h=450"/>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img src="https://rwmj.files.wordpress.com/2011/07/guestfs-browser3.png?w=366&h=450"/>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img src="https://rwmj.files.wordpress.com/2011/07/guestfs-browser4.png?w=366&h=450"/>
|
||||
</p>
|
||||
<p class="sourcelnk"><a href="https://rwmj.wordpress.com/2011/07/29/some-screenshots-from-the-new-guest-filesystem-browser/">source ...</a></p>
|
||||
|
||||
<p>
|
||||
<img src="https://rwmj.files.wordpress.com/2009/11/file-browser.png?w=500"/>
|
||||
</p>
|
||||
<p class="sourcelnk"><a href="https://rwmj.wordpress.com/2009/11/03/browsing-guests-using-fuse/">source ...</a></p>
|
||||
|
||||
|
||||
|
||||
<h2>Find out more ...</h2>
|
||||
|
||||
<p>
|
||||
<a href="http://libguestfs.org/">libguestfs.org</a> is the
|
||||
@@ -318,6 +382,11 @@ $ <b>virt-inspector -c qemu:///system -d Win7x32</b>
|
||||
local man command.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
For information about virt-v2v and virt-p2v, see
|
||||
<a href="http://libguestfs.org/virt-v2v/">http://libguestfs.org/virt-v2v/</a>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
|
||||
<p style="font-size: 70%;">
|
||||
|
||||
@@ -45,7 +45,7 @@ This is something that is possible using the libguestfs
|
||||
API, but we don't encourage it. There are three reasons
|
||||
why we don't encourage and support this: one is that
|
||||
because we're calling this from a C program, it's hard
|
||||
to construct shell commands and deal with quoting issues.
|
||||
to construct shell commands.
|
||||
Secondly it's hard to parse the result from commands
|
||||
(think about parted or lvs which are two commands that
|
||||
produce quite complex output that is hard to parse).
|
||||
@@ -100,8 +100,8 @@ are many more than are shown here.
|
||||
Starting at the top, "guestfish" is a shell for the API,
|
||||
letting you write simple shell scripts. If you look at
|
||||
the code examples below, you can see a small guestfish
|
||||
script that creates a new raw format partitioned filesystem
|
||||
with some content.
|
||||
script that creates a complete guest. Then we mount it on
|
||||
the host using guestmount (FUSE) and browse around.
|
||||
|
||||
Going round clockwise:
|
||||
|
||||
@@ -116,7 +116,6 @@ programs like the GNOME Nautilus file browser.
|
||||
|
||||
"virt-rescue" lets you use the appliance directly, and
|
||||
it's a useful way to rescue guests by hand.
|
||||
You just want to hammer out some shell commands manually.
|
||||
|
||||
"virt-win-reg" lets you read and write Windows Registry
|
||||
entries. There is a rather complex example below right.
|
||||
@@ -135,3 +134,29 @@ obsolete.
|
||||
|
||||
[4 Inspection]
|
||||
|
||||
Next I want to look at another aspect of the API which is
|
||||
called "inspection".
|
||||
|
||||
Inspection means taking arbitrary disk images and finding
|
||||
out what they contain, from just what partitions and filesystems
|
||||
are in a disk image, to whether and what operating system(s)
|
||||
it contains, to what applications are installed.
|
||||
|
||||
The two main command-line tools are virt-filesystems and
|
||||
virt-inspector, and you can see the output from these tools.
|
||||
However this information is also available through the
|
||||
API. The example there shows getting operating system
|
||||
inspection data from a C program. Programs can also get
|
||||
inspection information, as you can see in the screenshots
|
||||
from the latest virt-manager.
|
||||
|
||||
[5 Graphical browsers]
|
||||
|
||||
I've concentrated a lot on command line tools, but you can
|
||||
also use libguestfs from graphical programs. I wrote an
|
||||
experimental program called guestfs-browser, and there are
|
||||
screenshots shown. But many people will simply want to mount
|
||||
a filesystem on the host using guestmount, and then use
|
||||
ordinary tools. At the bottom is a screenshot of GNOME
|
||||
Nautilus browsing into a guest filesystem.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user