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:
Holger Finger
2023-04-22 15:03:21 +02:00
committed by GitHub
parent f6126464f1
commit cb051a8277
7 changed files with 20 additions and 5 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"
}
]
)