[PATCH] filearch: Add s390 and s390x detection and tests.
by Richard W.M. Jones
Unfortunately I was unable to build s390 binaries since multilib was
dropped in Fedora 24 on s390x. Going from the source of the 'file'
command it seems as if it prints "32-bit" (the architecture is really
31 bit).
---
generator/actions.ml | 12 ++++++++++++
src/filearch.c | 10 ++++++++++
test-data/Makefile.am | 2 ++
test-data/binaries/Makefile.am | 2 ++
test-data/binaries/bin-s390x-dynamic | Bin 0 -> 8448 bytes
test-data/binaries/lib-s390x.so | Bin 0 -> 7696 bytes
6 files changed, 26 insertions(+)
create mode 100755 test-data/binaries/bin-s390x-dynamic
create mode 100755 test-data/binaries/lib-s390x.so
diff --git a/generator/actions.ml b/generator/actions.ml
index 91a1819..43de38b 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -798,6 +798,8 @@ to specify the QEMU interface emulation to use at run time." };
InitISOFS, Always, TestResultString (
[["file_architecture"; "/bin-riscv64-dynamic"]], "riscv64"), [];
InitISOFS, Always, TestResultString (
+ [["file_architecture"; "/bin-s390x-dynamic"]], "s390x"), [];
+ InitISOFS, Always, TestResultString (
[["file_architecture"; "/bin-sparc-dynamic"]], "sparc"), [];
InitISOFS, Always, TestResultString (
[["file_architecture"; "/bin-win32.exe"]], "i386"), [];
@@ -818,6 +820,8 @@ to specify the QEMU interface emulation to use at run time." };
InitISOFS, Always, TestResultString (
[["file_architecture"; "/lib-riscv64.so"]], "riscv64"), [];
InitISOFS, Always, TestResultString (
+ [["file_architecture"; "/lib-s390x.so"]], "s390x"), [];
+ InitISOFS, Always, TestResultString (
[["file_architecture"; "/lib-sparc.so"]], "sparc"), [];
InitISOFS, Always, TestResultString (
[["file_architecture"; "/lib-win32.dll"]], "i386"), [];
@@ -880,6 +884,14 @@ Intel Itanium.
RISC-V 32-, 64- or 128-bit variants.
+=item \"s390\"
+
+31 bit IBM S/390.
+
+=item \"s390x\"
+
+64 bit IBM S/390.
+
=item \"sparc\"
32 bit SPARC.
diff --git a/src/filearch.c b/src/filearch.c
index 310038e..2c75425 100644
--- a/src/filearch.c
+++ b/src/filearch.c
@@ -102,6 +102,16 @@ canonical_elf_arch (guestfs_h *g,
ret = safe_asprintf (g, "riscv%s", bits);
goto no_strdup;
}
+ else if (strstr (elf_arch, "IBM S/390")) {
+ if (STREQ (bits, "32"))
+ r = "s390";
+ else if (STREQ (bits, "64"))
+ r = "s390x";
+ else {
+ error (g, "file_architecture: unknown S/390 bit size: %s", bits);
+ return NULL;
+ }
+ }
else
r = elf_arch;
diff --git a/test-data/Makefile.am b/test-data/Makefile.am
index 86cd5a2..0ac7354 100644
--- a/test-data/Makefile.am
+++ b/test-data/Makefile.am
@@ -42,6 +42,7 @@ image_files = \
$(srcdir)/binaries/bin-ppc64-dynamic \
$(srcdir)/binaries/bin-ppc64le-dynamic \
$(srcdir)/binaries/bin-riscv64-dynamic \
+ $(srcdir)/binaries/bin-s390x-dynamic \
$(srcdir)/binaries/bin-sparc-dynamic \
$(srcdir)/binaries/bin-win32.exe \
$(srcdir)/binaries/bin-win64.exe \
@@ -54,6 +55,7 @@ image_files = \
$(srcdir)/binaries/lib-ppc64.so \
$(srcdir)/binaries/lib-ppc64le.so \
$(srcdir)/binaries/lib-riscv64.so \
+ $(srcdir)/binaries/lib-s390x.so \
$(srcdir)/binaries/lib-sparc.so \
$(srcdir)/binaries/lib-win32.dll \
$(srcdir)/binaries/lib-win64.dll \
diff --git a/test-data/binaries/Makefile.am b/test-data/binaries/Makefile.am
index ccc7d00..05c1eb9 100644
--- a/test-data/binaries/Makefile.am
+++ b/test-data/binaries/Makefile.am
@@ -27,6 +27,7 @@ EXTRA_DIST = \
bin-ppc64-dynamic \
bin-ppc64le-dynamic \
bin-riscv64-dynamic \
+ bin-s390x-dynamic \
bin-sparc-dynamic \
bin-win32.exe \
bin-win64.exe \
@@ -39,6 +40,7 @@ EXTRA_DIST = \
lib-ppc64le.so \
lib-mipsel.so \
lib-riscv64.so \
+ lib-s390x.so \
lib-sparc.so \
lib-win32.dll \
lib-win64.dll \
diff --git a/test-data/binaries/bin-s390x-dynamic b/test-data/binaries/bin-s390x-dynamic
new file mode 100755
index 0000000000000000000000000000000000000000..43d3b3ddd1ec36ab2b8653212d9ee128c630d046
GIT binary patch
literal 8448
zcmeHMdu&@*89&!?>ZFY`ckN0?w{j<fXc2Lov}7#<&1oJ@ru0D;P>~QfPV6P_96Pmd
zrlk9$mZ(I>MyUo&2niAK$^`sTG>J8uU=|W(qh-wyh)M{lB`cZ~p}DA36OWqTch32)
zk8d4m2=QOO=-lsozwdb-_xjwMQ~kpOfq*4E3W#m!OQ0x%5sk+czrQ4TT<jCgA}$^j
z?}xkrtx@6v7^vvu2=^}GRW6z!G@u0u6(X>Yu0<aQbPwSm=2RCo&PO`RCy6;qdP^b9
z<uJ&PY6Z1!r)yE{tl_9*E8*Z07ee|40I*+-wD7CpC~2ASDwpF60-y#84AK?jtKoq9
z2nR6_CfyrHA#1-4I!`T!zKxtf%*pRlkae9>_g*d$_>I6&=UZ!DthZG#=ECa8q{lll
z$?m<;LN3}VwG<<QW*t2IX=Sd~nC6d&^fbQ>q`&c`v*qcR9(rw|`IqAt|C~J0d-3N#
zAR`djQ<Ljui8#8FWSrZdJlw&+8vH@KzGBn88ZU~5vS)&EOwbs*h2v1)DY%Ke>r5xo
zSs;_sxvWMUad3F(K(Esk?NZLN9#qMDlEyB==`^Jw-A73#Dhk^MBfE`g9s#F)Mz)(6
zT+NkZqHQTCKCt-D%GgQ-g|?MS*s;+P;<rAs5&;V?1;pmX)1o1KeI<S~B7*Q*7QxW1
zPzWCT;6b+c{WesNMVjCNi_p!Gpg*bEs-lE$h9l^;h^?htl}hCX)zA|!H?72wHMrPZ
zDK8a88Fd`}L#QmuV)dQ!f@tfRDKC`9VESh1D6TJ*Y+S!kx`7D46GCEdQI_yudm<6k
z1Ec0&?1W8g=#5h3)yltLr|Lsz$uImz)Fny!T`t9dy}1%2pVd8hLTp^!A|4ejOHHB^
zvL!accMp6i&i9QtFLRvLE9EgYW8ojIlq+ME6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C#p8qz5t8+5?6!$C|&j+8k_4;||-#Bbc;(UZXgXZ^NR>lpQi@1`#EBo6(zJ})W
z=ig7}7RTWLJbseDdAEP#HBw;8u1RM6FG$OrpTq?;&L1EE=j;e^EScuQmSXi{=6?~e
z-#?~Iy>on9)m8S){6DSZe@y#pE}rxGoB2!7$#WC9-0;=+0rmex;HEvq8u>D0{`k-S
zHW?wTEm^HSL1w(Gka_&<zf1YGYF=aS_x}?Bx$nT)U(a8w=5qbn#`LH4`3ssazfCqE
zQcL1GSmyePucG<=wS9#B%=MxercCcJ98cHJ?>`Yf@0s>~|JwjKzaB4{5PAN*4-{Or
zCqH_pka<~I<=cOz`}}=_Rh*Ax>dSr4$|{eXQT@iZ!Reb2kB7&*9T>e^uaSS-40NEt
KA;rC`m;XPXE<-N>
literal 0
HcmV?d00001
diff --git a/test-data/binaries/lib-s390x.so b/test-data/binaries/lib-s390x.so
new file mode 100755
index 0000000000000000000000000000000000000000..387b56da990bd829acc7eb3a824361c2e5203a7e
GIT binary patch
literal 7696
zcmeHMUua}k89z6fWRh(Xr+;?a>Jl$)uvzF%X0sSmUph&eO;WPyn$5!cboWkXnvBk$
z?aWO{iduyrqPWz>q7QxOK1dKMY{iF$f*k}=q{yl$(ibgZeTlFWY(-Hz{=Rd*@6O5X
zomJ2WA9BJy-}!#upL5Q4&Yk<6lNV<f&vkV<DlFaV1lkPr%rl-f^ub%2X4RzXRay0L
zsN2JO9Z2ujj6i6LSn8wK;6tvV!x7pwYVfX%q1vtsZL!N5d^kd#hQWoZKJW>CK%AFY
z9-(T);2}-qgWI10#{IGM-;)&VmZ3&{qI8;{^G7XKLUl~Y<^eq2b4!=hlXLI<<#%0w
z`q8xu{jbzd?VtQa?#fq;jp_zX;?Z&J&nA@PHYm=7_2aqc&%d3W{=)UWH&0%E?)O6n
z-`pL#^P7F(9Sa<i9ZKTohU$9x5sR^!CtZuNnobAY?|@Hsz+c2_->-CW=MB~Mb>I{q
z6!(Imy8fz#+xn^d;^%b&_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4SUL7`nV~!trO>o~hFSZ^vBbPwV<KJdyFcfT)DaK5zK27JH&^;}M?cFaJME
ziJi#BfjyRA0hInFUaS||NB58D6Qx|temB{c$O%5Ts&_1qnqn_)-ggl#m7;eOCGlNU
e58-)?I24%=VU*K!=>Iqe(9!?1AVV%;|NjDizI)05
literal 0
HcmV?d00001
--
2.7.4
8 years
[PATCH 0/5] Import directly from OVA tar archive if possible
by Tomáš Golembiovský
This is still a draft, not ready for commit yet. But feedback is
welcomed.
This series is related to the problem of inefficient import of OVA
files. The needed enhancements of QEMU was merged into the codebase and
should be available in QEMU 2.8. From there we can use 'size' and
'offset' options in raw driver to tell QEMU to use only subset of a file
as an image.
The first three patches are just preparation. The main work is in patch
four.
There are still some issues that need to be addressed:
1) The obviously missing check whether QEMU installed in the system
supports the feature we need. Do we already have such (or similar)
checks in libguestfs? Should it be compile-time check or runtime
check?
2) Lots of 'tar' invocations that may not be easily understandable.
3) We need a check for sparse files in tar archive. There is a GNU
extension to tar format that allows space-efficient archiving of
sparse files. While the OVF standard does not allow the use of GNU
extensions we probably should not rely on that.
To address points 2) and 3) I see two possible options. We can either
use some OCaml module that understands tar. There is however a risk that
such module won't provide the necessary info to detect 3). The second
option is to use e.g. libarchive and write small set of C functions that
would implement the necessary magic and use those in OCaml code.
Richard, do you have any preferences or suggestions in this matter?
Tomáš Golembiovský (5):
mllib: compute checksum of file inside tar
v2v: ova: don't detect compressed disks, read the OVF instead
v2v: ova: move the untar function
v2v: ova: don't extract files from OVA if it's not needed
v2v: update tests to match changes in OVA import
mllib/checksums.ml | 10 ++-
mllib/checksums.mli | 2 +-
v2v/Makefile.am | 1 +
v2v/input_ova.ml | 144 ++++++++++++++++++++++++++-------
v2v/test-v2v-i-ova-formats.sh | 5 +-
v2v/test-v2v-i-ova-gz.ovf | 2 +-
v2v/test-v2v-i-ova-subfolders.expected | 2 +-
v2v/test-v2v-i-ova-tar.expected | 18 +++++
v2v/test-v2v-i-ova-tar.ovf | 138 +++++++++++++++++++++++++++++++
v2v/test-v2v-i-ova-tar.sh | 64 +++++++++++++++
v2v/test-v2v-i-ova-two-disks.expected | 4 +-
v2v/test-v2v-i-ova-two-disks.sh | 5 +-
12 files changed, 354 insertions(+), 41 deletions(-)
create mode 100644 v2v/test-v2v-i-ova-tar.expected
create mode 100644 v2v/test-v2v-i-ova-tar.ovf
create mode 100755 v2v/test-v2v-i-ova-tar.sh
--
2.10.1
8 years
[PATCH 0/6] Feature: Yara file scanning
by Matteo Cafasso
Yara is a rule based scanning engine aimed to help malware analysts in finding and classifying interesting samples.
https://github.com/VirusTotal/yara
This series adds Yara support to Libguestfs allowing to upload sets of rules and scanning files against them.
Currently provided APIs:
- yara_load: loads a set of rules
- yara_destroy: free resources allocated by loaded rules
- yara_scan: scans a file with the loaded rules
Future APIs:
- yara_scan_recursive: scan the entire FS starting from the given point (could it be a flag in yara_scan?)
- yara_scan_inode: use TSK to scan files by inodes allowing to scan deleted or hidden files
Code ready for review, available here:
https://github.com/noxdafox/libguestfs/tree/yara
Matteo Cafasso (6):
appliance: add libyara dependency
New API: yara_load
New API: yara_destroy
New API: internal_yara_scan
New API: yara_scan
yara_scan: added API tests
appliance/packagelist.in | 1 +
configure.ac | 1 +
daemon/Makefile.am | 4 +-
daemon/yara.c | 318 +++++++++++++++++++++++++++++++
generator/actions.ml | 59 ++++++
generator/structs.ml | 9 +
gobject/Makefile.inc | 2 +
java/Makefile.inc | 1 +
java/com/redhat/et/libguestfs/.gitignore | 1 +
m4/guestfs_daemon.m4 | 8 +
src/MAX_PROC_NR | 2 +-
src/Makefile.am | 1 +
src/yara.c | 140 ++++++++++++++
tests/yara/Makefile.am | 26 +++
tests/yara/test-yara-scan.sh | 72 +++++++
15 files changed, 643 insertions(+), 2 deletions(-)
create mode 100644 daemon/yara.c
create mode 100644 src/yara.c
create mode 100644 tests/yara/Makefile.am
create mode 100755 tests/yara/test-yara-scan.sh
--
2.10.1
8 years
Transform and "Lenses xx and xx could be used to load this file"
by Richard W.M. Jones
Hi David,
We have a general problem using Augeas in libguestfs and I wonder
if you have any advice.
The problem is that we often -- as with yesterday's patch -- add new
config file paths to lenses. Or we want to parse config files which
are not necessarily in the exact paths that Augeas is expecting.
Now it's easy enough to parse such files using an arbitrary lens by
calling aug_transform, eg:
$ ls
passwd
$ augtool -r `pwd`
augtool> transform passwd incl /passwd
augtool> load
augtool> ls /files/passwd/
abrt/ lightdm/ rjones/
adm/ lirc/ root/
akmods/ lp/ rpc/
# etc
As you can see I applied the 'passwd' lens to the /passwd file
because it's not in the expected location (/etc/passwd).
However if the Augeas lens happens to contain that path already,
things go wrong:
augtool> transform passwd incl /etc/passwd
augtool> load
# /etc/passwd is not parsed by the passwd lens
augtool> get /augeas/files/etc/passwd/error/message
/augeas/files/etc/passwd/error/message = Lenses @Passwd and passwd.lns could be used to load this file
This is specifically a problem when libguestfs adds a call to
aug_transform to cater for a file that is not covered by an existing
lens, but then Augeas adds that file, and then we get the error above
until libguestfs removes the call to aug_transform. We cannot control
when Augeas and libguestfs are released in different Linux distros.
There are workarounds for this involving fishing out the existing
transform and working out if it covers the file or not, but that's
pretty tedious.
It seems to be that Augeas could be cleverer here and could just
ignore the case where two identical transforms apply to the same file
and DWIM.
What do you think?
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
8 years
[PATCH v4 1/2] v2v: bootloaders: search grub config for all distributions
by Richard W.M. Jones
From: Pavel Butsykin <pbutsykin(a)virtuozzo.com>
This patch improves the search of grub config on EFI partition. This
means that the config will be found not only for rhel but also for
many other distributions. Tests were performed on the following
distributions: centos, fedora, ubuntu, suse. In all cases, the config
path was /boot/efi/EFI/*distname*/grub.cfg
The main purpose of the patch is to improve support for converting of
vm with UEFI for most distributions. Unfortunately this patch does not
solve the problem for all distributions, for example Debian does not
store grub config on the EFI partition, therefore for such
distributions another solution is necessary.
Signed-off-by: Pavel Butsykin <pbutsykin(a)virtuozzo.com>
Signed-off-by: Richard W.M. Jones <rjones(a)redhat.com>
---
v2v/linux_bootloaders.ml | 83 ++++++++++++++++++++++++++++++------------------
1 file changed, 52 insertions(+), 31 deletions(-)
diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml
index e03d22b..9160dcc 100644
--- a/v2v/linux_bootloaders.ml
+++ b/v2v/linux_bootloaders.ml
@@ -42,6 +42,10 @@ type bootloader_type =
| Grub1
| Grub2
+let string_of_bootloader_type = function
+ | Grub1 -> "Grub1"
+ | Grub2 -> "Grub2"
+
(* Helper function for SUSE: remove (hdX,X) prefix from a path. *)
let remove_hd_prefix path =
let rex = Str.regexp "^(hd.*)\\(.*\\)" in
@@ -49,6 +53,10 @@ let remove_hd_prefix path =
(* Grub1 (AKA grub-legacy) representation. *)
class bootloader_grub1 (g : G.guestfs) inspect grub_config =
+ let () =
+ if grub_config = "/boot/efi/EFI/redhat/grub.conf" then
+ g#aug_transform "grub" "/boot/efi/EFI/redhat/grub.conf" in
+
(* Grub prefix? Usually "/boot". *)
let grub_prefix =
let mounts = g#inspect_get_mountpoints inspect.i_root in
@@ -191,7 +199,7 @@ type default_kernel_method =
| MethodNone (** No known way. *)
(* Grub2 representation. *)
-class bootloader_grub2 (g : G.guestfs) grub_config =
+class bootloader_grub2 (g : G.guestfs) inspect grub_config =
let grub2_mkconfig_cmd =
let elems = [
@@ -334,33 +342,46 @@ object (self)
end
let detect_bootloader (g : G.guestfs) inspect =
- let config_file, typ =
- let locations = [
- "/boot/grub2/grub.cfg", Grub2;
- "/boot/grub/grub.cfg", Grub2;
- "/boot/grub/menu.lst", Grub1;
- "/boot/grub/grub.conf", Grub1;
- ] in
- let locations =
- match inspect.i_firmware with
- | I_UEFI _ ->
- [
- "/boot/efi/EFI/redhat/grub.cfg", Grub2;
- "/boot/efi/EFI/redhat/grub.conf", Grub1;
- ] @ locations
- | I_BIOS -> locations in
- try
- List.find (
- fun (config_file, _) -> g#is_file ~followsymlinks:true config_file
- ) locations
- with
- Not_found ->
- error (f_"no bootloader detected") in
-
- match typ with
- | Grub1 ->
- if config_file = "/boot/efi/EFI/redhat/grub.conf" then
- g#aug_transform "grub" "/boot/efi/EFI/redhat/grub.conf";
-
- new bootloader_grub1 g inspect config_file
- | Grub2 -> new bootloader_grub2 g config_file
+ (* Where to start searching for bootloaders. *)
+ let mp =
+ match inspect.i_firmware with
+ | I_BIOS -> "/boot"
+ | I_UEFI _ -> "/boot/efi/EFI" in
+
+ (* Find all paths below the mountpoint, then filter them to find
+ * the grub config file.
+ *)
+ let paths =
+ try List.map ((^) mp) (Array.to_list (g#find mp))
+ with G.Error msg ->
+ error (f_"could not find bootloader mount point (%s): %s") mp msg in
+
+ (* We can determine if the bootloader config file is grub 1 or
+ * grub 2 just by looking at the filename.
+ *)
+ let bootloader_type_of_filename path =
+ match last_part_of path '/' with
+ | Some "grub.cfg" -> Some Grub2
+ | Some ("grub.conf" | "menu.lst") -> Some Grub1
+ | Some _
+ | None -> None
+ in
+
+ let grub_config, typ =
+ let rec loop = function
+ | [] -> error (f_"no bootloader detected")
+ | path :: paths ->
+ match bootloader_type_of_filename path with
+ | None -> loop paths
+ | Some typ ->
+ if not (g#is_file ~followsymlinks:true path) then loop paths
+ else path, typ
+ in
+ loop paths in
+
+ debug "detected bootloader %s at %s"
+ (string_of_bootloader_type typ) grub_config;
+
+ (match typ with
+ | Grub1 -> new bootloader_grub1
+ | Grub2 -> new bootloader_grub2) g inspect grub_config
--
2.9.3
8 years
[PATCH] v2v: add "colours-option" to machine readable sample output (RHBZ#1390876)
by Pino Toscano
---
v2v/virt-v2v.pod | 1 +
1 file changed, 1 insertion(+)
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index 5c5f078..4e0c65a 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -1861,6 +1861,7 @@ virt-v2v binary. Typical output looks like this:
$ virt-v2v --machine-readable
virt-v2v
libguestfs-rewrite
+ colours-option
input:disk
[...]
output:local
--
2.7.4
8 years
[PATCH v3] v2v: bootloaders: search grub config for all distributions
by Richard W.M. Jones
From: Pavel Butsykin <pbutsykin(a)virtuozzo.com>
This patch improves the search of grub config on EFI partition. This
means that the config will be found not only for rhel but also for
many other distributions. Tests were performed on the following
distributions: centos, fedora, ubuntu, suse. In all cases, the config
path was /boot/efi/EFI/*distname*/grub.cfg
The main purpose of the patch is to improve support for converting of
vm with UEFI for most distributions. Unfortunately this patch does not
solve the problem for all distributions, for example Debian does not
store grub config on the EFI partition, therefore for such
distributions another solution is necessary.
Signed-off-by: Pavel Butsykin <pbutsykin(a)virtuozzo.com>
Signed-off-by: Richard W.M. Jones <rjones(a)redhat.com>
---
v2v/linux_bootloaders.ml | 78 +++++++++++++++++++++++++++++-------------------
1 file changed, 47 insertions(+), 31 deletions(-)
diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml
index e03d22b..0c236e1 100644
--- a/v2v/linux_bootloaders.ml
+++ b/v2v/linux_bootloaders.ml
@@ -49,6 +49,14 @@ let remove_hd_prefix path =
(* Grub1 (AKA grub-legacy) representation. *)
class bootloader_grub1 (g : G.guestfs) inspect grub_config =
+ (* We expect Augeas to parse the grub_config file. However
+ * the upstream lens only lists a subset of the possible
+ * locations for this file. Therefore tell Augeas that
+ * grub_config is a grub file (this apparently doesn't affect
+ * Augeas if it already parsed the file).
+ *)
+ let () = g#aug_transform "grub" grub_config in
+
(* Grub prefix? Usually "/boot". *)
let grub_prefix =
let mounts = g#inspect_get_mountpoints inspect.i_root in
@@ -191,7 +199,7 @@ type default_kernel_method =
| MethodNone (** No known way. *)
(* Grub2 representation. *)
-class bootloader_grub2 (g : G.guestfs) grub_config =
+class bootloader_grub2 (g : G.guestfs) inspect grub_config =
let grub2_mkconfig_cmd =
let elems = [
@@ -333,34 +341,42 @@ object (self)
ignore (g#command [| grub2_mkconfig_cmd; "-o"; grub_config |])
end
+(* We can determine if the bootloader config file is grub 1 or
+ * grub 2 just by looking at the filename.
+ *)
+let bootloader_type_of_filename path =
+ if String.is_suffix path "/grub.cfg" then
+ Some Grub2
+ else if String.is_suffix path "/grub.conf" ||
+ String.is_suffix path "/menu.lst" then
+ Some Grub1
+ else
+ None
+
+(* Where to start searching for bootloaders. *)
+let bootloader_mountpoint = function
+ | { i_firmware = I_BIOS } -> "/boot"
+ | { i_firmware = I_UEFI _ } -> "/boot/efi/EFI"
+
let detect_bootloader (g : G.guestfs) inspect =
- let config_file, typ =
- let locations = [
- "/boot/grub2/grub.cfg", Grub2;
- "/boot/grub/grub.cfg", Grub2;
- "/boot/grub/menu.lst", Grub1;
- "/boot/grub/grub.conf", Grub1;
- ] in
- let locations =
- match inspect.i_firmware with
- | I_UEFI _ ->
- [
- "/boot/efi/EFI/redhat/grub.cfg", Grub2;
- "/boot/efi/EFI/redhat/grub.conf", Grub1;
- ] @ locations
- | I_BIOS -> locations in
- try
- List.find (
- fun (config_file, _) -> g#is_file ~followsymlinks:true config_file
- ) locations
- with
- Not_found ->
- error (f_"no bootloader detected") in
-
- match typ with
- | Grub1 ->
- if config_file = "/boot/efi/EFI/redhat/grub.conf" then
- g#aug_transform "grub" "/boot/efi/EFI/redhat/grub.conf";
-
- new bootloader_grub1 g inspect config_file
- | Grub2 -> new bootloader_grub2 g config_file
+ let mp = bootloader_mountpoint inspect in
+ let paths =
+ try List.map ((^) mp) (Array.to_list (g#find mp))
+ with G.Error msg ->
+ error (f_"could not find bootloader mount point (%s): %s") mp msg in
+
+ let grub_config, typ =
+ let rec loop = function
+ | [] -> error (f_"no bootloader detected")
+ | path :: paths ->
+ match bootloader_type_of_filename path with
+ | None -> loop paths
+ | Some typ ->
+ if not (g#is_file ~followsymlinks:true path) then loop paths
+ else path, typ
+ in
+ loop paths in
+
+ (match typ with
+ | Grub1 -> new bootloader_grub1
+ | Grub2 -> new bootloader_grub2) g inspect grub_config
--
2.9.3
8 years
[PATCH] v2v: glance: Set hw_video_model property to qxl|cirrus (RHBZ#1374651).
by Richard W.M. Jones
Thanks: Vladik Romanovsky, Ming Xie.
---
v2v/output_glance.ml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/v2v/output_glance.ml b/v2v/output_glance.ml
index e38b172..179448b 100644
--- a/v2v/output_glance.ml
+++ b/v2v/output_glance.ml
@@ -92,6 +92,10 @@ object
| Virtio_net -> "virtio"
| E1000 -> "e1000"
| RTL8139 -> "rtl8139");
+ "hw_video_model",
+ (match guestcaps.gcaps_video with
+ | QXL -> "qxl"
+ | Cirrus -> "cirrus");
"architecture", guestcaps.gcaps_arch;
"hypervisor_type", "kvm";
"vm_mode", "hvm";
--
2.7.4
8 years
[PATCH] v2v: bootloaders: search grub config for all distributions
by Pavel Butsykin
This patch improves the search of grub config on EFI partition. This means that
the config will be found not only for rhel but also for many other distributions.
Tests were performed on the following distributions: centos, fedora, ubuntu,
suse. In all cases, the config path was /boot/efi/EFI/*distname*/grub.cfg
The main purpose of the patch is to improve support for converting of vm with
UEFI for most distributions. Unfortunately this patch does not solve the problem
for all distributions, for example Debian does not store grub config on the EFI
partition, therefore for such distributions another solution is necessary.
Signed-off-by: Pavel Butsykin <pbutsykin(a)virtuozzo.com>
---
v2v/linux_bootloaders.ml | 56 +++++++++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 22 deletions(-)
diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml
index e03d22b..210c273 100644
--- a/v2v/linux_bootloaders.ml
+++ b/v2v/linux_bootloaders.ml
@@ -335,32 +335,44 @@ end
let detect_bootloader (g : G.guestfs) inspect =
let config_file, typ =
- let locations = [
- "/boot/grub2/grub.cfg", Grub2;
- "/boot/grub/grub.cfg", Grub2;
- "/boot/grub/menu.lst", Grub1;
- "/boot/grub/grub.conf", Grub1;
+ let grub_configs = [
+ "grub.cfg", Grub2;
+ "grub.conf", Grub1;
+ "menu.lst", Grub1;
] in
- let locations =
+
+ let boot_location =
match inspect.i_firmware with
- | I_UEFI _ ->
- [
- "/boot/efi/EFI/redhat/grub.cfg", Grub2;
- "/boot/efi/EFI/redhat/grub.conf", Grub1;
- ] @ locations
- | I_BIOS -> locations in
- try
- List.find (
- fun (config_file, _) -> g#is_file ~followsymlinks:true config_file
- ) locations
- with
- Not_found ->
- error (f_"no bootloader detected") in
+ | I_BIOS -> "/boot/"
+ | I_UEFI _ -> "/boot/efi/EFI/"
+ in
+
+ let rec find_grub dirs configs =
+ let rec config_check dir configs =
+ match configs with
+ | [] -> None
+ | (config, typ) :: configs ->
+ let cfg_path = boot_location ^ dir ^ "/" ^ config in
+ if g#is_file ~followsymlinks:true cfg_path then (
+ Some (cfg_path, typ)
+ ) else config_check dir configs;
+ in
+ match dirs with
+ | [] -> error (f_"no bootloader detected")
+ | dir :: dirs ->
+ let res = config_check dir configs in
+ match res with
+ | None -> find_grub dirs configs
+ | Some (cfg_path, typ) -> cfg_path, typ
+ in
+
+ find_grub (Array.to_list (g#ls boot_location)) grub_configs in
match typ with
| Grub1 ->
- if config_file = "/boot/efi/EFI/redhat/grub.conf" then
- g#aug_transform "grub" "/boot/efi/EFI/redhat/grub.conf";
-
+ (match inspect.i_firmware with
+ | I_BIOS -> ()
+ | I_UEFI _ -> g#aug_transform "grub" config_file
+ );
new bootloader_grub1 g inspect config_file
| Grub2 -> new bootloader_grub2 g config_file
--
2.8.3
8 years
[PATCH 0/4] supermin: use dnf on Mageia
by Pino Toscano
Hi,
as pointed out by Neal Gompa, Mageia recently introduced dnf in the
distribution (currently only in Cauldron, which is the future Mageia 6),
and most probably it will replace urpmi in the future.
As such, on Mageia make supermin prefer dnf over urpmi when found,
using the same code already used for Fedora.
Related change: make test-harder.sh work explicitly also on Mageia
("broken" since the recent switch to /etc/os-release).
Thanks,
Pino Toscano (4):
tests: add Mageia checks in test-harder
rpm: move fedora_download_all_packages_with_dnf around
rpm: isolate actual mageia download in own function
rpm: mageia: prefer dnf over urpmi
README | 3 +--
src/rpm.ml | 49 +++++++++++++++++++++++++++----------------------
tests/test-harder.sh | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+), 24 deletions(-)
--
2.7.4
8 years