Bug 1392990

Summary: virt-install doesn't create sparse raw disk image by default
Product: Red Hat Enterprise Linux 7 Reporter: David Jones <david.jones74>
Component: virt-managerAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: jdenemar, juzhou, kuwei, mxie, mzhan, rbalakri, tzheng, xiaodwan, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-manager-1.4.1-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 21:02:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Jones 2016-11-08 16:04:30 UTC
Description of problem:

I created a new KVM virtual machine, specifying a 1 TB raw image. According to the manpage for virt-install, the default is to create a sparse file, however, it creating a fully allocated file instead.


Version-Release number of selected component (if applicable):
1.2.8

How reproducible:
Haven't tried to reproduce it. 

Steps to Reproduce:

virt-install --network bridge:br0 --name myVm --ram=32000 --vcpus=16 --disk /var/lib/libvirt/images/myVm.img,size=1000 --cdrom install.iso --os-type=linux --os-variant=rhel7 --graphics=spice

Actual results:
Creates fully allocated raw qemu disk.

Expected results:
Creates sparse raw qemu disk.

Additional info:
Both host and guest use XFS on physical partitions.

Comment 1 David Jones 2016-11-08 16:12:25 UTC
Update. I tried the same kind command, but specified sparse=true, and it created a sparse file. However, I believe this is a bug, because it doesn't follow the documented default behavior.

Comment 2 zhoujunqin 2016-11-09 07:43:14 UTC
I can reproduce bug issue with package:
virt-manager-1.4.0-2.el7.noarch
virt-install-1.4.0-2.el7.noarch
libvirt-2.0.0-10.el7.x86_64
qemu-kvm-rhev-2.6.0-27.el7.x86_64

steps:
1. Create a new vm with disk format=raw
#  virt-install --name myVm2raw --ram=2048 --vcpus=2 --disk /var/lib/libvirt/images/myVm2raw.img,size=10,format=raw  --cdrom RHEL-7.3-20161019.0-Server-x86_64-dvd1.iso --os-type=linux --os-variant=rhel7 --graphics=spice

2. When installation starts, check image file.

# qemu-img info /var/lib/libvirt/images/myVm2raw.img
image: /var/lib/libvirt/images/myVm2raw.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 10G

Result:
Creates fully allocated raw disk.

Comment 4 Pavel Hrdina 2017-01-17 11:58:21 UTC
Upstream commit:

commit b1c0a1c2d9f20bc10e426edf1972407e13a7c72c
Author: Pavel Hrdina <phrdina>
Date:   Mon Jan 16 17:08:28 2017 +0100

    virtinst/cli: set default value for disk sparse to "yes"

Comment 6 zhoujunqin 2017-03-16 03:34:15 UTC
Try to verify this bug with new build:
virt-manager-1.4.1-1.el7.noarch
virt-install-1.4.1-1.el7.noarch
virt-manager-common-1.4.1-1.el7.noarch
libvirt-3.1.0-2.el7.x86_64

Steps:
1. Create a new vm with disk format=raw
#  virt-install --name myVm2raw --ram=2048 --vcpus=2 --disk /var/lib/libvirt/images/myVm2raw.img,size=10,format=raw  --location http://download.eng.pek2.redhat.com/pub/rhel/released/RHEL-7/7.3-RC-3/Server/x86_64/os/  --os-type=linux --os-variant=rhel7 --graphics=spice

2. When installation starts, check image file.

# qemu-img info myVm2raw.img 
image: myVm2raw.img
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 1.2G

Result:
virt-install command creates sparse raw qemu disk by default.

So move this bug from ON_QA to VERIFIED.

Comment 7 errata-xmlrpc 2017-08-01 21:02:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2072