[libvirt] [PATCH 3/3] Use qemuOpenFile in qemu_driver.c

Martin Kletzander mkletzan at redhat.com
Fri May 24 20:25:09 UTC 2013


On two places, the usage of open() is replaced with qemuOpenFile as
that is the preferred method in those cases.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=963881

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/qemu/qemu_driver.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 87dedef..a08a72a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9165,6 +9165,7 @@ qemuDomainBlockPeek(virDomainPtr dom,
                     void *buffer,
                     unsigned int flags)
 {
+    virQEMUDriverPtr driver = dom->conn->privateData;
     virDomainObjPtr vm;
     int fd = -1, ret = -1;
     const char *actual;
@@ -9188,13 +9189,9 @@ qemuDomainBlockPeek(virDomainPtr dom,
     }
     path = actual;

-    /* The path is correct, now try to open it and get its size. */
-    fd = open(path, O_RDONLY);
-    if (fd == -1) {
-        virReportSystemError(errno,
-                             _("%s: failed to open"), path);
+    fd = qemuOpenFile(driver, vm, path, O_RDONLY, NULL, NULL);
+    if (fd == -1)
         goto cleanup;
-    }

     /* Seek and read. */
     /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should
@@ -9351,12 +9348,9 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
     path = disk->src;

     /* The path is correct, now try to open it and get its size. */
-    fd = open(path, O_RDONLY);
-    if (fd == -1) {
-        virReportSystemError(errno,
-                             _("failed to open path '%s'"), path);
+    fd = qemuOpenFile(driver, vm, path, O_RDONLY, NULL, NULL);
+    if (fd == -1)
         goto cleanup;
-    }

     /* Probe for magic formats */
     if (disk->format) {
-- 
1.8.2.1




More information about the libvir-list mailing list