]> xenbits.xensource.com Git - libvirt.git/commitdiff
virnetdevveth: Do report error if creating veth fails
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 2 Dec 2021 12:04:05 +0000 (13:04 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 2 Dec 2021 14:17:27 +0000 (15:17 +0100)
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@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virnetdevveth.c

index 7133af44a240f7c9b3a798d90bb09cd5f5061988..b580e105aced7b1fe740b574d7f68a901568eb51 100644 (file)
@@ -38,10 +38,19 @@ VIR_LOG_INIT("util.netdevveth");
 static int
 virNetDevVethCreateInternal(const char *veth1, const char *veth2)
 {
-    int status;     /* Just ignore it */
+    int error = 0;
     virNetlinkNewLinkData data = { .veth_peer = veth2 };
 
-    return virNetlinkNewLink(veth1, "veth", &data, &status);
+    if (virNetlinkNewLink(veth1, "veth", &data, &error) < 0) {
+        if (error != 0) {
+            virReportSystemError(-error,
+                                 _("unable to create %s <-> %s veth pair"),
+                                 veth1, veth2);
+        }
+        return -1;
+    }
+
+    return 0;
 }
 
 static int