[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v8 11/42] mllib, v2v: Split out OCaml utils bindings ‘common/mlutils ’.



Create a module ‘C_utils’ containing functions like ‘drive_name’ and
‘shell_unquote’ which come from the C utilities.

The new directory ‘common/mlutils’ also contains the ‘Unix_utils’
wrappers around POSIX functions missing from the OCaml stdlib.
---
 .gitignore                                  |   3 +
 Makefile.am                                 |  24 ++---
 builder/Makefile.am                         |   6 +-
 common/mlutils/Makefile.am                  | 154 ++++++++++++++++++++++++++++
 v2v/utils-c.c => common/mlutils/c_utils-c.c |   6 +-
 common/mlutils/c_utils.ml                   |  26 +++++
 common/mlutils/c_utils.mli                  |  30 ++++++
 common/mlutils/c_utils_unit_tests.ml        |  81 +++++++++++++++
 common/mlutils/dummy.c                      |   2 +
 {mllib => common/mlutils}/unix_utils-c.c    |   0
 {mllib => common/mlutils}/unix_utils.ml     |   0
 {mllib => common/mlutils}/unix_utils.mli    |   0
 configure.ac                                |   1 +
 customize/Makefile.am                       |   5 +-
 dib/Makefile.am                             |   5 +-
 docs/C_SOURCE_FILES                         |   5 +-
 docs/guestfs-hacking.pod                    |   5 +
 get-kernel/Makefile.am                      |   5 +-
 mllib/Makefile.am                           |   8 +-
 resize/Makefile.am                          |   5 +-
 sparsify/Makefile.am                        |   5 +-
 sysprep/Makefile.am                         |   5 +-
 v2v/Makefile.am                             |  12 ++-
 v2v/convert_linux.ml                        |   3 +-
 v2v/create_libvirt_xml.ml                   |   1 +
 v2v/parse_libvirt_xml.ml                    |   3 +-
 v2v/utils.ml                                |   5 -
 v2v/utils.mli                               |  11 --
 v2v/v2v.ml                                  |   1 +
 v2v/v2v_unit_tests.ml                       |  46 ---------
 30 files changed, 366 insertions(+), 97 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5cf0d8dbc..eadeda311 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,6 +129,9 @@ Makefile.in
 /common/mlstdutils/libdir.ml
 /common/mlstdutils/oUnit-*
 /common/mlstdutils/std_utils_tests
+/common/mlutils/.depend
+/common/mlutils/c_utils_unit_tests
+/common/mlutils/oUnit-*
 /common/mlvisit/.depend
 /common/mlvisit/visit_tests
 /common/mlxml/.depend
diff --git a/Makefile.am b/Makefile.am
index b14ce4813..9122d44ac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -155,18 +155,18 @@ SUBDIRS += csharp
 # OCaml tools.  Note 'common/ml*', 'mllib' and 'customize' contain
 # shared code used by other OCaml tools, so these must come first.
 if HAVE_OCAML
-SUBDIRS += \
-	common/mlprogress \
-	common/mlvisit \
-	common/mlxml \
-	mllib \
-	customize \
-	builder builder/templates \
-	get-kernel \
-	resize \
-	sparsify \
-	sysprep \
-	v2v
+SUBDIRS += common/mlutils
+SUBDIRS += common/mlprogress
+SUBDIRS += common/mlvisit
+SUBDIRS += common/mlxml
+SUBDIRS += mllib
+SUBDIRS += customize
+SUBDIRS += builder builder/templates
+SUBDIRS += get-kernel
+SUBDIRS += resize
+SUBDIRS += sparsify
+SUBDIRS += sysprep
+SUBDIRS += v2v
 if HAVE_OCAML_PKG_LIBVIRT
 SUBDIRS += v2v/test-harness
 endif
diff --git a/builder/Makefile.am b/builder/Makefile.am
index 5f0606ca4..09ae4ae3c 100644
--- a/builder/Makefile.am
+++ b/builder/Makefile.am
@@ -125,6 +125,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/gnulib/lib/.libs \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlstdutils \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/mllib \
 	-I $(top_builddir)/customize
 OCAMLPACKAGES_TESTS =
@@ -157,6 +158,7 @@ endif
 OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	customize.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
@@ -164,6 +166,7 @@ OCAMLLINKFLAGS = \
 virt_builder_DEPENDENCIES = \
 	$(OBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	../customize/customize.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
@@ -236,6 +239,7 @@ endif
 yajl_tests_DEPENDENCIES = \
 	$(yajl_tests_THEOBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	../customize/customize.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
@@ -307,7 +311,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/mlstdutils -I $(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/mlstdutils -I $(abs_top_builddir)/mlutils -I $(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/common/mlutils/Makefile.am b/common/mlutils/Makefile.am
new file mode 100644
index 000000000..684f0ce33
--- /dev/null
+++ b/common/mlutils/Makefile.am
@@ -0,0 +1,154 @@
+# libguestfs OCaml tools common code
+# Copyright (C) 2011-2017 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.
+
+include $(top_srcdir)/subdir-rules.mk
+
+EXTRA_DIST = \
+	$(SOURCES_MLI) \
+	$(SOURCES_ML) \
+	$(SOURCES_C)
+
+SOURCES_MLI = \
+	c_utils.mli \
+	unix_utils.mli
+
+SOURCES_ML = \
+	c_utils.ml \
+	unix_utils.ml
+
+SOURCES_C = \
+	c_utils-c.c \
+	unix_utils-c.c
+
+if HAVE_OCAML
+
+# We pretend that we're building a C library.  automake handles the
+# compilation of the C sources for us.  At the end we take the C
+# objects and OCaml objects and link them into the OCaml library.
+# This C library is never used.
+
+noinst_LIBRARIES = libmlcutils.a
+
+if !HAVE_OCAMLOPT
+MLCUTILS_CMA = mlcutils.cma
+else
+MLCUTILS_CMA = mlcutils.cmxa
+endif
+
+noinst_DATA = $(MLCUTILS_CMA)
+
+# lib/guestfs-internal-all.h header is used here.  It probably
+# shouldn't be located under lib.  XXX
+libmlcutils_a_SOURCES = $(SOURCES_C)
+libmlcutils_a_CPPFLAGS = \
+	-I. \
+	-I$(top_builddir) \
+	-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
+	-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
+	-I$(top_srcdir)/lib -I$(top_builddir)/lib \
+	-I$(shell $(OCAMLC) -where)
+libmlcutils_a_CFLAGS = \
+	$(WARN_CFLAGS) $(WERROR_CFLAGS) \
+	-fPIC
+
+BOBJECTS = $(SOURCES_ML:.ml=.cmo)
+XOBJECTS = $(BOBJECTS:.cmo=.cmx)
+
+OCAMLPACKAGES = \
+	-package str,unix \
+	-I $(top_builddir)/gnulib/lib/.libs \
+	-I $(top_builddir)/common/utils/.libs \
+	-I $(top_builddir)/common/mlstdutils \
+	-I $(builddir)
+
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+
+if !HAVE_OCAMLOPT
+OBJECTS = $(BOBJECTS)
+else
+OBJECTS = $(XOBJECTS)
+endif
+
+libmlcutils_a_DEPENDENCIES = $(OBJECTS)
+
+$(MLCUTILS_CMA): $(OBJECTS) libmlcutils.a
+	$(OCAMLFIND) mklib $(OCAMLPACKAGES) \
+	    $(OBJECTS) $(libmlcutils_a_OBJECTS) \
+	    -cclib -lutils \
+	    -o mlcutils
+
+# Tests.
+
+TESTS =
+check_PROGRAMS =
+
+if HAVE_OCAML_PKG_OUNIT
+TESTS += c_utils_unit_tests
+check_PROGRAMS += c_utils_unit_tests
+endif
+
+c_utils_unit_tests_BOBJECTS = \
+	c_utils_unit_tests.cmo
+c_utils_unit_tests_XOBJECTS = $(c_utils_unit_tests_BOBJECTS:.cmo=.cmx)
+
+c_utils_unit_tests_SOURCES = dummy.c
+c_utils_unit_tests_CPPFLAGS = $(libmlcutils_a_CPPFLAGS)
+c_utils_unit_tests_CFLAGS = $(libmlcutils_a_CFLAGS)
+
+if !HAVE_OCAMLOPT
+# Can't call this c_utils_unit_tests_OBJECTS because automake gets confused.
+c_utils_unit_tests_THEOBJECTS = $(c_utils_unit_tests_BOBJECTS)
+c_utils_unit_tests.cmo: OCAMLPACKAGES += -package oUnit
+else
+c_utils_unit_tests_THEOBJECTS = $(c_utils_unit_tests_XOBJECTS)
+c_utils_unit_tests.cmx: OCAMLPACKAGES += -package oUnit
+endif
+
+OCAMLLINKFLAGS = \
+	mlstdutils.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
+	$(LINK_CUSTOM_OCAMLC_ONLY)
+
+c_utils_unit_tests_DEPENDENCIES = \
+	$(c_utils_unit_tests_THEOBJECTS) \
+	../mlstdutils/mlstdutils.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
+	$(top_srcdir)/ocaml-link.sh
+c_utils_unit_tests_LINK = \
+	$(top_srcdir)/ocaml-link.sh -cclib '-lutils -lgnu' -- \
+	  $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) \
+	  $(OCAMLPACKAGES) -package oUnit \
+	  $(OCAMLLINKFLAGS) \
+	  $(c_utils_unit_tests_THEOBJECTS) -o $@
+
+# Dependencies.
+depend: .depend
+
+.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
+	rm -f $@ $ -t
+	$(OCAMLFIND) ocamldep -I $(abs_srcdir) $^ | \
+	  $(SED) 's/ *$$//' | \
+	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
+	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
+	  sort > $ -t
+	mv $ -t $@
+
+-include .depend
+
+endif
+
+.PHONY: depend docs
diff --git a/v2v/utils-c.c b/common/mlutils/c_utils-c.c
similarity index 93%
rename from v2v/utils-c.c
rename to common/mlutils/c_utils-c.c
index 69b070fc2..32edbd4a7 100644
--- a/v2v/utils-c.c
+++ b/common/mlutils/c_utils-c.c
@@ -41,7 +41,7 @@ extern void unix_error (int errcode, char * cmdname, value arg) Noreturn;
 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
 
 value
-v2v_utils_drive_name (value indexv)
+guestfs_int_mlutils_drive_name (value indexv)
 {
   CAMLparam1 (indexv);
   CAMLlocal1 (namev);
@@ -54,7 +54,7 @@ v2v_utils_drive_name (value indexv)
 }
 
 value
-v2v_utils_drive_index (value strv)
+guestfs_int_mlutils_drive_index (value strv)
 {
   CAMLparam1 (strv);
   ssize_t r;
@@ -67,7 +67,7 @@ v2v_utils_drive_index (value strv)
 }
 
 value
-v2v_utils_shell_unquote (value strv)
+guestfs_int_mlutils_shell_unquote (value strv)
 {
   CAMLparam1 (strv);
   CAMLlocal1 (retv);
diff --git a/common/mlutils/c_utils.ml b/common/mlutils/c_utils.ml
new file mode 100644
index 000000000..e4263962d
--- /dev/null
+++ b/common/mlutils/c_utils.ml
@@ -0,0 +1,26 @@
+(* virt-v2v
+ * Copyright (C) 2009-2017 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.
+ *)
+
+(* OCaml bindings for C utility functions in [common/utils]. *)
+
+open Printf
+
+external drive_name : int -> string = "guestfs_int_mlutils_drive_name"
+external drive_index : string -> int = "guestfs_int_mlutils_drive_index"
+
+external shell_unquote : string -> string = "guestfs_int_mlutils_shell_unquote"
diff --git a/common/mlutils/c_utils.mli b/common/mlutils/c_utils.mli
new file mode 100644
index 000000000..7824f9658
--- /dev/null
+++ b/common/mlutils/c_utils.mli
@@ -0,0 +1,30 @@
+(* virt-v2v
+ * Copyright (C) 2009-2017 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.
+ *)
+
+(** OCaml bindings for C utility functions in [common/utils]. *)
+
+val drive_name : int -> string
+val drive_index : string -> int
+
+val shell_unquote : string -> string
+(** If the string looks like a shell quoted string, then attempt to
+    unquote it.
+
+    This is just intended to deal with quoting in configuration files
+    (like ones under /etc/sysconfig), and it doesn't deal with some
+    situations such as $variable interpolation. *)
diff --git a/common/mlutils/c_utils_unit_tests.ml b/common/mlutils/c_utils_unit_tests.ml
new file mode 100644
index 000000000..8840d6620
--- /dev/null
+++ b/common/mlutils/c_utils_unit_tests.ml
@@ -0,0 +1,81 @@
+(* virt-v2v
+ * Copyright (C) 2011-2017 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.
+ *)
+
+(* This file tests individual OCaml bindings for C utility functions. *)
+
+open Printf
+
+open OUnit2
+
+open Std_utils
+open C_utils
+
+let test_drive_name ctx =
+  let printer = identity in
+  assert_equal ~printer "a" (drive_name 0);
+  assert_equal ~printer "z" (drive_name 25);
+  assert_equal ~printer "aa" (drive_name 26);
+  assert_equal ~printer "ab" (drive_name 27);
+  assert_equal ~printer "az" (drive_name 51);
+  assert_equal ~printer "ba" (drive_name 52);
+  assert_equal ~printer "zz" (drive_name 701);
+  assert_equal ~printer "aaa" (drive_name 702);
+  assert_equal ~printer "zzz" (drive_name 18277)
+
+let test_drive_index ctx =
+  let printer = string_of_int in
+  assert_equal ~printer 0 (drive_index "a");
+  assert_equal ~printer 25 (drive_index "z");
+  assert_equal ~printer 26 (drive_index "aa");
+  assert_equal ~printer 27 (drive_index "ab");
+  assert_equal ~printer 51 (drive_index "az");
+  assert_equal ~printer 52 (drive_index "ba");
+  assert_equal ~printer 701 (drive_index "zz");
+  assert_equal ~printer 702 (drive_index "aaa");
+  assert_equal ~printer 18277 (drive_index "zzz");
+  let exn = Invalid_argument "drive_index: invalid parameter" in
+  assert_raises exn (fun () -> drive_index "");
+  assert_raises exn (fun () -> drive_index "abc123");
+  assert_raises exn (fun () -> drive_index "123");
+  assert_raises exn (fun () -> drive_index "Z");
+  assert_raises exn (fun () -> drive_index "aB")
+
+let test_shell_unquote ctx =
+  let printer = identity in
+  assert_equal ~printer "a" (shell_unquote "a");
+  assert_equal ~printer "b" (shell_unquote "'b'");
+  assert_equal ~printer "c" (shell_unquote "\"c\"");
+  assert_equal ~printer "dd" (shell_unquote "\"dd\"");
+  assert_equal ~printer "e\\e" (shell_unquote "\"e\\\\e\"");
+  assert_equal ~printer "f\\" (shell_unquote "\"f\\\\\"");
+  assert_equal ~printer "\\g" (shell_unquote "\"\\\\g\"");
+  assert_equal ~printer "h\\-h" (shell_unquote "\"h\\-h\"");
+  assert_equal ~printer "i`" (shell_unquote "\"i\\`\"");
+  assert_equal ~printer "j\"" (shell_unquote "\"j\\\"\"")
+
+(* Suites declaration. *)
+let suite =
+  "C_utils" >:::
+    [
+      "C_utils.drive_name" >:: test_drive_name;
+      "C_utils.drive_index" >:: test_drive_index;
+      "C_utils.shell_unquote" >:: test_shell_unquote;
+    ]
+
+let () =
+  run_test_tt_main suite
diff --git a/common/mlutils/dummy.c b/common/mlutils/dummy.c
new file mode 100644
index 000000000..ebab6198c
--- /dev/null
+++ b/common/mlutils/dummy.c
@@ -0,0 +1,2 @@
+/* Dummy source, to be used for OCaml-based tools with no C sources. */
+enum { foo = 1 };
diff --git a/mllib/unix_utils-c.c b/common/mlutils/unix_utils-c.c
similarity index 100%
rename from mllib/unix_utils-c.c
rename to common/mlutils/unix_utils-c.c
diff --git a/mllib/unix_utils.ml b/common/mlutils/unix_utils.ml
similarity index 100%
rename from mllib/unix_utils.ml
rename to common/mlutils/unix_utils.ml
diff --git a/mllib/unix_utils.mli b/common/mlutils/unix_utils.mli
similarity index 100%
rename from mllib/unix_utils.mli
rename to common/mlutils/unix_utils.mli
diff --git a/configure.ac b/configure.ac
index 8c782368f..7daf23162 100644
--- a/configure.ac
+++ b/configure.ac
@@ -188,6 +188,7 @@ AC_CONFIG_FILES([Makefile
                  common/mlprogress/Makefile
                  common/mlstdutils/Makefile
                  common/mlstdutils/guestfs_config.ml
+                 common/mlutils/Makefile
                  common/mlvisit/Makefile
                  common/mlxml/Makefile
                  common/options/Makefile
diff --git a/customize/Makefile.am b/customize/Makefile.am
index 674134b70..fb8946ce1 100644
--- a/customize/Makefile.am
+++ b/customize/Makefile.am
@@ -124,6 +124,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/gnulib/lib/.libs \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlstdutils \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/mllib \
 	-I $(builddir)
 if HAVE_OCAML_PKG_GETTEXT
@@ -153,6 +154,7 @@ endif
 OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	customize.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
@@ -172,6 +174,7 @@ virt_customize_DEPENDENCIES = \
 	$(top_srcdir)/ocaml-link.sh \
 	$(CUSTOMIZE_THEOBJECTS) \
 	$(CUSTOMIZE_CMA) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE)
 virt_customize_LINK = \
 	$(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \
@@ -304,7 +307,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/mllib $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/mllib $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/dib/Makefile.am b/dib/Makefile.am
index b10fa94c9..cc1287b35 100644
--- a/dib/Makefile.am
+++ b/dib/Makefile.am
@@ -80,6 +80,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/gnulib/lib/.libs \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlstdutils \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/mllib
 if HAVE_OCAML_PKG_GETTEXT
 OCAMLPACKAGES += -package gettext-stub
@@ -103,12 +104,14 @@ endif
 OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
 
 virt_dib_DEPENDENCIES = \
 	$(OBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
 virt_dib_LINK = \
@@ -144,7 +147,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/mllib $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/mllib $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
index 1f0758106..6bf0c3544 100644
--- a/docs/C_SOURCE_FILES
+++ b/docs/C_SOURCE_FILES
@@ -17,6 +17,9 @@ common/miniexpect/miniexpect.c
 common/miniexpect/miniexpect.h
 common/mlprogress/progress-c.c
 common/mlstdutils/dummy.c
+common/mlutils/c_utils-c.c
+common/mlutils/dummy.c
+common/mlutils/unix_utils-c.c
 common/mlvisit/dummy.c
 common/mlvisit/visit-c.c
 common/mlxml/xml-c.c
@@ -344,7 +347,6 @@ make-fs/make-fs.c
 mllib/common_utils-c.c
 mllib/dummy.c
 mllib/getopt-c.c
-mllib/unix_utils-c.c
 mllib/uri-c.c
 ocaml/guestfs-c-actions.c
 ocaml/guestfs-c-errnos.c
@@ -410,4 +412,3 @@ utils/qemu-speed-test/qemu-speed-test.c
 v2v/libvirt_utils-c.c
 v2v/qemuopts-c.c
 v2v/test-harness/dummy.c
-v2v/utils-c.c
diff --git a/docs/guestfs-hacking.pod b/docs/guestfs-hacking.pod
index fa00a9ab6..bfbe4526d 100644
--- a/docs/guestfs-hacking.pod
+++ b/docs/guestfs-hacking.pod
@@ -108,6 +108,11 @@ A library of pure OCaml utility functions used in many places.
 
 OCaml bindings for the progress bar functions (see F<common/progress>).
 
+=item F<common/mlutils>
+
+OCaml bindings for C functions in C<common/utils>, and some POSIX
+bindings which are missing from the OCaml stdlib.
+
 =item F<common/mlvisit>
 
 OCaml bindings for the visit functions (see F<common/visit>).
diff --git a/get-kernel/Makefile.am b/get-kernel/Makefile.am
index c6454d7a4..6cc7ec2fb 100644
--- a/get-kernel/Makefile.am
+++ b/get-kernel/Makefile.am
@@ -64,6 +64,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/gnulib/lib/.libs \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlstdutils \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/mllib
 if HAVE_OCAML_PKG_GETTEXT
 OCAMLPACKAGES += -package gettext-stub
@@ -87,12 +88,14 @@ endif
 OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
 
 virt_get_kernel_DEPENDENCIES = \
 	$(OBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
 virt_get_kernel_LINK = \
@@ -127,7 +130,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/mllib $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/mllib $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index 5f6f7fa85..ad86ac58e 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -28,7 +28,6 @@ EXTRA_DIST = \
 
 SOURCES_MLI = \
 	checksums.mli \
-	unix_utils.mli \
 	common_utils.mli \
 	curl.mli \
 	getopt.mli \
@@ -43,7 +42,6 @@ SOURCES_ML = \
 	$(OCAML_BYTES_COMPAT_ML) \
 	common_gettext.ml \
 	getopt.ml \
-	unix_utils.ml \
 	common_utils.ml \
 	URI.ml \
 	planner.ml \
@@ -60,7 +58,6 @@ SOURCES_C = \
 	../common/options/uri.c \
 	common_utils-c.c \
 	getopt-c.c \
-	unix_utils-c.c \
 	uri-c.c
 
 if HAVE_OCAML
@@ -90,7 +87,8 @@ libmllib_a_CPPFLAGS = \
 	-I$(top_srcdir)/lib \
 	-I$(top_srcdir)/common/options \
 	-I$(top_srcdir)/common/mlxml \
-	-I$(top_srcdir)/common/mlstdutils
+	-I$(top_srcdir)/common/mlstdutils \
+	-I$(top_srcdir)/common/mlutils
 libmllib_a_CFLAGS = \
 	$(WARN_CFLAGS) $(WERROR_CFLAGS) \
 	$(LIBVIRT_CFLAGS) $(LIBXML2_CFLAGS) \
@@ -110,6 +108,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlxml \
 	-I $(top_builddir)/common/mlstdutils \
+	-I $(top_builddir)/common/mlutils \
 	-I $(builddir)
 OCAMLPACKAGES_TESTS = $(MLLIB_CMA)
 if HAVE_OCAML_PKG_GETTEXT
@@ -189,6 +188,7 @@ endif
 
 OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
 
diff --git a/resize/Makefile.am b/resize/Makefile.am
index 3707d73b4..af65acbf5 100644
--- a/resize/Makefile.am
+++ b/resize/Makefile.am
@@ -63,6 +63,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlstdutils \
 	-I $(top_builddir)/common/mlprogress \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/mllib
 if HAVE_OCAML_PKG_GETTEXT
 OCAMLPACKAGES += -package gettext-stub
@@ -88,12 +89,14 @@ OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
 	mlprogress.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
 
 virt_resize_DEPENDENCIES = \
 	$(OBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
 virt_resize_LINK = \
@@ -138,7 +141,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/mlstdutils -I $(abs_top_builddir)/mllib $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/mllib $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
index a1395ccbd..c8062f353 100644
--- a/sparsify/Makefile.am
+++ b/sparsify/Makefile.am
@@ -68,6 +68,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlstdutils \
 	-I $(top_builddir)/common/mlprogress \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/mllib
 if HAVE_OCAML_PKG_GETTEXT
 OCAMLPACKAGES += -package gettext-stub
@@ -93,12 +94,14 @@ OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
 	mlprogress.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
 
 virt_sparsify_DEPENDENCIES = \
 	$(OBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
 virt_sparsify_LINK = \
@@ -145,7 +148,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/mllib $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/mllib $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 834baee6a..f42722453 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -114,6 +114,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/visit/.libs \
 	-I $(top_builddir)/common/mlstdutils \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/common/mlvisit \
 	-I $(top_builddir)/mllib \
 	-I $(top_builddir)/customize
@@ -142,6 +143,7 @@ endif
 OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	mlvisit.$(MLARCHIVE) \
 	customize.$(MLARCHIVE) \
@@ -150,6 +152,7 @@ OCAMLLINKFLAGS = \
 virt_sysprep_DEPENDENCIES = \
 	$(OBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	../customize/customize.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
@@ -218,7 +221,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/mlstdutils -I $(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 8a831a700..a4f4300cb 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -111,8 +111,7 @@ SOURCES_ML = \
 
 SOURCES_C = \
 	libvirt_utils-c.c \
-	qemuopts-c.c \
-	utils-c.c
+	qemuopts-c.c
 
 if HAVE_OCAML
 
@@ -147,6 +146,7 @@ OCAMLPACKAGES = \
 	-I $(top_builddir)/gnulib/lib/.libs \
 	-I $(top_builddir)/ocaml \
 	-I $(top_builddir)/common/mlstdutils \
+	-I $(top_builddir)/common/mlutils \
 	-I $(top_builddir)/common/mlxml \
 	-I $(top_builddir)/mllib \
 	-I $(top_builddir)/customize
@@ -174,6 +174,7 @@ OCAMLLINKFLAGS = \
 	mlstdutils.$(MLARCHIVE) \
 	mlguestfs.$(MLARCHIVE) \
 	mlxml.$(MLARCHIVE) \
+	mlcutils.$(MLARCHIVE) \
 	mllib.$(MLARCHIVE) \
 	$(LINK_CUSTOM_OCAMLC_ONLY)
 
@@ -184,8 +185,7 @@ virt_v2v_LINK = \
 	  $(OBJECTS) -o $@
 
 virt_v2v_copy_to_local_SOURCES = \
-	libvirt_utils-c.c \
-	utils-c.c
+	libvirt_utils-c.c
 virt_v2v_copy_to_local_CPPFLAGS = \
 	-I. \
 	-I$(top_builddir) \
@@ -214,6 +214,7 @@ virt_v2v_copy_to_local_DEPENDENCIES = \
 	$(COPY_TO_LOCAL_OBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
 	../common/mlxml/mlxml.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
 virt_v2v_copy_to_local_LINK = \
@@ -500,6 +501,7 @@ v2v_unit_tests_DEPENDENCIES = \
 	$(v2v_unit_tests_THEOBJECTS) \
 	../common/mlstdutils/mlstdutils.$(MLARCHIVE) \
 	../common/mlxml/mlxml.$(MLARCHIVE) \
+	../common/mlutils/mlcutils.$(MLARCHIVE) \
 	../mllib/mllib.$(MLARCHIVE) \
 	$(top_srcdir)/ocaml-link.sh
 v2v_unit_tests_LINK = \
@@ -514,7 +516,7 @@ depend: .depend
 
 .depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
 	rm -f $@ $ -t
-	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlxml -I $(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
+	$(OCAMLFIND) ocamldep -I ../ocaml -I $(abs_srcdir) -I $(abs_top_builddir)/common/mlstdutils -I $(abs_top_builddir)/common/mlutils -I $(abs_top_builddir)/common/mlxml -I $(abs_top_builddir)/mllib -I $(abs_top_builddir)/customize $^ | \
 	  $(SED) 's/ *$$//' | \
 	  $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
 	  $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index ffb43564f..c34bf3e91 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -28,6 +28,7 @@
 
 open Printf
 
+open C_utils
 open Std_utils
 open Common_utils
 open Common_gettext.Gettext
@@ -186,7 +187,7 @@ let rec convert (g : G.guestfs) inspect source output rcaps =
         fun line ->
           if Str.string_match rex line 0 then (
             let path = Str.matched_group 1 line in
-            let path = Utils.shell_unquote path in
+            let path = shell_unquote path in
             if String.length path >= 1 && path.[0] = '/' then (
               let vboxuninstall = path ^ "/uninstall.sh" in
               Some vboxuninstall
diff --git a/v2v/create_libvirt_xml.ml b/v2v/create_libvirt_xml.ml
index 3f22f3764..f5dca2d57 100644
--- a/v2v/create_libvirt_xml.ml
+++ b/v2v/create_libvirt_xml.ml
@@ -19,6 +19,7 @@
 open Printf
 
 open Std_utils
+open C_utils
 open Common_utils
 open Common_gettext.Gettext
 
diff --git a/v2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml
index 56f9ea297..285cf2f44 100644
--- a/v2v/parse_libvirt_xml.ml
+++ b/v2v/parse_libvirt_xml.ml
@@ -18,6 +18,7 @@
 
 open Printf
 
+open C_utils
 open Std_utils
 open Common_utils
 open Common_gettext.Gettext
@@ -39,7 +40,7 @@ and parsed_source =
  *)
 let get_drive_slot str offset =
   let name = String.sub str offset (String.length str - offset) in
-  try Some (Utils.drive_index name)
+  try Some (drive_index name)
   with Invalid_argument _ ->
        warning (f_"could not parse device name ‘%s’ from the source libvirt XML") str;
        None
diff --git a/v2v/utils.ml b/v2v/utils.ml
index 0dab5816e..0c6a1f444 100644
--- a/v2v/utils.ml
+++ b/v2v/utils.ml
@@ -24,11 +24,6 @@ open Std_utils
 open Common_utils
 open Common_gettext.Gettext
 
-external drive_name : int -> string = "v2v_utils_drive_name"
-external drive_index : string -> int = "v2v_utils_drive_index"
-
-external shell_unquote : string -> string = "v2v_utils_shell_unquote"
-
 (* Map guest architecture found by inspection to the architecture
  * that KVM must emulate.  Note for x86 we assume a 64 bit hypervisor.
  *)
diff --git a/v2v/utils.mli b/v2v/utils.mli
index 4906f0023..f267717d4 100644
--- a/v2v/utils.mli
+++ b/v2v/utils.mli
@@ -18,17 +18,6 @@
 
 (** Utilities used in virt-v2v only. *)
 
-val drive_name : int -> string
-val drive_index : string -> int
-
-val shell_unquote : string -> string
-(** If the string looks like a shell quoted string, then attempt to
-    unquote it.
-
-    This is just intended to deal with quoting in configuration files
-    (like ones under /etc/sysconfig), and it doesn't deal with some
-    situations such as $variable interpolation. *)
-
 val kvm_arch : string -> string
 (** Map guest architecture found by inspection to the architecture
     that KVM must emulate.  Note for x86 we assume a 64 bit hypervisor. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index f1ce9335a..00fbff2bc 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -19,6 +19,7 @@
 open Unix
 open Printf
 
+open C_utils
 open Std_utils
 open Common_utils
 open Unix_utils
diff --git a/v2v/v2v_unit_tests.ml b/v2v/v2v_unit_tests.ml
index be0bf0172..76f04f6fe 100644
--- a/v2v/v2v_unit_tests.ml
+++ b/v2v/v2v_unit_tests.ml
@@ -110,36 +110,6 @@ let test_get_ostype ctx =
                     i_product_variant = "Server";
                     i_arch = "x86_64" })
 
-let test_drive_name ctx =
-  let printer = identity in
-  assert_equal ~printer "a" (Utils.drive_name 0);
-  assert_equal ~printer "z" (Utils.drive_name 25);
-  assert_equal ~printer "aa" (Utils.drive_name 26);
-  assert_equal ~printer "ab" (Utils.drive_name 27);
-  assert_equal ~printer "az" (Utils.drive_name 51);
-  assert_equal ~printer "ba" (Utils.drive_name 52);
-  assert_equal ~printer "zz" (Utils.drive_name 701);
-  assert_equal ~printer "aaa" (Utils.drive_name 702);
-  assert_equal ~printer "zzz" (Utils.drive_name 18277)
-
-let test_drive_index ctx =
-  let printer = string_of_int in
-  assert_equal ~printer 0 (Utils.drive_index "a");
-  assert_equal ~printer 25 (Utils.drive_index "z");
-  assert_equal ~printer 26 (Utils.drive_index "aa");
-  assert_equal ~printer 27 (Utils.drive_index "ab");
-  assert_equal ~printer 51 (Utils.drive_index "az");
-  assert_equal ~printer 52 (Utils.drive_index "ba");
-  assert_equal ~printer 701 (Utils.drive_index "zz");
-  assert_equal ~printer 702 (Utils.drive_index "aaa");
-  assert_equal ~printer 18277 (Utils.drive_index "zzz");
-  let exn = Invalid_argument "drive_index: invalid parameter" in
-  assert_raises exn (fun () -> Utils.drive_index "");
-  assert_raises exn (fun () -> Utils.drive_index "abc123");
-  assert_raises exn (fun () -> Utils.drive_index "123");
-  assert_raises exn (fun () -> Utils.drive_index "Z");
-  assert_raises exn (fun () -> Utils.drive_index "aB")
-
 let test_virtio_iso_path_matches_guest_os ctx =
   (* Windows OSes fake inspection data. *)
   let make_win name major minor variant arch = {
@@ -779,19 +749,6 @@ let test_virtio_iso_path_matches_guest_os ctx =
          ) all_windows
   ) paths
 
-let test_shell_unquote ctx =
-  let printer = identity in
-  assert_equal ~printer "a" (Utils.shell_unquote "a");
-  assert_equal ~printer "b" (Utils.shell_unquote "'b'");
-  assert_equal ~printer "c" (Utils.shell_unquote "\"c\"");
-  assert_equal ~printer "dd" (Utils.shell_unquote "\"dd\"");
-  assert_equal ~printer "e\\e" (Utils.shell_unquote "\"e\\\\e\"");
-  assert_equal ~printer "f\\" (Utils.shell_unquote "\"f\\\\\"");
-  assert_equal ~printer "\\g" (Utils.shell_unquote "\"\\\\g\"");
-  assert_equal ~printer "h\\-h" (Utils.shell_unquote "\"h\\-h\"");
-  assert_equal ~printer "i`" (Utils.shell_unquote "\"i\\`\"");
-  assert_equal ~printer "j\"" (Utils.shell_unquote "\"j\\\"\"")
-
 let test_qemu_img_supports ctx =
   (* No assertion here, we don't know if qemu-img supports the
    * feature, so just run the code and make sure it doesn't crash.
@@ -945,11 +902,8 @@ let suite =
   "virt-v2v" >:::
     [
       "Create_ovf.get_ostype" >:: test_get_ostype;
-      "Utils.drive_name" >:: test_drive_name;
-      "Utils.drive_index" >:: test_drive_index;
       "Windows_virtio.virtio_iso_path_matches_guest_os" >::
         test_virtio_iso_path_matches_guest_os;
-      "Utils.shell_unquote" >:: test_shell_unquote;
       "Utils.qemu_img_supports" >:: test_qemu_img_supports;
       "Parse_vmx.parse_string" >::test_vmx_parse_string;
     ]
-- 
2.13.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]