diff --git a/.libguestfs.metadata b/.libguestfs.metadata new file mode 100644 index 0000000..708ece2 --- /dev/null +++ b/.libguestfs.metadata @@ -0,0 +1 @@ +7025453de58d7a7330903877e3bf788d5891cd07 SOURCES/libguestfs-1.22.6.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/0001-tests-Add-a-regression-test-for-all-disk_-info-comma.patch b/SOURCES/0001-tests-Add-a-regression-test-for-all-disk_-info-comma.patch new file mode 100644 index 0000000..8060c17 --- /dev/null +++ b/SOURCES/0001-tests-Add-a-regression-test-for-all-disk_-info-comma.patch @@ -0,0 +1,244 @@ +From 11e147bea7392f3c59b76efb1c62c81250e9ff20 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 18 Jul 2013 13:59:09 +0100 +Subject: [PATCH] tests: Add a regression test for all disk_* info commands + (RHBZ#981663). + +(cherry picked from commit 2311fb0632a64cfa2bab8bf65c82ffaa042d619e) +--- + Makefile.am | 1 + + configure.ac | 1 + + tests/disk-info/Makefile.am | 31 +++++++++ + tests/disk-info/disk-info.pl | 158 +++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 191 insertions(+) + create mode 100644 tests/disk-info/Makefile.am + create mode 100755 tests/disk-info/disk-info.pl + +diff --git a/Makefile.am b/Makefile.am +index 071fc43..de747b0 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -60,6 +60,7 @@ SUBDIRS += tests/hotplug + SUBDIRS += tests/nbd + SUBDIRS += tests/http + SUBDIRS += tests/syslinux ++SUBDIRS += tests/disk-info + SUBDIRS += tests/regressions + endif + +diff --git a/configure.ac b/configure.ac +index f48f3a3..62d558f 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1633,6 +1633,7 @@ AC_CONFIG_FILES([Makefile + tests/charsets/Makefile + tests/data/Makefile + tests/disks/Makefile ++ tests/disk-info/Makefile + tests/disk-labels/Makefile + tests/guests/Makefile + tests/guests/guests.xml +diff --git a/tests/disk-info/Makefile.am b/tests/disk-info/Makefile.am +new file mode 100644 +index 0000000..5a34c47 +--- /dev/null ++++ b/tests/disk-info/Makefile.am +@@ -0,0 +1,31 @@ ++# libguestfs ++# Copyright (C) 2013 Red Hat Inc. ++# ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++ ++include $(top_srcdir)/subdir-rules.mk ++ ++EXTRA_DIST = \ ++ $(TESTS) ++ ++TESTS = \ ++ disk-info.pl ++ ++TESTS_ENVIRONMENT = $(top_builddir)/run --test $(VG) ++ ++check-valgrind: ++ $(MAKE) VG="@VG@" check ++ ++CLEANFILES = *~ +diff --git a/tests/disk-info/disk-info.pl b/tests/disk-info/disk-info.pl +new file mode 100755 +index 0000000..2fecc20 +--- /dev/null ++++ b/tests/disk-info/disk-info.pl +@@ -0,0 +1,158 @@ ++#!/usr/bin/perl -w ++# Test guestfs_disk_* functions. ++# Copyright (C) 2013 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; ++ ++use File::Temp qw(tempdir); ++ ++use Sys::Guestfs; ++ ++# Bail on 32 bit perl. ++if (~1 == 4294967294) { ++ print "$0: test skipped because your perl is not 64 bits\n"; ++ exit 77; ++} ++ ++$ENV{LC_ALL} = "C"; ++ ++my $tmpdir = tempdir (CLEANUP => 1); ++my $errors = 0; ++ ++my $g = Sys::Guestfs->new (); ++ ++my ($format, $size, $backing); ++foreach $format ("raw", "qcow2") { ++ foreach $size (1024, 1024*1024, 1024*1024*1024, 1024*1024*1024*1024) { ++ foreach $backing (0, 1) { ++ # Raw files can't have backing files. ++ next if $format eq "raw" && $backing; ++ ++ my $filename = create_disk ($tmpdir, $format, $size, $backing); ++ ++ my $detected_format = $g->disk_format ($filename); ++ if ($detected_format ne $format) { ++ print_disk ($filename, $format, $size, $backing, \*STDERR); ++ printf STDERR ("unexpected format: detected %s, expected %s\n", ++ $detected_format, $format); ++ $errors++; ++ } ++ ++ my $detected_size = $g->disk_virtual_size ($filename); ++ if ($detected_size != $size) { ++ print_disk ($filename, $format, $size, $backing, \*STDERR); ++ printf STDERR ("unexpected size: detected %d, expected %d\n", ++ $detected_size, $size); ++ $errors++; ++ } ++ ++ my $detected_backing = $g->disk_has_backing_file ($filename); ++ if ($detected_backing != $backing) { ++ print_disk ($filename, $format, $size, $backing, \*STDERR); ++ printf STDERR ("unexpected backing file: detected %d, expected %d\n", ++ $detected_backing, $backing); ++ $errors++; ++ } ++ } ++ } ++} ++ ++# Check the negative cases too: file not found, file is a directory. ++# Note that since anything can be a raw file, there's no way to test ++# that this would fail for a non-disk-image. ++eval { $g->disk_format ($tmpdir . "/nosuchfile") }; ++if (!$@) { ++ print STDERR "expected non-existent file to fail, but it did not\n"; ++ $errors++; ++} ++if ($@ !~ /No such file/) { ++ print STDERR "unexpected error from non-existent file: $@\n"; ++ $errors++; ++} ++ ++my $testdir = $tmpdir . "/dir"; ++mkdir $testdir, 0755; ++eval { $g->disk_format ($testdir) }; ++if (!$@) { ++ print STDERR "expected directory fail, but it did not\n"; ++ $errors++; ++} ++if ($@ !~ /is a directory/) { ++ print STDERR "unexpected error from directory: $@\n"; ++ $errors++; ++} ++ ++#---------------------------------------------------------------------- ++ ++my $unique = 0; ++sub get_unique ++{ ++ return $unique++; ++} ++ ++sub create_disk ++{ ++ my $tmpdir = shift; ++ my $format = shift; ++ my $size = shift; ++ my $backing = shift; ++ ++ my $options; ++ ++ if ($backing) { ++ my $backing_file = sprintf ("%s/b%d", $tmpdir, get_unique ()); ++ qemu_img_create ("raw", "", $backing_file, 1024*1024); ++ $options = "backing_file=%s" ++ } ++ ++ my $filename = sprintf ("%s/d%d", $tmpdir, get_unique ()); ++ qemu_img_create ($format, $options, $filename, $size); ++ return $filename; ++} ++ ++sub qemu_img_create ++{ ++ my $format = shift; ++ my $options = shift; ++ my $filename = shift; ++ my $size = shift; ++ ++ my @cmd = ("qemu-img", "create", "-f", $format); ++ if (defined $options) { ++ push @cmd, "-o", $options; ++ } ++ push @cmd, $filename; ++ if (defined $size) { ++ push @cmd, $size; ++ } ++ system (@cmd) == 0 or die "system ", join (" ", @cmd), " failed: $?" ++} ++ ++sub print_disk ++{ ++ my $filename = shift; ++ my $format = shift; ++ my $size = shift; ++ my $backing = shift; ++ my $io = shift; ++ ++ printf $io ("created disk %s: format=%s, size=%d, backing=%d\n", ++ $filename, $format, $size, $backing); ++} ++ ++exit ($errors == 0 ? 0 : 1); +-- +1.8.3.1 + diff --git a/SOURCES/0002-New-API-add-drive-scratch.patch b/SOURCES/0002-New-API-add-drive-scratch.patch new file mode 100644 index 0000000..6712886 --- /dev/null +++ b/SOURCES/0002-New-API-add-drive-scratch.patch @@ -0,0 +1,147 @@ +From eaffd8105fcd164616aad47cea2b2bf56686acfa Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Fri, 19 Jul 2013 14:09:56 +0100 +Subject: [PATCH] New API: add-drive-scratch. + +This adds a temporary scratch drive to the handle. + +(cherry picked from commit 1b11a83d5248511abbf86775601eb6e25a36c1ee) +--- + generator/actions.ml | 15 +++++++++++++++ + gobject/Makefile.inc | 2 ++ + po/POTFILES | 1 + + src/drives.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 71 insertions(+) + +diff --git a/generator/actions.ml b/generator/actions.ml +index d30aec8..eb09aa7 100644 +--- a/generator/actions.ml ++++ b/generator/actions.ml +@@ -2954,6 +2954,21 @@ it is set to the empty string (but never C)." }; + longdesc = "\ + Get the program name. See C." }; + ++ { defaults with ++ name = "add_drive_scratch"; ++ style = RErr, [Int64 "size"], [OString "name"; OString "label"]; ++ blocking = false; ++ fish_alias = ["scratch"]; ++ shortdesc = "add a temporary scratch drive"; ++ longdesc = "\ ++This command adds a temporary scratch drive to the handle. The ++C parameter is the virtual size (in bytes). The scratch ++drive is blank initially (all reads return zeroes until you start ++writing to it). The drive is deleted when the handle is closed. ++ ++The optional arguments C and C