From 0cd762708e3d665bf982dc36ce8661eb982bf939 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 2 Oct 2012 08:50:55 +0100 Subject: [PATCH] Dublin talk. --- 2012-dublin/.gitignore | 5 + 2012-dublin/0000-introduction.html | 13 ++ 2012-dublin/0100-create.html | 37 ++++ 2012-dublin/0200-inspect.html | 30 +++ 2012-dublin/0300-modify.html | 23 +++ 2012-dublin/0400-shutdown.html | 20 ++ 2012-dublin/0500-mount-local.html | 31 ++++ 2012-dublin/0600-demo.d/.dir | 0 2012-dublin/0600-demo.term | 13 ++ 2012-dublin/0700-resizing.html | 13 ++ 2012-dublin/0800-svirt.html | 21 +++ 2012-dublin/0900-sparse.d/.dir | 0 2012-dublin/0900-sparse.term | 11 ++ 2012-dublin/1000-auditing.html | 13 ++ 2012-dublin/1100-summary.html | 25 +++ 2012-dublin/README | 8 + 2012-dublin/bashrc | 14 ++ 2012-dublin/code.js | 0 2012-dublin/fish.svg | 366 +++++++++++++++++++++++++++++++++++++ 2012-dublin/functions | 41 +++++ 2012-dublin/notes.txt | 45 +++++ 2012-dublin/run | 16 ++ 2012-dublin/style.css | 106 +++++++++++ 23 files changed, 851 insertions(+) create mode 100644 2012-dublin/.gitignore create mode 100644 2012-dublin/0000-introduction.html create mode 100644 2012-dublin/0100-create.html create mode 100644 2012-dublin/0200-inspect.html create mode 100644 2012-dublin/0300-modify.html create mode 100644 2012-dublin/0400-shutdown.html create mode 100644 2012-dublin/0500-mount-local.html create mode 100644 2012-dublin/0600-demo.d/.dir create mode 100755 2012-dublin/0600-demo.term create mode 100644 2012-dublin/0700-resizing.html create mode 100644 2012-dublin/0800-svirt.html create mode 100644 2012-dublin/0900-sparse.d/.dir create mode 100755 2012-dublin/0900-sparse.term create mode 100644 2012-dublin/1000-auditing.html create mode 100644 2012-dublin/1100-summary.html create mode 100644 2012-dublin/README create mode 100644 2012-dublin/bashrc create mode 100644 2012-dublin/code.js create mode 100644 2012-dublin/fish.svg create mode 100644 2012-dublin/functions create mode 100644 2012-dublin/notes.txt create mode 100755 2012-dublin/run create mode 100644 2012-dublin/style.css diff --git a/2012-dublin/.gitignore b/2012-dublin/.gitignore new file mode 100644 index 0000000..f36f5e2 --- /dev/null +++ b/2012-dublin/.gitignore @@ -0,0 +1,5 @@ +0600-demo.d/f16x32.img +0900-sparse.d/f16x32.img +0900-sparse.d/f16x32.img.xz +bindings +history diff --git a/2012-dublin/0000-introduction.html b/2012-dublin/0000-introduction.html new file mode 100644 index 0000000..f9ecd30 --- /dev/null +++ b/2012-dublin/0000-introduction.html @@ -0,0 +1,13 @@ + + + +
+

+ libguestfs

+ tools for viewing and modifying
virtual machine disk images +

+

+Richard W.M. Jones
Red Hat
+rjones @ redhat.com +

+
diff --git a/2012-dublin/0100-create.html b/2012-dublin/0100-create.html new file mode 100644 index 0000000..5012b7e --- /dev/null +++ b/2012-dublin/0100-create.html @@ -0,0 +1,37 @@ + + + + +
+

Using libguestfs from Python*

+ +

+Create handle — +Inspect — +Modify — +Shutdown

+ +
+import guestfs
+
+input = "f16x32.img"
+
+g = guestfs.GuestFS ()
+
+g.add_drive_opts (input,
+                  format = "raw",
+                  readonly = 0)
+
+g.launch ()
+
+ +

+* + +For more examples: +http://libguestfs.org/guestfs-python.3.html
+or man guestfs-python +
+

+ +
diff --git a/2012-dublin/0200-inspect.html b/2012-dublin/0200-inspect.html new file mode 100644 index 0000000..90072b1 --- /dev/null +++ b/2012-dublin/0200-inspect.html @@ -0,0 +1,30 @@ + + + + +
+

Using libguestfs from Python

+ +

+Create handle — +Inspect — +Modify — +Shutdown

+ +
+roots = g.inspect_os ()
+if len (roots) == 0:
+    raise (Error ("no operating systems found"))
+if len (roots) > 1:
+    raise (Error ("multi-boot operating system"))
+root = roots[0]
+
+type = g.inspect_get_type (root)
+distro = g.inspect_get_distro (root)
+major = g.inspect_get_major_version (root)
+minor = g.inspect_get_minor_version (root)
+
+mps = g.inspect_get_mountpoints (root)
+
+ +
diff --git a/2012-dublin/0300-modify.html b/2012-dublin/0300-modify.html new file mode 100644 index 0000000..c3aa1d0 --- /dev/null +++ b/2012-dublin/0300-modify.html @@ -0,0 +1,23 @@ + + + + +
+

Using libguestfs from Python

+ +

+Create handle — +Inspect — +Modify — +Shutdown

+ +
+if type == "linux" and distro == "fedora":
+    g.mkdir_p ("/etc/profile.d")
+    g.write ("/etc/profile.d/proxy.sh",
+             "http_proxy=http://cache:3128/")
+else
+    # etc
+
+ +
diff --git a/2012-dublin/0400-shutdown.html b/2012-dublin/0400-shutdown.html new file mode 100644 index 0000000..29f8fce --- /dev/null +++ b/2012-dublin/0400-shutdown.html @@ -0,0 +1,20 @@ + + + + +
+

Using libguestfs from Python

+ +

+Create handle — +Inspect — +Modify — +Shutdown

+ +
+g.shutdown ()
+
+g.close ()
+
+ +
diff --git a/2012-dublin/0500-mount-local.html b/2012-dublin/0500-mount-local.html new file mode 100644 index 0000000..8365c84 --- /dev/null +++ b/2012-dublin/0500-mount-local.html @@ -0,0 +1,31 @@ + + + + +
+

Using libguestfs from Python

+ +

+Create handle — +Inspect — +Modify — +Shutdown

+ +
+os.mkdir ("/mountpoint")
+
+g.mount_local ("/mountpoint")
+
+os.fork ()  ──────────────────────┐
+                                  │
+g.mount_local_run ()              │
+                                  │
+                              run ┆
+                                a ┆
+                           script ┆ in
+                                  ┆ /mountpoint
+                                  ┆
+                               (umount)
+
+ +
diff --git a/2012-dublin/0600-demo.d/.dir b/2012-dublin/0600-demo.d/.dir new file mode 100644 index 0000000..e69de29 diff --git a/2012-dublin/0600-demo.term b/2012-dublin/0600-demo.term new file mode 100755 index 0000000..67da7c5 --- /dev/null +++ b/2012-dublin/0600-demo.term @@ -0,0 +1,13 @@ +#!/bin/bash - + +source functions + +# History. +remember 'ls -l -h' +remember 'file f16x32.img' +remember 'guestfish -a f16x32.img -i --rw' + +echo "Example: Examine a disk image" + +cd 0600-demo.d +terminal diff --git a/2012-dublin/0700-resizing.html b/2012-dublin/0700-resizing.html new file mode 100644 index 0000000..5c847ee --- /dev/null +++ b/2012-dublin/0700-resizing.html @@ -0,0 +1,13 @@ + + + + +
+

Resizing

+ + + +
diff --git a/2012-dublin/0800-svirt.html b/2012-dublin/0800-svirt.html new file mode 100644 index 0000000..329f336 --- /dev/null +++ b/2012-dublin/0800-svirt.html @@ -0,0 +1,21 @@ + + + + +
+

sVirt

+ +
+        ┌─────────────────────┐
+        │ ☠ evil disk image ☠ │
+        └─────────────────────┘
+      │    appliance kernel     │
+      └─────────────────────────┘
+    │             qemu            │
+    └─────────────────────────────┘
+  │          sVirt & SELinux        │
+  └─────────────────────────────────┘
+│              host kernel            │
+└─────────────────────────────────────┘
+
+
diff --git a/2012-dublin/0900-sparse.d/.dir b/2012-dublin/0900-sparse.d/.dir new file mode 100644 index 0000000..e69de29 diff --git a/2012-dublin/0900-sparse.term b/2012-dublin/0900-sparse.term new file mode 100755 index 0000000..dea1e86 --- /dev/null +++ b/2012-dublin/0900-sparse.term @@ -0,0 +1,11 @@ +#!/bin/bash - + +source functions + +# History. +remember 'ls -l -h' + +echo "Example: Sparsifying a disk image" + +cd 0900-sparse.d +terminal diff --git a/2012-dublin/1000-auditing.html b/2012-dublin/1000-auditing.html new file mode 100644 index 0000000..61c51b0 --- /dev/null +++ b/2012-dublin/1000-auditing.html @@ -0,0 +1,13 @@ + + + + +
+

Auditing, CVEs, licensing

+ + + +
diff --git a/2012-dublin/1100-summary.html b/2012-dublin/1100-summary.html new file mode 100644 index 0000000..60ba3cf --- /dev/null +++ b/2012-dublin/1100-summary.html @@ -0,0 +1,25 @@ + + + + +
+

Summary

+ + + + + +

+git.annexia.org → libguestfs-talks + +

diff --git a/2012-dublin/README b/2012-dublin/README new file mode 100644 index 0000000..ba6143b --- /dev/null +++ b/2012-dublin/README @@ -0,0 +1,8 @@ +This was a talk given in private to Red Hat's OpenStack team. + +It gives an overview of libguestfs for OpenStack / Python programmers, +discusses some of the places that libguestfs might be used within +OpenStack. + +The whole talk is designed to take around 10 minutes, with lots of +time at the end for open discussion. \ No newline at end of file diff --git a/2012-dublin/bashrc b/2012-dublin/bashrc new file mode 100644 index 0000000..e8fcde3 --- /dev/null +++ b/2012-dublin/bashrc @@ -0,0 +1,14 @@ +# -*- shell-script -*- + +# Fancy prompt colours (see +# https://wiki.archlinux.org/index.php/Color_Bash_Prompt) +promptcol='\e[0;32m' ;# colour for the prompt +commandcol='\e[1;31m' ;# colour for the typed command +outputcol='\e[0m' ;# colour for command output + +export PS1="\n\[$promptcol\]\$ \[$commandcol\]" + +trap 'echo -ne "$outputcol"' DEBUG + +# Load key bindings (if any). +bind -f $talkdir/bindings diff --git a/2012-dublin/code.js b/2012-dublin/code.js new file mode 100644 index 0000000..e69de29 diff --git a/2012-dublin/fish.svg b/2012-dublin/fish.svg new file mode 100644 index 0000000..7768be4 --- /dev/null +++ b/2012-dublin/fish.svg @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/2012-dublin/functions b/2012-dublin/functions new file mode 100644 index 0000000..1e2cd55 --- /dev/null +++ b/2012-dublin/functions @@ -0,0 +1,41 @@ +# -*- shell-script -*- +# This creates some standard functions. See also $talkdir/bashrc +# which runs in the same bash context as the terminal. + +# Place any local environment variables and settings in "local". +if [ -f local ]; then source local; fi + +# Environment variables. +export HISTFILE=$talkdir/history +export PATH=$talkdir:$PATH +export LIBVIRT_DEFAULT_URI=qemu:///system +export EDITOR="emacs -nw" + +# remember +# +# This function does two things: (1) It adds the command and arguments +# to the shell history, so that commands can be recalled using up +# arrow or reverse search. (2) It makes a function key recall the +# command. The first command is assigned to F2, the second to F3 and +# so forth. + +rm -f $HISTFILE +touch $HISTFILE +rm -f $talkdir/bindings +touch bindings + +fnum=2 +keys=(- OP OQ OR OS '[15~' '[17~' '[18~' '[19~' '[20~' '[21~') + +remember () +{ + echo "$@" >> $HISTFILE + echo \"\\e${keys[$fnum]}\":\"\\C-k \\C-u"$@"\" >> $talkdir/bindings + ((fnum++)) +} + +terminal () +{ + chmod -w $HISTFILE + /bin/bash --rcfile $talkdir/bashrc "$@" +} diff --git a/2012-dublin/notes.txt b/2012-dublin/notes.txt new file mode 100644 index 0000000..d937b52 --- /dev/null +++ b/2012-dublin/notes.txt @@ -0,0 +1,45 @@ +[ ---- 0: Intro slide ---- ] + +libguestfs is a C library for viewing and modifying disk images. It +lets you open up any disk image, and look at the files inside it. You +can also analyze disk images, inject files, or even create disk images +from scratch. + +In this talk I'm going to show you a concrete example of using the +library from Python. Then I'm going to talk about some of the latest +features of libguestfs and how they might be useful in OpenStack. + +[ ---- 1: Creating the handle, adding drives, launching. ---- ] + +*** Link to guestfs-python + +[ ---- 2: Inspect ---- ] + +[ ---- 3: Inject files ---- ] + +[ ---- 4: Shutdown the handle ---- ] + +[ ---- 5: Alternative: mount-local ----- ] + +OpenStack uses libguestfs for file injection currently. With +RHEL 6.4 + mount-local support, we can do that much better. + +[ ---- 6: Demo ---- ] + +[ ---- 7: OpenStack: Resizing, partition auditing ---- ] + + + +[ ---- 8: OpenStack: sVirt ---- ] + +Starting with RHEL 7, libguestfs will use sVirt to confine +the appliance. This gives us exceptional, unmatched security +against malicious disk images that random users upload. + +[ ---- 9: OpenStack: Sparsify, archiving ---- ] + +[ ---- 10: OpenStack: Auditing, CVEs, licensing ---- ] + +[ ---- 11: Summary ---- ] + +Any questions? diff --git a/2012-dublin/run b/2012-dublin/run new file mode 100755 index 0000000..c3e4d40 --- /dev/null +++ b/2012-dublin/run @@ -0,0 +1,16 @@ +#!/bin/bash - +# Run the talk. + +# Avoid GNOME keyring stupidity +export GNOME_KEYRING_CONTROL= +export GNOME_KEYRING_PID= + +# Clean up everything. +find -name '*~' -delete + +# Get everything into the cache. +guestfish -a /dev/null run > /dev/null 2>&1 +guestfish --ro -a 0600-demo.d/f16x32.img run > /dev/null 2>&1 + +# Run techtalk. +techtalk-pse diff --git a/2012-dublin/style.css b/2012-dublin/style.css new file mode 100644 index 0000000..c7be03c --- /dev/null +++ b/2012-dublin/style.css @@ -0,0 +1,106 @@ +/* Red Hat red is rgb(204,0,0). */ + +body { + background: url(redhat.jpg) no-repeat; + background-position: 98% 0; + font-size: 24pt; /* For max */ + /* font-size: 20pt; */ /* For 1024x768 */ + font-family: liberation, helvetica; +} + +body td { /* why?? */ + /*font-size: 28pt;*/ + font-size: 20pt; +} + +h1 { + color: rgb(204,0,0); + /*font-size: 48px;*/ + font-size: 40px; + top: 8; + left: 0; + border-bottom: 2px solid rgb(204,0,0); +} + +b { + color: rgb(204,0,0); +} + +div#titlepage { + margin-top: 100px; + text-align: center; +} + +div#titlepage p.title { + color: rgb(204,0,0); + font-weight: bold; + font-size: 48px; +} + +div#titlepage author { + font-size: 36px; +} + +/* Bubble around names of virt-tools. */ +p.bubble { + font-weight: bold; + color: white; + width: 6em; + text-align: center; + background-color: rgb(204,0,0); + -moz-border-radius: 0.2em; + border-radius: 0.2em; +} + +p.bubbleinverse { + font-weight: bold; + color: rgb(204,0,0); + text-align: center; + background-color: white; +} + +table.tools td { + font-size: 18pt; + padding-bottom: 0.5em; + padding-right: 0.5em; +} + +/* Code */ +pre.code { + margin-left: 1em; + background: #eee; +} + +/* Steps */ +p#steps { + margin-bottom: -16px; + text-align: right; + font-size: 16pt; +} + +p#steps b { + background-color: rgb(204,0,0); + color: white; + padding-left: 8px; + padding-right: 8px; + border-radius: 0.2em; +} + +/* sVirt slide */ +span.svirt { + color: rgb(204,0,0); +} + +/* Bullet points */ +li { + padding-bottom: 16px; +} + +/* Logo */ +img#fish { + position: absolute; + top: 128px; + right: 64px; + width: 200px; + /*height: 256px;*/ +} \ No newline at end of file -- 1.8.3.1