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

Re: [Libguestfs] [PATCH v3 8/8] lib/canonical-name.c: Hide EINVAL error from underlying API call.



This is the patch I tested which works (on top of the
patch posted):

diff --git a/lib/canonical-name.c b/lib/canonical-name.c
index e0c7918b4..ae4def692 100644
--- a/lib/canonical-name.c
+++ b/lib/canonical-name.c
@@ -53,8 +53,16 @@ guestfs_impl_canonical_device_name (guestfs_h *g, const char *device)
      * BitLocker-encrypted volume, so simply return the original
      * name in that case.
      */
-    if (ret == NULL && guestfs_last_errno (g) == EINVAL)
-      ret = safe_strdup (g, device);
+    if (ret == NULL) {
+      if (guestfs_last_errno (g) == EINVAL)
+        ret = safe_strdup (g, device);
+      else
+        /* Make sure the original error gets pushed through the
+         * error handlers.
+         */
+        guestfs_int_error_errno (g, guestfs_last_errno (g),
+                                 "%s", guestfs_last_error (g));
+    }
   }
   else
     ret = safe_strdup (g, device);

---

Current upstream:

$ guestfish scratch 1M : run : canonical-device-name "/dev/dm-999"
libguestfs: error: lvm_canonical_lv_name: stat: /dev/dm-999: No such file or directory
/dev/dm-999

Patch posted without the above patch added:

$ ./run guestfish scratch 1M : run : canonical-device-name "/dev/dm-999"

(no output, but the command fails with exit code 1)

Patch posted + above patch:

$ ./run guestfish scratch 1M : run : canonical-device-name "/dev/dm-999"
libguestfs: error: lvm_canonical_lv_name: stat: /dev/dm-999: No such file or directory

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v


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