X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=contrib%2Fintro%2Flibguestfs-intro.html;h=fe1e833b7d2b43a52cda3e98e4c2358bc9c8f9bf;hb=f499d7d42567349a7e45170df95de97f38db5b52;hp=cfc7b8b6533d4ca80c6f4032b5247f3d33fe4c8a;hpb=4ac261b3ee3fbc72614623b4ef630a55393b462f;p=libguestfs.git diff --git a/contrib/intro/libguestfs-intro.html b/contrib/intro/libguestfs-intro.html index cfc7b8b..fe1e833 100644 --- a/contrib/intro/libguestfs-intro.html +++ b/contrib/intro/libguestfs-intro.html @@ -1,4 +1,5 @@ - + + Short introduction to libguestfs @@ -7,7 +8,7 @@ counter-reset: chapter; } - body p { + body > p, body > img, body > pre, body > table { margin-left: 2em; } @@ -26,8 +27,7 @@ } h2 { - background-color: #f3f3f3; - margin-top: 2em; + margin-top: 4em; color: rgb(204,0,0); counter-increment: chapter; counter-reset: section; @@ -35,20 +35,20 @@ h2:before { font-size: 80%; color: #666; - content: counter(chapter) " — "; + content: counter(chapter) " ... "; } pre { background-color: #fcfcfc; - border-top: 1px dotted #888; - border-bottom: 1px dotted #888; - border-left: 6px solid rgb(204,0,0); + border-top: 1px dotted #eee; + border-bottom: 1px dotted #eee; + border-left: 2px solid rgb(204,0,0); padding: 5px; margin-left: 1em; } p.sourcelnk { - text-align: right; + text-align: left; font-size: 70%; } @@ -62,7 +62,9 @@

Reuse qemu, Linux kernel and userspace tools to read and write disk images.

- + + +

The Stable API

@@ -89,7 +91,7 @@ free (fstype);
-
+
   ("vfs_type",
    (RString "fstype",
         [Device "device"], []),
@@ -110,7 +112,7 @@ For example a string such as C<ext3> or C<ntfs>.");
         
-
+
 char *
 do_vfs_type (const char *device)
 {
@@ -172,19 +174,33 @@ get_blkid_tag (const char *device, const char *tag)
 
     

Tools written around the API

- + + + - + + -
+
-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%
@@ -192,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' \
@@ -212,15 +244,125 @@ F15x32:/dev/vg_f15x32/lv_root 5.5G  3.4G      1.8G  63%
 
     

Inspection

+
+$ 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>
+    <root>/dev/sda2</root>
+    <name>windows</name>
+    <arch>i386</arch>
+    <distro>windows</distro>
+    <product_name>Windows 7 Enterprise</product_name>
+    <product_variant>Client</product_variant>
+    <major_version>6</major_version>
+    <minor_version>1</minor_version>
+    <windows_systemroot>/Windows</windows_systemroot>
+    <windows_current_control_set>ControlSet001</windows_current_control_set>
+    <hostname>win7x32</hostname>
+... etc ...
+
+

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

+ +
+  char **roots;
+  size_t i;
+  char *type, *distro, *product_name;
+  int major, minor;
+
+  roots = guestfs_inspect_os (g);
+
+  if (roots == NULL)
+    exit (EXIT_FAILURE);
+
+  if (roots[0] == NULL) {
+    fprintf (stderr, "no operating systems found\n");
+    exit (EXIT_FAILURE);
+  }
+
+  for (i = 0; roots[i] != NULL; ++i) {
+    type = guestfs_inspect_get_type (g, roots[i]);
+    distro = guestfs_inspect_get_distro (g, roots[i]);
+    product_name = guestfs_inspect_get_product_name (g, roots[i]);
+    major = guestfs_inspect_get_major_version (g, roots[i]);
+    minor = guestfs_inspect_get_minor_version (g, roots[i]);
+
+    printf ("Root: %s\n"
+            "  Type: %s\n"
+            "  Distro: %s\n"
+            "  Version: %d.%d\n"
+            "  Product name: %s\n\n");
+            roots[i],
+            type ? : "unknown", distro ? : "unknown", major, minor,
+            product_name ? : "");
+
+    free (type);
+    free (distro);
+    free (product_name);
+    free (roots[i]);
+  }
+
+  free (roots);
+
+

full source ...

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

Graphical browsers

+ +

+ +

+

+ +

+

+ +

-

V2V & P2V

+

+ +

+

source ...

+

+ +

+

source ...

-

Read more ...

+

Find out more ...

libguestfs.org is the @@ -240,6 +382,11 @@ F15x32:/dev/vg_f15x32/lv_root 5.5G 3.4G 1.8G 63% local man command.

+

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

+