Commit Graph

6282 Commits

Author SHA1 Message Date
Richard W.M. Jones
f0f95bd038 perl: Data::Dumper and String::ShellQuote modules are no longer required.
They used to be used by old Perl virt-make-fs.  Nothing else uses
them.

This updates commit d3512deb67.
2014-01-29 08:45:19 +00:00
Richard W.M. Jones
32cbd7ca0d make-fs: Remove warning from man page about lone --partition argument.
C's getopt_long has no problem with this.
2014-01-29 08:20:38 +00:00
Richard W.M. Jones
a8a655a859 make-fs: Ensure --partition (on its own) creates an MBR partition.
This fixes commit d3512deb67.
2014-01-29 08:20:38 +00:00
Richard W.M. Jones
90d3378778 make-fs: Refactor debug stats code.
Code motion, no functional change.
2014-01-29 08:20:38 +00:00
Richard W.M. Jones
5bf8c81d7d make-fs: Use an anonymous pipe instead of a named pipe.
The previous translation from Perl slavishly followed the Perl code a
bit too much and used a named pipe to communicate between the
uncompressing subprocess and libguestfs tar-in.  From C we can use an
anonymous pipe instead.

This updates commit d3512deb67.
2014-01-29 08:20:18 +00:00
Richard W.M. Jones
c86fcc0fd4 make-fs: Make check-valgrind do something. 2014-01-29 08:00:55 +00:00
Richard W.M. Jones
f5bc913434 make-fs: Run virt-make-fs in test from builddir, not srcdir. 2014-01-29 08:00:30 +00:00
Richard W.M. Jones
59fce974e2 pod: Remove stray +x (executable) mode on various POD files.
find -name '*.pod' -perm /0111 -exec chmod -x {} \;
2014-01-28 22:17:12 +00:00
Richard W.M. Jones
1771e1f2b2 Version 1.25.31. 1.25.31 2014-01-28 22:10:25 +00:00
Richard W.M. Jones
233d5410e5 sysprep: Add script4.sh (test script) to EXTRA_DIST.
This fixes commit ce9d4d335b.
2014-01-28 21:56:18 +00:00
Richard W.M. Jones
dc91bf7231 Version 1.25.30. 1.25.30 2014-01-28 21:02:13 +00:00
Richard W.M. Jones
642cf4c5dc tests: Test --label and other options in virt-make-fs. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
d3512deb67 Rewrite virt-make-fs in C (originally Perl).
It should be very compatible with the Perl version.
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
40512c66af daemon: Always pass -F option to mkfs.ntfs.
Otherwise it moans about:

  mkfs: ntfs: /dev/sda: /dev/sda is entire device, not just one partition.
  Refusing to make a filesystem here!

This has been happening for a while, so I don't know why we didn't
notice it before.  It even happens on RHEL 6.

A simple reproducer is:

  virt-make-fs -t ntfs any-tarball.tar.gz test.img
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
9015d5ac14 virt-make-fs: Use disk-create API instead of calling qemu-img create.
Strictly speaking this reduces the number of formats that virt-make-fs
can output to, but it's likely that no one cares and if they do we can
add new formats in future.
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
a594b7f90a sparsify: Use new disk-create API instead of calling qemu-img.
disk-create doesn't support the lazy_refcounts option.
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
40261e4adc rescue: Note that we're not using add-drive-scratch here, and maybe we should be. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
f02fddc26b tests: Update miscellaneous tests to use disk-create API.
Instead of calling out to qemu-img / truncate.
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
bd12e784e7 builder: Use disk-create API instead of calling qemu-img create. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
d60e6a23a6 examples: Update various examples to use new disk-create API. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
2794eac739 fish: Use disk-create API to implement guestfish 'alloc' and 'sparse' commands. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
1e5eb0aebb lib: Use disk-create API instead of qemu-img/truncate inside the library. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
588af1953e New API: disk-create for creating blank disks.
This is a wrapper around either 'qemu-img create' or calls to open,
truncate and posix_fallocate which litter and complicate existing
code.
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
65fc841ea6 src/Makefile.am: Reorder SOURCES into alphabetical order. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
e3f72805d1 run: Actually use timeout --foreground option (RHBZ#1025269).
The following commit managed to not actually add the --foreground
option to the timeout command, just test for it.  Add it this time.

  commit 6814888774
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Thu Dec 19 08:21:53 2013 +0000

    run: Use timeout --foreground option.

    If timeout doesn't have this option (RHEL 6) don't use timeout at all.

    Attempt to fix RHBZ#1025269.
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
d9cd2dc9b0 daemon: Add a note about how 'mount --rbind' doesn't work. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
9df50877f8 daemon: If /selinux exists in the guest, bind-mount /sys/fs/selinux to there.
Commit 72afcf450a was partially
incorrect.  If the guest userspace is expecting /selinux to exist,
then we should bind-mount /sys/fs/selinux from the appliance kernel
there.
2014-01-28 21:02:11 +00:00
Pino Toscano
ce9d4d335b builder, sysprep: initialise the random generator
virt-builder and virt-sysprep may make use of
Common_utils.string_random8 (which uses Random.int) for constructing
temporary paths; not initialising the random generator means that every
invocation will reuse the same name used previously (!).
Thus just call Random.self_init, just like virt-sparsify already does.

Expand the test-virt-sysprep-script.sh test to ensure that virt-sysprep
is not affected again by this issue.
2014-01-28 15:04:38 +01:00
Pino Toscano
95f8144cb6 tests/regressions: remove C part of rhbz1044014
All it did was checking for a libvirt version, which is what
libvirt-is-version now does; hence remove the C part, and use guestfish,
ignoring the launch failure (as the C test did).
2014-01-27 17:25:55 +01:00
Pino Toscano
4310f8f175 tests/disks: skip test-qemu-drive-libvirt.sh if libvirt is < 1.1.3
This test relies on the <test:runstate> element in the domain XML, which
has been introduced in libvirt 1.1.3.
2014-01-27 16:33:22 +01:00
Pino Toscano
c01fb37839 tests: add a a simple libvirt-is-version test tool
libvirt-is-version returns successfully in case the available version of
libvirt is greater or equal than the specified major/minor/release
values.
2014-01-27 16:31:32 +01:00
Pino Toscano
f66d6a85b6 tests/mountable: add missing space in test-mountable-inspect.sh
No actual behaviour, other than getting rid of a bash warning.
2014-01-27 14:25:47 +01:00
Richard W.M. Jones
de7a8336cd Version 1.25.29. 1.25.29 2014-01-25 12:04:37 +00:00
Richard W.M. Jones
4e18712562 tests/disks/test-qemu-drive-libvirt: Include test data.
This was inadvertantly deleted.

This fixes commit 01d27033bd.
2014-01-25 11:56:40 +00:00
Richard W.M. Jones
24e61492cc Version 1.25.28. 1.25.28 2014-01-25 10:59:03 +00:00
Richard W.M. Jones
080300dfec builder: Add documentation for enabling Puppet (agent) in a guest. 2014-01-25 09:41:10 +00:00
Richard W.M. Jones
90e23b4e56 builder: Add --selinux-relabel option to perform SELinux relabelling.
This adds the --selinux-relabel option which enables selinux in the
appliance and runs:

  if load_policy && fixfiles restore; then
    rm -f /.autorelabel
  else
    touch /.autorelabel
  fi

at the end of installation.

When possible this fixes SELinux labels in the guest and makes the
autorelabel step unnecessary.

Notes:

 - The previous commit is required so that load_policy works.

 - During the build, SELinux is enabled but no policy is loaded.  This
   works because SELinux is in permissive mode.

 - This flag does not work if the appliance kernel and the guest have
   greatly differing versions, eg. a RHEL 6 guest with a Fedora 20
   appliance.  This is because SELinux changes the policy format and
   breaks backwards compatibility.  You would see errors like this:

   libsepol.policydb_write: policy version 15 cannot support MLS
   libsepol.policydb_to_image: could not compute policy length
   libsepol.policydb_to_image: could not create policy image
   SELinux:  Could not downgrade policy file /etc/selinux/targeted/policy/policy.24, searching for an older version.
   SELinux:  Could not open policy file <= /etc/selinux/targeted/policy/policy.24:  No such file or directory

   These errors are ignored (they go to the log file) and relabelling
   is done at boot instead.

 - It's not clear if loading guest policy is safe.  You should trust
   the virt-builder templates and to use libguestfs confinement for
   additional protection.
2014-01-25 09:41:07 +00:00
Richard W.M. Jones
ab33653ef3 daemon: Bind-mount /sys/fs/selinux into sysroot when running commands.
Even though we are already bind-mounting /sys, it is necessary to also
bind-mount /sys/fs/selinux in order for SELinux commands (in
particular, 'load_policy') to work.

This fixes/reverts commit 7367729ec7.
2014-01-24 19:36:33 +00:00
Richard W.M. Jones
0e2489974b fuse: In mount-local-run, test if root filesystem has been mounted (RHBZ#1057504).
It is never normally valid to use the mount-local* APIs when you
haven't mounted some filesystems in the libguestfs namespace.

If you try it, it results in some odd errors.  The mount-local-run
call is successful, but subsequent operations fail:

$ mkdir -p /tmp/mnt
$ guestfish -x -N fs mount-local /tmp/mnt : mount-local-run
libguestfs: error: lstat: lstat_stub: you must call 'mount' first to mount the root filesystem
libguestfs: error: lstat: lstat_stub: you must call 'mount' first to mount the root filesystem

With this commit, the mount-local-run call gives an error:

libguestfs: error: you must call 'guestfs_mount' first to mount a filesystem on '/'.
Note: '/tmp/mnt' is still mounted.  Use 'guestunmount /tmp/mnt' to clean up.

The error is implemented by calling guestfs_exists (g, "/") which has
the side effect of running the NEED_ROOT macro in the daemon.  (There
is no simple equivalent of NEED_ROOT on the library side.)
2014-01-24 12:26:34 +00:00
Richard W.M. Jones
01d27033bd lib, fish: Handle Gluster, NBD, iSCSI and Sheepdog paths properly.
This fixes the handling of paths for the protocols named above, with
respect to leading '/' (or not) on the volume/export name.

See previous commits which did the same fixes for Ceph:
commit 53a3ff9c00
commit 992a6b2970
2014-01-23 21:49:16 +00:00
Richard W.M. Jones
870f076bdd Version 1.25.27. 1.25.27 2014-01-23 19:35:23 +00:00
Richard W.M. Jones
3331db84bc resize: Don't truncate libguestfs error messages.
If we rely on OCaml's internal exception printing, then it will
truncate error messages like this:

  Fatal error: exception Guestfs.Error("could not create appliance
  through libvirt.

  Try running qemu directly without libvirt using this environment
  variable: export LIBGUESTFS_BACKEND=direct

  Original error from libvirt: unable to set security context
  'unconfined_u:object_r:svi
note the truncation here ^^^^^^^

Instead of using the internal exception printing, wrap the whole
program in a 'main ()' function and add an exception handler.

This large change is non-functional apart from the addition of the
exception handlers at the end.
2014-01-23 15:08:52 +00:00
Richard W.M. Jones
e8c1067021 launch: direct: Stop using deprecated -no-kvm-pit-reinjection if qemu is new enough (RHBZ#1053847). 2014-01-23 14:46:03 +00:00
Richard W.M. Jones
1d6ba35e6f tests: Add a test of libvirt domain XML to qemu command line (RHBZ#1026688).
This tests that libvirt domain XML (ie. guestfish -d option) is parsed
correctly and results in the correct qemu command line when using the
direct backend.

This is a good end-to-end test of various layers.
2014-01-23 14:46:03 +00:00
Richard W.M. Jones
1ed0ce3ef8 libvirt domain: Allow network drives with no <source name="..."> attr.
This is valid for some network drives, for example:

  <source protocol='nbd'>
    <host name='foo' port='1234'/>
  </source>

We pass an empty string as path to the guestfs_add_drive_opts API in
this case.
2014-01-23 14:46:03 +00:00
Richard W.M. Jones
1d2e74414b libvirt-domain: Remove unnecessary and wrongly indented parens. 2014-01-23 14:46:03 +00:00
Richard W.M. Jones
58ada01783 libvirt domain: Allow network drives with no <host> elements.
This is valid for some network drives:

<source protocol='rbd' name='abc-def/ghi-jkl'/>

instead of this:

<source protocol='rbd' name='abc-def/ghi-jkl'>
  <host name='foo' port='1234'/>
</source>

Allow both forms.
2014-01-23 14:46:03 +00:00
Richard W.M. Jones
992a6b2970 fish: Handle Ceph/rbd URIs and convert them to paths properly (RHBZ#1026688).
The path at the API level (for guestfs_add_drive_opts) is:

  pool/disk

The URI syntax is either rbd:///pool/disk or rbd://server:port/pool/disk.
Because of the way URI parsing works we may need to remove a leading
'/' character before passing the path down to the API.
2014-01-23 14:46:03 +00:00
Richard W.M. Jones
53a3ff9c00 lib: Handle Ceph/rbd paths properly (RHBZ#1026688).
The path at the protocol level is:

  pool/disk

(with no leading '/' character).  This is now what you have to pass to
guestfs_add_drive_opts.

Also Ceph can be called with no explicit servers (it uses the contents
of /etc/ceph/ceph.conf instead).  So allow zero servers to be used.
2014-01-23 14:46:03 +00:00
Richard W.M. Jones
b93a1d50ad fish/uri: Tidy up error messages. 2014-01-23 14:46:03 +00:00