Commit Graph

10 Commits

Author SHA1 Message Date
Richard W.M. Jones
45de287447 lib: Autodetect backing format for qemu-img create -b
qemu 6.1 has decided to change qemu-img create so that a backing
format (-F) is required if a backing file (-b) is specified.  Since we
don't want to change the libguestfs API to force callers to specify
this because that would be an API break, autodetect it.

This is similar to commit c8c181e8d9 ("launch: libvirt: Autodetect
backing format for readonly drive overlays").

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1998820
2021-08-31 08:35:52 +01:00
Richard W.M. Jones
786dba91d1 Revert "lib: Autodetect backing format and specify it explicitly."
This reverts commit 92fd5d5d40.

See discussion here:
https://www.redhat.com/archives/libguestfs/2020-March/thread.html#00041
2020-03-09 12:54:05 +00:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
92fd5d5d40 lib: Autodetect backing format and specify it explicitly.
In the guestfs_disk_create API we have traditionally allowed you to
set backingfile without setting backingformat.  The meaning of this is
to let qemu autodetect the backing format when opening the overlay
disk.

However libvirt >= 6.0 refuses to even pass such disks to qemu (see
https://bugzilla.redhat.com/show_bug.cgi?id=1798148).

For this reason, move the autodetection earlier and make it explicit.
We now autodetect the format of the backing disk at the time of
creation of the overlay, and set that as the backing format in the
overlay disk itself, allowing libvirt to open the disk later.
2020-03-06 19:03:03 +00:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Pino Toscano
962e8b6255 lib: create: avoid one extra string allocation
When creating the qemu-img command, use the guestfs_int_cmd_add_arg &
guestfs_int_cmd_add_arg_format APIs to add the proper filename directly,
without creating a string for it.

This should cause no functional change.
2018-08-23 13:22:00 +02:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
5856323e6f lib: create: Allow any [[:alnum:]]+ string as a backingfmt parameter (RHBZ#1459979).
If you use the libguestfs tools which open disk images read-only
(eg. virt-df), with formats such as 'vdi', then you will see an error:

  error: invalid value for backingformat parameter 'vdi'

This is because opening a disk image read-only will try to create a
qcow2 file with the original image as a backing file.  However the
list of permitted backing formats was very restrictive and did not
include 'vdi' (nor many other uncommon formats).

Instead of using a whitelist for backing formats, just validate that
the string is alphanumeric and short.

Thanks: Mike Goodwin for reporting the bug.
2017-06-09 12:57:03 +01:00
Richard W.M. Jones
ee206d7ba8 Use Unicode single quotes ‘’ in place of short single quoted strings throughout.
Only in end-user messages and documentation.  This change was done
mostly mechanically using the Perl script attached below.

I also changed don't -> don’t etc and made some other simple fixes.

See also: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

----------
 #!/usr/bin/perl -w

use strict;
use Locale::PO;

my $re = qr{'([-\w%.,=?*/]+)'};

my %files = ();

foreach my $filename ("po/libguestfs.pot", "po-docs/libguestfs-docs.pot") {
    my $poref = Locale::PO->load_file_asarray($filename);

    foreach my $po (@$poref) {
        if ($po->msgid =~ $re) {
            my @refs = split /\s+/, $po->reference;
            foreach my $ref (@refs) {
                my ($file, $lineno) = split /:/, $ref, 2;
                $file =~ s{^\.\./}{};
                if (exists $files{$file}) {
                    push @{$files{$file}}, $lineno;
                } else {
                    $files{$file} = [$lineno];
                }
            }
        }
    }
}

foreach my $file (sort keys %files) {
    unless (-w $file) {
        warn "warning: $file is probably generated\n"; # have to edit generator
        next;
    }
    my @lines = sort { $a <=> $b } @{$files{$file}};

    #print "editing $file at lines ", join (", ", @lines), " ...\n";
    open FILE, "<$file" or die "$file: $!";
    my @all = ();
    push @all, $_ while <FILE>;
    close FILE;

    my $ext = $file;
    $ext =~ s/^.*\.//;

    foreach (@lines) {
        # Don't mess with verbatim sections in POD files.
        next if $ext eq "pod" && $all[$_-1] =~ m/^ /;

        unless ($all[$_-1] =~ $re) {
            # this can happen for multi-line strings, have to edit it
            # by hand
            warn "warning: $file:$_ does not contain expected content\n";
            next;
        }
        $all[$_-1] =~ s/$re/‘$1’/g;
    }

    rename "$file", "$file.bak";
    open FILE, ">$file" or die "$file: $!";
    print FILE $_ for @all;
    close FILE;
    my $mode = (stat ("$file.bak"))[2];
    chmod ($mode & 0777, "$file");
}
2017-04-04 18:47:37 +01:00
Richard W.M. Jones
f161c9ea57 Rename src/ to lib/ 2017-01-26 15:05:46 +00:00