Blame SOURCES/libvirt-qemuDomainSaveImageStartVM-Use-VIR_AUTOCLOSE-for-intermediatefd.patch

a41c76
From 6442aa5565de857371a7076c56ced84fbea0ec66 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <6442aa5565de857371a7076c56ced84fbea0ec66@dist-git>
a41c76
From: Michal Privoznik <mprivozn@redhat.com>
a41c76
Date: Thu, 16 Jan 2020 10:03:51 +0100
a41c76
Subject: [PATCH] qemuDomainSaveImageStartVM: Use VIR_AUTOCLOSE for
a41c76
 @intermediatefd
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
a41c76
a41c76
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1718707
a41c76
a41c76
(cherry picked from commit 1c16f261d0764ff70fb33ece4367f25e741cdb74)
a41c76
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a41c76
Message-Id: <f181efbc202853298ca06eecf78e7dad1063dc16.1579165329.git.mprivozn@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_driver.c | 5 ++---
a41c76
 1 file changed, 2 insertions(+), 3 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
a41c76
index d6b1e9f00c..9de5bc6a32 100644
a41c76
--- a/src/qemu/qemu_driver.c
a41c76
+++ b/src/qemu/qemu_driver.c
a41c76
@@ -6803,7 +6803,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
a41c76
     int ret = -1;
a41c76
     bool restored = false;
a41c76
     virObjectEventPtr event;
a41c76
-    int intermediatefd = -1;
a41c76
+    VIR_AUTOCLOSE intermediatefd = -1;
a41c76
     virCommandPtr cmd = NULL;
a41c76
     g_autofree char *errbuf = NULL;
a41c76
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
a41c76
@@ -6829,6 +6829,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
a41c76
 
a41c76
         if (virCommandRunAsync(cmd, NULL) < 0) {
a41c76
             *fd = intermediatefd;
a41c76
+            intermediatefd = -1;
a41c76
             goto cleanup;
a41c76
         }
a41c76
     }
a41c76
@@ -6872,8 +6873,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
a41c76
 
a41c76
         virErrorRestore(&orig_err);
a41c76
     }
a41c76
-    VIR_FORCE_CLOSE(intermediatefd);
a41c76
-
a41c76
     if (VIR_CLOSE(*fd) < 0) {
a41c76
         virReportSystemError(errno, _("cannot close file: %s"), path);
a41c76
         restored = false;
a41c76
-- 
a41c76
2.25.0
a41c76