[PATCH] appliance: move virt-rescue welcome to /etc/issue
by Cédric Bosdonnat
To allow easier downstream tweaks to the virt-rescue welcome message,
just output the content of the /etc/issue file in the appliance.
Thus, a new extras.tar.gz file appeared in supermin.d containing
the etc/issue file and future tweaks like this one.
---
appliance/Makefile.am | 11 +++++++++++
appliance/init | 11 ++---------
appliance/issue | 9 +++++++++
3 files changed, 22 insertions(+), 9 deletions(-)
create mode 100644 appliance/issue
diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index e23778e..f26c4d4 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -36,6 +36,7 @@ EXTRA_DIST = \
guestfs_shadow.aug \
hostfiles.in \
init \
+ issue \
libguestfs-make-fixed-appliance.in \
libguestfs-make-fixed-appliance.pod \
make.sh.in \
@@ -49,6 +50,7 @@ superminfs_DATA = \
supermin.d/base.tar.gz \
supermin.d/daemon.tar.gz \
supermin.d/excludefiles \
+ supermin.d/extras.tar.gz \
supermin.d/hostfiles \
supermin.d/init.tar.gz \
supermin.d/packages \
@@ -107,6 +109,15 @@ supermin.d/excludefiles: excludefiles.in Makefile
cmp -s $@ excludefiles-t || mv excludefiles-t $@
rm -f excludefiles-t
+supermin.d/extras.tar.gz: issue
+ rm -f $@ $@-t
+ rm -rf tmp-d
+ mkdir -p tmp-d/etc
+ cp issue tmp-d/etc
+ ( cd tmp-d && tar zcf - * ) > $@-t
+ rm -r tmp-d
+ mv $@-t $@
+
supermin.d/hostfiles: hostfiles.in Makefile
m4 $(PACKAGELIST_CPP_FLAGS) $< | \
grep -v '^[[:space:]]*$$' | grep -v '^#' > hostfiles-t
diff --git a/appliance/init b/appliance/init
index 3816dfd..e549df0 100755
--- a/appliance/init
+++ b/appliance/init
@@ -184,15 +184,8 @@ else
echo "PS1='><rescue> '" >> $HOME/.bashrc
echo "export TERM PS1" >> $HOME/.bashrc
- echo
- echo "------------------------------------------------------------"
- echo
- echo "Welcome to virt-rescue, the libguestfs rescue shell."
- echo
- echo "Note: The contents of / are the rescue appliance."
- echo "You have to mount the guest's partitions under /sysroot"
- echo "before you can examine them."
- echo
+ cat /etc/issue
+
bash -i
echo
echo "virt-rescue: Syncing the disk now before exiting ..."
diff --git a/appliance/issue b/appliance/issue
new file mode 100644
index 0000000..40b8e17
--- /dev/null
+++ b/appliance/issue
@@ -0,0 +1,9 @@
+
+------------------------------------------------------------
+
+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 can examine them.
+
--
2.6.6
7 years, 11 months
Memory corruption when testing nbdkit python plugin with nbd-tester-client?
by Carl-Daniel Hailfinger
Hi,
has anyone ever run "make check" from nbd against nbdkit with a python
plugin? I usually get segfaults during such a run, and sometimes various
other errors happen before the segfault, suggesting that some memory
corruption is underway.
AFAICS a pure python plugin should not be able to cause memory corruption.
Examples of nbdkit logs for running "make check" or subsets of it from
nbd against nbdkit:
nbdkit -n -f python script=ssd-ftl-wearleveling.py disksize=52428800
nbdkit: python[6]: error: ssd-ftl-wearleveling.py: callback failed: close
nbdkit: python[7]: error: invalid flush request: expecting offset and
length == 0
nbdkit: python[7]: error: write reply: Connection reset by peer
Segmentation fault
nbdkit -n -f python script=ssd-ftl-wearleveling.py disksize=52428800
Fatal Python error: GC object already tracked
Segmentation fault
nbdkit -n -f python script=ssd-ftl-wearleveling.py disksize=52428800
Segmentation fault
nbdkit -n -f python script=ssd-ftl-wearleveling.py disksize=52428800
nbdkit: python[1]: error: invalid flush request: expecting offset and
length == 0
nbdkit: python[1]: error: write reply: Broken pipe
nbdkit: python[3]: error: client sent NBD_OPT_ABORT to abort the connection
nbdkit: python[6]: error: ssd-ftl-wearleveling.py: callback failed: close
Traceback (most recent call last):
File "ssd-ftl-wearleveling.py", line 221, in close
pickle.dump(lbahist, f)
File "/usr/lib/python2.7/pickle.py", line 1370, in dump
Segmentation fault (core dumped)
My close function just dumps the disk image and write access history
with python pickle. It does not have any return statement, and because
of that I seriously doubt that said close function can fail.
I'm now trying to replicate this with example.py. Will report back.
Regards,
Carl-Daniel
8 years
[PATCH 0/2] supermin: use /etc/os-release
by Pino Toscano
Hi,
let's make supermin use /etc/os-release as primary source instead of
the various release files in /etc; apparently distros (e.g. openSUSE)
are starting removing them.
Thanks,
Pino Toscano (2):
Add simple handling of /etc/os-release
Use os-release to detect the distro
src/Makefile.am | 3 +++
src/dpkg.ml | 3 ++-
src/os_release.ml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/os_release.mli | 26 ++++++++++++++++++
src/pacman.ml | 5 ++--
src/rpm.ml | 15 ++++++-----
6 files changed, 121 insertions(+), 9 deletions(-)
create mode 100644 src/os_release.ml
create mode 100644 src/os_release.mli
--
2.7.4
8 years
[PATCH] nbdkit: flags are 32 bits for oldstyle connections
by Carl-Daniel Hailfinger
# HG changeset patch
# User Carl-Daniel Hailfinger <Carl-Daniel.Hailfinger(a)inf.h-brs.de>
# Date 1474903734 -7200
# Mon Sep 26 17:28:54 2016 +0200
# Node ID dbd1ea0a401cedcfa426097a289d852971b14f1e
# Parent d7d5078d08c711032837dcac79a4450226ec2ce5
nbdkit: Fix flags in old-style connection
diff -r d7d5078d08c7 -r dbd1ea0a401c src/connections.c
--- a/src/connections.c Sun Sep 25 05:04:02 2016 +0200
+++ b/src/connections.c Mon Sep 26 17:28:54 2016 +0200
@@ -155,7 +155,7 @@
struct old_handshake handshake;
int64_t r;
uint64_t exportsize;
- uint16_t gflags, eflags;
+ uint32_t flags;
int fl;
r = plugin_get_size (conn);
@@ -169,14 +169,13 @@
exportsize = (uint64_t) r;
conn->exportsize = exportsize;
- gflags = 0;
- eflags = NBD_FLAG_HAS_FLAGS;
+ flags = NBD_FLAG_HAS_FLAGS;
fl = plugin_can_write (conn);
if (fl == -1)
return -1;
if (readonly || !fl) {
- eflags |= NBD_FLAG_READ_ONLY;
+ flags |= NBD_FLAG_READ_ONLY;
conn->readonly = 1;
}
@@ -184,7 +183,7 @@
if (fl == -1)
return -1;
if (fl) {
- eflags |= NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA;
+ flags |= NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA;
conn->can_flush = 1;
}
@@ -192,7 +191,7 @@
if (fl == -1)
return -1;
if (fl) {
- eflags |= NBD_FLAG_ROTATIONAL;
+ flags |= NBD_FLAG_ROTATIONAL;
conn->is_rotational = 1;
}
@@ -200,7 +199,7 @@
if (fl == -1)
return -1;
if (fl) {
- eflags |= NBD_FLAG_SEND_TRIM;
+ flags |= NBD_FLAG_SEND_TRIM;
conn->can_trim = 1;
}
@@ -208,19 +207,17 @@
if (fl == -1)
return -1;
if (fl) {
- eflags |= NBD_FLAG_SEND_MARKNOREMANENCE;
+ flags |= NBD_FLAG_SEND_MARKNOREMANENCE;
conn->can_marknoremanence = 1;
}
- debug ("oldstyle negotiation: flags: global 0x%x export 0x%x",
- gflags, eflags);
+ debug ("oldstyle negotiation: server flags: 0x%x", flags);
memset (&handshake, 0, sizeof handshake);
memcpy (handshake.nbdmagic, "NBDMAGIC", 8);
handshake.version = htobe64 (OLD_VERSION);
handshake.exportsize = htobe64 (exportsize);
- handshake.gflags = htobe16 (gflags);
- handshake.eflags = htobe16 (eflags);
+ handshake.flags = htobe32 (flags);
if (xwrite (conn->sockout, &handshake, sizeof handshake) == -1) {
nbdkit_error ("write: %m");
diff -r d7d5078d08c7 -r dbd1ea0a401c src/protocol.h
--- a/src/protocol.h Sun Sep 25 05:04:02 2016 +0200
+++ b/src/protocol.h Mon Sep 26 17:28:54 2016 +0200
@@ -41,8 +41,7 @@
char nbdmagic[8]; /* "NBDMAGIC" */
uint64_t version; /* OLD_VERSION, in network byte order */
uint64_t exportsize; /* in network byte order */
- uint16_t gflags; /* global flags, in network byte order */
- uint16_t eflags; /* per-export flags, in network byte order */
+ uint32_t flags; /* flags, in network byte order */
char zeroes[124]; /* must be sent as zero bytes */
} __attribute__((packed));
8 years
Extracting files from OVA is bad
by Tomáš Golembiovský
Hi,
recently we (oVirt) have started discussing whether the way virt-v2v
handles import from OVA files is good. And I would be interested in
ideas how it can be improved. It is likely somebody already gave some
thought to this problem.
TL;DR: Extracting the OVA before import is a problem for large VMs (in
sizes of TBs). Can we change something to prevent the extraction and
work directly over OVA?
What we consider a huge shortcoming is the fact that whole OVA is
extracted prior to the import into a temporary directory and processed
afterwards. Under normal situation user can have up to three copies of
the VM on his drive at the end of import:
* original OVA,
* temporary extracted files (will be deleted when virt-v2v terminates,
* converted VM.
This is not a good idea for large VMs that have hunderds of GBs or even
TBs in size. The requirements on the necessary storage space can be
lessened with proper partitioning. I.e. source OVA and converted VM
don't end up on the same drive and TMPDIR is set to put even temporary
files somewhere else. But this is not a general solution. And sometimes
the necessary space may not be available at all.
The question is how to change the import path so that virt-v2v doesn't
have to extract the OVA. I can see the following solutions:
1) Solve it virt-v2v: create a layer for directly accessing the files
in the archive.
2) Solve it in QEMU: create backing method that would allow creating
qemu disk backed by the archive.
3) Solve it on oVirt side: use some FUSE-based tool to provide
access to the archive and pass the OVA to virt-v2v not as a file but
as directory.
Does anyone have any other ideas or suggestions?
Best regards,
Tomas Golembiovsky
--
Tomáš Golembiovský <tgolembi(a)redhat.com>
8 years
[PATCH 0/3] v2v: further bits of Debian/Ubuntu guests supports
by Pino Toscano
Hi,
this series adds a couple bits more in v2v to convert Debian/Ubuntu
(and derived) guests. The series does not complete the support (see
known issues below), but all the patches here should be fit for review
and inclusion. The series does not enable the conversion, yet.
Known issues:
* currently tested with simple local guest images, hence needs testing
with real guests on libvirt/VMware/Xen/VirtualBox/etc (which have
various tools to be removed/tweaked)
* is tweaking the "enterprise-linux" module the correct/wanted way?
should it be renamed to just "linux" then?
* surely something else I'm missing
Thanks,
Pino Toscano (3):
v2v: linux kernels: set type of 'g'
v2v: linux: check also kernel config for modules
v2v: bootloaders: improve detection of Grub2 default method
v2v/linux_bootloaders.ml | 61 ++++++++++++++++++++++++++++++++++--------------
v2v/linux_kernels.ml | 22 +++++++++++++++--
2 files changed, 64 insertions(+), 19 deletions(-)
--
2.7.4
8 years
[PATCH 0/4] Consolidate Checksums as common code
by Pino Toscano
Hi,
this small series moves the OCaml Checksums module from virt-builder to
mllib, adding more features to use it also for v2v.
Thanks,
Pino Toscano (4):
mllib: move Checksums from builder
mllib, builder: add and use Checksums.of_string
mllib: add SHA1 support in Checksums
v2v: -i ova: use Checksums
builder/Makefile.am | 2 --
builder/builder.ml | 6 +++-
builder/checksums.ml | 57 -----------------------------------
builder/checksums.mli | 33 --------------------
builder/simplestreams_parser.ml | 8 +++--
mllib/Makefile.am | 4 ++-
mllib/checksums.ml | 67 +++++++++++++++++++++++++++++++++++++++++
mllib/checksums.mli | 42 ++++++++++++++++++++++++++
v2v/input_ova.ml | 17 +++--------
9 files changed, 128 insertions(+), 108 deletions(-)
delete mode 100644 builder/checksums.ml
delete mode 100644 builder/checksums.mli
create mode 100644 mllib/checksums.ml
create mode 100644 mllib/checksums.mli
--
2.7.4
8 years
[PATCH 1/2] v2v: ova: fix checking of the manifest file
by Tomáš Golembiovský
The regular expression for parsing the manifest line was wrong. There is
a mandatory space between '=' and the hash.
Another problem was that only the first line of the manifest file was
actually processed.
Also added some debugging info and warning to catch problems with
parsing.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/input_ova.ml | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 4f848e2..513fe30 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -133,9 +133,10 @@ object
(* Read any .mf (manifest) files and verify sha1. *)
let mf = find_files exploded ".mf" in
- let rex = Str.regexp "SHA1(\\(.*\\))=\\([0-9a-fA-F]+\\)\r?" in
+ let rex = Str.regexp "SHA1(\\(.*\\))= \\([0-9a-fA-F]+\\)\r?" in
List.iter (
fun mf ->
+ debug "Processing manifest %s" mf;
let mf_folder = Filename.dirname mf in
let chan = open_in mf in
let rec loop () =
@@ -156,6 +157,11 @@ object
debug "sha1 of %s matches expected checksum %s" disk expected
| _::_ -> error (f_"cannot parse output of sha1sum command")
)
+ else
+ warning (f_"Unable to parse line from manifest file. Line is \"%s\"")
+ (String.replace line "\r" "")
+ ;
+ loop ()
in
(try loop () with End_of_file -> ());
close_in chan
--
2.10.0
8 years
[PATCH] customize: Add --append-line.
by Richard W.M. Jones
This appends a single line to a file, with some cleverness
involving guessing the right line endings to use.
Also adds a test.
---
builder/test-virt-builder.sh | 57 +++++++++++++++++++++++++++++++++++-
customize/Makefile.am | 2 ++
customize/append_line.ml | 70 ++++++++++++++++++++++++++++++++++++++++++++
customize/append_line.mli | 20 +++++++++++++
customize/customize_run.ml | 11 +++++++
generator/customize.ml | 34 +++++++++++++++++++++
6 files changed, 193 insertions(+), 1 deletion(-)
create mode 100644 customize/append_line.ml
create mode 100644 customize/append_line.mli
diff --git a/builder/test-virt-builder.sh b/builder/test-virt-builder.sh
index 2a9227b..80dcd98 100755
--- a/builder/test-virt-builder.sh
+++ b/builder/test-virt-builder.sh
@@ -70,6 +70,19 @@ $VG virt-builder phony-fedora \
--delete /Makefile \
--link /etc/foo/bar/baz/foo:/foo \
--link /etc/foo/bar/baz/foo:/foo1:/foo2:/foo3 \
+ --append-line '/etc/append1:hello' \
+ --append-line '/etc/append2:line1' \
+ --append-line '/etc/append2:line2' \
+ --write '/etc/append3:line1' \
+ --append-line '/etc/append3:line2' \
+ --write '/etc/append4:line1
+' \
+ --append-line '/etc/append4:line2' \
+ --touch /etc/append5 \
+ --append-line '/etc/append5:line1' \
+ --write '/etc/append6:
+' \
+ --append-line '/etc/append6:line2' \
--firstboot Makefile --firstboot-command 'echo "hello"' \
--firstboot-install "minicom,inkscape"
@@ -97,6 +110,24 @@ echo -----
# Password
is-file /etc/shadow
cat /etc/shadow | sed -r '/^root:/!d;s,^(root:\\\$6\\\$).*,\\1,g'
+
+echo -----
+# Line appending
+# Note that the guestfish 'cat' command appends a newline
+echo append1:
+cat /etc/append1
+echo append2:
+cat /etc/append2
+echo append3:
+cat /etc/append3
+echo append4:
+cat /etc/append4
+echo append5:
+cat /etc/append5
+echo append6:
+cat /etc/append6
+
+echo -----
EOF
if [ "$(cat test-virt-builder.out)" != "true
@@ -113,7 +144,31 @@ true
/usr/share/zoneinfo/Europe/London
-----
true
-root:\$6\$" ]; then
+root:\$6\$
+-----
+append1:
+hello
+
+append2:
+line1
+line2
+
+append3:
+line1
+line2
+
+append4:
+line1
+line2
+
+append5:
+line1
+
+append6:
+
+line2
+
+-----" ]; then
echo "$0: unexpected output:"
cat test-virt-builder.out
exit 1
diff --git a/customize/Makefile.am b/customize/Makefile.am
index ae37b51..ce5c662 100644
--- a/customize/Makefile.am
+++ b/customize/Makefile.am
@@ -34,6 +34,7 @@ generator_built = \
customize-synopsis.pod
SOURCES_MLI = \
+ append_line.mli \
crypt.mli \
customize_cmdline.mli \
customize_run.mli \
@@ -51,6 +52,7 @@ SOURCES_MLI = \
# This list must be in dependency order.
SOURCES_ML = \
customize_utils.ml \
+ append_line.ml \
crypt.ml \
firstboot.ml \
hostname.ml \
diff --git a/customize/append_line.ml b/customize/append_line.ml
new file mode 100644
index 0000000..0095ff6
--- /dev/null
+++ b/customize/append_line.ml
@@ -0,0 +1,70 @@
+(* virt-customize
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * 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 Common_utils
+open Common_gettext.Gettext
+
+module G = Guestfs
+
+let append_line (g : G.guestfs) root path line =
+ (* The default line ending for this guest type. This is only
+ * used when we don't know anything more about the file.
+ *)
+ let default_newline () =
+ match g#inspect_get_type root with
+ | "windows" -> "\r\n"
+ | _ -> "\n"
+ in
+
+ if not (g#exists path) then (
+ g#write path (line ^ default_newline ())
+ )
+ else (
+ (* Stat the file. We want to know it's a regular file, and
+ * also its size.
+ *)
+ let { G.st_mode = mode; st_size = size } = g#statns path in
+ if Int64.logand mode 0o170000_L <> 0o100000_L then
+ error (f_"append_line: %s is not a file") path;
+
+ (* Guess the line ending from the first part of the file, else
+ * use the default for this guest type.
+ *)
+ let newline =
+ let content = g#pread path 8192 0L in
+ if String.find content "\r\n" >= 0 then "\r\n"
+ else if String.find content "\n" >= 0 then "\n"
+ else default_newline () in
+
+ let line = line ^ newline in
+
+ (* Do we need to append a newline to the existing file? *)
+ let last_chars =
+ let len = String.length newline in
+ if size <= 0L then newline (* empty file ends in virtual newline *)
+ else if size >= Int64.of_int len then
+ g#pread path len (size -^ Int64.of_int len)
+ else
+ g#pread path len 0L in
+ let line =
+ if last_chars = newline then line
+ else newline ^ line in
+
+ (* Finally, append. *)
+ g#write_append path line
+ )
diff --git a/customize/append_line.mli b/customize/append_line.mli
new file mode 100644
index 0000000..11c2da5
--- /dev/null
+++ b/customize/append_line.mli
@@ -0,0 +1,20 @@
+(* virt-customize
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * 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.
+ *)
+
+val append_line : Guestfs.guestfs -> string -> string -> string -> unit
+(** append_line [g root file line] appends a single line to a text file. *)
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index 3e759a2..9ec7b5a 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -25,6 +25,7 @@ open Common_utils
open Customize_utils
open Customize_cmdline
open Password
+open Append_line
let run (g : Guestfs.guestfs) root (ops : ops) =
(* Is the host_cpu compatible with the guest arch? ie. Can we
@@ -204,6 +205,16 @@ exec >>%s 2>&1
(* Perform the remaining customizations in command-line order. *)
List.iter (
function
+ | `AppendLine (path, line) ->
+ (* It's an error if it's not a single line. This is
+ * to prevent incorrect line endings being added to a file.
+ *)
+ if String.contains line '\n' then
+ error (f_"--append-line: line must not contain newline characters. Use the --append-line option multiple times to add several lines.");
+
+ message (f_"Appending line to %s") path;
+ append_line g root path line
+
| `Chmod (mode, path) ->
message (f_"Changing permissions of %s to %s") path mode;
(* If the mode string is octal, add the OCaml prefix for octal values
diff --git a/generator/customize.ml b/generator/customize.ml
index 259cd26..d3a1946 100644
--- a/generator/customize.ml
+++ b/generator/customize.ml
@@ -49,6 +49,40 @@ and op_type =
| SMPoolSelector of string (* pool selector *)
let ops = [
+ { op_name = "append-line";
+ op_type = StringPair "FILE:LINE";
+ op_discrim = "`AppendLine";
+ op_shortdesc = "Append line(s) to the file";
+ op_pod_longdesc = "\
+Append a single line of text to the C<FILE>. If the file does not already
+end with a newline, then one is added before the appended
+line. Also a newline is added to the end of the C<LINE> string
+automatically.
+
+For example (assuming ordinary shell quoting) this command:
+
+ --append-line '/etc/hosts:10.0.0.1 foo'
+
+will add either C<10.0.0.1 foo⏎> or C<⏎10.0.0.1 foo⏎> to
+the file, the latter only if the existing file does not
+already end with a newline.
+
+C<⏎> represents a newline character, which is guessed by
+looking at the existing content of the file, so this command
+does the right thing for files using Unix or Windows line endings.
+It also works for empty or non-existent files.
+
+To insert several lines, use the same option several times:
+
+ --append-line '/etc/hosts:10.0.0.1 foo' \
+ --append-line '/etc/hosts:10.0.0.2 bar'
+
+To insert a blank line before the appended line, do:
+
+ --append-line '/etc/hosts:'
+ --append-line '/etc/hosts:10.0.0.1 foo'";
+ };
+
{ op_name = "chmod";
op_type = StringPair "PERMISSIONS:FILE";
op_discrim = "`Chmod";
--
2.9.3
8 years, 1 month
[PATCH 2/2] v2v: ova: support SHA256 hashes in manifest
by Tomáš Golembiovský
The OVF standard allows the use of SHA256 hashes in the manifest file.
Adding support for this.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/input_ova.ml | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 513fe30..5420c85 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -133,7 +133,7 @@ object
(* Read any .mf (manifest) files and verify sha1. *)
let mf = find_files exploded ".mf" in
- let rex = Str.regexp "SHA1(\\(.*\\))= \\([0-9a-fA-F]+\\)\r?" in
+ let rex = Str.regexp "SHA\\(1\\|256\\)(\\(.*\\))= \\([0-9a-fA-F]+\\)\r?" in
List.iter (
fun mf ->
debug "Processing manifest %s" mf;
@@ -142,20 +142,23 @@ object
let rec loop () =
let line = input_line chan in
if Str.string_match rex line 0 then (
- let disk = Str.matched_group 1 line in
- let expected = Str.matched_group 2 line in
- let cmd = sprintf "sha1sum %s" (quote (mf_folder // disk)) in
+ let sha_num = Str.matched_group 1 line in
+ let disk = Str.matched_group 2 line in
+ let expected = Str.matched_group 3 line in
+ let sha = sprintf "sha%ssum" sha_num in
+ let cmd = sprintf "%s %s" sha (quote (mf_folder // disk)) in
let out = external_command cmd in
match out with
| [] ->
- error (f_"no output from sha1sum command, see previous errors")
+ error (f_"no output from %s command, see previous errors")
+ sha
| [line] ->
let actual, _ = String.split " " line in
if actual <> expected then
- error (f_"checksum of disk %s does not match manifest %s (actual sha1(%s) = %s, expected sha1 (%s) = %s)")
- disk mf disk actual disk expected;
- debug "sha1 of %s matches expected checksum %s" disk expected
- | _::_ -> error (f_"cannot parse output of sha1sum command")
+ error (f_"checksum of disk %s does not match manifest %s (actual sha%s(%s) = %s, expected sha%s (%s) = %s)")
+ disk mf sha_num disk actual sha_num disk expected;
+ debug "%s of %s matches expected checksum %s" sha disk expected
+ | _::_ -> error (f_"cannot parse output of %s command") sha
)
else
warning (f_"Unable to parse line from manifest file. Line is \"%s\"")
--
2.10.0
8 years, 1 month