virt-install: Default to qcow2 for new images

Following along with virt-manager's change. It has all the features and
good enough performace, and is easy enough to override for people that
care.
This commit is contained in:
Cole Robinson 2014-02-10 18:47:58 -05:00
parent cdd9dbe7fc
commit 21fb072d4a
5 changed files with 25 additions and 7 deletions

View File

@ -565,6 +565,8 @@ read and write caching.
Disk image format. For file volumes, this can be 'raw', 'qcow2', 'vmdk', etc. See format types in L<http://libvirt.org/storage.html> for possible values. This is often mapped to the B<driver_type> value as well.
If not specified when creating file images, this will default to 'qcow2'.
If creating storage, this will be the format of the new image. If using an existing image, this overrides libvirt's format auto-detection.
=item B<driver_name>
@ -1417,17 +1419,17 @@ C<~/.cache/virt-manager/virt-install.log> even if this parameter is omitted.
=head1 EXAMPLES
Install a Fedora 13 KVM guest with virtio accelerated disk/network,
creating a new 8GB storage file, installing from media in the hosts
CDROM drive, auto launching a graphical VNC viewer
Install a Fedora 20 KVM guest with virtio accelerated disk/network,
creating a new 10GB qcow2 file, installing from media in the hosts
CDROM drive. This will use Spice graphics by default, and launch autolaunch
a graphical client.
# virt-install \
--connect qemu:///system \
--virt-type kvm \
--name demo \
--memory 500 \
--disk size=8 \
--graphics vnc \
--disk size=10 \
--cdrom /dev/cdrom \
--os-variant fedora13

View File

@ -69,6 +69,10 @@
</iotune>
<readonly/>
</disk>
<disk type="file" device="disk">
<source file="/var/lib/libvirt/images/foobar.qcow2"/>
<target dev="hdc" bus="ide"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1">
<address type="pci" domain="0" bus="0" slot="4" function="7"/>
</controller>
@ -209,6 +213,10 @@
</iotune>
<readonly/>
</disk>
<disk type="file" device="disk">
<source file="/var/lib/libvirt/images/foobar.qcow2"/>
<target dev="hdc" bus="ide"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1">
<address type="pci" domain="0" bus="0" slot="4" function="7"/>
</controller>

View File

@ -548,6 +548,7 @@ c.add_compare("""--hvm --pxe \
--disk %(EXISTUPPER)s,cache=writeback,io=threads,perms=sh,serial=WD-WMAP9A966149,boot_order=2 \
--disk %(NEWIMG1)s,sparse=false,size=.001,perms=ro,error_policy=enospace \
--disk device=cdrom,bus=sata,read_bytes_sec=1,read_iops_sec=2,total_bytes_sec=10,total_iops_sec=20,write_bytes_sec=5,write_iops_sec=6 \
--disk size=1 \
--serial tcp,host=:2222,mode=bind,protocol=telnet \
--filesystem /source,/target,mode=squash \
--network user,mac=12:34:56:78:11:22 \

View File

@ -360,12 +360,13 @@ class vmmConnection(vmmGObject):
fmt = self.config.get_default_storage_format()
if fmt != "qcow2":
return
return fmt
if self.check_support(self._backend.SUPPORT_CONN_DEFAULT_QCOW2):
return fmt
return None
####################################
# Connection pretty print routines #
####################################

View File

@ -1522,6 +1522,12 @@ class ParserPM(VirtCLIParser):
# --disk parsing #
##################
def _default_image_file_format(conn):
if conn.check_support(conn.SUPPORT_CONN_DEFAULT_QCOW2):
return "qcow2"
return "raw"
def _parse_disk_source(guest, path, pool, vol, size, fmt, sparse):
abspath = None
volinst = None
@ -1556,7 +1562,7 @@ def _parse_disk_source(guest, path, pool, vol, size, fmt, sparse):
tmpvol = virtinst.StorageVolume(guest.conn)
tmpvol.pool = poolobj
if fmt is None and tmpvol.file_type == tmpvol.TYPE_FILE:
fmt = "raw"
fmt = _default_image_file_format(guest.conn)
ext = virtinst.StorageVolume.get_file_extension_for_format(fmt)
vname = virtinst.StorageVolume.find_free_name(