Commit Graph

1189 Commits

Author SHA1 Message Date
Richard Jones
cefc644d58 guestfs_find: Fix memory leak of sysrootdir. 2009-10-20 10:31:55 +01:00
Richard Jones
ea12489788 virt-ls: Modify to use find0 instead of find.
find0 is more scalable than find.  virt-ls will no longer
crash if asked to recursively list / on a Linux guest.
2009-10-20 10:31:54 +01:00
Richard Jones
42c89f2e6b New API: find0 (unlimited version of find)
This adds a new API call guestfs_find0, which is like guestfs_find
but mainly doesn't suffer from the protocol limit of the earlier
command.  The earlier command is not deprecated because it is
still very useful.

guestfs_find0 uses a FileOut parameter and writes the results to
an external file.  The filenames in the output are separated by
ASCII NUL characters (so a bit like "find -print0").

There is also the addition of a regression test for this command.
2009-10-20 10:31:54 +01:00
Richard Jones
55f5dc6f11 guestfs_find: Document protocol limits for this API call.
guestfs_find has to send the complete list of files in a single
protocol message (hence, limited to 2-4 MB).  Unfortunately on
a typical Linux guest, guestfs_find ("/") will exceed this limit
resulting in an error.

Therefore we should add an unlimited version of this call in a
future commit.  This commit just documents the current limit.
2009-10-20 10:31:54 +01:00
Richard Jones
4dd6b77ff7 New tool: virt-ls
This tool makes available the functionality of "ls", "ll", and "find"
in a slightly simpler to use form.

Examples:

  virt-ls -l myguest /tmp
2009-10-20 10:31:54 +01:00
Richard Jones
984a35cfc0 New tool: virt-tar
This adds a new tool call virt-tar which is a general purpose
archive and uploading tool.  It doesn't add any functionality
which wasn't previously possible using guestfish, but makes it
simpler to access for some users.

Examples:

 virt-tar -zx myguest /home home.tar.gz
 virt-tar -zu myguest uploadstuff.tar.gz /tmp
2009-10-20 10:31:44 +01:00
Richard Jones
5c4bf92bc2 tools: Make warnings about running on live guests more prominent.
Add prominent warnings to the man pages about how it is dangerous
to run these tools against live guests.
2009-10-19 10:45:44 +01:00
Richard Jones
945b6e0a08 Move virt tools (virt-cat, virt-edit etc) into tools/ subdirectory.
This moves the tool programs into a single directory:
  cat/* -> tools/virt-cat
  df/* -> tools/virt-df
  edit/* -> tools/virt-edit
  rescue/* -> tools/virt-rescue

This in itself simplifies the build process because we only need
one Makefile and one copy of 'run-locally'.

'run-*-locally' has become just 'run-locally' and takes an extra
parameter which is the name of the tool, eg:
  run-locally cat [virt-cat params...]

virt-inspector stays in its own directory, because this contains
more than just a single Perl script.
2009-10-19 10:18:46 +01:00
Richard Jones
854f8e0d56 Comment: Describe the build order requirements for toplevel directories. 2009-10-19 09:10:15 +01:00
Richard Jones
29148ac40f Prepare for 1.0.73. 1.0.73 2009-10-14 11:24:52 +01:00
Richard Jones
f57f338c3b Add some missing EXTRA_DIST files. 2009-10-14 11:24:33 +01:00
Richard Jones
d37f697953 inspector: Generate language bindings for OCaml.
This commit adds a generic mechanism for deriving language bindings
for virt-inspector, and implements one concrete binding, for OCaml.

The bindings are generated from the RELAX NG schema (virt-inspector.rng)
which is supposed to be a correct and always up to date description
of the XML that the virt-inspector program can generate.

From the RNG we generate a set of types to describe the output of
virt-inspector for the language, plus an XML parser, plus some
glue code to actually run an external instance of virt-inspector
and parse the resulting XML.

At runtime, an external 'virt-inspector --xml <name>' command runs
and the XML is parsed into language-specific structures.

This has been tested on the four example files (inspector/example?.xml)

The only particular difficulty about the OCaml binding is the use of
Obj.magic, which is naughty but works because of the isomorphism
between the representation of tuples and records in OCaml.  This
seems to cause no problems in my test program.  Apart from this, the
OCaml binding is straightforward and could be adapted easily for any
other languages that want type-safe virt-inspector bindings.

It's important to keep virt-inspector.rng up to date with changes
to virt-inspector's XML output format.
2009-10-13 17:53:20 +01:00
Jim Meyering
c6b8db6493 build: avoid parallel ocaml/... build failure
A parallel build could fail due to the use in ocaml/examples
of ocaml/guestfs.cmi before it was built.
* Makefile.am (SUBDIRS): Add both ocaml and ocaml/examples,
to ensure they're built in this order, and not in parallel.
* ocaml/Makefile.am (SUBDIRS): Don't define.
2009-10-05 14:16:46 +02:00
Piotr Drąg
65d61d4244 Updated Polish translation 2009-10-05 12:20:53 +01:00
Richard Jones
9f206cc4a6 inspector: Fix inspector/Makefile.am
Accidentally pushed the older version of the patch in
commit 9d25e82491.

This includes Jim Meyering's suggested changes from
https://www.redhat.com/archives/libguestfs/2009-October/msg00017.html
2009-10-02 15:50:43 +01:00
Jim Meyering
dde81c0c0e build: fix compile error
Link demo scripts with just-build library, not the installed one.
* ocaml/examples/Makefile.am (OCAMLFINDFLAGS): New variable.
(lvs, viewer): Use it.
This fix is based on a suggestion from Rich Jones.
This addresses RHBZ#526917.
2009-10-02 16:15:12 +02:00
Richard Jones
9d25e82491 inspector: Add tests for RELAX NG schema. 2009-10-02 15:00:27 +02:00
Richard Jones
ee21bc1f80 inspector: Add RELAX NG schema for virt-inspector --xml output. 2009-10-02 15:00:27 +02:00
Richard Jones
3c58ea10c7 configure: Update comment about viewer.ml. 2009-10-02 09:51:31 +01:00
Richard Jones
bf6ea12557 inspector: Canonicalize device names (fix RHBZ#526717).
Make filesystem device names canonical, so they are /dev/sd*
instead of /dev/vd*.
2009-10-01 17:06:46 +01:00
Richard Jones
5d01670e31 run-*-locally: The programs are now virt-[tool], not virt-[tool].pl
This fixes commit b488436cc5.
2009-10-01 15:22:12 +01:00
Richard Jones
5021b2efea inspector: Don't bomb if no kernels detected.
If $os->{kernels} wasn't defined, virt-inspector would exit with
an error, leaving partial XML output.

Change the code so it doesn't die in this case, instead just
leaves out the <kernels> section.
2009-10-01 15:20:14 +01:00
Richard Jones
d525103c86 OCaml viewer: Use ocamlduce to replace xpath code. 2009-09-30 16:14:35 +01:00
Richard Jones
d278ef8ad9 OCaml viewer: Handle exceptions properly. 2009-09-29 11:56:26 +01:00
Richard Jones
4c8bdd3424 OCaml example: graphical disk usage viewer.
This is an example of how to write an app which uses libguestfs
and libvirt, and has a responsive user interface (using threads).
It is a Gtk-based "graphical virt-df".

Read the top of the 'viewer.ml' file first for instructions on
how to compile.  This program is not compiled by default.
2009-09-29 11:05:26 +01:00
Richard Jones
f8a96c6596 virt-df: Add note about parsing CSV. 2009-09-24 11:22:37 +01:00
Jim Meyering
6a14f1c250 avoid use of all ctype macros
* cfg.mk (disable_temporarily): Don't disable sc_avoid_ctype_macros.
* fish/tilde.c: Remove unnecessary inclusion of ctype.h.
* bootstrap: Add gnulib's c-ctype module to the list.
* daemon/m4/gnulib-cache.m4: Likewise.
* daemon/ext2.c: Include "c-ctype.h", not <ctype.h>.
Use c_isspace, etc, rather than isspace.
* daemon/guestfsd.c: Likewise.
* daemon/lvm.c: Likewise.
* daemon/proto.c: Likewise.
* fish/fish.c: Likewise.
* fish/tilde.c: Likewise.
* src/generator.ml: Likewise.
* src/guestfs.c: Likewise.
* examples/to-xml.c: Likewise.
* examples/Makefile.am (to_xml_CPPFLAGS): Add -I$(top_srcdir)/gnulib/lib
so inclusion of "c-ctype.h" works.
(to_xml_CPPFLAGS): Rename from to_xml_CFLAGS.
2009-09-24 11:00:44 +02:00
Jim Meyering
0ca36888c6 maint: prune dead wood from list of skipped syntax-check rules
* cfg.mk (local-checks-to-skip): Remove now-passing and
no-longer-relevant rule names.
2009-09-24 11:00:44 +02:00
Jim Meyering
dc0c80b388 maint: use spaces, not TABs for indentation
"make syntax-check" was failing.  This fixes it.
* HACKING: Indent with spaces, not TABs.
* configure.ac: Likewise.
* rescue/virt-rescue: Likewise.
* src/generator.ml: Likewise.
2009-09-24 10:59:53 +02:00
Richard Jones
275b0db961 Prepare for 1.0.72.
Also update PO files.
1.0.72
2009-09-23 14:24:04 +01:00
Richard Jones
4bd623f6a2 More HTMLFILES. 2009-09-23 14:24:04 +01:00
Richard Jones
406d4aea4d Include virt tools in EXTRA_DIST.
Partially revert b488436cc5.
It turns out that automake doesn't automatically place bin_SCRIPTS
in EXTRA_DIST.
2009-09-23 14:03:05 +01:00
Richard Jones
b488436cc5 Rename virt-[tool].pl as virt-[tool] 2009-09-23 12:37:26 +01:00
Richard Jones
75b6338da3 Check return value from readlink. 2009-09-23 12:09:26 +01:00
Richard Jones
9adddc19e4 Create manpage atomically.
Don't fail with a partial file if disk full, etc.
2009-09-23 12:05:55 +01:00
Richard Jones
154370c0e8 Replace @...@ with $(...) in these common Makefile.am files. 2009-09-23 12:04:25 +01:00
Richard Jones
82918538ab guestfish: Update 'SEE ALSO' section of the manpage. 2009-09-23 11:50:49 +01:00
Richard Jones
7801621dc9 New tool: virt-edit
Edit any file in a guest.  This was possibly previously
using guestfish, but having a separate command makes it
simpler.

The usage is simply:

  virt-edit mydomain /some/file

It runs $EDITOR or vi on the file, and if the user changes
it, uploads the result back to the VM.
2009-09-23 11:37:37 +01:00
Richard Jones
d15195bad9 virt-cat: Remove some unused Perl module includes. 2009-09-23 11:18:45 +01:00
Richard Jones
1b21ed4f5d Add 'virt-rescue' command.
This command runs a "rescue appliance" against a virtual machine
or disk image.  This is useful for making ad-hoc interactive
changes to virtual machines.

  $ virt-rescue --ro /dev/vg_trick/F11x64

  Welcome to virt-rescue, the libguestfs rescue shell.

  Note: The contents of / are the rescue appliance.
  You have to mount the guest's partitions under /sysroot
  before you will be able to examine them.

  bash: cannot set terminal process group (-1): Inappropriate ioctl for device
  bash: no job control in this shell
  ><rescue> mount /dev/vg_f11x64/lv_root /sysroot
  EXT4-fs (dm-0): barriers enabled
  kjournald2 starting: pid 269, dev dm-0:8, commit interval 5 seconds
  EXT4-fs (dm-0): internal journal on dm-0:8
  EXT4-fs (dm-0): delayed allocation enabled
  EXT4-fs: file extents enabled
  EXT4-fs: mballoc enabled
  EXT4-fs (dm-0): mounted filesystem with ordered data mode
  ><rescue> ls /sysroot/
  bin   dev  home  lib64       media  opt   root  selinux  sys  usr
  boot  etc  lib   lost+found  mnt    proc  sbin  srv      tmp  var
  ><rescue> exit
2009-09-23 11:18:45 +01:00
Richard Jones
3bc5555135 Add direct appliance mode flag and implementation.
When the g->direct flag is set, the appliance stdin/stdout
are not connected to the library.  Instead they inherit the
stdin/stdout of the caller.

This is used to implement virt-rescue.
2009-09-23 11:18:45 +01:00
Richard Jones
d186e9d3d3 Tidy up appliance rescue code.
The appliance shouldn't run the daemon after we leave the
rescue shell.  It should just exit instead.
2009-09-23 11:18:45 +01:00
Richard Jones
0d9325bd10 Rejig configure.ac tests for qemu vmchannel support.
vmchannel is no longer required, so we shouldn't test for it.
However we should test instead for user mode networking support.

Also fix up the documentation / error messages.

Always test for vmchannel and user mode networking support in
qemu.  This gives us more troubleshooting information if people
report bugs.
2009-09-23 11:18:41 +01:00
Richard Jones
b9da0fe3f7 Prepare for 1.0.71.
Update version number and update PO files.

Put latest version and release date on the website front page.
1.0.71
2009-09-22 14:51:14 +01:00
Richard Jones
1e9e6e50bd Change handling of spaces on Linux kernel command line. 2009-09-22 11:03:22 +01:00
Richard Jones
419cf4bb01 Update documentation of qemu / vmchannel. 2009-09-22 11:03:22 +01:00
Richard Jones
ae2e569489 Implement "null vmchannel" - no vmchannel needed!
This commit removes the requirement for vmchannel, although retaining
support for it.

In this configuration, known as "null vmchannel", the library
listens on a random loopback port.  It passes the number of this
port to the appliance (guestfs_vmchannel=tcp:10.0.2.2:12345), and
the daemon then connects back.  The library, instead of connecting,
listens and accepts the connection during guestfs_launch.

QEMU SLIRP (user mode networking) is still required to make this
work: SLIRP forwards the TCP connection transparently (instead of
explicitly as with guestfwd) to 127.0.0.1:<port>

There is a window in which any other local process on the machine
could see the port number in the qemu command line and try to
connect to it.  This would be a devastating security hole, because
any local process could pretend to be the daemon and feed back
malicious replies to our remote procedure calls.  To prevent this,
we check the UID of the other side of the TCP connection.  If
the UID is different from the library's EUID, then we reject the
connection.  To do this we have to parse /proc/net/tcp.  (On Solaris
we could use getsockopt (SO_PEERCRED), but this doesn't work on
Linux TCP sockets).

Other vmchannel(s) are still supported.  This is important, because
we can't in general be sure the qemu will always support SLIRP.
In particular, in recent versions of qemu it is possible to compile
out SLIRP.
2009-09-22 11:03:16 +01:00
Richard Jones
dcb5aa0183 Gnulib: Add arpa-inet and netinet-in modules. 2009-09-22 10:55:03 +01:00
Richard Jones
8b217a87bf Flexible guestfs_vmchannel parameter for future appliances.
This reimplements parts of commit da0a4f8d1f
in a different, but compatible way.

We pass guestfs_vmchannel=tcp:<ip>:<port> on the command line.  This
is intended to be used as follows (now and in future versions):

  tcp:10.0.2.4:6666    for guestfwd vmchannel
  tcp:10.0.2.2:<port>  for future "no vmchannel" implementation
  /dev/vcon4           for future virtio-console vmchannel*

It also accepts the old-style guestfs=10.0.2.4:6666 parameter which
is sent by older libraries, and turns this transparently into the
correct format above.

If no guestfs_vmchannel is passed, then this defaults to the guestfwd
vmchannel which older libraries would expect.

* Maybe this last one should be dev:/dev/vcon4 or file:/dev/vcon4, but
we don't need to decide that now.
2009-09-22 10:26:58 +01:00
Richard Jones
8b91ee5e2d Rearrange and tidy up code in guestfsd.c
This just tidies up the main() function in the daemon.  There is
no longer a huge fixed-sized buffer used for the kernel command
line.  Variables are moved closer to where they are used.  Some
local variables turned out to be unused - these are removed.  Finally
the part that reads the kernel command line is moved into a separate
function.

There is only minimal functional change here (it now prints out
the kernel command line).

Literal '4' replaced with 'sizeof' expression, at Jim Meyering's
suggestion during patch review.
2009-09-22 10:00:49 +01:00