[PATCH 1/2] mllib: remove spurious check_SCRIPTS from Makefile.am
by Pino Toscano
Not actually useful, as TESTS defines the tests, and it breaks when
oUnit is not available (as it tries to build an oUnit-based unit test).
---
mllib/Makefile.am | 3 ---
1 file changed, 3 deletions(-)
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index 0b43684..e363f27 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -132,9 +132,6 @@ libdir.ml: Makefile
# Tests.
-check_SCRIPTS = \
- common_utils_tests
-
if HAVE_OCAMLOPT
common_utils_tests.cmx: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
common_utils_tests: config.cmx common_gettext.cmx common_utils.cmx common_utils_tests.cmx
--
2.1.0
9 years, 6 months
[PATCH 1/2] mllib: Require OUnit2 for tests.
by Richard W.M. Jones
OUnit2 has an OUnit (v1) compatibility module. Unfortunately it
is rather gravely broken:
https://forge.ocamlcore.org/tracker/?func=detail&aid=1392&group_id=162&at...
Since there is no new release fixing this, it's easier to switch to
using OUnit2 for unit tests.
---
.gitignore | 2 +-
README | 2 +-
mllib/JSON_tests.ml | 56 ++++++++++++++++++++-------------------------
mllib/Makefile.am | 2 ++
mllib/common_utils_tests.ml | 50 +++++++++++++++++-----------------------
5 files changed, 50 insertions(+), 62 deletions(-)
diff --git a/.gitignore b/.gitignore
index d5c6742..2a3cc81 100644
--- a/.gitignore
+++ b/.gitignore
@@ -312,7 +312,7 @@ Makefile.in
/mllib/JSON_tests
/mllib/libdir.ml
/mllib/link.sh
-/mllib/oUnit-anon.cache
+/mllib/oUnit-*
/ocaml/bindtests.bc
/ocaml/bindtests.opt
/ocaml/bindtests.ml
diff --git a/README b/README
index ec08c01..4a5786c 100644
--- a/README
+++ b/README
@@ -242,7 +242,7 @@ The full requirements are described below.
+--------------+-------------+---+-----------------------------------------+
| bash-completion | O | For tab-completion of commands in bash. |
+--------------+-------------+---+-----------------------------------------+
-| ocaml-ounit | | O | For the tests of the common OCaml |
+| ocaml-ounit | 2.0.0 | O | For the tests of the common OCaml |
| | | | modules. |
+--------------+-------------+---+-----------------------------------------+
| ocaml-libvirt| 0.6.1.5 | O | For building the virt-v2v test harness. |
diff --git a/mllib/JSON_tests.ml b/mllib/JSON_tests.ml
index fa37171..281d38e 100644
--- a/mllib/JSON_tests.ml
+++ b/mllib/JSON_tests.ml
@@ -18,19 +18,19 @@
(* This file tests the JSON module. *)
-open OUnit
+open OUnit2
(* Utils. *)
let assert_equal_string = assert_equal ~printer:(fun x -> x)
(* "basic" suite. *)
-let test_empty () =
+let test_empty ctx =
let doc = [] in
assert_equal_string "{}" (JSON.string_of_doc doc);
assert_equal_string "{
}" (JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_string () =
+let test_string ctx =
let doc = [ "test_string", JSON.String "foo"; ] in
assert_equal_string "{ \"test_string\": \"foo\" }"
(JSON.string_of_doc doc);
@@ -39,7 +39,7 @@ let test_string () =
}"
(JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_bool () =
+let test_bool ctx =
let doc = [ "test_true", JSON.Bool true;
"test_false", JSON.Bool false ] in
assert_equal_string
@@ -52,7 +52,7 @@ let test_bool () =
}"
(JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_int () =
+let test_int ctx =
let doc = [ "test_zero", JSON.Int 0;
"test_pos", JSON.Int 5;
"test_neg", JSON.Int (-5);
@@ -71,7 +71,7 @@ let test_int () =
}"
(JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_list () =
+let test_list ctx =
let doc = [ "item", JSON.List [ JSON.String "foo"; JSON.Int 10; JSON.Bool true ] ] in
assert_equal_string
"{ \"item\": [ \"foo\", 10, true ] }"
@@ -86,7 +86,7 @@ let test_list () =
}"
(JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_nested_dict () =
+let test_nested_dict ctx =
let doc = [
"item", JSON.Dict [ "int", JSON.Int 5; "string", JSON.String "foo"; ];
"last", JSON.Int 10;
@@ -104,7 +104,7 @@ let test_nested_dict () =
}"
(JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_nested_nested_dict () =
+let test_nested_nested_dict ctx =
let doc = [
"item", JSON.Dict [ "int", JSON.Int 5;
"item2", JSON.Dict [ "int", JSON.Int 0; ];
@@ -126,7 +126,7 @@ let test_nested_nested_dict () =
}"
(JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_escape () =
+let test_escape ctx =
let doc = [ "test_string", JSON.String "test \" ' \n \b \r \t"; ] in
assert_equal_string "{ \"test_string\": \"test \\\" ' \\n \\b \\r \\t\" }"
(JSON.string_of_doc doc);
@@ -136,7 +136,7 @@ let test_escape () =
(JSON.string_of_doc ~fmt:JSON.Indented doc)
(* "examples" suite. *)
-let test_qemu () =
+let test_qemu ctx =
let doc = [
"file.driver", JSON.String "https";
"file.url", JSON.String "https://libguestfs.org";
@@ -155,7 +155,7 @@ let test_qemu () =
}"
(JSON.string_of_doc ~fmt:JSON.Indented doc)
-let test_builder () =
+let test_builder ctx =
let doc = [
"version", JSON.Int 1;
"sources", JSON.List [
@@ -221,25 +221,19 @@ let test_builder () =
(* Suites declaration. *)
let suite =
- TestList ([
- "basic" >::: [
- "empty" >:: test_empty;
- "string" >:: test_string;
- "bool" >:: test_bool;
- "int" >:: test_int;
- "list" >:: test_list;
- "nested dict" >:: test_nested_dict;
- "nested nested dict" >:: test_nested_nested_dict;
- "escape" >:: test_escape;
- ];
- "examples" >::: [
- "qemu" >:: test_qemu;
- "virt-builder" >:: test_builder;
- ];
- ])
-
-let _ =
- run_test_tt_main suite
+ "mllib JSON" >:::
+ [
+ "basic.empty" >:: test_empty;
+ "basic.string" >:: test_string;
+ "basic.bool" >:: test_bool;
+ "basic.int" >:: test_int;
+ "basic.list" >:: test_list;
+ "basic.nested_dict" >:: test_nested_dict;
+ "basic.nested_nested dict" >:: test_nested_nested_dict;
+ "basic.escape" >:: test_escape;
+ "examples.qemu" >:: test_qemu;
+ "examples.virt-builder" >:: test_builder;
+ ]
let () =
- Printf.fprintf stderr "\n"
+ run_test_tt_main suite
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index d5faf19..0b43684 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -165,6 +165,8 @@ if HAVE_OCAML_PKG_OUNIT
TESTS += common_utils_tests JSON_tests
endif
+CLEANFILES += oUnit-*
+
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check
diff --git a/mllib/common_utils_tests.ml b/mllib/common_utils_tests.ml
index 283e9a1..a06476b 100644
--- a/mllib/common_utils_tests.ml
+++ b/mllib/common_utils_tests.ml
@@ -1,5 +1,5 @@
-(* virt-resize
- * Copyright (C) 2011 Red Hat Inc.
+(* Common utilities for OCaml tools in libguestfs.
+ * Copyright (C) 2011-2015 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
@@ -18,7 +18,7 @@
(* This file tests the Common_utils module. *)
-open OUnit
+open OUnit2
open Common_utils
let prog = "common_utils_tests"
@@ -30,12 +30,12 @@ let assert_equal_int64 = assert_equal ~printer:(fun x -> Int64.to_string x)
let assert_equal_stringlist = assert_equal ~printer:(fun x -> "(" ^ (String.escaped (String.concat "," x)) ^ ")")
(* Test Common_utils.int_of_le32 and Common_utils.le32_of_int. *)
-let test_le32 () =
+let test_le32 ctx =
assert_equal_int64 0x20406080L (int_of_le32 "\x80\x60\x40\x20");
assert_equal_string "\x80\x60\x40\x20" (le32_of_int 0x20406080L)
(* Test Common_utils.parse_size. *)
-let test_parse_resize () =
+let test_parse_resize ctx =
(* For absolute sizes, oldsize is ignored. *)
assert_equal_int64 100_L (parse_resize ~prog 100_L "100b");
assert_equal_int64 100_L (parse_resize ~prog 1000_L "100b");
@@ -74,7 +74,7 @@ let test_parse_resize () =
assert_equal_int64 101100_L (parse_resize ~prog 100000_L "+1.12%")
(* Test Common_utils.human_size. *)
-let test_human_size () =
+let test_human_size ctx =
assert_equal_string "100" (human_size 100_L);
assert_equal_string "-100" (human_size (-100_L));
assert_equal_string "1.0K" (human_size 1024_L);
@@ -87,7 +87,7 @@ let test_human_size () =
assert_equal_string "-3.4G" (human_size (-3650722201_L))
(* Test Common_utils.string_prefix. *)
-let test_string_prefix () =
+let test_string_prefix ctx =
assert_bool "string_prefix,," (string_prefix "" "");
assert_bool "string_prefix,foo," (string_prefix "foo" "");
assert_bool "string_prefix,foo,foo" (string_prefix "foo" "foo");
@@ -95,7 +95,7 @@ let test_string_prefix () =
assert_bool "not (string_prefix,,foo" (not (string_prefix "" "foo"))
(* Test Common_utils.string_suffix. *)
-let test_string_suffix () =
+let test_string_suffix ctx =
assert_bool "string_suffix,," (string_suffix "" "");
assert_bool "string_suffix,foo," (string_suffix "foo" "");
assert_bool "string_suffix,foo,foo" (string_suffix "foo" "foo");
@@ -103,7 +103,7 @@ let test_string_suffix () =
assert_bool "not string_suffix,,foo" (not (string_suffix "" "foo"))
(* Test Common_utils.string_find. *)
-let test_string_find () =
+let test_string_find ctx =
assert_equal_int 0 (string_find "" "");
assert_equal_int 0 (string_find "foo" "");
assert_equal_int 1 (string_find "foo" "o");
@@ -112,7 +112,7 @@ let test_string_find () =
assert_equal_int (-1) (string_find "foobar" "baz")
(* Test Common_utils.string_lines_split. *)
-let test_string_lines_split () =
+let test_string_lines_split ctx =
assert_equal_stringlist [""] (string_lines_split "");
assert_equal_stringlist ["A"] (string_lines_split "A");
assert_equal_stringlist ["A"; ""] (string_lines_split "A\n");
@@ -129,24 +129,16 @@ let test_string_lines_split () =
(* Suites declaration. *)
let suite =
- TestList ([
- "numeric" >::: [
- "le32" >:: test_le32;
- ];
- "sizes" >::: [
- "parse_resize" >:: test_parse_resize;
- "human_size" >:: test_human_size;
- ];
- "strings" >::: [
- "prefix" >:: test_string_prefix;
- "suffix" >:: test_string_suffix;
- "find" >:: test_string_find;
- "string_lines_split" >:: test_string_lines_split;
- ];
- ])
-
-let _ =
- run_test_tt_main suite
+ "mllib Common_utils" >:::
+ [
+ "numeric.le32" >:: test_le32;
+ "sizes.parse_resize" >:: test_parse_resize;
+ "sizes.human_size" >:: test_human_size;
+ "strings.prefix" >:: test_string_prefix;
+ "strings.suffix" >:: test_string_suffix;
+ "strings.find" >:: test_string_find;
+ "strings.string_lines_split" >:: test_string_lines_split;
+ ]
let () =
- Printf.fprintf stderr "\n"
+ run_test_tt_main suite
--
2.3.1
9 years, 6 months
[PATCH 1/3] builder: move gpg status parsing within import_keyfile
by Pino Toscano
Parse the gpg status output directly within import_keyfile, returning
just the key fingerprint.
Just code motion, no actual behaviour changes.
---
builder/sigchecker.ml | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/builder/sigchecker.ml b/builder/sigchecker.ml
index 0c292fb..a1a4220 100644
--- a/builder/sigchecker.ml
+++ b/builder/sigchecker.ml
@@ -43,7 +43,17 @@ let import_keyfile ~gpg ~gpghome ~verbose keyfile =
let r = Sys.command cmd in
if r <> 0 then
error (f_"could not import public key\nUse the '-v' option and look for earlier error messages.");
- status_file
+ let status = read_whole_file status_file in
+ let status = string_nsplit "\n" status in
+ let fingerprint = ref "" in
+ List.iter (
+ fun line ->
+ let line = string_nsplit " " line in
+ match line with
+ | "[GNUPG:]" :: "IMPORT_OK" :: _ :: fp :: _ -> fingerprint := fp
+ | _ -> ()
+ ) status;
+ !fingerprint
let rec create ~verbose ~gpg ~gpgkey ~check_signature =
(* Create a temporary directory for gnupg. *)
@@ -69,18 +79,7 @@ let rec create ~verbose ~gpg ~gpgkey ~check_signature =
| No_Key ->
assert false
| KeyFile kf ->
- let status_file = import_keyfile gpg tmpdir verbose kf in
- let status = read_whole_file status_file in
- let status = string_nsplit "\n" status in
- let fingerprint = ref "" in
- List.iter (
- fun line ->
- let line = string_nsplit " " line in
- match line with
- | "[GNUPG:]" :: "IMPORT_OK" :: _ :: fp :: _ -> fingerprint := fp
- | _ -> ()
- ) status;
- !fingerprint
+ import_keyfile gpg tmpdir verbose kf
| Fingerprint fp ->
let filename = Filename.temp_file "vbpubkey" ".asc" in
unlink_on_exit filename;
--
2.1.0
9 years, 6 months
Re: [Libguestfs] VM import to oVirt
by Richard W.M. Jones
On Mon, May 11, 2015 at 09:35:59AM -0400, Tim Macy wrote:
> On Mon, May 11, 2015 at 9:31 AM, Richard W.M. Jones <rjones(a)redhat.com> wrote:
> > On Mon, May 11, 2015 at 09:27:03AM -0400, Tim Macy wrote:
[...]
> > > After finding the bug on this issue -
> > > https://bugzilla.redhat.com/show_bug.cgi?id=1213701 I would like to
> > > give virt-v2v-1.28.1-1.25.el7.x86_64
> > > a try, but cant find these packages anywhere. Do you have a location
> > where
> > > I can pull these packages from?
> >
> > No, but you can just hack on the OVF after virt-v2v has written it --
> > see comments 17 (easy) or comment 8 (harder but more "correct" fix).
>
> Thanks for the prompt response! How does one edit the OVF?
I'm CCing this on the libguestfs mailing list so others can use it.
Assuming you're using '-o rhev' mode, which I guess you must be, you
will need to look in the Export Storage Domain directory after the
run. There will be a directory in there called something like
//esd_server/mountpoint/<UUID>/master/vms/<VM_UUID>/
which will contain the OVF file (<VM_UUID>.ovf)
And that is the file you can edit. Make sure you keep the file
ownership as 36:36 (I think vdsm:vdsm), else oVirt won't be able to
read the file after you have edited it.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
9 years, 6 months
[PATCH 00/10] virt-resize: add support for resizing MBR logical partitions
by Chen Hanxiao
In current virt-resize, only primary partitions(including
extended partition) are supported. They are collected in an
array for resize operations. Logical partitions are not
supported.
This series add support for resizing logical partitions.
Original patches by Hu Tao at:
https://www.redhat.com/archives/libguestfs/2014-October/msg00238.html
Chen Hanxiao (10):
resize: don't filter out logical partitions
resize: don't count new size of logical and extended partition
resize: caculate the size of logical partitions
resize: update calculate_target_partitions for logical partitions
resize: calculate location of the partitions of logical partition
resize: skip overlap check for logical partitions
resize: parted logical partitions
resize: caculate surplus for resize extended partition
resize: support resize extended partition
resize: test: add support for resizing extended and logical partitions
resize/resize.ml | 144 ++++++++++++++++++++++++++++++++++-----------
resize/test-virt-resize.pl | 32 ++--------
2 files changed, 114 insertions(+), 62 deletions(-)
--
2.1.0
9 years, 6 months
[libguestfs] conversion issue on NFS shares
by Artur Krzywdzinski
Hi
T'm trying to convert XEN virtual machine image into raw. Source file is on
NFS export and destination is also on nfs export. (both exports are mounted
on migration servers RW access). I'm getting permission denied.
I have RW access to both exports - I can create, delete objects on both
exports from migration server. But when I copy img file onto migration
server local filesystem, conversion works, from local fs to nfs export.
However when I tried to run guestfish against file located on NFS - I'm
getting the same erro - Permission denied .
[root@kvm01 export]# virt-v2v -i disk migr01.img -o local -os /tmp
[ 0.0] Opening the source -i disk migr01.img
[ 0.0] Creating an overlay to protect the source from being modified
[ 0.0] Opening the overlay
virt-v2v: error: libguestfs 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: internal error: process exited while
connecting to monitor: 2014-10-16T14:25:13.729270Z qemu-kvm: -drive
file=/var/tmp/v2vovl60e1a0.qcow2,if=none,id=drive-scsi0-0-0-0,format=qcow2,cache=unsafe,discard=unmap:
could not open disk image /var/tmp/v2vovl60e1a0.qcow2: Could not open
backing file: Could not open '/mnt/xen01/export/migr01.img': Permission
denied
[code=1 domain=10]
If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:
virt-v2v -v -x [...]
[root@kvm01 export]#
--
Artur Krzywdzinski
9 years, 6 months
[PATCH] build: remove unreadable files after filtering
by Pino Toscano
Move the removal of the files which don't exist or cannot be read, doing
it after the filtering with excludefiles and hostfiles files.
This avoid stat'ing files which will be excluded later anyway, hence
reducing the I/O during a supermin build phase.
---
src/build.ml | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/build.ml b/src/build.ml
index b9b44ac..d7d0781 100644
--- a/src/build.ml
+++ b/src/build.ml
@@ -125,22 +125,6 @@ let rec build debug
if debug >= 1 then
printf "supermin: build: %d files\n%!" (List.length files);
- (* Remove files from the list which don't exist on the host or are
- * unreadable to us.
- *)
- let files =
- List.filter (
- fun file ->
- try ignore (lstat file.ft_source_path); true
- with Unix_error _ ->
- try ignore (lstat file.ft_path); true
- with Unix_error _ -> false
- ) files in
-
- if debug >= 1 then
- printf "supermin: build: %d files, after removing unreadable files\n%!"
- (List.length files);
-
(* Remove excludefiles from the list. Notes: (1) The current
* implementation does not apply excludefiles to the base image. (2)
* The current implementation does not apply excludefiles to the
@@ -185,6 +169,22 @@ let rec build debug
printf "supermin: build: %d files, after adding hostfiles\n%!"
(List.length files);
+ (* Remove files from the list which don't exist on the host or are
+ * unreadable to us.
+ *)
+ let files =
+ List.filter (
+ fun file ->
+ try ignore (lstat file.ft_source_path); true
+ with Unix_error _ ->
+ try ignore (lstat file.ft_path); true
+ with Unix_error _ -> false
+ ) files in
+
+ if debug >= 1 then
+ printf "supermin: build: %d files, after removing unreadable files\n%!"
+ (List.length files);
+
(* Difficult to explain what this does. See comment below. *)
let files = munge files in
--
2.1.0
9 years, 6 months