virt-sparsify broken after recent changes
by Olaf Hering
With 1.9.37 the following script worked fine, with 1.9.39 it fails.
Any idea what the issue is?
Olaf
...
mount -o /dev/vda1 /sysroot/
[ 1.396411] EXT4-fs (vda1): mounting ext2 file system using the ext4 subsystem
[ 1.533090] EXT4-fs (vda1): mounted filesystem without journal. Opts: (null)
guestfsd: main_loop: proc 1 (mount) took 0.45 seconds
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 01 | 00 00 00 01 | 00 12 34 08 | ...
Fill free space in /dev/vda1 with zero ...
libguestfs: send_to_daemon: 52 bytes: 00 00 00 30 | 20 00 f5 f5 | 00 00 00 04 | 00 00 01 37 | 00 00 00 00 | ...
guestfsd: main_loop: new request, len 0x30
random filename: /sysroot//ubhvwzh2.xu8
fsync /dev/vda
guestfsd: main_loop: proc 311 (zero_free_space) took 1.46 seconds
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 01 37 | 00 00 00 01 | 00 12 34 09 | ...
libguestfs: send_to_daemon: 44 bytes: 00 00 00 28 | 20 00 f5 f5 | 00 00 00 04 | 00 00 00 2f | 00 00 00 00 | ...
guestfsd: main_loop: new request, len 0x28
umount /sysroot
guestfsd: main_loop: proc 47 (umount_all) took 0.01 seconds
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 2f | 00 00 00 01 | 00 12 34 0a | ...
libguestfs: send_to_daemon: 44 bytes: 00 00 00 28 | 20 00 f5 f5 | 00 00 00 04 | 00 00 00 0a | 00 00 00 00 | ...
guestfsd: main_loop: new request, len 0x28
lvm vgs -o vg_name --noheadings
No volume groups found
guestfsd: main_loop: proc 10 (vgs) took 0.01 seconds
libguestfs: recv_from_daemon: 44 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 0a | 00 00 00 01 | 00 12 34 0b | ...
libguestfs: send_to_daemon: 44 bytes: 00 00 00 28 | 20 00 f5 f5 | 00 00 00 04 | 00 00 01 1a | 00 00 00 00 | ...
guestfsd: main_loop: new request, len 0x28
fsync /dev/vda
guestfsd: main_loop: proc 282 (internal_autosync) took 0.02 seconds
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 01 1a | 00 00 00 01 | 00 12 34 0c | ...
libguestfs: sending SIGTERM to process 26256
libguestfs: closing guestfs handle 0x1e66470 (state 0)
Fatal error: exception Guestfs.Handle_closed("disk_format")
...
#!/bin/bash
set -x
img=disk.img
sprs=disk.sparse.img
kname=vda
test -f ${img} && exit 1
test -f ${sprs} && exit 1
find /usr/share/ -type f -print0 | xargs -0 cat | dd bs=$(( 1024 * 1024 )) count=$(( 42 )) iflag=fullblock of=${img}
ls -lhsS ${img}
time guestfish -v <<_EOF_
add ${img}
run
part-disk /dev/${kname} mbr
blockdev-rereadpt /dev/${kname}
mkfs ext2 /dev/${kname}1
blockdev-rereadpt /dev/${kname}
mount /dev/${kname}1 /
mkdir /y
ls /
ls /y
umount /
sync
_EOF_
time virt-sparsify -v ${img} ${sprs}
ls -lhsS ${img} ${sprs}
12 years, 1 month
[PATCH] fix fuse_opt_add_opt_escaped return type
by Olaf Hering
I: Program returns random data in a function
E: libguestfs no-return-in-nonvoid-function guestmount.c:75
The function fuse_opt_add_opt_escaped has only one caller and a return
code is not checked.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index 17e94ba..1eb0553 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -49,7 +49,7 @@ static int write_pid_file (const char *pid_file, pid_t pid);
* Copyright (C) 2001-2007 Miklos Szeredi <miklos(a)szeredi.hu>
* This [function] can be distributed under the terms of the GNU LGPLv2.
*/
-static int
+static void
fuse_opt_add_opt_escaped (char **opts, const char *opt)
{
unsigned oldlen = *opts ? strlen(*opts) : 0;
--
1.7.11.5
12 years, 1 month
[PATCH] daemon: provide list of checksum commands
by Olaf Hering
While adding the list of external commands I missed the
various checksum tools.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
WARNING: not compile tested ...
diff --git a/daemon/checksum.c b/daemon/checksum.c
index f2e040d..f16a7c0 100644
--- a/daemon/checksum.c
+++ b/daemon/checksum.c
@@ -31,24 +31,31 @@
GUESTFSD_EXT_CMD(str_find, find);
GUESTFSD_EXT_CMD(str_xargs, xargs);
+GUESTFSD_EXT_CMD(str_cksum, cksum);
+GUESTFSD_EXT_CMD(str_md5sum, md5sum);
+GUESTFSD_EXT_CMD(str_sha1sum, sha1sum);
+GUESTFSD_EXT_CMD(str_sha224sum, sha224sum);
+GUESTFSD_EXT_CMD(str_sha256sum, sha256sum);
+GUESTFSD_EXT_CMD(str_sha384sum, sha384sum);
+GUESTFSD_EXT_CMD(str_sha512sum, sha512sum);
static const char *
program_of_csum (const char *csumtype)
{
if (STRCASEEQ (csumtype, "crc"))
- return "cksum";
+ return str_cksum;
else if (STRCASEEQ (csumtype, "md5"))
- return "md5sum";
+ return str_md5sum;
else if (STRCASEEQ (csumtype, "sha1"))
- return "sha1sum";
+ return str_sha1sum;
else if (STRCASEEQ (csumtype, "sha224"))
- return "sha224sum";
+ return str_sha224sum;
else if (STRCASEEQ (csumtype, "sha256"))
- return "sha256sum";
+ return str_sha256sum;
else if (STRCASEEQ (csumtype, "sha384"))
- return "sha384sum";
+ return str_sha384sum;
else if (STRCASEEQ (csumtype, "sha512"))
- return "sha512sum";
+ return str_sha512sum;
else {
reply_with_error ("unknown checksum type, expecting crc|md5|sha1|sha224|sha256|sha384|sha512");
return NULL;
--
1.7.11.5
12 years, 2 months
fallback to virtio_blk if guest kernel lacks virtio_scsi support
by Olaf Hering
Currently virtio_scsi is forced if qemu in the host supports this
feature. This test does however not take the capabilities of the started
guest into account. As a result no disks will be found if the guest
kernel is older than 3.4.
I forced qemu_supports_virtio_scsi to return always 0, which seem to
work well for the kernel versions as shipped in SLES11SP2, openSuSE 12.1
and older. Is there any functionality that would be missing if a guest
kernel has just virtio_blk?
How can I force the host tools to not enable virtio_scsi? Should it be a
runtime option, or should it be done at build time with
--disable-virtio_scsi or something like that?
Olaf
12 years, 2 months
[PATCH] daemon: remove call to obsolete udevsettle
by Olaf Hering
udevadm is included in all reasonable recent distributions.
This avoids 'command not found' errors in verbose mode.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index e6d5fde..0db56e4 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -54,7 +54,6 @@
#include "daemon.h"
GUESTFSD_EXT_CMD(str_udevadm, udevadm);
-GUESTFSD_EXT_CMD(str_udevsettle, udevsettle);
static char *read_cmdline (void);
@@ -1287,16 +1286,9 @@ random_name (char *template)
*
* Use 'udevadm settle' after certain commands, but don't be too
* fussed if it fails.
- *
- * 'udevsettle' was the old name for this command (RHEL 5). This was
- * deprecated in favour of 'udevadm settle'. The old 'udevsettle'
- * command was left as a symlink. Then in Fedora 13 the old symlink
- * remained but it stopped working (RHBZ#548121), so we have to be
- * careful not to assume that we can use 'udevsettle' if it exists.
*/
void
udev_settle (void)
{
(void) command (NULL, NULL, str_udevadm, "settle", NULL);
- (void) command (NULL, NULL, str_udevsettle, NULL);
}
--
1.7.11.5
12 years, 2 months
[PATCH] sysprep: remove hostname from ifcfg-*
by Wanlong Gao
Remove hostname from network interface configuration.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
po/POTFILES-ml | 1 +
sysprep/Makefile.am | 1 +
sysprep/sysprep_operation_net_hostname.ml | 58 +++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+)
create mode 100644 sysprep/sysprep_operation_net_hostname.ml
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index 76043a0..c9422fb 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
@@ -27,6 +27,7 @@ sysprep/sysprep_operation_logfiles.ml
sysprep/sysprep_operation_lvm_uuids.ml
sysprep/sysprep_operation_machine_id.ml
sysprep/sysprep_operation_mail_spool.ml
+sysprep/sysprep_operation_net_hostname.ml
sysprep/sysprep_operation_net_hwaddr.ml
sysprep/sysprep_operation_pacct_log.ml
sysprep/sysprep_operation_package_manager_cache.ml
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 2ee9abf..46b8309 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -55,6 +55,7 @@ operations = \
logfiles \
machine_id \
mail_spool \
+ net_hostname \
net_hwaddr \
pacct_log \
package_manager_cache \
diff --git a/sysprep/sysprep_operation_net_hostname.ml b/sysprep/sysprep_operation_net_hostname.ml
new file mode 100644
index 0000000..44c6939
--- /dev/null
+++ b/sysprep/sysprep_operation_net_hostname.ml
@@ -0,0 +1,58 @@
+(* virt-sysprep
+ * Copyright (C) 2012 Fujitsu Limited
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Utils
+open Sysprep_operation
+open Sysprep_gettext.Gettext
+
+module G = Guestfs
+
+let net_hostname_perform g root =
+ let typ = g#inspect_get_type root in
+ let distro = g#inspect_get_distro root in
+ match typ, distro with
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ let filenames = g#glob_expand "/etc/sysconfig/network-scripts/ifcfg-*" in
+ Array.iter (
+ fun filename ->
+ (* Replace HOSTNAME=... entry. *)
+ let lines = Array.to_list (g#read_lines filename) in
+ let lines = List.filter (
+ fun line -> not (string_prefix line "HOSTNAME=")
+ ) lines in
+ let file = String.concat "\n" lines ^ "\n" in
+ g#write filename file
+ ) filenames;
+
+ if filenames <> [||] then [ `Created_files ] else []
+
+ | _ -> []
+
+let net_hostname_op = {
+ name = "net-hostname";
+ enabled_by_default = true;
+ heading = s_"Remove HOSTNAME in network interface configuration";
+ pod_description = Some (s_"\
+For Fedora and Red Hat Enterprise Linux,
+this is removed from C<ifcfg-*> files.");
+ extra_args = [];
+ perform_on_filesystems = Some net_hostname_perform;
+ perform_on_devices = None;
+}
+
+let () = register_operation net_hostname_op
--
1.7.12
12 years, 2 months
Re: [Libguestfs] [virt-tools-list] Possible bug, problem with virt-sparsify image format detection
by Richard W.M. Jones
[I don't normally monitor this list for issues - it's
better to send bugs to the libguestfs mailing list]
On Tue, Aug 28, 2012 at 09:07:23PM +0100, Paul Maunders wrote:
> I've found an issue with virt-sparsify on Centos 6.3 with it's image
> format detection. If I take a qcow2 image and attempt to sparsify it
> with...
>
> virt-sparsify -v centos6.3-gold.img centos6.3-gold.img-sparsified
>
> ... it creates a raw file as it's output rather than a qcow2 file. In
> the man page it says that the format should be preserved. In the log I
> can see:
>
> qemu-img convert -f qcow2 -O 'raw' '/tmp/sparsifycfbc31.qcow2'
> 'centos6.3-gold.img-sparsified'
This is a bug:
https://bugzilla.redhat.com/show_bug.cgi?id=853762
https://bugzilla.redhat.com/show_bug.cgi?id=853763
> However, if I manually set the input format and output format then it
> works fine....
>
> virt-sparsify -v --format qcow2 --convert qcow2 centos6.3-gold.img
> centos6.3-gold.img-sparsified
If you force the output format by using the --convert option then
detection of the input format is not used at all. Same if you specify
the input format using --format.
> In the log I get:
>
> qemu-img convert -f qcow2 -O 'qcow2' '/tmp/sparsify2e15e4.qcow2'
> 'centos6.3-gold.img-sparsified'
>
> I have version 1.16.19-1 of libguestfs-tools installed. I have also
> tried on an Ubuntu system running an older version of the tools, and
> it doesn't seem to have this problem.
It depends on the version of the 'file' command that is installed,
because the method used to detect the input format is not especially
robust.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
12 years, 2 months