[PATCH 1/8] qemu: domain: Use g_file_read_link instead of virFileReadLink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In an effort to remove as much gnulib usage as possible let's
reimplement virFileReadLink. Since it's used in two places only I opted
to open-code it.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 842b70dc26..40a617845a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -13170,12 +13170,13 @@ qemuDomainCreateDeviceRecursive(const char *device,
     }

     if (isLink) {
+        g_autoptr(GError) gerr = NULL;
+
         /* We are dealing with a symlink. Create a dangling symlink and descend
          * down one level which hopefully creates the symlink's target. */
-        if (virFileReadLink(device, &target) < 0) {
-            virReportSystemError(errno,
-                                 _("unable to resolve symlink %s"),
-                                 device);
+        if (!(target = g_file_read_link(device, &gerr))) {
+            virReportError(VIR_ERR_SYSTEM_ERROR,
+                           _("failed to resolve symlink %s: %s"), device, gerr->message);
             goto cleanup;
         }

@@ -14164,10 +14165,11 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,

         data.target = target;
     } else if (isLink) {
-        if (virFileReadLink(file, &target) < 0) {
-            virReportSystemError(errno,
-                                 _("unable to resolve symlink %s"),
-                                 file);
+        g_autoptr(GError) gerr = NULL;
+
+        if (!(target = g_file_read_link(file, &gerr))) {
+            virReportError(VIR_ERR_SYSTEM_ERROR,
+                           _("failed to resolve symlink %s: %s"), file, gerr->message);
             return ret;
         }

-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux