[Pkg-libvirt-commits] [libguestfs] 152/233: virt-make-fs: Use disk-create API instead of calling qemu-img create.

Hilko Bengen bengen at moszumanska.debian.org
Wed Feb 19 21:11:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 9015d5ac1491a7a1fa662deab007f3fee7e4e53e
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Jan 28 15:08:16 2014 +0000

    virt-make-fs: Use disk-create API instead of calling qemu-img create.
    
    Strictly speaking this reduces the number of formats that virt-make-fs
    can output to, but it's likely that no one cares and if they do we can
    add new formats in future.
---
 tools/virt-make-fs | 44 ++++++--------------------------------------
 1 file changed, 6 insertions(+), 38 deletions(-)

diff --git a/tools/virt-make-fs b/tools/virt-make-fs
index 605d067..f1cc09d 100755
--- a/tools/virt-make-fs
+++ b/tools/virt-make-fs
@@ -231,9 +231,6 @@ Choose the output disk image format.
 
 The default is C<raw> (raw sparse disk image).
 
-For other choices, see the L<qemu-img(1)> manpage.  The only other
-choice that would really make sense here is C<qcow2>.
-
 =cut
 
 my $type = "ext2";
@@ -425,46 +422,17 @@ if (!defined $size) {
 
 $size = int ($size);
 
-# Create the output disk.
-#
-# Use qemu-img so we can control the output format, but capture any
-# output temporarily and only display it if the command fails.
-
-my @options = ();
- at options = ("-o", "preallocation=metadata") if $format eq "qcow2";
-
-my @cmd = ("qemu-img", "create", "-f", $format, @options, $output, $size);
-if ($debug) {
-    print STDERR ("running: ", join (" ", @cmd), "\n");
-}
-
-{
-    my $tmpfh = tempfile ();
-    my ($r, $oldout, $olderr);
-
-    open $oldout, ">&STDOUT" or die __"cannot dup STDOUT";
-    open $olderr, ">&STDERR" or die __"cannot dup STDERR";
-    close STDOUT;
-    close STDERR;
-    open STDOUT, ">&", \$tmpfh or die __"cannot redirect STDOUT";
-    open STDERR, ">&", \$tmpfh or die __"cannot redirect STDERR";
-    $r = system (@cmd);
-    open STDOUT, ">&", $oldout or die __"cannot restore STDOUT";
-    open STDERR, ">&", $olderr or die __"cannot restore STDERR";
-
-    unless ($r == 0) {
-        print STDERR __"qemu-img create: failed to create disk image:\n";
-        seek $tmpfh, 0, SEEK_SET;
-        print STDERR $_ while <$tmpfh>;
-        die "\n";
-    }
-}
-
 eval {
     print STDERR "starting libguestfs ...\n" if $debug;
 
     # Run libguestfs.
     my $g = Sys::Guestfs->new ();
+
+    # Create the output disk.
+    my %options = ();
+    $options{preallocation} = "metadata" if $format eq "qcow2";
+    $g->disk_create ($output, $format, $size, %options);
+
     $g->add_drive ($output, format => $format);
     $g->launch ();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list