[PATCH] virnetdevveth: Do report error if creating veth fails

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

 



For some weird reason we are ignoring errors when creating veth
pair that netlink reports. This affects the LXC driver which
creates interfaces for container in
virLXCProcessSetupInterfaces(). If creating a veth pair fails, no
error is reported and the control jumps onto cleanup label where
some cryptic error message is reported instead (something about
inability to remove veth pair).

Let's report error that netlink returned - it's probably the most
accurate reason anyways.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/225
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/util/virnetdevveth.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index 7133af44a2..ddf304036a 100644
--- a/src/util/virnetdevveth.c
+++ b/src/util/virnetdevveth.c
@@ -38,10 +38,17 @@ VIR_LOG_INIT("util.netdevveth");
 static int
 virNetDevVethCreateInternal(const char *veth1, const char *veth2)
 {
-    int status;     /* Just ignore it */
+    int error;
     virNetlinkNewLinkData data = { .veth_peer = veth2 };
 
-    return virNetlinkNewLink(veth1, "veth", &data, &status);
+    if (virNetlinkNewLink(veth1, "veth", &data, &error) < 0) {
+        virReportSystemError(-error,
+                             _("unable to create %s <-> %s veth pair"),
+                             veth1, veth2);
+        return -1;
+    }
+
+    return 0;
 }
 
 static int
-- 
2.32.0




[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