[et-mgmt-tools] [PATCH 5 of 5] Allow specification of output disk format

john.levon at sun.com john.levon at sun.com
Wed Jul 9 18:29:39 UTC 2008


# HG changeset patch
# User john.levon at sun.com
# Date 1215628144 25200
# Node ID eca4a4800ad7c6254fdaef56587f143cf16f5262
# Parent  a36c666ef5d381e3961545d0359949e82d6d064b
Allow specification of output disk format

In particular, allow the disk conversion to be skipped.

Signed-off-by: John Levon <john.levon at sun.com>

diff --git a/man/en/virt-convert.1 b/man/en/virt-convert.1
--- a/man/en/virt-convert.1
+++ b/man/en/virt-convert.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "VIRT-CONVERT 1"
-.TH VIRT-CONVERT 1 "2008-07-04" "perl v5.8.8" "Virtual Machine Install Tools"
+.TH VIRT-CONVERT 1 "2008-07-09" "perl v5.8.8" "Virtual Machine Install Tools"
 .SH "NAME"
 virt\-convert \- convert virtual machines between formats
 .SH "SYNOPSIS"
@@ -175,6 +175,10 @@
 .IP "\-o format" 4
 .IX Item "-o format"
 Output format. Currently, \f(CW\*(C`virt\-image\*(C'\fR  is the only supported output format.
+.IP "\-D format" 4
+.IX Item "-D format"
+Output disk format, or \f(CW\*(C`none\*(C'\fR if no conversion should be performed. See
+\&\fIqemu\-img\fR\|(1).
 .IP "\-d, \-\-debug" 4
 .IX Item "-d, --debug"
 Print debugging information
@@ -196,7 +200,7 @@
 .Ve
 .SH "AUTHOR"
 .IX Header "AUTHOR"
-Written by Joey Boggs
+Written by Joey Boggs and John Levon
 .PP
 See the \s-1AUTHORS\s0 file in the source distribution for the complete list of credits.
 .SH "BUGS"
diff --git a/man/en/virt-convert.pod b/man/en/virt-convert.pod
--- a/man/en/virt-convert.pod
+++ b/man/en/virt-convert.pod
@@ -58,6 +58,11 @@
 
 Output format. Currently, C<virt-image>  is the only supported output format.
 
+=item  -D format
+
+Output disk format, or C<none> if no conversion should be performed. See
+L<qemu-img(1)>.
+
 =item -d, --debug
 
 Print debugging information
@@ -80,7 +85,7 @@
 
 =head1 AUTHOR
 
-Written by Joey Boggs
+Written by Joey Boggs and John Levon
 
 See the AUTHORS file in the source distribution for the complete list of credits.
 
diff --git a/virt-convert b/virt-convert
--- a/virt-convert
+++ b/virt-convert
@@ -24,6 +24,7 @@
 import os
 import logging
 import errno
+import platform
 from optparse import OptionParser
 
 import virtinst.cli as cli
@@ -53,6 +54,8 @@
     opts.add_option("-o", "--output-format", action="store",
                     dest="output_format", default="virt-image",
                     help=("Output format, e.g. 'virt-image'"))
+    opts.add_option("-D", "--disk-format", action="store",
+                    dest="disk_format", help=("Output disk format"))
     opts.add_option("-v", "--hvm", action="store_true", dest="fullvirt",
                     help=("This guest should be a fully virtualized guest"))
     opts.add_option("-p", "--paravirt", action="store_true", dest="paravirt",
@@ -64,6 +67,10 @@
     if len(args) > 2:
         opts.error(("Too many arguments provided"))
     
+    if (options.disk_format and
+        options.disk_format not in diskcfg.disk_formats()):
+        opts.error("Unknown output disk format \"%s\"" % options.disk_format)
+
     # hard-code for now
     if options.input_format != "vmx":
         opts.error(("Unsupported input format \"%s\"" % options.input_format))
@@ -191,9 +198,22 @@
 
     try:
         for d in vmdef.disks:
-            verbose(options, "Converting disk \"%s\" to type %s..." %
-                (d.path, "raw"))
-            d.convert(options.input_dir, options.output_dir, "raw")
+            format = options.disk_format
+
+            # no auto-conversion on Solaris for VMDK disks
+            if (d.format == diskcfg.DISK_FORMAT_VMDK and
+                not format and platform.system() == "SunOS"):
+                continue
+
+            if not format:
+                format = "raw"
+
+            if format != "none":
+                verbose(options, "Converting disk \"%s\" to type %s..." %
+                    (d.path, format))
+
+            d.convert(options.input_dir, options.output_dir, format)
+
     except OSError, e:
         cleanup("Couldn't convert disks: %s" % e.strerror,
             options, vmdef, clean)




More information about the et-mgmt-tools mailing list