mirror of https://gitee.com/openkylin/libvirt.git
storage: Disallow create/resize of qcow2 encrypted images
https://bugzilla.redhat.com/show_bug.cgi?id=1526382
Since commit c4eedd793
disallowed qcow2 encrypted images to be
used for domains, it no longer makes sense to allow a qcow2
encrypted volume to be created or resized.
Add a test that will exhibit the failure of creation as well
as the xml2xml validation of the format still being correct.
Update the documentation to note the removal of the capability
to create and use qcow/default encrypted volumes.
Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a02d879858
commit
8f83af6823
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
This secret is associated with a volume, whether the format is either
|
This secret is associated with a volume, whether the format is either
|
||||||
for a "qcow" or a "luks" encrypted volume. Each volume will have a
|
for a "luks" encrypted volume. Each volume will have a
|
||||||
unique secret associated with it and it is safe to delete the
|
unique secret associated with it and it is safe to delete the
|
||||||
secret after the volume is deleted. The
|
secret after the volume is deleted. The
|
||||||
<code><usage type='volume'></code> element must contain a
|
<code><usage type='volume'></code> element must contain a
|
||||||
|
@ -83,16 +83,6 @@ Secret value set
|
||||||
#
|
#
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
|
||||||
The volume type secret can be supplied in domain XML for a qcow storage
|
|
||||||
volume <a href="formatstorageencryption.html">encryption</a> as follows:
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
<encryption format='qcow'>
|
|
||||||
<secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
|
|
||||||
</encryption>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The volume type secret can be supplied either in volume XML during
|
The volume type secret can be supplied either in volume XML during
|
||||||
creation of a <a href="formatstorage.html#StorageVol">storage volume</a>
|
creation of a <a href="formatstorage.html#StorageVol">storage volume</a>
|
||||||
|
@ -120,6 +110,16 @@ Secret value set
|
||||||
#
|
#
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The volume type secret can be supplied in domain XML for a luks storage
|
||||||
|
volume <a href="formatstorageencryption.html">encryption</a> as follows:
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
<encryption format='luks'>
|
||||||
|
<secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc57'/>
|
||||||
|
</encryption>
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h3><a id="CephUsageType">Usage type "ceph"</a></h3>
|
<h3><a id="CephUsageType">Usage type "ceph"</a></h3>
|
||||||
<p>
|
<p>
|
||||||
This secret is associated with a Ceph RBD (rados block device).
|
This secret is associated with a Ceph RBD (rados block device).
|
||||||
|
|
|
@ -39,22 +39,14 @@
|
||||||
specified <code>uuid</code>.
|
specified <code>uuid</code>.
|
||||||
</p>
|
</p>
|
||||||
<h3><a id="StorageEncryptionDefault">"default" format</a></h3>
|
<h3><a id="StorageEncryptionDefault">"default" format</a></h3>
|
||||||
<p>
|
|
||||||
<code><encryption format="default"/></code> can be specified only
|
|
||||||
when creating a qcow volume. If the volume is successfully created, the
|
|
||||||
encryption formats, parameters and secrets will be auto-generated by
|
|
||||||
libvirt and the attached <code>encryption</code> tag will be updated.
|
|
||||||
The unmodified contents of the <code>encryption</code> tag can be used
|
|
||||||
in later operations with the volume, or when setting up a domain that
|
|
||||||
uses the volume.
|
|
||||||
</p>
|
|
||||||
<h3><a id="StorageEncryptionQcow">"qcow" format</a></h3>
|
<h3><a id="StorageEncryptionQcow">"qcow" format</a></h3>
|
||||||
<p>
|
<p>
|
||||||
The <code>qcow</code> format specifies that the built-in encryption
|
<span class="since">Since 4.5.0,</span> encryption formats
|
||||||
support in <code>qcow</code>- or <code>qcow2</code>-formatted volume
|
<code>default</code> and <code>qcow</code> may no longer be used
|
||||||
images should be used. A single
|
to create an encrypted volume. Usage of qcow encrypted volumes
|
||||||
<code><secret type='passphrase'></code> element is expected. Note
|
in QEMU began phasing out in QEMU 2.3 and by QEMU 2.9 creation
|
||||||
that this encryption is inherently broken and should not be used any more.
|
of a qcow encrypted volume via qemu-img required usage of secret
|
||||||
|
objects, but that support was not added to libvirt.
|
||||||
</p>
|
</p>
|
||||||
<h3><a id="StorageEncryptionLuks">"luks" format</a></h3>
|
<h3><a id="StorageEncryptionLuks">"luks" format</a></h3>
|
||||||
<p>
|
<p>
|
||||||
|
@ -121,15 +113,6 @@
|
||||||
|
|
||||||
<h2><a id="example">Examples</a></h2>
|
<h2><a id="example">Examples</a></h2>
|
||||||
|
|
||||||
<p>
|
|
||||||
Here is a simple example, specifying use of the <code>qcow</code> format:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
<encryption format='qcow'>
|
|
||||||
<secret type='passphrase' uuid='c1f11a6d-8c5d-4a3e-ac7a-4e171c5e0d4a' />
|
|
||||||
</encryption></pre>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Assuming a <a href="formatsecret.html#VolumeUsageType">
|
Assuming a <a href="formatsecret.html#VolumeUsageType">
|
||||||
<code>luks volume type secret</code></a> is already defined,
|
<code>luks volume type secret</code></a> is already defined,
|
||||||
|
|
|
@ -1214,6 +1214,15 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
|
||||||
|
|
||||||
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
|
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
|
||||||
|
|
||||||
|
if (enc && (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_QCOW ||
|
||||||
|
enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT) &&
|
||||||
|
(vol->target.format == VIR_STORAGE_FILE_QCOW ||
|
||||||
|
vol->target.format == VIR_STORAGE_FILE_QCOW2)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("creation of qcow2 encrypted image is not supported"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (virStorageBackendCreateQemuImgSetInfo(pool, vol, inputvol, &info) < 0)
|
if (virStorageBackendCreateQemuImgSetInfo(pool, vol, inputvol, &info) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -1232,8 +1241,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool,
|
||||||
if (info.backingPath)
|
if (info.backingPath)
|
||||||
virCommandAddArgList(cmd, "-b", info.backingPath, NULL);
|
virCommandAddArgList(cmd, "-b", info.backingPath, NULL);
|
||||||
|
|
||||||
if (info.format == VIR_STORAGE_FILE_RAW && enc &&
|
if (enc) {
|
||||||
enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
|
|
||||||
if (!info.secretPath) {
|
if (!info.secretPath) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("path to secret data file is required"));
|
_("path to secret data file is required"));
|
||||||
|
@ -2354,6 +2362,16 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool,
|
||||||
const char *type;
|
const char *type;
|
||||||
char *secretPath = NULL;
|
char *secretPath = NULL;
|
||||||
char *secretAlias = NULL;
|
char *secretAlias = NULL;
|
||||||
|
virStorageEncryptionPtr enc = vol->target.encryption;
|
||||||
|
|
||||||
|
if (enc && (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_QCOW ||
|
||||||
|
enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT) &&
|
||||||
|
(vol->target.format == VIR_STORAGE_FILE_QCOW ||
|
||||||
|
vol->target.format == VIR_STORAGE_FILE_QCOW2)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("resize of qcow2 encrypted image is not supported"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
img_tool = virFindFileInPath("qemu-img");
|
img_tool = virFindFileInPath("qemu-img");
|
||||||
if (!img_tool) {
|
if (!img_tool) {
|
||||||
|
|
|
@ -232,6 +232,10 @@ mymain(void)
|
||||||
"pool-dir", "vol-file-iso",
|
"pool-dir", "vol-file-iso",
|
||||||
"iso-input", 0);
|
"iso-input", 0);
|
||||||
|
|
||||||
|
DO_TEST_FAIL("pool-dir", "vol-qcow2-encryption",
|
||||||
|
NULL, NULL,
|
||||||
|
"qcow2-encryption", 0);
|
||||||
|
|
||||||
DO_TEST("pool-dir", "vol-luks",
|
DO_TEST("pool-dir", "vol-luks",
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
"luks", 0);
|
"luks", 0);
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<volume>
|
||||||
|
<name>OtherDemo.img</name>
|
||||||
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
|
<source>
|
||||||
|
</source>
|
||||||
|
<capacity unit="G">5</capacity>
|
||||||
|
<allocation>294912</allocation>
|
||||||
|
<target>
|
||||||
|
<path>/var/lib/libvirt/images/OtherDemo.img</path>
|
||||||
|
<format type='qcow2'/>
|
||||||
|
<permissions>
|
||||||
|
<mode>0644</mode>
|
||||||
|
<owner>0</owner>
|
||||||
|
<group>0</group>
|
||||||
|
<label>unconfined_u:object_r:virt_image_t:s0</label>
|
||||||
|
</permissions>
|
||||||
|
<encryption format='qcow'>
|
||||||
|
<secret type='passphrase' uuid='e78d4b51-a2af-485f-b0f5-afca709a80f4'/>
|
||||||
|
</encryption>
|
||||||
|
</target>
|
||||||
|
<backingStore>
|
||||||
|
<path>/dev/null</path>
|
||||||
|
<format type='raw'/>
|
||||||
|
<permissions>
|
||||||
|
<mode>0644</mode>
|
||||||
|
<owner>0</owner>
|
||||||
|
<group>0</group>
|
||||||
|
<label>unconfined_u:object_r:virt_image_t:s0</label>
|
||||||
|
</permissions>
|
||||||
|
</backingStore>
|
||||||
|
</volume>
|
|
@ -0,0 +1,31 @@
|
||||||
|
<volume type='file'>
|
||||||
|
<name>OtherDemo.img</name>
|
||||||
|
<key>/var/lib/libvirt/images/OtherDemo.img</key>
|
||||||
|
<source>
|
||||||
|
</source>
|
||||||
|
<capacity unit='bytes'>5368709120</capacity>
|
||||||
|
<allocation unit='bytes'>294912</allocation>
|
||||||
|
<target>
|
||||||
|
<path>/var/lib/libvirt/images/OtherDemo.img</path>
|
||||||
|
<format type='qcow2'/>
|
||||||
|
<permissions>
|
||||||
|
<mode>0644</mode>
|
||||||
|
<owner>0</owner>
|
||||||
|
<group>0</group>
|
||||||
|
<label>unconfined_u:object_r:virt_image_t:s0</label>
|
||||||
|
</permissions>
|
||||||
|
<encryption format='qcow'>
|
||||||
|
<secret type='passphrase' uuid='e78d4b51-a2af-485f-b0f5-afca709a80f4'/>
|
||||||
|
</encryption>
|
||||||
|
</target>
|
||||||
|
<backingStore>
|
||||||
|
<path>/dev/null</path>
|
||||||
|
<format type='raw'/>
|
||||||
|
<permissions>
|
||||||
|
<mode>0644</mode>
|
||||||
|
<owner>0</owner>
|
||||||
|
<group>0</group>
|
||||||
|
<label>unconfined_u:object_r:virt_image_t:s0</label>
|
||||||
|
</permissions>
|
||||||
|
</backingStore>
|
||||||
|
</volume>
|
|
@ -106,6 +106,7 @@ mymain(void)
|
||||||
DO_TEST("pool-dir", "vol-qcow2-lazy");
|
DO_TEST("pool-dir", "vol-qcow2-lazy");
|
||||||
DO_TEST("pool-dir", "vol-qcow2-0.10-lazy");
|
DO_TEST("pool-dir", "vol-qcow2-0.10-lazy");
|
||||||
DO_TEST("pool-dir", "vol-qcow2-nobacking");
|
DO_TEST("pool-dir", "vol-qcow2-nobacking");
|
||||||
|
DO_TEST("pool-dir", "vol-qcow2-encryption");
|
||||||
DO_TEST("pool-dir", "vol-luks");
|
DO_TEST("pool-dir", "vol-luks");
|
||||||
DO_TEST("pool-dir", "vol-luks-cipher");
|
DO_TEST("pool-dir", "vol-luks-cipher");
|
||||||
DO_TEST("pool-disk", "vol-partition");
|
DO_TEST("pool-disk", "vol-partition");
|
||||||
|
|
Loading…
Reference in New Issue