render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From 97edaf4f3dc5af717f88e41577a1cda77982f4c1 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <97edaf4f3dc5af717f88e41577a1cda77982f4c1.1381871411.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Mon, 7 Oct 2013 17:17:28 +0100
43fe83
Subject: [PATCH] Avoid reporting an error if veth device is already deleted
43fe83
43fe83
For
43fe83
43fe83
  https://bugzilla.redhat.com/show_bug.cgi?id=1014604
43fe83
43fe83
The kernel automatically destroys veth devices when cleaning
43fe83
up the container network namespace. During normal shutdown, it
43fe83
is thus likely that the attempt to run 'ip link del vethN'
43fe83
will fail. If it fails, check if the device exists, and avoid
43fe83
reporting an error if it has gone. This switches to use the
43fe83
virCommand APIs instead of virRun too.
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit 10caf94ddc568d36561d89ca28fe0c58154a50f9)
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 po/POTFILES.in           |  1 +
43fe83
 src/util/virnetdevveth.c | 17 ++++++++++++++---
43fe83
 2 files changed, 15 insertions(+), 3 deletions(-)
43fe83
43fe83
diff --git a/po/POTFILES.in b/po/POTFILES.in
43fe83
index 884b70a..8afd015 100644
43fe83
--- a/po/POTFILES.in
43fe83
+++ b/po/POTFILES.in
43fe83
@@ -168,6 +168,7 @@ src/util/virnetdevbridge.c
43fe83
 src/util/virnetdevmacvlan.c
43fe83
 src/util/virnetdevopenvswitch.c
43fe83
 src/util/virnetdevtap.c
43fe83
+src/util/virnetdevveth.c
43fe83
 src/util/virnetdevvportprofile.c
43fe83
 src/util/virnetlink.c
43fe83
 src/util/virnodesuspend.c
43fe83
diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
43fe83
index 039767f..c0d32c4 100644
43fe83
--- a/src/util/virnetdevveth.c
43fe83
+++ b/src/util/virnetdevveth.c
43fe83
@@ -161,9 +161,20 @@ cleanup:
43fe83
  */
43fe83
 int virNetDevVethDelete(const char *veth)
43fe83
 {
43fe83
-    const char *argv[] = {"ip", "link", "del", veth, NULL};
43fe83
+    virCommandPtr cmd = virCommandNewArgList("ip", "link", "del", veth, NULL);
43fe83
+    int status;
43fe83
 
43fe83
-    VIR_DEBUG("veth: %s", veth);
43fe83
+    if (virCommandRun(cmd, &status) < 0)
43fe83
+        return -1;
43fe83
 
43fe83
-    return virRun(argv, NULL);
43fe83
+    if (status != 0) {
43fe83
+        if (!virNetDevExists(veth)) {
43fe83
+            VIR_DEBUG("Device %s already deleted (by kernel namespace cleanup)", veth);
43fe83
+            return 0;
43fe83
+        }
43fe83
+        virReportError(VIR_ERR_INTERNAL_ERROR,
43fe83
+                       _("Failed to delete veth device %s"), veth);
43fe83
+        return -1;
43fe83
+    }
43fe83
+    return 0;
43fe83
 }
43fe83
-- 
43fe83
1.8.3.2
43fe83