[PATCH] v2v: Refactor some command line error messages.
by Richard W.M. Jones
This change (mostly) has no effect, except I changed the content of
two error messages to make them consistent with the others.
---
v2v/cmdline.ml | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index a72aa49..c294e57 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -334,6 +334,11 @@ read the man page virt-v2v(1).
error (f_"expecting an OVA file name on the command line") in
Input_ova.input_ova filename in
+ (* Common error message. *)
+ let error_option_cannot_be_used_in_output_mode mode opt =
+ error (f_"-o %s: %s option cannot be used in this output mode") mode opt
+ in
+
(* Parse the output mode. *)
if output_mode <> `Not_set && in_place then
error (f_"-o and --in-place cannot be used at the same time");
@@ -341,13 +346,13 @@ read the man page virt-v2v(1).
match output_mode with
| `Glance ->
if output_conn <> None then
- error (f_"-o glance: -oc option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "glance" "-oc";
if output_storage <> None then
- error (f_"-o glance: -os option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "glance" "-os";
if qemu_boot then
- error (f_"-o glance: --qemu-boot option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "glance" "--qemu-boot";
if not do_copy then
- error (f_"--no-copy and '-o glance' cannot be used at the same time");
+ error_option_cannot_be_used_in_output_mode "glance" "--no-copy";
Output_glance.output_glance (),
output_format, output_alloc
@@ -356,9 +361,9 @@ read the man page virt-v2v(1).
let output_storage =
match output_storage with None -> "default" | Some os -> os in
if qemu_boot then
- error (f_"-o libvirt: --qemu-boot option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "libvirt" "--qemu-boot";
if not do_copy then
- error (f_"--no-copy and '-o libvirt' cannot be used at the same time");
+ error_option_cannot_be_used_in_output_mode "libvirt" "--no-copy";
Output_libvirt.output_libvirt output_conn output_storage,
output_format, output_alloc
@@ -371,21 +376,21 @@ read the man page virt-v2v(1).
error (f_"-os %s: output directory does not exist or is not a directory") d
| Some d -> d in
if qemu_boot then
- error (f_"-o local: --qemu-boot option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "local" "--qemu-boot";
Output_local.output_local os,
output_format, output_alloc
| `Null ->
if output_alloc <> Sparse then
- error (f_"-o null: -oa option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "null" "-oa";
if output_conn <> None then
- error (f_"-o null: -oc option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "null" "-oc";
if output_format <> None then
- error (f_"-o null: -of option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "null" "-of";
if output_storage <> None then
- error (f_"-o null: -os option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "null" "-os";
if qemu_boot then
- error (f_"-o null: --qemu-boot option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "null" "--qemu-boot";
Output_null.output_null (),
(* Force output format to raw sparse in -o null mode. *)
Some "raw", Sparse
@@ -408,7 +413,7 @@ read the man page virt-v2v(1).
error (f_"-o rhv: output storage was not specified, use '-os'");
| Some d -> d in
if qemu_boot then
- error (f_"-o rhv: --qemu-boot option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "rhv" "--qemu-boot";
Output_rhv.output_rhv os output_alloc,
output_format, output_alloc
@@ -419,7 +424,7 @@ read the man page virt-v2v(1).
error (f_"-o vdsm: output storage was not specified, use '-os'");
| Some d -> d in
if qemu_boot then
- error (f_"-o vdsm: --qemu-boot option cannot be used in this output mode");
+ error_option_cannot_be_used_in_output_mode "vdsm" "--qemu-boot";
let vdsm_vm_uuid =
match vdsm_vm_uuid with
| None ->
--
2.9.3
7 years, 9 months
[PATCH] v2v: -o null: Force output format to be raw sparse.
by Richard W.M. Jones
When converting and throwing away the output (-o null), the input
format should not really matter. However it does currently matter for
a couple of reasons:
(1) If the input is not raw or qcow2, then you'll get the error below
because virt-v2v wants to write the same output format as input format
but only allows raw or qcow2 as output formats:
virt-v2v: error: output format should be 'raw' or 'qcow2'.
(2) If you use -o null -oa preallocated then a non-sparse temporary
disk is created before being deleted, but that just wastes disk space
for no reason.
Therefore this change
(i) prevents '-o null -oa preallocated' from being specified on the
command line,
(ii) prevents '-o null -of <anything>',
(iii) forces the output (temporary file) to be raw sparse.
---
v2v/cmdline.ml | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index f417dea..a72aa49 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -337,7 +337,7 @@ read the man page virt-v2v(1).
(* Parse the output mode. *)
if output_mode <> `Not_set && in_place then
error (f_"-o and --in-place cannot be used at the same time");
- let output =
+ let output, output_format, output_alloc =
match output_mode with
| `Glance ->
if output_conn <> None then
@@ -348,7 +348,8 @@ read the man page virt-v2v(1).
error (f_"-o glance: --qemu-boot option cannot be used in this output mode");
if not do_copy then
error (f_"--no-copy and '-o glance' cannot be used at the same time");
- Output_glance.output_glance ()
+ Output_glance.output_glance (),
+ output_format, output_alloc
| `Not_set
| `Libvirt ->
@@ -358,7 +359,8 @@ read the man page virt-v2v(1).
error (f_"-o libvirt: --qemu-boot option cannot be used in this output mode");
if not do_copy then
error (f_"--no-copy and '-o libvirt' cannot be used at the same time");
- Output_libvirt.output_libvirt output_conn output_storage
+ Output_libvirt.output_libvirt output_conn output_storage,
+ output_format, output_alloc
| `Local ->
let os =
@@ -370,16 +372,23 @@ read the man page virt-v2v(1).
| Some d -> d in
if qemu_boot then
error (f_"-o local: --qemu-boot option cannot be used in this output mode");
- Output_local.output_local os
+ Output_local.output_local os,
+ output_format, output_alloc
| `Null ->
+ if output_alloc <> Sparse then
+ error (f_"-o null: -oa option cannot be used in this output mode");
if output_conn <> None then
error (f_"-o null: -oc option cannot be used in this output mode");
+ if output_format <> None then
+ error (f_"-o null: -of option cannot be used in this output mode");
if output_storage <> None then
error (f_"-o null: -os option cannot be used in this output mode");
if qemu_boot then
error (f_"-o null: --qemu-boot option cannot be used in this output mode");
- Output_null.output_null ()
+ Output_null.output_null (),
+ (* Force output format to raw sparse in -o null mode. *)
+ Some "raw", Sparse
| `QEmu ->
let os =
@@ -389,7 +398,8 @@ read the man page virt-v2v(1).
| Some d when not (is_directory d) ->
error (f_"-os %s: output directory does not exist or is not a directory") d
| Some d -> d in
- Output_qemu.output_qemu os qemu_boot
+ Output_qemu.output_qemu os qemu_boot,
+ output_format, output_alloc
| `RHV ->
let os =
@@ -399,7 +409,8 @@ read the man page virt-v2v(1).
| Some d -> d in
if qemu_boot then
error (f_"-o rhv: --qemu-boot option cannot be used in this output mode");
- Output_rhv.output_rhv os output_alloc
+ Output_rhv.output_rhv os output_alloc,
+ output_format, output_alloc
| `VDSM ->
let os =
@@ -423,7 +434,8 @@ read the man page virt-v2v(1).
ovf_output = vdsm_ovf_output;
compat = vdsm_compat;
} in
- Output_vdsm.output_vdsm os vdsm_params output_alloc in
+ Output_vdsm.output_vdsm os vdsm_params output_alloc,
+ output_format, output_alloc in
{
compressed = compressed; debug_overlays = debug_overlays;
--
2.9.3
7 years, 9 months
Can I ask questions about libguestfs usage in SUSE linux ?
by Wang, Phoenix
Hi all,
Glad to join this mail list. As for project usage, we have to use libguestfs to mount guest image in SUSE Linux. While I see this mail list is in redhat, can I ask some question about libguest issue in SUSE ?
To be or not to be, that's the question.
Phoenix Wang
EMC China COE Chengdu Center
T: +86 (28) 8296 6862
7 years, 9 months
[PATCH v4 0/9] Introducing virt-builder-repository
by Cédric Bosdonnat
Hi all,
Here is a v4 of my series. It includes the changes according to
Pino and Richard's comments.
However, the perrorf/debug problem is addressed differently:
instead of adding an implementation for the internal function
names when building for mllib, I redefine these macros. Obviously
this is not perfect, but at least easier to understand.
Pino's comment about the Notes regex wasn't quite right... thus
I added a unit test for the Index_parser.write_entry
As some more code has been moved around, the number of commits
in the series increased a little bit ;)
Cédric Bosdonnat (9):
lib/osinfo.c: Extract xml processing into a callback
lib: extract osinfo DB traversing API
mllib: ocaml wrapper for lib/osinfo
builder: rename docs test script
builder: add Index_parser.write_entry function
builder: add a template parameter to get_index
dib: move do_cp to mllib.Commun_utils
mllib: add do_mv helper function to Common_utils
Add a virt-builder-repository tool
.gitignore | 4 +
builder/Makefile.am | 121 +++++-
builder/builder.ml | 2 +-
builder/index.mli | 3 +
builder/index_parser.ml | 72 +++-
builder/index_parser.mli | 8 +-
builder/index_parser_tests.ml | 95 ++++
builder/repository_main.ml | 466 ++++++++++++++++++++
.../{test-virt-builder-docs.sh => test-docs.sh} | 2 +
builder/virt-builder-repository.pod | 183 ++++++++
dib/utils.ml | 4 -
lib/Makefile.am | 2 +
lib/osinfo-iso.c | 462 ++++++++++++++++++++
lib/osinfo.c | 476 ++-------------------
lib/osinfo.h | 27 ++
mllib/Makefile.am | 11 +-
mllib/common_utils.ml | 11 +
mllib/common_utils.mli | 6 +
mllib/osinfo-c.c | 100 +++++
mllib/osinfo.ml | 26 ++
mllib/osinfo.mli | 31 ++
21 files changed, 1654 insertions(+), 458 deletions(-)
create mode 100644 builder/index_parser_tests.ml
create mode 100644 builder/repository_main.ml
rename builder/{test-virt-builder-docs.sh => test-docs.sh} (93%)
create mode 100644 builder/virt-builder-repository.pod
create mode 100644 lib/osinfo-iso.c
create mode 100644 lib/osinfo.h
create mode 100644 mllib/osinfo-c.c
create mode 100644 mllib/osinfo.ml
create mode 100644 mllib/osinfo.mli
--
2.11.0
7 years, 9 months
[PATCH] v2v: Add extra tests for malformed OVA files.
by Richard W.M. Jones
Test:
- Bad SHA1 sum
- Bad SHA256 sum
- Invalid lines in manifest (x2)
- Good checksum and manifest
These tests were originally written by Tomáš Golembiovský. All I have
done is to integrate them into the virt-v2v test suite.
---
.gitignore | 1 +
v2v/Makefile.am | 22 +++++++-
v2v/test-v2v-i-ova-bad-sha1.sh | 66 +++++++++++++++++++++++
v2v/test-v2v-i-ova-bad-sha256.sh | 66 +++++++++++++++++++++++
v2v/test-v2v-i-ova-checksums.ovf | 95 +++++++++++++++++++++++++++++++++
v2v/test-v2v-i-ova-good-checksums.sh | 64 ++++++++++++++++++++++
v2v/test-v2v-i-ova-invalid-manifest1.sh | 65 ++++++++++++++++++++++
v2v/test-v2v-i-ova-invalid-manifest2.sh | 64 ++++++++++++++++++++++
8 files changed, 442 insertions(+), 1 deletion(-)
create mode 100755 v2v/test-v2v-i-ova-bad-sha1.sh
create mode 100755 v2v/test-v2v-i-ova-bad-sha256.sh
create mode 100644 v2v/test-v2v-i-ova-checksums.ovf
create mode 100755 v2v/test-v2v-i-ova-good-checksums.sh
create mode 100755 v2v/test-v2v-i-ova-invalid-manifest1.sh
create mode 100755 v2v/test-v2v-i-ova-invalid-manifest2.sh
diff --git a/.gitignore b/.gitignore
index e3b6d7b..7dd49e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -635,6 +635,7 @@ Makefile.in
/v2v/virt-v2v.1
/v2v/virt-v2v-copy-to-local
/v2v/virt-v2v-copy-to-local.1
+/v2v/windows.vmdk
/website/*.html
/website/README.txt
/website/TODO.txt
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 55f7e70..9c685f9 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -256,10 +256,15 @@ TESTS_ENVIRONMENT = $(top_builddir)/run --test
TESTS = \
test-v2v-docs.sh \
- test-v2v-i-ova-tar.sh \
+ test-v2v-i-ova-bad-sha1.sh \
+ test-v2v-i-ova-bad-sha256.sh \
test-v2v-i-ova-formats.sh \
+ test-v2v-i-ova-good-checksums.sh \
test-v2v-i-ova-gz.sh \
+ test-v2v-i-ova-invalid-manifest1.sh \
+ test-v2v-i-ova-invalid-manifest2.sh \
test-v2v-i-ova-subfolders.sh \
+ test-v2v-i-ova-tar.sh \
test-v2v-i-ova-two-disks.sh \
test-v2v-bad-networks-and-bridges.sh
@@ -302,6 +307,20 @@ TESTS += \
endif
endif ENABLE_APPLIANCE
+# The VMDK file is used for some -i ova tests.
+check_DATA = windows.vmdk
+windows.vmdk: ../test-data/phony-guests/windows.img
+ rm -f $@ $@-t
+ if [ -s $< ]; then \
+ qemu-img convert -f raw $< -O vmdk $@-t; \
+ mv $@-t $@; \
+ else \
+ touch $@; \
+ fi
+
+DISTCLEANFILES += \
+ windows.vmdk
+
check-valgrind:
$(MAKE) VG="@VG@" check
@@ -355,6 +374,7 @@ EXTRA_DIST += \
test-v2v-floppy.sh \
test-v2v-floppy.xml \
test-v2v-i-disk.sh \
+ test-v2v-i-ova-checksums.ovf \
test-v2v-i-ova-formats.expected \
test-v2v-i-ova-formats.ovf \
test-v2v-i-ova-formats.sh \
diff --git a/v2v/test-v2v-i-ova-bad-sha1.sh b/v2v/test-v2v-i-ova-bad-sha1.sh
new file mode 100755
index 0000000..3724c71
--- /dev/null
+++ b/v2v/test-v2v-i-ova-bad-sha1.sh
@@ -0,0 +1,66 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014-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.
+
+# Test -i ova option with a good manifest containing a bad SHA1 checksum.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
+
+if [ ! -f windows.vmdk -o ! -s windows.vmdk ]; then
+ echo "$0: test skipped because windows.vmdk was not created"
+ exit 77
+fi
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+
+d=test-v2v-i-ova-bad-sha1.d
+rm -rf $d
+mkdir $d
+
+pushd $d
+
+# Create the test OVA.
+cp ../test-v2v-i-ova-checksums.ovf test.ovf
+cp ../windows.vmdk disk.vmdk
+echo "SHA1(test.ovf)=" `do_sha1 test.ovf` > test.mf
+sha1=`do_sha1 disk.vmdk | tr '0-5' 'a-f'`
+echo "SHA1(disk.vmdk)=" $sha1 >> test.mf
+tar cf test.ova test.ovf disk.vmdk test.mf
+
+# Run virt-v2v but only as far as the --print-source stage.
+# It is expected to fail with an error.
+if $VG virt-v2v --debug-gc --quiet \
+ -i ova test.ova \
+ --print-source >test.out 2>&1; then
+ cat test.out
+ echo "$0: expected virt-v2v to fail, but it succeeded"
+ exit 1
+fi
+cat test.out
+if ! grep "error: checksum of disk disk.vmdk does not match manifest" test.out
+then
+ echo "$0: did not see the expected error in the output of virt-v2v"
+ exit 1
+fi
+
+popd
+rm -rf $d
diff --git a/v2v/test-v2v-i-ova-bad-sha256.sh b/v2v/test-v2v-i-ova-bad-sha256.sh
new file mode 100755
index 0000000..7cd06f5
--- /dev/null
+++ b/v2v/test-v2v-i-ova-bad-sha256.sh
@@ -0,0 +1,66 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014-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.
+
+# Test -i ova option with a good manifest containing a bad SHA256 checksum.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
+
+if [ ! -f windows.vmdk -o ! -s windows.vmdk ]; then
+ echo "$0: test skipped because windows.vmdk was not created"
+ exit 77
+fi
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+
+d=test-v2v-i-ova-bad-sha256.d
+rm -rf $d
+mkdir $d
+
+pushd $d
+
+# Create the test OVA.
+cp ../test-v2v-i-ova-checksums.ovf test.ovf
+cp ../windows.vmdk disk.vmdk
+echo "SHA256(test.ovf)=" `do_sha256 test.ovf` > test.mf
+sha256=`do_sha256 disk.vmdk | tr '0-5' 'a-f'`
+echo "SHA256(disk.vmdk)=" $sha256 >> test.mf
+tar cf test.ova test.ovf disk.vmdk test.mf
+
+# Run virt-v2v but only as far as the --print-source stage.
+# It is expected to fail with an error.
+if $VG virt-v2v --debug-gc --quiet \
+ -i ova test.ova \
+ --print-source >test.out 2>&1; then
+ cat test.out
+ echo "$0: expected virt-v2v to fail, but it succeeded"
+ exit 1
+fi
+cat test.out
+if ! grep "error: checksum of disk disk.vmdk does not match manifest" test.out
+then
+ echo "$0: did not see the expected error in the output of virt-v2v"
+ exit 1
+fi
+
+popd
+rm -rf $d
diff --git a/v2v/test-v2v-i-ova-checksums.ovf b/v2v/test-v2v-i-ova-checksums.ovf
new file mode 100644
index 0000000..5bb7f6e
--- /dev/null
+++ b/v2v/test-v2v-i-ova-checksums.ovf
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationS..." xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettin..." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <References>
+ <File ovf:href="disk.vmdk" ovf:id="file1" ovf:size="4063232" />
+ </References>
+ <DiskSection>
+ <Info>Virtual disk information</Info>
+ <Disk ovf:capacity="512" ovf:capacityAllocationUnits="byte * 2^20" ovf:diskId="vmdisk1" ovf:fileRef="file1" />
+ </DiskSection>
+ <VirtualSystem ovf:id="ova-test">
+ <Info>A virtual machine</Info>
+ <Name>ova-test</Name>
+ <OperatingSystemSection ovf:id="69">
+ <Info>The kind of installed guest operating system</Info>
+ <Description>Microsoft Windows Server 2003 (32-bit)</Description>
+ </OperatingSystemSection>
+ <VirtualHardwareSection>
+ <Info>Virtual hardware requirements</Info>
+ <System>
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
+ <vssd:InstanceID>0</vssd:InstanceID>
+ <vssd:VirtualSystemIdentifier>ova-test</vssd:VirtualSystemIdentifier>
+ <vssd:VirtualSystemType>vmx-08</vssd:VirtualSystemType>
+ </System>
+ <Item>
+ <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
+ <rasd:Description>Number of Virtual CPUs</rasd:Description>
+ <rasd:ElementName>2 virtual CPU(s)</rasd:ElementName>
+ <rasd:InstanceID>1</rasd:InstanceID>
+ <rasd:ResourceType>3</rasd:ResourceType>
+ <rasd:VirtualQuantity>2</rasd:VirtualQuantity>
+ </Item>
+ <Item>
+ <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
+ <rasd:Description>Memory Size</rasd:Description>
+ <rasd:ElementName>4096MB of memory</rasd:ElementName>
+ <rasd:InstanceID>2</rasd:InstanceID>
+ <rasd:ResourceType>4</rasd:ResourceType>
+ <rasd:VirtualQuantity>4096</rasd:VirtualQuantity>
+ </Item>
+ <Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>SCSI Controller</rasd:Description>
+ <rasd:ElementName>SCSI controller 0</rasd:ElementName>
+ <rasd:InstanceID>3</rasd:InstanceID>
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+ <rasd:ResourceType>6</rasd:ResourceType>
+ </Item>
+ <Item>
+ <rasd:Address>1</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE 1</rasd:ElementName>
+ <rasd:InstanceID>4</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </Item>
+ <Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE 0</rasd:ElementName>
+ <rasd:InstanceID>5</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </Item>
+ <Item ovf:required="false">
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:ElementName>Video card</rasd:ElementName>
+ <rasd:InstanceID>6</rasd:InstanceID>
+ <rasd:ResourceType>24</rasd:ResourceType>
+ </Item>
+ <Item ovf:required="false">
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:ElementName>VMCI device</rasd:ElementName>
+ <rasd:InstanceID>7</rasd:InstanceID>
+ <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
+ <rasd:ResourceType>1</rasd:ResourceType>
+ </Item>
+ <Item ovf:required="false">
+ <rasd:AddressOnParent>1</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:ElementName>CD/DVD drive 1</rasd:ElementName>
+ <rasd:InstanceID>8</rasd:InstanceID>
+ <rasd:Parent>4</rasd:Parent>
+ <rasd:ResourceSubType>vmware.cdrom.remotepassthrough</rasd:ResourceSubType>
+ <rasd:ResourceType>15</rasd:ResourceType>
+ </Item>
+ <Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:ElementName>Hard disk 1</rasd:ElementName>
+ <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
+ <rasd:InstanceID>9</rasd:InstanceID>
+ <rasd:Parent>3</rasd:Parent>
+ <rasd:ResourceType>17</rasd:ResourceType>
+ </Item>
+ </VirtualHardwareSection>
+ </VirtualSystem>
+</Envelope>
diff --git a/v2v/test-v2v-i-ova-good-checksums.sh b/v2v/test-v2v-i-ova-good-checksums.sh
new file mode 100755
index 0000000..6f42701
--- /dev/null
+++ b/v2v/test-v2v-i-ova-good-checksums.sh
@@ -0,0 +1,64 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014-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.
+
+# Test -i ova option with good checksums.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
+
+if [ ! -f windows.vmdk -o ! -s windows.vmdk ]; then
+ echo "$0: test skipped because windows.vmdk was not created"
+ exit 77
+fi
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+
+d=test-v2v-i-ova-good-checksums.d
+rm -rf $d
+mkdir $d
+
+pushd $d
+
+# Create the test OVA.
+cp ../test-v2v-i-ova-checksums.ovf test.ovf
+cp ../windows.vmdk disk.vmdk
+echo "SHA1(test.ovf)=" `do_sha1 test.ovf` > test.mf
+echo "SHA1(disk.vmdk)=" `do_sha1 disk.vmdk` >> test.mf
+tar cf test.ova test.ovf disk.vmdk test.mf
+
+# Run virt-v2v but only as far as the --print-source stage.
+# It should succeed with no warnings.
+if ! $VG virt-v2v --debug-gc --quiet \
+ -i ova test.ova \
+ --print-source >test.out 2>&1; then
+ cat test.out
+ exit 1
+fi
+cat test.out
+
+if grep -sq "warning: " test.out; then
+ echo "$0: unexpected warning in virt-v2v output: see messages above"
+ exit 1
+fi
+
+popd
+rm -rf $d
diff --git a/v2v/test-v2v-i-ova-invalid-manifest1.sh b/v2v/test-v2v-i-ova-invalid-manifest1.sh
new file mode 100755
index 0000000..f26a9ab
--- /dev/null
+++ b/v2v/test-v2v-i-ova-invalid-manifest1.sh
@@ -0,0 +1,65 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014-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.
+
+# Test -i ova option with invalid manifest.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
+
+if [ ! -f windows.vmdk -o ! -s windows.vmdk ]; then
+ echo "$0: test skipped because windows.vmdk was not created"
+ exit 77
+fi
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+
+d=test-v2v-i-ova-invalid-manifest1.d
+rm -rf $d
+mkdir $d
+
+pushd $d
+
+# Create the test OVA.
+cp ../test-v2v-i-ova-checksums.ovf test.ovf
+cp ../windows.vmdk disk.vmdk
+echo "SHA1(test.ovf)=" `do_sha1 test.ovf` > test.mf
+echo "SHA1(disk.vmdk)=" `do_sha1 disk.vmdk` >> test.mf
+echo "garbage line" >> test.mf
+tar cf test.ova test.ovf disk.vmdk test.mf
+
+# Run virt-v2v but only as far as the --print-source stage.
+# It should succeed with a warning.
+if ! $VG virt-v2v --debug-gc --quiet \
+ -i ova test.ova \
+ --print-source >test.out 2>&1; then
+ cat test.out
+ exit 1
+fi
+cat test.out
+
+if ! grep -sq "warning: unable to parse line.*garbage" test.out; then
+ echo "$0: did not see the expected warning in the output of virt-v2v"
+ exit 1
+fi
+
+popd
+rm -rf $d
diff --git a/v2v/test-v2v-i-ova-invalid-manifest2.sh b/v2v/test-v2v-i-ova-invalid-manifest2.sh
new file mode 100755
index 0000000..a336e5e
--- /dev/null
+++ b/v2v/test-v2v-i-ova-invalid-manifest2.sh
@@ -0,0 +1,64 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014-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.
+
+# Test -i ova option with invalid manifest.
+
+set -e
+
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
+
+if [ ! -f windows.vmdk -o ! -s windows.vmdk ]; then
+ echo "$0: test skipped because windows.vmdk was not created"
+ exit 77
+fi
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+
+d=test-v2v-i-ova-invalid-manifest2.d
+rm -rf $d
+mkdir $d
+
+pushd $d
+
+# Create the test OVA.
+cp ../test-v2v-i-ova-checksums.ovf test.ovf
+cp ../windows.vmdk disk.vmdk
+echo "SHA1(test.ovf)=" `do_sha1 test.ovf` > test.mf
+echo "SHA1(disk.vmdk)=$(do_sha1 disk.vmdk)" >> test.mf
+tar cf test.ova test.ovf disk.vmdk test.mf
+
+# Run virt-v2v but only as far as the --print-source stage.
+# It should succeed with a warning.
+if ! $VG virt-v2v --debug-gc --quiet \
+ -i ova test.ova \
+ --print-source >test.out 2>&1; then
+ cat test.out
+ exit 1
+fi
+cat test.out
+
+if ! grep -sq "warning: unable to parse line" test.out; then
+ echo "$0: did not see the expected warning in the output of virt-v2v"
+ exit 1
+fi
+
+popd
+rm -rf $d
--
2.9.3
7 years, 9 months
SECURITY: Various security issues in icoutils 'wrestool', used by libguestfs
by Richard W.M. Jones
Sorry for missing the importance of these earlier. These
vulnerabilities were first disclosed this January.
There are seven vulnerabilities reported in the icoutils package, in
the 'wrestool' program.
Unfortunately because libguestfs downloads untrusted guest content and
processes it with 'wrestool -x' on the host, libguestfs is vulnerable
to these. This could lead to host local code execution if you run
inspection tools (like virt-inspector) on untrusted guests or disk
images.
Virt-manager is also vulnerable if you have python-libguestfs
installed and are running any untrusted guests.
The suggested action is to immediately update icoutils to the
non-vulnerable version (at least 0.31.1).
* CVE-2017-5208 (wrestool):
When calling the guestfs_inspect_get_icon API to find the icon
associated with Windows XP or Windows 7 guests, libguestfs will run
'wrestool -x ...' on an untrusted file from the guest. wrestool could
be exploited to run local code on the host.
Note that any guest can "pretend" to look like Windows as far as
libguestfs inspection is concerned, so just because you don't have any
Windows guests does not help.
Original bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=850017
* CVE-2017-6009 (wrestool):
Also memory corruption in wrestool, could cause a crash and might be
exploitable in other ways. Original bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854050
* CVE-2017-6010, CVE-2017-6011 (both in wrestool):
Also memory corruption in wrestool, could cause a crash and might be
exploitable in other ways. Original bug report:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854054
* CVE-2017-5331, CVE-2017-5332 and CVE-2017-5333 (all in wrestool):
These are also all local code execution bugs in wrestool and could be
exploited in the same way as above.
Upstream fixes for these CVEs:
http://git.savannah.gnu.org/cgit/icoutils.git/commit/?id=4fbe9222fd79ee31...
http://git.savannah.gnu.org/cgit/icoutils.git/commit/?id=1aa9f28f7bcbdfff...
http://git.savannah.gnu.org/cgit/icoutils.git/commit/?id=1a108713ac26215c...
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
7 years, 9 months
[PATCH] v2v: -o local: Check that UEFI firmware is installed before conversion.
by Richard W.M. Jones
Avoids a lengthy conversion followed by failure if we discover at the
end that OVMF is not installed.
This also changes the order of the methods in -o libvirt and -o qemu
so that it matches the order in the class interface, and also
logically makes more sense.
Partial fix for: https://bugzilla.redhat.com/show_bug.cgi?id=1429506
Thanks: Christopher Brown
---
v2v/output_libvirt.ml | 4 ++--
v2v/output_local.ml | 13 +++++++++++--
v2v/output_qemu.ml | 4 ++--
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/v2v/output_libvirt.ml b/v2v/output_libvirt.ml
index 072b94f..33f69dc 100644
--- a/v2v/output_libvirt.ml
+++ b/v2v/output_libvirt.ml
@@ -76,8 +76,6 @@ class output_libvirt oc output_pool = object
| None -> sprintf "-o libvirt -os %s" output_pool
| Some uri -> sprintf "-o libvirt -oc %s -os %s" uri output_pool
- method supported_firmware = [ TargetBIOS; TargetUEFI ]
-
method prepare_targets source targets =
(* Get the capabilities from libvirt. *)
let xml = Libvirt_utils.capabilities ?conn:oc () in
@@ -140,6 +138,8 @@ class output_libvirt oc output_pool = object
{ t with target_file = target_file }
) targets
+ method supported_firmware = [ TargetBIOS; TargetUEFI ]
+
method check_target_firmware guestcaps target_firmware =
match target_firmware with
| TargetBIOS -> ()
diff --git a/v2v/output_local.ml b/v2v/output_local.ml
index 9ba1d6f..9c105ef 100644
--- a/v2v/output_local.ml
+++ b/v2v/output_local.ml
@@ -30,8 +30,6 @@ class output_local dir = object
method as_options = sprintf "-o local -os %s" dir
- method supported_firmware = [ TargetBIOS; TargetUEFI ]
-
method prepare_targets source targets =
List.map (
fun t ->
@@ -39,6 +37,17 @@ class output_local dir = object
{ t with target_file = target_file }
) targets
+ method supported_firmware = [ TargetBIOS; TargetUEFI ]
+
+ method check_target_firmware guestcaps target_firmware =
+ match target_firmware with
+ | TargetBIOS -> ()
+ | TargetUEFI ->
+ (* This will fail with an error if the target firmware is
+ * not installed on the host.
+ *)
+ ignore (find_uefi_firmware guestcaps.gcaps_arch)
+
method create_metadata source _ target_buses guestcaps _ target_firmware =
(* We don't know what target features the hypervisor supports, but
* assume a common set that libvirt supports.
diff --git a/v2v/output_qemu.ml b/v2v/output_qemu.ml
index 3e28ad0..84efd45 100644
--- a/v2v/output_qemu.ml
+++ b/v2v/output_qemu.ml
@@ -31,8 +31,6 @@ object
method as_options =
sprintf "-o qemu -os %s%s" dir (if qemu_boot then " --qemu-boot" else "")
- method supported_firmware = [ TargetBIOS; TargetUEFI ]
-
method prepare_targets source targets =
List.map (
fun t ->
@@ -40,6 +38,8 @@ object
{ t with target_file = target_file }
) targets
+ method supported_firmware = [ TargetBIOS; TargetUEFI ]
+
method check_target_firmware guestcaps target_firmware =
match target_firmware with
| TargetBIOS -> ()
--
2.9.3
7 years, 9 months
[PATCH] lib: Prefer tirpc for XDR, and rationlise how we search for alternatives.
by Richard W.M. Jones
glibc in Fedora is currently configured with `--enable-obsolete-rpc',
so I guess we can see the way the wind is blowing.
(1) This changes our configure script to prefer libtirpc if it is
available.
If libtirpc is _not_ available then:
(a) Headers must be located in <rpc/xdr.h>, or the user must supply
the right CFLAGS.
(b) XDR functions must be located in one of -lportablexdr, -lrpc,
-lxdr, -lnsl or no library at all (ie. -lc), and the user must set
LDFLAGS if needed.
(2) We no longer add these paths automatically to $(CFLAGS)/$(LIBS).
Any part of libguestfs which needs <rpc/*.h> or the xdr_* functions
must use $(RPC_CFLAGS)/$(RPC_LIBS) explicitly.
(3) Previously Mac OS X had a workaround for the broken 64 bit support
in the supplied rpcgen. This workaround "activates" all the time if
you use tirpc, so breaking Linux after the above changes. tirpc is
supported on OS X, so I think it's just better to use that rather than
the broken rpcgen.
Thanks: Roy Keene
---
common/protocol/Makefile.am | 14 ++------------
daemon/Makefile.am | 4 +++-
docs/guestfs-building.pod | 13 +++++++++++--
fish/Makefile.am | 16 ++++------------
generator/XDR.ml | 15 ---------------
lib/Makefile.am | 4 +++-
m4/guestfs_libraries.m4 | 32 ++++++++++++++++++--------------
7 files changed, 41 insertions(+), 57 deletions(-)
diff --git a/common/protocol/Makefile.am b/common/protocol/Makefile.am
index c426f26..eb935f6 100644
--- a/common/protocol/Makefile.am
+++ b/common/protocol/Makefile.am
@@ -36,25 +36,15 @@ libprotocol_la_SOURCES = guestfs_protocol.c guestfs_protocol.h
libprotocol_la_CFLAGS = \
-Wall -Wno-unused -fno-strict-aliasing $(GCC_VISIBILITY_HIDDEN)
-if HAVE_RPCGEN
-RPCGEN_DEFS =
-if HAVE_XDR_U_INT64_T
-RPCGEN_DEFS += -DHAVE_XDR_U_INT64_T=1
-else
-if HAVE_XDR_UINT64_T
-RPCGEN_DEFS += -DHAVE_XDR_UINT64_T=1
-endif
-endif
-
guestfs_protocol.c: guestfs_protocol.x
rm -f $@-t $@-t2
- $(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $<
+ $(RPCGEN) -c -o $@-t $<
$(SED) 's,\.\./\(\.\./\)*lib,.,' < $@-t > $@-t2
rm $@-t
mv $@-t2 $@
guestfs_protocol.h: guestfs_protocol.x
rm -f $@-t
- $(RPCGEN) $(RPCGEN_DEFS) -h -o $@-t $<
+ $(RPCGEN) -h -o $@-t $<
mv $@-t $@
endif
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 5c4ae8e..e3ad053 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -186,7 +186,8 @@ guestfsd_LDADD = \
$(LIBINTL) \
$(SERVENT_LIB) \
$(PCRE_LIBS) \
- $(TSK_LIBS)
+ $(TSK_LIBS) \
+ $(RPC_LIBS)
guestfsd_CPPFLAGS = \
-I$(top_srcdir)/gnulib/lib \
@@ -199,6 +200,7 @@ guestfsd_CPPFLAGS = \
-I$(top_builddir)/common/protocol
guestfsd_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
+ $(RPC_CFLAGS) \
$(AUGEAS_CFLAGS) \
$(HIVEX_CFLAGS) \
$(SD_JOURNAL_CFLAGS) \
diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod
index 53a4d94..11ffe5f 100644
--- a/docs/guestfs-building.pod
+++ b/docs/guestfs-building.pod
@@ -87,8 +87,17 @@ below.
=item glibc
-I<Required>. We use various glibc-isms, and glibc also provides XDR
-libraries and the C<rpcgen> tool.
+I<Required>. We use the custom printf formatters extension of
+glibc (see L<guestfs-hacking(1)/DAEMON CUSTOM PRINTF FORMATTERS>).
+
+=item XDR (tirpc, glibc or other)
+
+I<Required>. We use the XDR implementation from
+C<E<lt>rpc/xdr.hE<gt>>, which may come from glibc, tirpc or another
+library.
+
+The C<rpcgen> tool is optional, except if you want to compile from git
+and/or patch libguestfs with new APIs.
=item Gcc or Clang
diff --git a/fish/Makefile.am b/fish/Makefile.am
index 44c6ccd..d689fa8 100644
--- a/fish/Makefile.am
+++ b/fish/Makefile.am
@@ -133,6 +133,7 @@ guestfish_CPPFLAGS = \
guestfish_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
+ $(RPC_CFLAGS) \
$(LIBCONFIG_CFLAGS) \
$(LIBXML2_CFLAGS)
@@ -147,32 +148,23 @@ guestfish_LDADD = \
$(LIBREADLINE) \
$(LIBTINFO_LIBS) \
$(LTLIBINTL) \
+ $(RPC_LIBS) \
-lm
# Make guestfish use the convenience libraries.
noinst_LTLIBRARIES = libcmds.la librc_protocol.la
guestfish_LDADD += libcmds.la librc_protocol.la ../gnulib/lib/libgnu.la
-if HAVE_RPCGEN
-RPCGEN_DEFS =
-if HAVE_XDR_U_INT64_T
-RPCGEN_DEFS += -DHAVE_XDR_U_INT64_T=1
-else
-if HAVE_XDR_UINT64_T
-RPCGEN_DEFS += -DHAVE_XDR_UINT64_T=1
-endif
-endif
-
rc_protocol.c: rc_protocol.x
rm -f $@-t $@-t2
- $(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $<
+ $(RPCGEN) -c -o $@-t $<
$(SED) 's,\.\./\(\.\./\)*fish,.,' < $@-t > $@-t2
rm $@-t
mv $@-t2 $@
rc_protocol.h: rc_protocol.x
rm -f $@-t
- $(RPCGEN) $(RPCGEN_DEFS) -h -o $@-t $<
+ $(RPCGEN) -h -o $@-t $<
mv $@-t $@
endif
diff --git a/generator/XDR.ml b/generator/XDR.ml
index 575be46..634a4f3 100644
--- a/generator/XDR.ml
+++ b/generator/XDR.ml
@@ -51,21 +51,6 @@ let generate_xdr () =
pr "%%#include <config.h>\n";
pr "\n";
- pr "/* This has to be defined to get around a limitation in Mac OS X's rpcgen. */\n";
- pr "#if HAVE_XDR_U_INT64_T\n";
- pr "#define uint64_t u_int64_t\n";
- pr "%%#if HAVE_XDR_UINT64_T\n";
- pr "%%#define xdr_u_int64_t xdr_uint64_t\n";
- pr "%%#define u_int64_t uint64_t\n";
- pr "%%#endif\n";
- pr "#else\n";
- pr "%%#if HAVE_XDR_U_INT64_T\n";
- pr "%%#define xdr_uint64_t xdr_u_int64_t\n";
- pr "%%#define uint64_t u_int64_t\n";
- pr "%%#endif\n";
- pr "#endif\n";
- pr "\n";
-
pr "/* This has to be defined to get around a limitation in Sun's rpcgen. */\n";
pr "typedef string guestfs_str<>;\n";
pr "\n";
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 774274b..063706f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -141,6 +141,7 @@ libguestfs_la_CPPFLAGS = \
libguestfs_la_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
+ $(RPC_CFLAGS) \
$(GCC_VISIBILITY_HIDDEN) \
$(PCRE_CFLAGS) \
$(LIBVIRT_CFLAGS) \
@@ -164,7 +165,8 @@ libguestfs_la_LIBADD = \
$(LTLIBINTL) \
$(LTLIBTHREAD) \
$(LTLIBICONV) \
- $(SERVENT_LIB)
+ $(SERVENT_LIB) \
+ $(RPC_LIBS)
# Force libtool to name the library 'libguestfs.so.0.$(MAX_PROC_NR).0'.
# Include the version script to limit which symbols are exported.
diff --git a/m4/guestfs_libraries.m4 b/m4/guestfs_libraries.m4
index c265b29..4e58ba0 100644
--- a/m4/guestfs_libraries.m4
+++ b/m4/guestfs_libraries.m4
@@ -171,22 +171,26 @@ AC_CHECK_HEADERS([dlfcn.h],[have_dlfcn=yes],[have_dlfcn=no])
AM_CONDITIONAL([HAVE_LIBDL],
[test "x$have_libdl" = "xyes" && test "x$have_dlfcn" = "xyes"])
-dnl Check for rpcgen and XDR library. rpcgen is optional.
+dnl Check for an XDR library (required) and rpcgen binary (optional).
+PKG_CHECK_MODULES([RPC], [libtirpc], [], [
+ dnl If we don't have libtirpc, then we must have <rpc/xdr.h> and
+ dnl some library to link to in libdir.
+ RPC_CFLAGS=""
+ AC_CHECK_HEADER([rpc/xdr.h],[],[
+ AC_MSG_ERROR([XDR header files are required])])
+
+ old_LIBS="$LIBS"
+ LIBS=""
+ AC_SEARCH_LIBS([xdrmem_create],[portablexdr rpc xdr nsl])
+ RPC_LIBS="$LIBS"
+ LIBS="$old_LIBS"
+
+ AC_SUBST([RPC_CFLAGS])
+ AC_SUBST([RPC_LIBS])
+])
+
AC_CHECK_PROG([RPCGEN],[rpcgen],[rpcgen],[no])
AM_CONDITIONAL([HAVE_RPCGEN],[test "x$RPCGEN" != "xno"])
-AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
- AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
-])
-AC_SEARCH_LIBS([xdr_u_int64_t],[portablexdr rpc xdr nsl],[
- AC_DEFINE([HAVE_XDR_U_INT64_T],[1],[Define to 1 if xdr_u_int64_t() exists.])
-])
-AC_SEARCH_LIBS([xdr_uint64_t],[portablexdr rpc xdr nsl],[
- AC_DEFINE([HAVE_XDR_UINT64_T],[1],[Define to 1 if xdr_uint64_t() exists.])
-])
-AM_CONDITIONAL([HAVE_XDR_U_INT64_T],
- [test "x$ac_cv_search_xdr_u_int64_t" != "xno"])
-AM_CONDITIONAL([HAVE_XDR_UINT64_T],
- [test "x$ac_cv_search_xdr_uint64_t" != "xno"])
dnl Check for libselinux (optional).
AC_CHECK_HEADERS([selinux/selinux.h])
--
2.9.3
7 years, 9 months