[PATCH v6 0/6] New API - find_inode
by Matteo Cafasso
This series should be ready for merge
v6:
- rebase on master
- changes according to last comments
Matteo Cafasso (6):
filesystem_walk: fixed root inode listing
daemon: refactor tsk code
lib: rename tsk internal function
New API: internal_find_inode
New API: find_inode
find_inode: added API tests
daemon/tsk.c | 155 ++++++++++++++++++++++++++++++-------------
generator/actions.ml | 26 +++++++-
src/MAX_PROC_NR | 2 +-
src/tsk.c | 32 ++++++++-
tests/tsk/Makefile.am | 3 +-
tests/tsk/test-find-inode.sh | 66 ++++++++++++++++++
6 files changed, 229 insertions(+), 55 deletions(-)
create mode 100755 tests/tsk/test-find-inode.sh
--
2.9.3
8 years, 3 months
[PATCH v5 0/6] New API - find_inode
by Matteo Cafasso
v5:
- small doc fix: filesystem_walk claimed '.' and '..' entries were
not reported but Root is now reported as '.'
- bump to 1.35.6
Matteo Cafasso (6):
filesystem_walk: fixed root inode listing
daemon: refactor tsk code
lib: rename tsk internal function
New API: internal_find_inode
New API: find_inode
find_inode: added API tests
daemon/tsk.c | 161 ++++++++++++++++++++++++++++++-------------
generator/actions.ml | 26 ++++++-
src/MAX_PROC_NR | 2 +-
src/tsk.c | 32 ++++++++-
tests/tsk/Makefile.am | 3 +-
tests/tsk/test-find-inode.sh | 66 ++++++++++++++++++
6 files changed, 235 insertions(+), 55 deletions(-)
create mode 100755 tests/tsk/test-find-inode.sh
--
2.9.3
8 years, 3 months
[PATCH v4] v2v: linux: correctly reconfigure the initrd on Debian
by Tomáš Golembiovský
Using update-initramfs is the native way of updating initrd on Debian
based systems.
To add some modules to the image we can list them in file
/etc/initramfs-tools/modules.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/convert_linux.ml | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 08f4b2a..22a7919 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -478,6 +478,15 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
ignore (g#command (Array.of_list args))
in
+ let run_update_initramfs_command () =
+ let args =
+ "/usr/sbin/update-initramfs" ::
+ (if verbose () then [ "-v" ] else [])
+ @ [ "-c"; "-k"; mkinitrd_kv ]
+ in
+ ignore (g#command (Array.of_list args))
+ in
+
if g#is_file ~followsymlinks:true "/sbin/dracut" then
run_dracut_command "/sbin/dracut"
else if g#is_file ~followsymlinks:true "/usr/bin/dracut" then
@@ -491,6 +500,30 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
"-k"; kernel.ki_vmlinuz |]
)
)
+ else if family = `Debian_family then (
+ if not (g#is_file ~followsymlinks:true "/usr/sbin/update-initramfs") then
+ error (f_"unable to rebuild initrd (%s) because update-initramfs was not found in the guest")
+ initrd;
+
+ if List.length modules > 0 then (
+ (* The modules to add to initrd are defined in:
+ * /etc/initramfs-tools/modules
+ * File format is same as modules(5).
+ *)
+ let file = "/etc/initramfs-tools/modules" in
+ let path = sprintf "/files%s" file in
+ g#aug_transform "modules" file;
+ g#aug_load ();
+ g#aug_set (sprintf "%s/#comment[last()+1]" path)
+ "The following modules were added by virt-v2v";
+ List.iter (
+ fun m -> g#aug_clear (sprintf "%s/%s" path m)
+ ) modules;
+ g#aug_save ();
+ );
+
+ run_update_initramfs_command ()
+ )
else if g#is_file ~followsymlinks:true "/sbin/mkinitrd" then (
let module_args = List.map (sprintf "--with=%s") modules in
let args =
--
2.9.3
v4 changes: using Augeas to do the dirty job
8 years, 3 months
[PATCH 1/2] filearch: Add RISC-V architecture.
by Richard W.M. Jones
---
src/filearch.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/filearch.c b/src/filearch.c
index 5985b73..cbc8372 100644
--- a/src/filearch.c
+++ b/src/filearch.c
@@ -56,14 +56,16 @@ cleanup_magic_t_free (void *ptr)
# endif
COMPILE_REGEXP (re_file_elf,
- "ELF.*(MSB|LSB).*(?:executable|shared object|relocatable), (.+?),", 0)
+ "ELF (\\d+)-bit (MSB|LSB).*(?:executable|shared object|relocatable), (.+?),", 0)
COMPILE_REGEXP (re_elf_ppc64, ".*64.*PowerPC", 0)
/* Convert output from 'file' command on ELF files to the canonical
* architecture string. Caller must free the result.
*/
static char *
-canonical_elf_arch (guestfs_h *g, const char *endianness, const char *elf_arch)
+canonical_elf_arch (guestfs_h *g,
+ const char *bits, const char *endianness,
+ const char *elf_arch)
{
const char *r;
char *ret;
@@ -98,10 +100,15 @@ canonical_elf_arch (guestfs_h *g, const char *endianness, const char *elf_arch)
r = "aarch64";
else if (strstr (elf_arch, "ARM"))
r = "arm";
+ else if (strstr (elf_arch, "UCB RISC-V")) {
+ ret = safe_asprintf (g, "riscv%s", bits);
+ goto no_strdup;
+ }
else
r = elf_arch;
ret = safe_strdup (g, r);
+ no_strdup:
return ret;
}
@@ -120,6 +127,7 @@ magic_for_file (guestfs_h *g, const char *filename, bool *loading_ok,
int flags;
CLEANUP_MAGIC_T_FREE magic_t m = NULL;
const char *line;
+ CLEANUP_FREE char *bits = NULL;
CLEANUP_FREE char *elf_arch = NULL;
CLEANUP_FREE char *endianness = NULL;
@@ -151,7 +159,7 @@ magic_for_file (guestfs_h *g, const char *filename, bool *loading_ok,
if (loading_ok)
*loading_ok = true;
- if (!match2 (g, line, re_file_elf, &endianness, &elf_arch)) {
+ if (!match3 (g, line, re_file_elf, &bits, &endianness, &elf_arch)) {
error (g, "no re_file_elf match in '%s'", line);
return NULL;
}
@@ -159,7 +167,7 @@ magic_for_file (guestfs_h *g, const char *filename, bool *loading_ok,
if (matched)
*matched = true;
- return canonical_elf_arch (g, endianness, elf_arch);
+ return canonical_elf_arch (g, bits, endianness, elf_arch);
}
/* Download and uncompress the cpio file to find binaries within. */
@@ -319,6 +327,7 @@ char *
guestfs_impl_file_architecture (guestfs_h *g, const char *path)
{
CLEANUP_FREE char *file = NULL;
+ CLEANUP_FREE char *bits = NULL;
CLEANUP_FREE char *elf_arch = NULL;
CLEANUP_FREE char *endianness = NULL;
char *ret = NULL;
@@ -330,8 +339,8 @@ guestfs_impl_file_architecture (guestfs_h *g, const char *path)
if (file == NULL)
return NULL;
- if ((match2 (g, file, re_file_elf, &endianness, &elf_arch)) != 0)
- ret = canonical_elf_arch (g, endianness, elf_arch);
+ if ((match3 (g, file, re_file_elf, &bits, &endianness, &elf_arch)) != 0)
+ ret = canonical_elf_arch (g, bits, endianness, elf_arch);
else if (strstr (file, "PE32 executable"))
ret = safe_strdup (g, "i386");
else if (strstr (file, "PE32+ executable"))
--
2.9.3
8 years, 3 months
[PATCH] v2v: -o libvirt: always write pool names (RHBZ#1141631)
by Pino Toscano
When creating the XML for the new guest, always put the name of the pool
containing the disks, even when -os specified a pool UUID: libvirt does
not handle pool UUIDs for storage, but only names.
---
v2v/output_libvirt.ml | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index 5fa338f..e934335 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -340,6 +340,7 @@ class output_libvirt oc output_pool = object
inherit output
val mutable capabilities_doc = None
+ val mutable pool_name = None
method as_options =
match oc with
@@ -392,6 +393,15 @@ class output_libvirt oc output_pool = object
| Some dir when not (is_directory dir) ->
error (f_"-o libvirt: output pool '%s' has type='dir' but the /pool/target/path element is not a local directory. See virt-v2v(1) section \"OUTPUT TO LIBVIRT\"") output_pool
| Some dir -> dir in
+ (* Get the name of the pool, since we have to use that
+ * (and not the UUID) in the XML of the guest.
+ *)
+ let name =
+ match xpath_string "/pool/name/text()" with
+ | None ->
+ error (f_"-o libvirt: output pool '%s' does not have /pool/name element. See virt-v2v(1) section \"OUTPUT TO LIBVIRT\"") output_pool
+ | Some name -> name in
+ pool_name <- Some name;
(* Set up the targets. *)
List.map (
@@ -426,6 +436,11 @@ class output_libvirt oc output_pool = object
if run_command cmd <> 0 then
warning (f_"could not refresh libvirt pool %s") output_pool;
+ let pool_name =
+ match pool_name with
+ | None -> output_pool
+ | Some n -> n in
+
(* Parse the capabilities XML in order to get the supported features. *)
let doc =
match capabilities_doc with
@@ -436,7 +451,7 @@ class output_libvirt oc output_pool = object
(* Create the metadata. *)
let doc =
- create_libvirt_xml ~pool:output_pool source target_buses
+ create_libvirt_xml ~pool:pool_name source target_buses
guestcaps target_features target_firmware in
let tmpfile, chan = Filename.open_temp_file "v2vlibvirt" ".xml" in
--
2.7.4
8 years, 3 months
[PATCH v3 2/2] v2v: ilnux: detect name of grub2-mkconfig
by Tomáš Golembiovský
On Debian family of OSes Grub2 tools are prefixed with 'grub-', not with
'grub2-'. We have to detect the correct name of the tool to use it.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/linux_bootloaders.ml | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml
index a5e4c8d..4f53f87 100644
--- a/v2v/linux_bootloaders.ml
+++ b/v2v/linux_bootloaders.ml
@@ -186,6 +186,19 @@ end
(* Grub2 representation. *)
class bootloader_grub2 (g : G.guestfs) grub_config =
+
+ let grub2_mkconfig_cmd =
+ let elems = [
+ "/sbin/grub2-mkconfig";
+ "/usr/sbin/grub2-mkconfig";
+ "/sbin/grub-mkconfig";
+ "/usr/sbin/grub-mkconfig"
+ ] in
+ try List.find (g#is_file ~followsymlinks:true) elems
+ with Not_found ->
+ error (f_"failed to find grub2-mkconfig binary (but Grub2 was detected on guest)")
+ in
+
object (self)
inherit bootloader
@@ -218,7 +231,7 @@ object (self)
g#aug_save ();
try
- ignore (g#command [| "grub2-mkconfig"; "-o"; grub_config |])
+ ignore (g#command [| grub2_mkconfig_cmd; "-o"; grub_config |])
with
G.Error msg ->
warning (f_"could not rebuild grub2 configuration file (%s). This may mean that grub output will not be sent to the serial port, but otherwise should be harmless. Original error message: %s")
@@ -290,7 +303,7 @@ object (self)
method remove_console = self#grub2_update_console ~remove:true
method update () =
- ignore (g#command [| "grub2-mkconfig"; "-o"; grub_config |])
+ ignore (g#command [| grub2_mkconfig_cmd; "-o"; grub_config |])
end
let detect_bootloader (g : G.guestfs) inspect =
--
2.9.3
8 years, 3 months
[PATCH v3 1/2] v2v: linux: correctly reconfigure the initrd on Debian
by Tomáš Golembiovský
Using update-initramfs is the native way of updating initrd on Debian
based systems.
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/convert_linux.ml | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
index 08f4b2a..b09d03e 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -478,6 +478,15 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
ignore (g#command (Array.of_list args))
in
+ let run_update_initramfs_command () =
+ let args =
+ "/usr/sbin/update-initramfs" ::
+ (if verbose () then [ "-v" ] else [])
+ @ [ "-c"; "-k"; mkinitrd_kv ]
+ in
+ ignore (g#command (Array.of_list args))
+ in
+
if g#is_file ~followsymlinks:true "/sbin/dracut" then
run_dracut_command "/sbin/dracut"
else if g#is_file ~followsymlinks:true "/usr/bin/dracut" then
@@ -491,6 +500,18 @@ let rec convert ~keep_serial_console (g : G.guestfs) inspect source rcaps =
"-k"; kernel.ki_vmlinuz |]
)
)
+ else if family = `Debian_family then (
+ if not (g#is_file ~followsymlinks:true "/usr/sbin/update-initramfs") then
+ error (f_"unable to rebuild initrd (%s) because update-initramfs was not found in the guest")
+ initrd;
+
+ (* The modules to add to initrd are defined in a file. *)
+ let modules = String.concat "\n" modules in
+ let modules = "#\n# Added by virt-v2v\n" ^ modules ^ "\n" in
+ ignore (g#write_append "/etc/initramfs-tools/modules" modules);
+
+ run_update_initramfs_command ()
+ )
else if g#is_file ~followsymlinks:true "/sbin/mkinitrd" then (
let module_args = List.map (sprintf "--with=%s") modules in
let args =
--
2.9.3
8 years, 3 months
[PATCH] v2v: -o glance: set all properties during creation (RHBZ#1374405)
by Pino Toscano
The glance client v1.0.0 defaults to the Image v2 API: this means that
an image can be referenced only by its UUID, and not anymore by the name
as well (which does not need to be unique). This caused our glance
invocation to set the properties for the newly created image to fail,
since we are using the name as identifier.
Instead of first creating the image and then setting all the properties
for it, set all the properties when creating the image: other than being
simplier, it also avoid parsing the output of the 'glance image-create'
command for the UUID ('id') of the image.
---
v2v/output_glance.ml | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml
index d2660a7..399b45c 100644
--- a/v2v/output_glance.ml
+++ b/v2v/output_glance.ml
@@ -73,12 +73,6 @@ object
if i == 0 then source.s_name
else sprintf "%s-disk%d" source.s_name (i+1) in
- let cmd = [ "glance"; "image-create"; "--name"; name;
- "--disk-format=" ^ target_format;
- "--container-format=bare"; "--file"; target_file ] in
- if run_command cmd <> 0 then
- error (f_"glance: image upload to glance failed, see earlier errors");
-
(* Set the properties (ie. metadata). *)
let min_ram = source.s_memory /^ 1024L /^ 1024L in
let properties = [
@@ -114,26 +108,18 @@ object
| x, 0 -> ("os_version", string_of_int x) :: properties
| x, y -> ("os_version", sprintf "%d.%d" x y) :: properties in
- (* Glance doesn't appear to check the properties. *)
- let cmd = [ "glance"; "image-update"; "--min-ram";
- Int64.to_string min_ram ] @
+ let cmd = [ "glance"; "image-create"; "--name"; name;
+ "--disk-format=" ^ target_format;
+ "--container-format=bare"; "--file"; target_file;
+ "--min-ram"; Int64.to_string min_ram ] @
(List.flatten
(List.map (
fun (k, v) ->
[ "--property"; sprintf "%s=%s" k v ]
) properties
- )) @
- [ name ] in
- if run_command cmd <> 0 then (
- warning (f_"glance: failed to set image properties (ignored)");
- (* Dump out the image properties so the user can set them. *)
- eprintf "Image properties:\n";
- eprintf " --min-ram %Ld\n" min_ram;
- List.iter (
- fun (k, v) ->
- eprintf " --property %s=%s" (quote k) (quote v)
- ) properties
- )
+ )) in
+ if run_command cmd <> 0 then
+ error (f_"glance: image upload to glance failed, see earlier errors");
) targets
end
--
2.7.4
8 years, 3 months
[PATCH v3 0/2] More on the topic of Debian/Ubuntu conversion
by Tomáš Golembiovský
v3: Simplified code around List.find based on comments.
Tomáš Golembiovský (2):
v2v: linux: correctly reconfigure the initrd on Debian
v2v: ilnux: detect name of grub2-mkconfig
v2v/convert_linux.ml | 21 +++++++++++++++++++++
v2v/linux_bootloaders.ml | 17 +++++++++++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
--
2.9.3
8 years, 3 months
[PATCH] perl: Guestfs.c file is not translatable, don't include it in po/POTFILES.
by Richard W.M. Jones
Reported by Nikos Skalkotos
https://aur.archlinux.org/packages/libguestfs/
---
Makefile.am | 2 +-
po/POTFILES | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 5defbce..663958d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -320,7 +320,7 @@ po/POTFILES: configure.ac
rm -f $@ $@-t
cd $(srcdir); \
find $(DIST_SUBDIRS) -name '*.c' -o -name '*.pl' -o -name '*.pm' | \
- grep -v -E '^(examples|gnulib|gobject/docs|perl/(blib|examples)|po-docs|tests|test-data)/' | \
+ grep -v -E '^(examples|gnulib|gobject/docs|perl/(blib|examples)|perl/lib/Sys/Guestfs\.c|po-docs|tests|test-data)/' | \
grep -v -E '/((guestfs|rc)_protocol\.c)$$' | \
grep -v -E '^python/utils\.c$$' | \
LC_ALL=C sort > $@-t
diff --git a/po/POTFILES b/po/POTFILES
index c988d5d..dd9464f 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -337,7 +337,6 @@ p2v/ssh.c
p2v/utils.c
p2v/whole-file.c
perl/bindtests.pl
-perl/lib/Sys/Guestfs.c
perl/lib/Sys/Guestfs.pm
php/extension/guestfs_php.c
python/actions-0.c
--
2.7.4
8 years, 3 months