On Mon, Apr 14, 2014 at 16:54:14 -0600, Eric Blake wrote:
Domain snapshots should only permit an external snapshot into
a storage format that permits a backing chain, since the new
snapshot file necessarily must be backed by the existing file.
The C code for the qemu driver is a little bit stricter in
currently enforcing only qcow2 or qed, but at the XML parser
level, including virt-xml-validate, it is fairly easy to
enforce that a user can't request a 'raw' external snapshot.
* docs/schemas/storagecommon.rng (storageFormat): Split out...
(storageFormatBacking): ...new sublist.
* docs/schemas/domainsnapshot.rng (disksnapshotdriver): Use new
type.
* src/util/virstoragefile.h (virStorageFileFormat): Rearrange for
easier code management.
* src/util/virstoragefile.c (virStorageFileFormat, fileTypeInfo):
Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML): Use
new marker to limit selection of formats.
While you are rearranging the lists of file formats, why not make them
all consistent? ACK with the following patch squashed in.
Jirka
diff --git i/docs/schemas/storagecommon.rng w/docs/schemas/storagecommon.rng
index 2d61abc..1015e8d 100644
--- i/docs/schemas/storagecommon.rng
+++ w/docs/schemas/storagecommon.rng
@@ -72,9 +72,9 @@
<value>dmg</value>
<value>iso</value>
<value>vpc</value>
+ <value>vdi</value>
<value>fat</value>
<value>vhd</value>
- <value>vdi</value>
<ref name='storageFormatBacking'/>
</choice>
</define>
diff --git i/src/util/virstoragefile.c w/src/util/virstoragefile.c
index 42e9865..ea80c1d 100644
--- i/src/util/virstoragefile.c
+++ w/src/util/virstoragefile.c
@@ -60,7 +60,9 @@ VIR_ENUM_IMPL(virStorageFileFormat,
"none",
"raw", "dir", "bochs",
"cloop", "dmg", "iso",
- "vpc", "fat", "vhd", "vdi",
+ "vpc", "vdi",
+ /* Not direct file formats, but used for various drivers */
+ "fat", "vhd",
/* Formats with backing file below here */
"cow", "qcow", "qcow2", "qed",
"vmdk")
diff --git i/src/util/virstoragefile.h w/src/util/virstoragefile.h
index 29f93c1..1b8b14f 100644
--- i/src/util/virstoragefile.h
+++ w/src/util/virstoragefile.h
@@ -67,9 +67,11 @@ enum virStorageFileFormat {
VIR_STORAGE_FILE_DMG,
VIR_STORAGE_FILE_ISO,
VIR_STORAGE_FILE_VPC,
+ VIR_STORAGE_FILE_VDI,
+
+ /* Not direct file formats, but used for various drivers */
VIR_STORAGE_FILE_FAT,
VIR_STORAGE_FILE_VHD,
- VIR_STORAGE_FILE_VDI,
/* Not a format, but a marker: all formats below this point have
* libvirt support for following a backing chain */