[PATCH 00/14] Miscellaneous changes and fixes to virt-v2v
by Richard W.M. Jones
Miscellaneous changes to virt-v2v.
This is just a dump of the patchset for virt-v2v that I'm working on,
minus "the big one" which changes how virtio kernel/grub inspection
works which is not ready for primetime yet.
Rich.
10 years, 5 months
[PATCH] ls: add -m option
by Pino Toscano
Implement the -m/--mount as available in guestfish to override the
automatic introspection and specify which partitions to mount instead.
---
cat/ls.c | 25 +++++++++++++++++++------
cat/virt-ls.pod | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/cat/ls.c b/cat/ls.c
index 97022c5..38acc4d 100644
--- a/cat/ls.c
+++ b/cat/ls.c
@@ -102,6 +102,8 @@ usage (int status)
" -h|--human-readable Human-readable sizes in output\n"
" --keys-from-stdin Read passphrases from stdin\n"
" -l|--long Long listing\n"
+ " -m|--mount dev[:mnt[:opts[:fstype]]]\n"
+ " Mount dev on mnt (if omitted, /)\n"
" -R|--recursive Recursive listing\n"
" --times Display file times\n"
" --time-days Display file times as days before now\n"
@@ -130,7 +132,7 @@ main (int argc, char *argv[])
enum { HELP_OPTION = CHAR_MAX + 1 };
- static const char *options = "a:c:d:hlRvVx";
+ static const char *options = "a:c:d:hlm:RvVx";
static const struct option long_options[] = {
{ "add", 1, 0, 'a' },
{ "checksum", 2, 0, 0 },
@@ -147,6 +149,7 @@ main (int argc, char *argv[])
{ "keys-from-stdin", 0, 0, 0 },
{ "long", 0, 0, 'l' },
{ "long-options", 0, 0, 0 },
+ { "mount", 1, 0, 'm' },
{ "recursive", 0, 0, 'R' },
{ "time", 0, 0, 0 },
{ "times", 0, 0, 0 },
@@ -161,6 +164,9 @@ main (int argc, char *argv[])
};
struct drv *drvs = NULL;
struct drv *drv;
+ struct mp *mps = NULL;
+ struct mp *mp;
+ char *p;
const char *format = NULL;
int c;
int option_index;
@@ -247,6 +253,11 @@ main (int argc, char *argv[])
mode |= MODE_LS_L;
break;
+ case 'm':
+ OPTION_m;
+ inspector = 0;
+ break;
+
case 'R':
mode |= MODE_LS_R;
break;
@@ -313,7 +324,7 @@ main (int argc, char *argv[])
* values.
*/
assert (read_only == 1);
- assert (inspector == 1);
+ assert (inspector == 1 || mps != NULL);
assert (live == 0);
/* Many flags only apply to -lR mode. */
@@ -342,18 +353,20 @@ main (int argc, char *argv[])
if (drvs == NULL)
usage (EXIT_FAILURE);
- /* Add drives, inspect and mount. Note that inspector is always true,
- * and there is no -m option.
- */
+ /* Add drives, inspect and mount. */
add_drives (drvs, 'a');
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
- inspect_mount ();
+ if (mps != NULL)
+ mount_mps (mps);
+ else
+ inspect_mount ();
/* Free up data structures, no longer needed after this point. */
free_drives (drvs);
+ free_mps (mps);
unsigned errors = 0;
diff --git a/cat/virt-ls.pod b/cat/virt-ls.pod
index be955d3..b7b676e 100644
--- a/cat/virt-ls.pod
+++ b/cat/virt-ls.pod
@@ -357,6 +357,42 @@ L</RECURSIVE LONG LISTING> above.
Read key or passphrase parameters from stdin. The default is
to try to read passphrases from the user by opening C</dev/tty>.
+=item B<-m dev[:mountpoint[:options[:fstype]]]>
+
+=item B<--mount dev[:mountpoint[:options[:fstype]]]>
+
+Mount the named partition or logical volume on the given mountpoint.
+
+If the mountpoint is omitted, it defaults to C</>.
+
+Specifying any mountpoint disables the inspection of the guest and
+the mount of its root and all of its mountpoints, so make sure
+to mount all the mountpoints needed to work with the filenames
+gives as arguments.
+
+If you don't know what filesystems a disk image contains, you can
+either run guestfish without this option, then list the partitions,
+filesystems and LVs available (see L</list-partitions>,
+L</list-filesystems> and L</lvs> commands), or you can use the
+L<virt-filesystems(1)> program.
+
+The third (and rarely used) part of the mount parameter is the list of
+mount options used to mount the underlying filesystem. If this is not
+given, then the mount options are either the empty string or C<ro>
+(the latter if the I<--ro> flag is used). By specifying the mount
+options, you override this default choice. Probably the only time you
+would use this is to enable ACLs and/or extended attributes if the
+filesystem can support them:
+
+ -m /dev/sda1:/:acl,user_xattr
+
+Using this flag is equivalent to using the C<mount-options> command.
+
+The fourth part of the parameter is the filesystem driver to use, such
+as C<ext3> or C<ntfs>. This is rarely needed, but can be useful if
+multiple drivers are valid for a filesystem (eg: C<ext2> and C<ext3>),
+or if libguestfs misidentifies a filesystem.
+
=item B<-l>
=item B<--long>
--
1.9.3
10 years, 5 months
[libldm 1/3] relax uuid, zlib version requirements
by Hilko Bengen
---
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 469ea96..0e7e2ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,14 +85,14 @@ PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.32.0],
]
)
-PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.5],
+PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2],
[
AC_SUBST([ZLIB_CFLAGS])
AC_SUBST([ZLIB_LIBS])
]
)
-PKG_CHECK_MODULES([UUID], [uuid >= 2.21.0],
+PKG_CHECK_MODULES([UUID], [uuid],
[
AC_SUBST([UUID_CFLAGS])
AC_SUBST([UUID_LIBS])
--
2.0.0
10 years, 5 months
Script to read systemd journal of a guest to find its IP address
by Kashyap Chamarthy
Heya,
Thanks Rich for the hints on IRC about journal bindings for libguestfs.
The below script is what I ended up with. At least I learnt how to
iterate over the systemd journal entries.
$ sudo python find-ip.py
192.162.122.118
Obviously, this only searches for the _first_ occurance of the IP
address and doesn't take into account the guest may have acquired a new
IP on a later reboot. (I guess I'd have to do some thing like
$ journalctl --lines=500 | egrep -i 'dhclient.*bound').
-------------------------------------------------------------------
#!/usr/bin/python
#-----------------------------------------------------------------
# PURPOSE: To find what IP address a guest has acquired from DHCP
#-----------------------------------------------------------------
image = "/var/lib/libvirt/images/ostack-controller.qcow2"
root_filesystem = "/dev/fedora/root"
import os
import sys
import re
import guestfs
g = guestfs.GuestFS ()
g.add_drive (image, format='qcow2')
g.launch ()
#print g.list_partitions()
# Set trace
#g.set_trace (1)
g.mount_options ("ro", root_filesystem, "/")
# Open the journal
g.journal_open ("/var/log/journal")
# Loop over the journal to find a specific string
count = 0
prog = re.compile("dhclient.*bound")
while g.journal_next():
count += 1
output = g.journal_get()
#print output
flag = 0
for i in output:
if i['attrname']=="MESSAGE" and i['attrval'].startswith("bound"):
print i['attrval'].split()[2]
flag = 1
break
if flag == 1:
break
# Close the journal handle
g.journal_close ()
# Unmount all the file system(s)
g.umount_all ()
g.sync ()
sys.exit(0)
-------------------------------------------------------------------
--
/kashyap
10 years, 5 months
[PATCH] fuse: UID 0 should override all permissions checks (RHBZ#1106548).
by Richard W.M. Jones
Previously if you were root, and you tried to change directory into a
directory which was not owned by you and not readable (eg. 0700
bin:bin), it would fail.
This doesn't fail on regular directories because when you are root the
kernel just ignores permissions.
Although libguestfs in general tries not to duplicate kernel code, in
the case where we emulate the FUSE access(2) system call,
unfortunately we have to do it by stat-ing the object and performing
some (half-arsed) heuristics.
This commit modifies the FUSE access(2) system call, so root is now
able to chdir to any directory.
It also adds some debugging so we can debug these complex permissions
checks in the field if some other problem arises in future.
---
src/fuse.c | 51 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 36 insertions(+), 15 deletions(-)
diff --git a/src/fuse.c b/src/fuse.c
index dd63729..292ebee 100644
--- a/src/fuse.c
+++ b/src/fuse.c
@@ -301,21 +301,42 @@ mount_local_access (const char *path, int mask)
fuse = fuse_get_context ();
- if (mask & R_OK)
- ok = ok &&
- ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IRUSR
- : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IRGRP
- : statbuf.st_mode & S_IROTH);
- if (mask & W_OK)
- ok = ok &&
- ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IWUSR
- : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IWGRP
- : statbuf.st_mode & S_IWOTH);
- if (mask & X_OK)
- ok = ok &&
- ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IXUSR
- : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IXGRP
- : statbuf.st_mode & S_IXOTH);
+ /* Root user should be able to access everything, so only bother
+ * with these fine-grained tests for non-root. (RHBZ#1106548).
+ */
+ if (fuse->uid != 0) {
+ if (mask & R_OK)
+ ok = ok &&
+ ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IRUSR
+ : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IRGRP
+ : statbuf.st_mode & S_IROTH);
+ if (mask & W_OK)
+ ok = ok &&
+ ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IWUSR
+ : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IWGRP
+ : statbuf.st_mode & S_IWOTH);
+ if (mask & X_OK)
+ ok = ok &&
+ ( fuse->uid == statbuf.st_uid ? statbuf.st_mode & S_IXUSR
+ : fuse->gid == statbuf.st_gid ? statbuf.st_mode & S_IXGRP
+ : statbuf.st_mode & S_IXOTH);
+ }
+
+ debug (g, "%s: "
+ "testing access mask%s%s%s%s: "
+ "caller UID:GID = %d:%d, "
+ "file UID:GID = %d:%d, "
+ "file mode = %o, "
+ "result = %s",
+ path,
+ mask & R_OK ? " R_OK" : "",
+ mask & W_OK ? " W_OK" : "",
+ mask & X_OK ? " X_OK" : "",
+ mask == 0 ? " 0" : "",
+ fuse->uid, fuse->gid,
+ statbuf.st_uid, statbuf.st_gid,
+ statbuf.st_mode,
+ ok ? "OK" : "EACCESS");
return ok ? 0 : -EACCES;
}
--
1.9.0
10 years, 5 months
[PATCH] podwrapper: Put the =encoding line at the correct place in the input (RHBZ#1109174).
by Richard W.M. Jones
Commit c4dc70f8c43a7faae2a8698027a4ed23d316dfa0 broke the man pages
for the Perl scripts in the tools/ directory.
It inserted the =encoding line at the top of the file, instead of in
front of the first =head1 entry, and this meant that the #!/usr/bin/perl
and the prologue became a part of the POD, which was not intended.
---
podwrapper.pl.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/podwrapper.pl.in b/podwrapper.pl.in
index c2cb5e1..a685a4e 100755
--- a/podwrapper.pl.in
+++ b/podwrapper.pl.in
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
# podwrapper.pl
-# Copyright (C) 2010-2012 Red Hat Inc.
+# Copyright (C) 2010-2014 Red Hat Inc.
# @configure_input@
#
# This program is free software; you can redistribute it and/or modify
@@ -293,7 +293,7 @@ foreach (@verbatims) {
die "$progname: $input: =encoding must not be present in input\n"
if $content =~ /^=encoding/m;
-$content = "=encoding utf8\n\n$content";
+$content =~ s/^=head1(.*)/\n=encoding utf8\n\n=head1$1/m;
if ($strict_checks) {
# Verify sections present / not present.
--
1.9.0
10 years, 5 months
Offline virtio installation on Windows 2012R2
by Nikos Skalkotos
Hello all,
I'm trying to automate the installation of the VirtIO drivers on a
Windows image in the same way it is done in [1] and [2].
Registering the viostor service and adding the driver under the
HKEY_LOCALE_MACHINE\SYSTEM\CurrentControlSet\CriticalDeviceDatabase
registry key, makes an Windows 2008R2 image boot if the hd is under the
virtio interface, but I cannot make this work for Windows 2012R2. As far
as I've seen, the CDDB registry keys are deprecated in newer Windows and
creating them back does not seem to make this work.
Has anybody had any luck with this? Is there any other way to do it for
newer Windows?
If this does not work out, I'll probably try to add the driver
installations process in a RunOnce registry entry, boot the image using
the ide interface and reboot it using VirtIO after the drivers have been
installed, but I wanted to know if there is an easier way to do this.
Thank you in advanced,
Nikos
[1] https://github.com/libguestfs/hivex/blob/master/sh/example6
[2]
https://git.fedorahosted.org/cgit/virt-v2v.git/tree/lib/Sys/VirtConvert/C...
10 years, 5 months
libguestfs supermin error
by abhishek jain
Hi
I have compiled libguestfs-1.26.1 on powerpc ubuntu using
supermin_5.1.8-2_powerpc.deb as it dependency package.
When I'm executing the binary libguestfs-test-tool on powerpc ubuntu,I'm
getting supermin error...
ATH=/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin
SELinux: sh: getenforce: command not found
guestfs_get_append: (null)
guestfs_get_autosync: 1
guestfs_get_backend: direct
guestfs_get_backend_settings: []
guestfs_get_cachedir: /var/tmp
guestfs_get_direct: 0
guestfs_get_hv: /usr/bin/kvm
guestfs_get_memsize: 768
guestfs_get_network: 0
guestfs_get_path: /usr/local/lib/guestfs
guestfs_get_pgroup: 0
guestfs_get_program: libguestfs-test-tool
guestfs_get_recovery_proc: 1
guestfs_get_selinux: 0
guestfs_get_smp: 1
guestfs_get_tmpdir: /tmp
guestfs_get_trace: 0
guestfs_get_verbose: 1
host_cpu: powerpc64
Launching appliance, timeout set to 600 seconds.
libguestfs: launch: program=libguestfs-test-tool
libguestfs: launch: version=1.26.1
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=direct
libguestfs: launch: tmpdir=/tmp/libguestfsbnHqnU
libguestfs: launch: umask=0002
libguestfs: launch: euid=1000
libguestfs: [00000ms] begin building supermin appliance
libguestfs: [00000ms] run supermin
libguestfs: command: run: /usr/bin/supermin
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-1000/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu powerpc64
libguestfs: command: run: \ /usr/local/lib/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-1000/appliance.d
supermin: version: 5.1.8
supermin: package handler: debian/dpkg
supermin: acquiring lock on /var/tmp/.guestfs-1000/lock
supermin: build: /usr/local/lib/guestfs/supermin.d
supermin: build: visiting /usr/local/lib/guestfs/supermin.d/base.tar.gz
type gzip base image (tar)
supermin: build: visiting /usr/local/lib/guestfs/supermin.d/daemon.tar.gz
type gzip base image (tar)
supermin: build: visiting /usr/local/lib/guestfs/supermin.d/excludefiles
type uncompressed excludefiles
supermin: build: visiting /usr/local/lib/guestfs/supermin.d/hostfiles type
uncompressed hostfiles
supermin: build: visiting /usr/local/lib/guestfs/supermin.d/init.tar.gz
type gzip base image (tar)
supermin: build: visiting /usr/local/lib/guestfs/supermin.d/packages type
uncompressed packages
supermin: build: visiting
/usr/local/lib/guestfs/supermin.d/udev-rules.tar.gz type gzip base image
(tar)
supermin: build: 121 packages, including dependencies
supermin: build: 7109 files
supermin: build: 7109 files, after removing unreadable files
supermin: build: 4939 files, after matching excludefiles
supermin: build: 4941 files, after adding hostfiles
supermin: build: 4944 files, after munging
supermin: failed to find a suitable kernel (host_cpu=powerpc64).
I looked for kernels in /boot and modules in /lib/modules.
If this is a Xen guest, and you only have Xen domU kernels
installed, try installing a fullvirt kernel (only for
supermin use, you shouldn't boot the Xen guest with it).
libguestfs: error: /usr/bin/supermin exited with error status 1, see debug
messages above
libguestfs-test-tool: failed to launch appliance
libguestfs: closing guestfs handle 0x10016848 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfsbnHqnU
Please help regarding this.
Thanks
Abhishek Jain
10 years, 5 months
Xen drivers for virt-builder images
by George Dunlap
I've just been playing around with virt-builder, and it seems like a
pretty useful tool. However, it seems that in a number of the images,
the initrd file is missing drivers for Xen virtual block and network
devices. This results in a VM that can't find its root device.
The files needed are drivers/block/xen-blkfront.ko and
drivers/net/xen-netfront.ko. They seem to be present in centos-6 and
ubuntu-14.04, but not in rhel-7rc or fedora-20.
Whom would I contact to get these added?
Thanks!
-George
10 years, 5 months