From 4ac261b3ee3fbc72614623b4ef630a55393b462f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 1 Nov 2011 14:07:59 +0000 Subject: [PATCH] contrib: Add libguestfs talk. This is a short (10-15 min) talk that I give to introduce the main features of libguestfs. The "slides" are in the form of a complete self-contained HTML page with a handful images that can be easily distributed before the talk. --- contrib/README | 6 + contrib/intro/libguestfs-intro.html | 253 +++++++++++++ contrib/intro/overview.svg | 524 ++++++++++++++++++++++++++ contrib/intro/talk.txt | 7 + contrib/intro/tools.svg | 711 ++++++++++++++++++++++++++++++++++++ 5 files changed, 1501 insertions(+) create mode 100644 contrib/intro/libguestfs-intro.html create mode 100644 contrib/intro/overview.svg create mode 100644 contrib/intro/talk.txt create mode 100644 contrib/intro/tools.svg diff --git a/contrib/README b/contrib/README index ce695ec..a708d90 100644 --- a/contrib/README +++ b/contrib/README @@ -28,6 +28,12 @@ guestfsd-in-wine.sh Run a Windows-compiled guestfsd under Wine. Read the instructions at the top of this file carefully. +intro/ "Slides" for an intro to libguestfs. This is a short (10-15 + min) talk that I give to introduce the main features of + libguestfs. The slides are in the form of a complete + self-contained HTML page with a handful images that can be + easily distributed before the talk. + visualize-alignment/ Tests for visualizing block device reads and writes and alignment using a patched qemu. See the README file in that diff --git a/contrib/intro/libguestfs-intro.html b/contrib/intro/libguestfs-intro.html new file mode 100644 index 0000000..cfc7b8b --- /dev/null +++ b/contrib/intro/libguestfs-intro.html @@ -0,0 +1,253 @@ + + + + Short introduction to libguestfs + + + +

Short introduction to libguestfs

+ by Richard W.M. Jones <rjones@redhat.com> + +

The Idea

+ +

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

+ + + +

The Stable API

+ +
+  /* get the Linux VFS type corresponding to a mounted device */
+extern char *guestfs_vfs_type (guestfs_h *g, const char *device);
+
+ + + + +
Example using this API: +
+#include <guestfs.h>
+
+char *fstype = guestfs_vfs_type (g, "/dev/vda1");
+printf ("%s\n", fstype);
+free (fstype);
+→ ntfs
+
+

click to see a real example ...

+
+ + + + + +
+ +
+  ("vfs_type",
+   (RString "fstype",
+        [Device "device"], []),
+   198, [],
+   [ (* tests *) ],
+   "get the Linux VFS type corresponding to a mounted device",
+   "\
+This command gets the filesystem type corresponding to
+the filesystem on C<device>.
+
+For most filesystems, the result is the name of the Linux
+VFS module which would be used to mount this filesystem
+if you mounted it without specifying the filesystem type.
+For example a string such as C<ext3> or C<ntfs>.");
+
+

full source ...

+ +
+ +
+char *
+do_vfs_type (const char *device)
+{
+  return get_blkid_tag (device, "TYPE");
+}
+
+static char *
+get_blkid_tag (const char *device, const char *tag)
+{
+  char *out, *err;
+  int r;
+
+  r = commandr (&out, &err,
+                "blkid",
+                "-c", "/dev/null",
+                "-o", "value", "-s", tag, device, NULL);
+  if (r != 0 && r != 2) {
+    if (r >= 0)
+      reply_with_error ("%s: %s (blkid returned %d)",
+                        device, err, r);
+    else
+      reply_with_error ("%s: %s", device, err);
+    free (out);
+    free (err);
+    return NULL;
+  }
+
+  /* ... */
+
+  return out;             /* caller frees */
+}
+
+

full source ...

+ +
+ +

+ Just these two fragments generate: +

+ + + +

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"
+EOF
+
+

manual ...

+
+
+virt-df -a /dev/vg/F15x32 -h
+Filesystem                    Size  Used Available Use%
+F15x32:/dev/sda1              484M   31M      428M   7%
+F15x32:/dev/vg_f15x32/lv_root 5.5G  3.4G      1.8G  63%
+
+

manual ...

+
+
+virt-edit -c qemu:///system -d F15x32 /etc/passwd
+(launches editor)
+
+

manual ...

+
+
+virt-win-reg -c qemu:///system --unsafe-printable-strings \
+  Win7x32 'HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters' \
+  | grep DhcpIPAddress
+"DhcpIPAddress"=str(1):"192.168.122.178"
+
+

manual ...

+
+ +

Inspection

+ + + + +

V2V & P2V

+ + + + +

Read more ...

+ +

+ libguestfs.org is the + main website. +

+ +

+ guestfs(3) + is the manual page documenting the C API and the internals. +

+ +

+ There are manual pages + documenting guestfish, guestmount + and each virt tool. See + the main website or your + local man command. +

+ +
+ +

+ This page © 2011 Red Hat Inc. and distributed + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. +

+ + + diff --git a/contrib/intro/overview.svg b/contrib/intro/overview.svg new file mode 100644 index 0000000..25f245a --- /dev/null +++ b/contrib/intro/overview.svg @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + libguestfs + + Linux kernel + + + mkfs + + + + lvcreate + + + + parted + + + + + + + + + + + + + + + + + virt tools,scripts,yourprograms + + + + + stable API + + + qemu + raw + qcow2 + vmdk + ext4 + btrfs + + diff --git a/contrib/intro/talk.txt b/contrib/intro/talk.txt new file mode 100644 index 0000000..a8632f6 --- /dev/null +++ b/contrib/intro/talk.txt @@ -0,0 +1,7 @@ +This is a short (10-15 min) talk that I give to introduce the main +features of libguestfs. The "slides" are in the form of a complete +self-contained HTML page with a handful images that can be easily +distributed before the talk. + +---------------------------------------------------------------------- + diff --git a/contrib/intro/tools.svg b/contrib/intro/tools.svg new file mode 100644 index 0000000..fe1f034 --- /dev/null +++ b/contrib/intro/tools.svg @@ -0,0 +1,711 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + libguestfs + + + mkfs + + + + lvcreate + + + + parted + + + + qemu + raw + qcow2 + vmdk + + + + Linux kernel + ext4 + btrfs + + + + + virt-resize + + + + guestmount + + + + guestfish + + + + virt-rescue + + + + virt-sparsify + + + + virt-alignment-scan + + + + virt-inspector + + + + virt-filesystems + + + + virt-df + + + + virt-win-reg + + FUSE / POSIX + shell scripts + align & resize + inspection + Windowsguests + + -- 1.8.3.1