Convert Xen PV to KVM
by XenonHost.ro - Edelweiss srl
Hello!
Is it possible to convert a live centos xen pv vps to kvm?
Marian Titieni
Edelweiss srl
Tel: +4 0746.149496
www.xenonhost.ro <http://www.xenonhost.ro/>
www.xenonshop.ro <http://www.xenonshop.ro/>
www.piese-electro.ro <http://www.piese-electro.ro/>
---------------------------------------------------------------------------------------------------------------
This message and any attachment are confidential and may be privileged or otherwise protected from disclosure.
If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system.
If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person.
Please consider the environmental impact before printing this document and its attachment(s). Print black and white and double-sided where possible.
------------------------------------------------------------------------------
10 years, 1 month
[PATCH] inspector: Document that -a option can take a URI for remote storage (RHBZ#1156301).
by Richard W.M. Jones
---
inspector/virt-inspector.pod | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/inspector/virt-inspector.pod b/inspector/virt-inspector.pod
index f8744b1..1282608 100644
--- a/inspector/virt-inspector.pod
+++ b/inspector/virt-inspector.pod
@@ -68,6 +68,12 @@ them with separate I<-a> options.
The format of the disk image is auto-detected. To override this and
force a particular format use the I<--format=..> option.
+=item B<-a> URI
+
+=item B<--add> URI
+
+Add a remote disk. See L<guestfish(1)/ADDING REMOTE STORAGE>.
+
=item B<-c URI>
=item B<--connect URI>
--
2.0.4
10 years, 1 month
[PATCH 00/16] Small bits of non-Linux porting
by Pino Toscano
Hi,
from time to time, there have been requests (or attempts, like the
mingw port posted on the list some months ago) to make libguestfs work
on OSes different than Linux. Of course this would imply using a fixed
appliance, since it is currently heavily dependent on Linux.
The attached series provides some easy changes in this direction,
resolving some of the easy issues found in porting to FreeBSD; while
they don't solve all the build and runtime issues, at least they get
libguestfs a bit closer to it, while causing no actual changes on
Linux.
Other issues (with partial solutions, or not dealt yet) w.r.t porting
to non-Linux so far found are the following:
a) lack of UNIX_PATH_MAX (which seems Linux-specific anyway)
b) usage of meta /dev/fd/N files; while on (k)FreeBSD there's a fdescfs
filesystem providing it, IMHO a better solution would be adding API
using FDs, like download_fd, upload_fd, tar_in_fd, and tar_out_fd
c) program_invocation_short_name is specific to GNU libc
d) iconv outside of GNU libc, in an own libintl
e) different cli tools, and different output for them
Also, as mentioned in the mingw porting patch,
https://www.redhat.com/archives/libguestfs/2014-February/msg00160.html
a way to disable entirely the usage of supermin (thus leaving only the
fixed appliance as appliance style) is needed too.
Thanks,
--
Pino
Pino Toscano (16):
build: use the ptsname_r gnulib module
Include string.h where needed
Include sys/wait.h where needed
build: look for and use sys/endian.h
fuse: test-fuse: enclose acl vars within HAVE_ACL
p2v: remove unused variable
normalize iconv handling
builder: rename "program_name" into "progname"
tests: isolate iso_system_id baseline string
Include stdint.h where needed
build: use $(SED) instead of sed when possible
tests/c-api: add a way to skip test when host and appliance differ
actions: mark as IfNotCrossAppliance tests of command and
command_lines
customize, mllib: use the libvirt CFLAGS
tests: switch from get_current_dir_name to getcwd(0, NULL)
configure: map also amd64 as host_cpu to x86_64 qemu
bootstrap | 2 ++
builder/index-parse.y | 4 +--
builder/index-parser-c.c | 2 +-
builder/index-struct.h | 2 +-
configure.ac | 4 ++-
customize/Makefile.am | 1 +
daemon/ext2.c | 1 +
daemon/hotplug.c | 1 +
daemon/initrd.c | 1 +
daemon/journal.c | 5 +++
daemon/ldm.c | 1 +
daemon/lvm-filter.c | 1 +
daemon/mktemp.c | 1 +
daemon/utsname.c | 1 +
diff/diff.c | 1 +
fish/Makefile.am | 2 +-
fish/file-edit.c | 1 +
fuse/test-fuse.c | 2 ++
generator/actions.ml | 50 +++++++++++++++---------------
generator/c.ml | 1 +
generator/tests_c_api.ml | 20 +++++++++++-
generator/types.ml | 5 +++
m4/.gitignore | 3 ++
mllib/Makefile.am | 1 +
p2v/Makefile.am | 2 +-
p2v/ssh.c | 2 --
po-docs/Makefile.am | 2 +-
run.in | 2 +-
sparsify/statvfs-c.c | 1 +
src/Makefile.am | 3 +-
src/create.c | 1 +
src/dbdump.c | 1 +
src/file.c | 1 +
src/filearch.c | 1 +
src/fuse.c | 1 +
src/info.c | 1 +
src/inspect-apps.c | 3 ++
src/inspect-fs-windows.c | 5 ++-
src/inspect-icon.c | 1 +
src/journal.c | 3 ++
src/launch-direct.c | 1 +
src/launch-libvirt.c | 1 +
src/launch-unix.c | 1 +
src/libvirt-auth.c | 1 +
src/libvirt-domain.c | 1 +
tests/c-api/test-pwd.c | 2 +-
tests/c-api/tests-main.c | 39 +++++++++++++++++++++++
tests/c-api/tests.h | 1 +
tests/events/test-libvirt-auth-callbacks.c | 4 +--
tests/guests/Makefile.am | 2 +-
50 files changed, 153 insertions(+), 43 deletions(-)
--
1.9.3
10 years, 1 month
[PATCH 1/2] ocaml: Factor out flags into configure script.
by Richard W.M. Jones
No change, just refactoring.
---
builder/Makefile.am | 2 +-
configure.ac | 6 ++++++
customize/Makefile.am | 2 +-
generator/Makefile.am | 2 +-
mllib/Makefile.am | 2 +-
ocaml/Makefile.am | 2 +-
resize/Makefile.am | 2 +-
sparsify/Makefile.am | 2 +-
sysprep/Makefile.am | 2 +-
v2v/Makefile.am | 2 +-
10 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/builder/Makefile.am b/builder/Makefile.am
index dd96533..fd5c8e2 100644
--- a/builder/Makefile.am
+++ b/builder/Makefile.am
@@ -158,7 +158,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX-3 $(OCAMLPACKAGES)
+OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) $(OCAMLPACKAGES)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
OCAMLCLIBS = \
diff --git a/configure.ac b/configure.ac
index d464615..20f87ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1093,6 +1093,12 @@ AC_CHECK_PROG([OCAML_GETTEXT],[ocaml-gettext],[ocaml-gettext],[no])
AM_CONDITIONAL([HAVE_OCAML_GETTEXT],
[test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_gettext" != "xno" && test "x$OCAML_GETTEXT" != "xno"])
+dnl Flags we want to pass to every OCaml compiler call.
+OCAML_WARN_ERROR="-warn-error CDEFLMPSUVYZX-3"
+AC_SUBST([OCAML_WARN_ERROR])
+OCAML_FLAGS="-g"
+AC_SUBST([OCAML_FLAGS])
+
dnl Check for Perl (optional, for Perl bindings and Perl tools).
AC_ARG_ENABLE([perl],
AS_HELP_STRING([--disable-perl], [disable Perl language bindings]),
diff --git a/customize/Makefile.am b/customize/Makefile.am
index 0760476..0ea8d39 100644
--- a/customize/Makefile.am
+++ b/customize/Makefile.am
@@ -115,7 +115,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX-3 $(OCAMLPACKAGES)
+OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) $(OCAMLPACKAGES)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
OCAMLCLIBS = \
diff --git a/generator/Makefile.am b/generator/Makefile.am
index 3716c77..6e4928f 100644
--- a/generator/Makefile.am
+++ b/generator/Makefile.am
@@ -95,7 +95,7 @@ objects = \
EXTRA_DIST = $(sources) files-generated.txt
-OCAMLCFLAGS = -warn-error CDEFLMPSUVYZX-3 -I $(srcdir) -I . -package unix,str
+OCAMLCFLAGS = $(OCAML_WARN_ERROR) -I $(srcdir) -I . -package unix,str
noinst_PROGRAM = generator
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index 653b8aa..903a77d 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -95,7 +95,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX-3 $(OCAMLPACKAGES)
+OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) $(OCAMLPACKAGES)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
OCAMLCLIBS = \
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 94f11ef..41270a6 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -37,7 +37,7 @@ CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so
if HAVE_OCAML
-OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX-3
+OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
noinst_DATA = mlguestfs.cma META
diff --git a/resize/Makefile.am b/resize/Makefile.am
index eb4ded3..629fa22 100644
--- a/resize/Makefile.am
+++ b/resize/Makefile.am
@@ -67,7 +67,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX-3 $(OCAMLPACKAGES)
+OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) $(OCAMLPACKAGES)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
OCAMLCLIBS = \
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
index 48cd5f0..a7d4166 100644
--- a/sparsify/Makefile.am
+++ b/sparsify/Makefile.am
@@ -72,7 +72,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLFLAGS = -g -warn-error CDEFLMPSUVYZX-3
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index b1cebc2..6c760a8 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -130,7 +130,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX-3 $(OCAMLPACKAGES)
+OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) $(OCAMLPACKAGES)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
OCAMLCLIBS = \
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 921fb93..2f1f9bc 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -156,7 +156,7 @@ if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
-OCAMLFLAGS = -g -warn-error CDEFLMPSUVYZX-3
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
if !HAVE_OCAMLOPT
OBJECTS = $(BOBJECTS)
--
2.0.4
10 years, 1 month
[PATCH] tests: rename $SRCDIR to $srcdir
by Pino Toscano
No functional changes to the tests.
---
tests/guests/Makefile.am | 12 ++++++------
tests/guests/guest-aux/make-debian-img.sh | 6 +++---
tests/guests/guest-aux/make-fedora-img.pl | 10 +++++-----
tests/guests/guest-aux/make-ubuntu-img.sh | 4 ++--
tests/guests/guest-aux/make-windows-img.sh | 6 +++---
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am
index 62f5d14..88e0f57 100644
--- a/tests/guests/Makefile.am
+++ b/tests/guests/Makefile.am
@@ -75,7 +75,7 @@ fedora.img: guest-aux/make-fedora-img.pl \
guest-aux/fedora-journal.tar.xz \
guest-aux/fedora-name.db \
guest-aux/fedora-packages.db
- SRCDIR=$(srcdir) LAYOUT=partitions $(top_builddir)/run --test $<
+ srcdir=$(srcdir) LAYOUT=partitions $(top_builddir)/run --test $<
# Make a (dummy) Fedora image using md devices
fedora-md1.img fedora-md2.img: stamp-fedora-md.img
@@ -85,27 +85,27 @@ stamp-fedora-md.img: guest-aux/make-fedora-img.pl \
guest-aux/fedora-name.db \
guest-aux/fedora-packages.db
rm -f $@
- SRCDIR=$(srcdir) LAYOUT=partitions-md $(top_builddir)/run --test $<
+ srcdir=$(srcdir) LAYOUT=partitions-md $(top_builddir)/run --test $<
touch $@
fedora-btrfs.img: guest-aux/make-fedora-img.pl \
guest-aux/fedora-journal.tar.xz \
guest-aux/fedora-name.db \
guest-aux/fedora-packages.db
- SRCDIR=$(srcdir) LAYOUT=btrfs $(top_builddir)/run --test $<
+ srcdir=$(srcdir) LAYOUT=btrfs $(top_builddir)/run --test $<
# Make a (dummy) Debian image.
debian.img: guest-aux/make-debian-img.sh
- SRCDIR=$(srcdir) $(top_builddir)/run --test $<
+ srcdir=$(srcdir) $(top_builddir)/run --test $<
# Make a (dummy) Ubuntu image.
ubuntu.img: guest-aux/make-ubuntu-img.sh
- SRCDIR=$(srcdir) $(top_builddir)/run --test $<
+ srcdir=$(srcdir) $(top_builddir)/run --test $<
# Make a (dummy) Windows image.
windows.img: guest-aux/make-windows-img.sh \
guest-aux/windows-software guest-aux/windows-system
- SRCDIR=$(srcdir) $(top_builddir)/run --test $<
+ srcdir=$(srcdir) $(top_builddir)/run --test $<
guests-all-good.xml: guest-aux/make-guests-all-good.pl $(disk_images)
rm -f $@ $@-t
diff --git a/tests/guests/guest-aux/make-debian-img.sh b/tests/guests/guest-aux/make-debian-img.sh
index 95228ab..a86d939 100755
--- a/tests/guests/guest-aux/make-debian-img.sh
+++ b/tests/guests/guest-aux/make-debian-img.sh
@@ -82,11 +82,11 @@ upload fstab.tmp.$$ /etc/fstab
write /etc/debian_version "5.0.1"
write /etc/hostname "debian.invalid"
-upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status
+upload $srcdir/guest-aux/debian-packages /var/lib/dpkg/status
-upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls
+upload $srcdir/../data/bin-x86_64-dynamic /bin/ls
-upload $SRCDIR/guest-aux/debian-syslog /var/log/syslog
+upload $srcdir/guest-aux/debian-syslog /var/log/syslog
mkdir /boot/grub
touch /boot/grub/grub.conf
diff --git a/tests/guests/guest-aux/make-fedora-img.pl b/tests/guests/guest-aux/make-fedora-img.pl
index 1c23b6d..a693eed 100755
--- a/tests/guests/guest-aux/make-fedora-img.pl
+++ b/tests/guests/guest-aux/make-fedora-img.pl
@@ -44,7 +44,7 @@ my $g = Sys::Guestfs->new ();
my $bootdev;
-foreach ('LAYOUT', 'SRCDIR') {
+foreach ('LAYOUT', 'srcdir') {
defined ($ENV{$_}) or die "Missing environment variable: $_";
}
@@ -217,12 +217,12 @@ if (-f "mdadm.tmp.$$") {
unlink ("mdadm.tmp.$$") or die;
}
-$g->upload ($ENV{SRCDIR}.'/guest-aux/fedora-name.db', '/var/lib/rpm/Name');
-$g->upload ($ENV{SRCDIR}.'/guest-aux/fedora-packages.db', '/var/lib/rpm/Packages');
+$g->upload ($ENV{srcdir}.'/guest-aux/fedora-name.db', '/var/lib/rpm/Name');
+$g->upload ($ENV{srcdir}.'/guest-aux/fedora-packages.db', '/var/lib/rpm/Packages');
-$g->upload ($ENV{SRCDIR}.'/../data/bin-x86_64-dynamic', '/bin/ls');
+$g->upload ($ENV{srcdir}.'/../data/bin-x86_64-dynamic', '/bin/ls');
-$g->txz_in ($ENV{SRCDIR}.'/guest-aux/fedora-journal.tar.xz', '/var/log/journal');
+$g->txz_in ($ENV{srcdir}.'/guest-aux/fedora-journal.tar.xz', '/var/log/journal');
$g->mkdir ('/boot/grub');
$g->touch ('/boot/grub/grub.conf');
diff --git a/tests/guests/guest-aux/make-ubuntu-img.sh b/tests/guests/guest-aux/make-ubuntu-img.sh
index 183985b..49cc9fc 100755
--- a/tests/guests/guest-aux/make-ubuntu-img.sh
+++ b/tests/guests/guest-aux/make-ubuntu-img.sh
@@ -73,9 +73,9 @@ write /etc/debian_version "5.0.1"
upload release.tmp.$$ /etc/lsb-release
write /etc/hostname "ubuntu.invalid"
-upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status
+upload $srcdir/guest-aux/debian-packages /var/lib/dpkg/status
-upload $SRCDIR/../data/bin-x86_64-dynamic /bin/ls
+upload $srcdir/../data/bin-x86_64-dynamic /bin/ls
mkdir /boot/grub
touch /boot/grub/grub.conf
diff --git a/tests/guests/guest-aux/make-windows-img.sh b/tests/guests/guest-aux/make-windows-img.sh
index 575c2ee..fa6fa09 100755
--- a/tests/guests/guest-aux/make-windows-img.sh
+++ b/tests/guests/guest-aux/make-windows-img.sh
@@ -59,10 +59,10 @@ mount /dev/sda2 /
mkdir-p /Windows/System32/Config
mkdir-p /Windows/System32/Drivers
-upload $SRCDIR/guest-aux/windows-software /Windows/System32/Config/SOFTWARE
-upload $SRCDIR/guest-aux/windows-system /Windows/System32/Config/SYSTEM
+upload $srcdir/guest-aux/windows-software /Windows/System32/Config/SOFTWARE
+upload $srcdir/guest-aux/windows-system /Windows/System32/Config/SYSTEM
-upload $SRCDIR/../data/bin-win32.exe /Windows/System32/cmd.exe
+upload $srcdir/../data/bin-win32.exe /Windows/System32/cmd.exe
mkdir "/Program Files"
touch /autoexec.bat
--
1.9.3
10 years, 1 month
[PATCH] tests/regressions: Remove executable stack test.
by Pino Toscano
From: "Richard W.M. Jones" <rjones(a)redhat.com>
It's not our job to worry about downstream packaging issues ...
---
tests/regressions/Makefile.am | 6 +--
tests/regressions/test-noexec-stack.pl | 84 ----------------------------------
2 files changed, 2 insertions(+), 88 deletions(-)
delete mode 100755 tests/regressions/test-noexec-stack.pl
diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am
index a5e7cfc..661f6f9 100644
--- a/tests/regressions/Makefile.am
+++ b/tests/regressions/Makefile.am
@@ -41,8 +41,7 @@ EXTRA_DIST = \
rhbz1044014.in \
rhbz1044014.xml \
rhbz1054761.sh \
- rhbz1091803.sh \
- test-noexec-stack.pl
+ rhbz1091803.sh
TESTS = \
rhbz501893 \
@@ -65,8 +64,7 @@ TESTS = \
rhbz1001875.sh \
rhbz1054761.sh \
rhbz1055452 \
- rhbz1091803.sh \
- test-noexec-stack.pl
+ rhbz1091803.sh
if HAVE_LIBVIRT
TESTS += rhbz1044014.sh
diff --git a/tests/regressions/test-noexec-stack.pl b/tests/regressions/test-noexec-stack.pl
deleted file mode 100755
index 68bbb0b..0000000
--- a/tests/regressions/test-noexec-stack.pl
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/perl
-# Copyright (C) 2009 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.
-
-use strict;
-use warnings;
-
-if ($ENV{SKIP_TEST_NOEXEC_STACK_PL}) {
- print "$0: skipped test because environment variable is set\n";
- exit 77;
-}
-
-die("NOEXEC_CHECK not set") unless(exists($ENV{NOEXEC_CHECK}));
-
-my @files = split(/ /, $ENV{NOEXEC_CHECK});
-
-FILES: foreach my $file (@files) {
- my $output;
- my @cmd = ('readelf', '-l', $file);
- open($output, '-|', @cmd)
- or die("$0: failed to run: '".join(' ', @cmd)."': $!\n");
-
- my $offset;
- my $line = 1;
-
- # Find the offset of the Flags field
- while(<$output>) {
- next unless(/^\s*Type\b/);
-
- my @lines;
- push(@lines, $_);
-
- # Look for a Flg field on this line (32 bit)
- $offset = index($_, 'Flg ');
-
- if(-1 == $offset) {
- # 64 bit is split over 2 lines. Look for a Flags field on the next
- # line
- $_ = <$output>;
- $offset = index($_, 'Flags ');
- $line = 2;
- push(@lines, $_);
- }
-
- die("Unrecognised header: ".join("\n", @lines)) if(-1 == $offset);
- last;
- }
-
- # Find the GNU_STACK entry
- while(<$output>) {
- next unless(/^\s*GNU_STACK\b/);
-
- # Skip over input lines according to the header
- for(my $i = 1; $i < $line; $i++) {
- $_ = <$output>;
- }
-
- my $flags = substr($_, $offset, 3);
-
- $flags =~ /^[ R][ W]([ E])$/ or die("Unrecognised flags: $flags");
-
- if('E' eq $1) {
- print "***** $file has an executable stack *****\n";
- exit(1);
- }
-
- next FILES;
- }
-
- die("Didn't find GNU_STACK entry");
-}
--
1.9.3
10 years, 1 month
[PATCH] tests: c-api: add $datadir and $databuilddir
by Pino Toscano
Modify "tests" to expand any kind of environment variable than just
$srcdir; use $datadir and $databuilddir to point to the files in
$srcdir/tests/data and $builddir/tests/data, so it is easier to point at
the data for the tests.
Most of the work (except the $databuilddir and the integration in the
Makefile.am) has been done as part of larger changes by
Richard W.M. Jones <rjones(a)redhat.com>, see
https://www.redhat.com/archives/libguestfs/2014-October/msg00044.html
---
generator/actions.ml | 62 ++++++++++++++++++++++++------------------------
generator/tests_c_api.ml | 9 ++++---
tests/c-api/Makefile.am | 2 ++
tests/c-api/tests-main.c | 58 ++++++++++++++++++++++++++++++--------------
tests/c-api/tests.h | 2 +-
5 files changed, 78 insertions(+), 55 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index 4cfba0d..370e6e0 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -2744,19 +2744,19 @@ data." };
style = RString "format", [String "filename"], [];
tests = [
InitEmpty, Always, TestResultString (
- [["disk_format"; "../data/blank-disk-1s.raw"]], "raw"), [];
+ [["disk_format"; "$databuilddir/blank-disk-1s.raw"]], "raw"), [];
InitEmpty, Always, TestResultString (
- [["disk_format"; "../data/blank-disk-1s.qcow2"]], "qcow2"), [];
+ [["disk_format"; "$databuilddir/blank-disk-1s.qcow2"]], "qcow2"), [];
InitEmpty, Always, TestResultString (
- [["disk_format"; "../data/blank-disk-1K.raw"]], "raw"), [];
+ [["disk_format"; "$databuilddir/blank-disk-1K.raw"]], "raw"), [];
InitEmpty, Always, TestResultString (
- [["disk_format"; "../data/blank-disk-1K.qcow2"]], "qcow2"), [];
+ [["disk_format"; "$databuilddir/blank-disk-1K.qcow2"]], "qcow2"), [];
InitEmpty, Always, TestResultString (
- [["disk_format"; "../data/blank-disk-1M.raw"]], "raw"), [];
+ [["disk_format"; "$databuilddir/blank-disk-1M.raw"]], "raw"), [];
InitEmpty, Always, TestResultString (
- [["disk_format"; "../data/blank-disk-1M.qcow2"]], "qcow2"), [];
+ [["disk_format"; "$databuilddir/blank-disk-1M.qcow2"]], "qcow2"), [];
InitEmpty, Always, TestResultString (
- [["disk_format"; "../data/blank-disk-with-backing.qcow2"]], "qcow2"), [];
+ [["disk_format"; "$databuilddir/blank-disk-with-backing.qcow2"]], "qcow2"), [];
];
shortdesc = "detect the disk format of a disk image";
longdesc = "\
@@ -2774,19 +2774,19 @@ See also: L<guestfs(3)/DISK IMAGE FORMATS>" };
style = RInt64 "size", [String "filename"], [];
tests = [
InitEmpty, Always, TestResult (
- [["disk_virtual_size"; "../data/blank-disk-1s.raw"]], "ret == 512"), [];
+ [["disk_virtual_size"; "$databuilddir/blank-disk-1s.raw"]], "ret == 512"), [];
InitEmpty, Always, TestResult (
- [["disk_virtual_size"; "../data/blank-disk-1s.qcow2"]], "ret == 512"), [];
+ [["disk_virtual_size"; "$databuilddir/blank-disk-1s.qcow2"]], "ret == 512"), [];
InitEmpty, Always, TestResult (
- [["disk_virtual_size"; "../data/blank-disk-1K.raw"]], "ret == 1024"), [];
+ [["disk_virtual_size"; "$databuilddir/blank-disk-1K.raw"]], "ret == 1024"), [];
InitEmpty, Always, TestResult (
- [["disk_virtual_size"; "../data/blank-disk-1K.qcow2"]], "ret == 1024"), [];
+ [["disk_virtual_size"; "$databuilddir/blank-disk-1K.qcow2"]], "ret == 1024"), [];
InitEmpty, Always, TestResult (
- [["disk_virtual_size"; "../data/blank-disk-1M.raw"]], "ret == 1024*1024"), [];
+ [["disk_virtual_size"; "$databuilddir/blank-disk-1M.raw"]], "ret == 1024*1024"), [];
InitEmpty, Always, TestResult (
- [["disk_virtual_size"; "../data/blank-disk-1M.qcow2"]], "ret == 1024*1024"), [];
+ [["disk_virtual_size"; "$databuilddir/blank-disk-1M.qcow2"]], "ret == 1024*1024"), [];
InitEmpty, Always, TestResult (
- [["disk_virtual_size"; "../data/blank-disk-with-backing.qcow2"]], "ret == 1024*1024"), [];
+ [["disk_virtual_size"; "$databuilddir/blank-disk-with-backing.qcow2"]], "ret == 1024*1024"), [];
];
shortdesc = "return virtual size of a disk";
longdesc = "\
@@ -2801,19 +2801,19 @@ circumstances. See L<guestfs(3)/CVE-2010-3851>." };
style = RBool "backingfile", [String "filename"], [];
tests = [
InitEmpty, Always, TestResultFalse (
- [["disk_has_backing_file"; "../data/blank-disk-1s.raw"]]), [];
+ [["disk_has_backing_file"; "$databuilddir/blank-disk-1s.raw"]]), [];
InitEmpty, Always, TestResultFalse (
- [["disk_has_backing_file"; "../data/blank-disk-1s.qcow2"]]), [];
+ [["disk_has_backing_file"; "$databuilddir/blank-disk-1s.qcow2"]]), [];
InitEmpty, Always, TestResultFalse (
- [["disk_has_backing_file"; "../data/blank-disk-1K.raw"]]), [];
+ [["disk_has_backing_file"; "$databuilddir/blank-disk-1K.raw"]]), [];
InitEmpty, Always, TestResultFalse (
- [["disk_has_backing_file"; "../data/blank-disk-1K.qcow2"]]), [];
+ [["disk_has_backing_file"; "$databuilddir/blank-disk-1K.qcow2"]]), [];
InitEmpty, Always, TestResultFalse (
- [["disk_has_backing_file"; "../data/blank-disk-1M.raw"]]), [];
+ [["disk_has_backing_file"; "$databuilddir/blank-disk-1M.raw"]]), [];
InitEmpty, Always, TestResultFalse (
- [["disk_has_backing_file"; "../data/blank-disk-1M.qcow2"]]), [];
+ [["disk_has_backing_file"; "$databuilddir/blank-disk-1M.qcow2"]]), [];
InitEmpty, Always, TestResultTrue (
- [["disk_has_backing_file"; "../data/blank-disk-with-backing.qcow2"]]), [];
+ [["disk_has_backing_file"; "$databuilddir/blank-disk-with-backing.qcow2"]]), [];
];
shortdesc = "return whether disk has a backing file";
longdesc = "\
@@ -4735,15 +4735,15 @@ To get the checksums for many files, use C<guestfs_checksums_out>." };
tests = [
InitScratchFS, Always, TestResultString (
[["mkdir"; "/tar_in"];
- ["tar_in"; "$srcdir/../data/helloworld.tar"; "/tar_in"; "NOARG"];
+ ["tar_in"; "$datadir/helloworld.tar"; "/tar_in"; "NOARG"];
["cat"; "/tar_in/hello"]], "hello\n"), [];
InitScratchFS, Always, TestResultString (
[["mkdir"; "/tar_in_gz"];
- ["tar_in"; "$srcdir/../data/helloworld.tar.gz"; "/tar_in_gz"; "gzip"];
+ ["tar_in"; "$datadir/helloworld.tar.gz"; "/tar_in_gz"; "gzip"];
["cat"; "/tar_in_gz/hello"]], "hello\n"), [];
InitScratchFS, IfAvailable "xz", TestResultString (
[["mkdir"; "/tar_in_xz"];
- ["tar_in"; "$srcdir/../data/helloworld.tar.xz"; "/tar_in_xz"; "xz"];
+ ["tar_in"; "$datadir/helloworld.tar.xz"; "/tar_in_xz"; "xz"];
["cat"; "/tar_in_xz/hello"]], "hello\n"), []
];
shortdesc = "unpack tarfile to directory";
@@ -4800,7 +4800,7 @@ instead of user/group names.
tests = [
InitScratchFS, Always, TestResultString (
[["mkdir"; "/tgz_in"];
- ["tgz_in"; "$srcdir/../data/helloworld.tar.gz"; "/tgz_in"];
+ ["tgz_in"; "$datadir/helloworld.tar.gz"; "/tgz_in"];
["cat"; "/tgz_in/hello"]], "hello\n"), []
];
shortdesc = "unpack compressed tarball to directory";
@@ -8130,7 +8130,7 @@ or growing unnecessarily." };
tests = [
InitScratchFS, Always, TestResultString (
[["mkdir"; "/txz_in"];
- ["txz_in"; "$srcdir/../data/helloworld.tar.xz"; "/txz_in"];
+ ["txz_in"; "$datadir/helloworld.tar.xz"; "/txz_in"];
["cat"; "/txz_in/hello"]], "hello\n"), []
];
shortdesc = "unpack compressed tarball to directory";
@@ -8242,7 +8242,7 @@ types (see C<guestfs_part_get_parttype>)." };
tests = [
InitISOFS, Always, TestResult (
[["checksum_device"; "md5"; "/dev/sdd"]],
- "check_file_md5 (ret, \"../data/test.iso\") == 0"), []
+ "check_file_md5 (ret, \"$databuilddir/test.iso\") == 0"), []
];
shortdesc = "compute MD5, SHAx or CRC checksum of the contents of a device";
longdesc = "\
@@ -8316,7 +8316,7 @@ to find out what it is for." };
cancellable = true;
tests = [
InitScratchFS, Always, TestResultString (
- [["base64_in"; "../data/hello.b64"; "/base64_in"];
+ [["base64_in"; "$databuilddir/hello.b64"; "/base64_in"];
["cat"; "/base64_in"]], "hello\n"), []
];
shortdesc = "upload base64-encoded data to file";
@@ -10708,7 +10708,7 @@ C<guestfs_xfs_growfs> calls." };
optional = Some "hivex";
tests = [
InitScratchFS, Always, TestRun (
- [["upload"; "$srcdir/../data/minimal"; "/hivex_open"];
+ [["upload"; "$datadir/minimal"; "/hivex_open"];
["hivex_open"; "/hivex_open"; ""; ""; "false"];
["hivex_root"]; (* in this hive, it returns 0x1020 *)
["hivex_node_name"; "0x1020"];
@@ -10856,11 +10856,11 @@ See also: C<guestfs_hivex_value_utf8>." };
optional = Some "hivex";
tests = [
InitScratchFS, Always, TestRun (
- [["upload"; "$srcdir/../data/minimal"; "/hivex_commit1"];
+ [["upload"; "$datadir/minimal"; "/hivex_commit1"];
["hivex_open"; "/hivex_commit1"; ""; ""; "true"];
["hivex_commit"; "NULL"]]), [["hivex_close"]];
InitScratchFS, Always, TestResultTrue (
- [["upload"; "$srcdir/../data/minimal"; "/hivex_commit2"];
+ [["upload"; "$datadir/minimal"; "/hivex_commit2"];
["hivex_open"; "/hivex_commit2"; ""; ""; "true"];
["hivex_commit"; "/hivex_commit2_copy"];
["is_file"; "/hivex_commit2_copy"; "false"]]), [["hivex_close"]]
diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
index 88aa07e..86bf08e 100644
--- a/generator/tests_c_api.ml
+++ b/generator/tests_c_api.ml
@@ -385,17 +385,16 @@ and generate_test_command_call ?(expect_error = false) ?test ?ret test_name cmd=
| String _, arg, sym
| OptString _, arg, sym
| Key _, arg, sym
- | GUID _, arg, sym ->
- pr " const char *%s = \"%s\";\n" sym (c_quote arg);
+ | GUID _, arg, sym
+ | FileIn _, arg, sym ->
+ pr " CLEANUP_FREE char *%s = substitute_environment (\"%s\");\n"
+ sym (c_quote arg)
| BufferIn _, arg, sym ->
pr " const char *%s = \"%s\";\n" sym (c_quote arg);
pr " size_t %s_size = %d;\n" sym (String.length arg)
| Int _, _, _
| Int64 _, _, _
| Bool _, _, _ -> ()
- | FileIn _, arg, sym ->
- pr " CLEANUP_FREE char *%s = substitute_srcdir (\"%s\");\n"
- sym (c_quote arg)
| FileOut _, _, _ -> ()
| StringList _, "", sym
| DeviceList _, "", sym ->
diff --git a/tests/c-api/Makefile.am b/tests/c-api/Makefile.am
index 6ea22e9..17c88d7 100644
--- a/tests/c-api/Makefile.am
+++ b/tests/c-api/Makefile.am
@@ -69,6 +69,8 @@ TESTS_ENVIRONMENT = \
SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
SKIP_TEST_COMMAND_LINES=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
SKIP_TEST_COMMAND=$(shell ldd test-pwd | grep -sq 'not a dynamic executable' || echo 1) \
+ datadir=$(srcdir)/../data \
+ databuilddir=$(builddir)/../data \
$(top_builddir)/run --test $(VG)
#SKIP_TEST_CHECKSUM_8=$(shell if test `find ../initramfs -name squashfs.ko | wc -l` -eq 0; then echo 1; fi)
diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c
index e81e15e..986894d 100644
--- a/tests/c-api/tests-main.c
+++ b/tests/c-api/tests-main.c
@@ -357,35 +357,45 @@ match_re (const char *str, const char *pattern)
return r != PCRE_ERROR_NOMATCH;
}
-/* Used for FileIn parameters in tests. If the path starts with
- * "$srcdir" then replace that with the contents of the $srcdir
- * environment variable (this is set by automake and run time). The
- * caller must free the returned string.
+/* Used for some parameters in tests. If the string starts with
+ * "$variable" then replace that with the contents of the named
+ * environment variable. The caller must free the returned string.
*/
char *
-substitute_srcdir (const char *path)
+substitute_environment (const char *str)
{
char *ret;
+ size_t len;
+ CLEANUP_FREE char *name = NULL;
+ const char *value;
+
+ if (STRPREFIX (str, "$")) {
+ len = strspn (str+1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
+ if (len == 0) {
+ fprintf (stderr, "tests: invalid environment variable in string (%s)\n",
+ str);
+ exit (EXIT_FAILURE);
+ }
+ name = strndup (str+1, len);
+ if (name == NULL) {
+ perror ("strndup");
+ exit (EXIT_FAILURE);
+ }
- if (STRPREFIX (path, "$srcdir")) {
- const char *srcdir;
-
- srcdir = getenv ("srcdir");
- if (!srcdir) {
- fprintf (stderr, "tests: environment variable $srcdir is not defined.\n"
- "Normally it is defined by automake. If you are running the\n"
- "tests directly, set $srcdir to point to the source tests/c-api\n"
- "directory.\n");
+ value = getenv (name);
+ if (!value) {
+ fprintf (stderr, "tests: environment variable $%s is not defined.\n",
+ name);
exit (EXIT_FAILURE);
}
- if (asprintf (&ret, "%s%s", srcdir, path + 7) == -1) {
+ if (asprintf (&ret, "%s%s", value, str + 1 + len) == -1) {
perror ("asprintf");
exit (EXIT_FAILURE);
}
}
else {
- ret = strdup (path);
+ ret = strdup (str);
if (!ret) {
perror ("strdup");
exit (EXIT_FAILURE);
@@ -424,6 +434,8 @@ static guestfs_h *
create_handle (void)
{
guestfs_h *g;
+ const char *databuilddir;
+ CLEANUP_FREE char *test_iso = NULL;
g = guestfs_create ();
if (g == NULL) {
@@ -446,8 +458,18 @@ create_handle (void)
exit (EXIT_FAILURE);
}
- if (guestfs_add_drive_ro (g, "../data/test.iso") == -1) {
- printf ("FAIL: guestfs_add_drive_ro ../data/test.iso\n");
+ databuilddir = getenv ("databuilddir");
+ if (databuilddir == NULL) {
+ fprintf (stderr, "environment variable $databuilddir is not defined\n");
+ exit (EXIT_FAILURE);
+ }
+ if (asprintf (&test_iso, "%s/test.iso", databuilddir) == -1) {
+ perror ("asprintf");
+ exit (EXIT_FAILURE);
+ }
+
+ if (guestfs_add_drive_ro (g, test_iso) == -1) {
+ printf ("FAIL: guestfs_add_drive_ro $databuilddir/test.iso\n");
exit (EXIT_FAILURE);
}
diff --git a/tests/c-api/tests.h b/tests/c-api/tests.h
index 7959570..129aee6 100644
--- a/tests/c-api/tests.h
+++ b/tests/c-api/tests.h
@@ -43,7 +43,7 @@ extern int check_file_md5 (const char *ret, const char *filename);
extern const char *get_key (char **hash, const char *key);
extern int check_hash (char **ret, const char *key, const char *expected);
extern int match_re (const char *str, const char *pattern);
-extern char *substitute_srcdir (const char *path);
+extern char *substitute_environment (const char *str);
extern void skipped (const char *test_name, const char *fs, ...) __attribute__((format (printf,2,3)));
#endif /* TESTS_H_ */
--
1.9.3
10 years, 1 month