From: Peter Krempa <[email protected]>

Code paths which create a file, such as snapshots or backups technically
make use of FD-passed new images, but would still attempt to create the
file based on the path, which is not desired as the path may not exist
in the environment.

Skip the creation when FD passing is in use.

Signed-off-by: Peter Krempa <[email protected]>
---
 src/qemu/qemu_backup.c   | 1 +
 src/qemu/qemu_driver.c   | 2 +-
 src/qemu/qemu_snapshot.c | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
index a0544c83dc..b4e5b7347f 100644
--- a/src/qemu/qemu_backup.c
+++ b/src/qemu/qemu_backup.c
@@ -451,6 +451,7 @@ qemuBackupDiskPrepareOneStorage(virDomainObj *vm,

     if (!reuse_external &&
         dd->store->type == VIR_STORAGE_TYPE_FILE &&
+        !virStorageSourceIsFD(dd->store) &&
         virStorageSourceSupportsCreate(dd->store)) {

         if (virFileExists(dd->store->path)) {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5922065897..fa5b589c29 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14904,7 +14904,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,

     /* pre-create the image file. This is required so that libvirt can properly
      * label the image for access by qemu */
-    if (!existing) {
+    if (!existing && !virStorageSourceIsFD(mirror)) {
         if (supports_create) {
             if (virStorageSourceCreate(mirror) < 0) {
                 virReportSystemError(errno, "%s", _("failed to create copy 
target"));
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 07548ca62e..f3d5b066f3 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -1351,7 +1351,7 @@ qemuSnapshotDiskPrepareOne(qemuSnapshotDiskContext 
*snapctxt,

         dd->initialized = true;

-        if (!reuse) {
+        if (!reuse && !virStorageSourceIsFD(dd->src)) {
             /* 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 (virStorageSourceCreate(dd->src) < 0) {
-- 
2.56.0

Reply via email to