From: Richard W.M. Jones Date: Mon, 21 Nov 2011 11:45:54 +0000 (+0000) Subject: contrib: Update introduction to libguestfs. X-Git-Tag: 1.15.5~2 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=7828f4dfe3d5ff4d086261218908c8da37bb9d97 contrib: Update introduction to libguestfs. --- diff --git a/contrib/intro/libguestfs-intro.html b/contrib/intro/libguestfs-intro.html index 67bdf9b..fe1e833 100644 --- a/contrib/intro/libguestfs-intro.html +++ b/contrib/intro/libguestfs-intro.html @@ -179,16 +179,28 @@ get_blkid_tag (const char *device, const char *tag) - + + -
+
-guestfish -N fs -m /dev/sda1 <<EOF
-  mkdir /etc
-  upload /etc/resolv.conf /etc/resolv.conf
-  write /etc/hostname "test01.redhat.com"
+guestfish -N bootrootlv:/dev/VG/LV:ext4:ext4:10G:256M <<EOF
+  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
 EOF
+guestmount -a test1.img -i mnt/
+ls mnt
+bin   dev  home        lib         mnt       proc  sbin  tmp  var
+boot  etc  initrd.img  lost+found  old-root  root  sys   usr  vmlinuz
+cat mnt/etc/HOSTNAME
+test01.example.com
+fusermount -u mnt
 
-

manual ...

-
+

manual for guestfish ...
+manual for guestmount ...

+
 virt-df -a /dev/vg/F15x32 -h
 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%
 

manual ...

+
+
+virt-cat -c qemu:///system -d WinXP 'c:\boot.ini'
+[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
+
+

manual ...

+
 virt-edit -c qemu:///system -d F15x32 /etc/passwd
-(launches editor)
+(launches text editor to edit guest /etc/passwd)
+
+virt-edit -c qemu:///system -d F15x32 /etc/passwd \
+  -e 's/^root:.*?:/root::/'
 

manual ...

-
+
 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%
     

Inspection

-$ virt-inspector -c qemu:///system -d Win7x32
+$ virt-filesystems -c qemu:///system -d Win7x32 --all --long -h --uuid
+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  -        -
+
+

+manual ... +

+
+$ virt-inspector -c qemu:///system -d Win7x32
 <?xml version="1.0"?>
 <operatingsystems>
   <operatingsystem>
@@ -235,18 +275,10 @@ $ virt-inspector -c qemu:///system -d Win7x32
     <hostname>win7x32</hostname>
 ... etc ...
 
-

full XML ...

- - - - -
- Click to enlarge the images -
- - - -
+

+full XML ...
+manual ... +

   char **roots;
@@ -290,15 +322,47 @@ $ virt-inspector -c qemu:///system -d Win7x32
 

full source ...

+ + + +
+ Click to enlarge the images +
+ + + +
+ + + + +

Graphical browsers

+ +

+ +

+

+ +

+

+ +

-

V2V & P2V

+

+ +

+

source ...

+

+ +

+

source ...

-

Read more ...

+

Find out more ...

libguestfs.org is the @@ -318,6 +382,11 @@ $ virt-inspector -c qemu:///system -d Win7x32 local man command.

+

+ For information about virt-v2v and virt-p2v, see + http://libguestfs.org/virt-v2v/ +

+

diff --git a/contrib/intro/talk.txt b/contrib/intro/talk.txt index d28bcc4..6fda60b 100644 --- a/contrib/intro/talk.txt +++ b/contrib/intro/talk.txt @@ -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. +