With blockdev we'll be able to support protocols which are not supported
by the storage backends in libvirt. This means that we have to be able
to skip the creation and relative storage path reading if it's not
supported. This will make it impossible to use relative backing for
network protocols but that would be almost insane anyways.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 22 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 39d9118953..8a0f1697cb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15316,6 +15316,8 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
{
char *backingStoreStr;
virDomainDiskDefPtr persistdisk;
+ bool supportsCreate;
+ bool supportsBacking;
dd->disk = disk;
@@ -15340,31 +15342,38 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
return -1;
}
- if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0)
- return -1;
-
- dd->initialized = true;
+ supportsCreate = virStorageFileSupportsCreate(dd->src);
+ supportsBacking = virStorageFileSupportsBackingChainTraversal(dd->src);
- /* relative backing store paths need to be updated so that relative
- * block commit still works */
- if (reuse) {
- if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
+ if (supportsCreate || supportsBacking) {
+ if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0)
return -1;
- if (backingStoreStr != NULL) {
- if (virStorageIsRelative(backingStoreStr))
- VIR_STEAL_PTR(dd->relPath, backingStoreStr);
- else
- VIR_FREE(backingStoreStr);
- }
- } else {
- /* pre-create the image file so that we can label it before handing it to qemu
*/
- if (dd->src->type != VIR_STORAGE_TYPE_BLOCK) {
- if (virStorageFileCreate(dd->src) < 0) {
- virReportSystemError(errno, _("failed to create image file
'%s'"),
- NULLSTR(dd->src->path));
- return -1;
+
+ dd->initialized = true;
+
+ /* relative backing store paths need to be updated so that relative
+ * block commit still works */
+ if (reuse) {
+ if (supportsBacking) {
+ if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr)
< 0)
+ return -1;
+ if (backingStoreStr != NULL) {
+ if (virStorageIsRelative(backingStoreStr))
+ VIR_STEAL_PTR(dd->relPath, backingStoreStr);
+ else
+ VIR_FREE(backingStoreStr);
+ }
+ }
+ } else {
+ /* pre-create the image file so that we can label it before handing it to
qemu */
+ if (supportsCreate && dd->src->type != VIR_STORAGE_TYPE_BLOCK)
{
+ if (virStorageFileCreate(dd->src) < 0) {
+ virReportSystemError(errno, _("failed to create image file
'%s'"),
+ NULLSTR(dd->src->path));
+ return -1;
+ }
+ dd->created = true;
}
- dd->created = true;
}
}
--
2.21.0