mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2024-07-07 04:22:58 -05:00
specify qcow2 compatibility version to not use very old 0.10 fallback (#1731)
Libvirt creates qcow2 volumes with very old `compat` version `0.10` if no `compat` version is specified in the xml (see [here](https://libvirt.org/formatstorage.html#id11)). It seems libvirt has backwards compatibility reasons to still use `0.10` if nothing is specified in the xml. Unfortunately this has the effect that VMs created by vagrant-libvirt are using the 10 year old `0.10` qcow2 version, instead of the `1.1` version that has **better performance and stability fixes**. This is even happening when the backing file of the vagrant box is in compat `1.1` format. This is the `qemu-img info` of the backing file provided by the vagrant box: ``` # qemu-img info /var/lib/libvirt/images/vagrant_box_image_0_box.img [...] Format specific information: compat: 1.1 [...] ``` Although the backing file provided by the box is using compat `1.1`, the created volume by vagrant-libvirt has only compat `0.1` as shown here: ``` # qemu-img info /var/lib/libvirt/images/vagrant-01-test_default.img [...] backing file: /var/lib/libvirt/images/vagrant_box_image_0_box.img Format specific information: compat: 0.10 [...] ``` With this MR, the volume of the VM will use the same `compat` version as provided by the backing image of the vagrant box. If `qemu-img info` does not return a `compat` flag, it falls back to the very old `0.10` version.
This commit is contained in:
parent
f6126464f1
commit
cb051a8277
|
@ -60,6 +60,7 @@ module VagrantPlugins
|
|||
xml.group storage_gid(env)
|
||||
xml.label 'virt_image_t'
|
||||
end
|
||||
xml.compat '1.1'
|
||||
end
|
||||
xml.backingStore do
|
||||
xml.path(@backing_file)
|
||||
|
|
|
@ -43,6 +43,7 @@ module VagrantPlugins
|
|||
:name => HandleBoxImage.get_volume_name(env[:machine].box, 'box', image_path, env[:ui]),
|
||||
:virtual_size => HandleBoxImage.get_virtual_size(env),
|
||||
:format => box_format,
|
||||
:compat => "1.1",
|
||||
}]
|
||||
else
|
||||
# Handle box v2 format
|
||||
|
@ -57,7 +58,7 @@ module VagrantPlugins
|
|||
raise Errors::BoxFormatMissingAttribute, attribute: "disks[#{i}]['path']" if disks[i]['path'].nil?
|
||||
|
||||
image_path = HandleBoxImage.get_box_image_path(env[:machine].box, disks[i]['path'])
|
||||
format, virtual_size = HandleBoxImage.get_box_disk_settings(image_path)
|
||||
format, virtual_size, compat = HandleBoxImage.get_box_disk_settings(image_path)
|
||||
volume_name = HandleBoxImage.get_volume_name(
|
||||
env[:machine].box,
|
||||
disks[i].fetch('name', disks[i]['path'].sub(/#{File.extname(disks[i]['path'])}$/, '')),
|
||||
|
@ -76,7 +77,8 @@ module VagrantPlugins
|
|||
:path => image_path,
|
||||
:name => volume_name,
|
||||
:virtual_size => virtual_size,
|
||||
:format => HandleBoxImage.verify_box_format(format)
|
||||
:format => HandleBoxImage.verify_box_format(format),
|
||||
:compat => compat,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -180,8 +182,9 @@ module VagrantPlugins
|
|||
image_info = JSON.parse(stdout)
|
||||
format = image_info['format']
|
||||
virtual_size = ByteNumber.new(image_info['virtual-size'])
|
||||
compat = image_info.fetch("format-specific", {}).fetch("data", {}).fetch("compat", "0.10")
|
||||
|
||||
return format, virtual_size
|
||||
return format, virtual_size, compat
|
||||
end
|
||||
|
||||
def send_box_image(env, config, box_image_file, box_volume)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<group>0</group>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
<compat>1.1</compat>
|
||||
</target>
|
||||
<backingStore>
|
||||
<path>/test/path_0.img</path>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<group>0</group>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
<compat>1.1</compat>
|
||||
</target>
|
||||
<backingStore>
|
||||
<path>/test/path_0.img</path>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<group>0</group>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
<compat>1.1</compat>
|
||||
</target>
|
||||
<backingStore>
|
||||
<path>/test/path_1.img</path>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<group>0</group>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
<compat>1.1</compat>
|
||||
</target>
|
||||
<backingStore>
|
||||
<path>/test/path_2.img</path>
|
||||
|
|
|
@ -88,6 +88,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|||
:virtual_size=>byte_number_5G,
|
||||
:format=>"qcow2",
|
||||
:device=>'vda',
|
||||
:compat=>"1.1",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
@ -118,6 +119,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|||
:virtual_size=>byte_number_5G,
|
||||
:format=>"qcow2",
|
||||
:device=>'vda',
|
||||
:compat=>"1.1",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
@ -156,6 +158,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|||
:virtual_size=>byte_number_5G,
|
||||
:format=>"qcow2",
|
||||
:device=>'vda',
|
||||
:compat=>"1.1",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
@ -177,6 +180,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|||
:virtual_size=>byte_number_20G,
|
||||
:format=>"qcow2",
|
||||
:device=>'vda',
|
||||
:compat=>"1.1",
|
||||
}
|
||||
]
|
||||
)
|
||||
|
@ -269,18 +273,21 @@ describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
|
|||
:virtual_size=>byte_number_5G,
|
||||
:format=>"qcow2",
|
||||
:device=>'vda',
|
||||
:compat=>"0.10"
|
||||
},
|
||||
{
|
||||
:path=>"/test/disk.qcow2",
|
||||
:name=>"test_vagrant_box_image_1.1.1_disk.img",
|
||||
:virtual_size=>byte_number_10G,
|
||||
:format=>"qcow2"
|
||||
:format=>"qcow2",
|
||||
:compat=>"0.10"
|
||||
},
|
||||
{
|
||||
:path=>"/test/box_2.img",
|
||||
:name=>"test_vagrant_box_image_1.1.1_box_2.img",
|
||||
:virtual_size=>byte_number_20G,
|
||||
:format=>"qcow2"
|
||||
:format=>"qcow2",
|
||||
:compat=>"0.10"
|
||||
}
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user