This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-changelog] [xen-unstable] ioemu: Attempt to setup tap interface up

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] ioemu: Attempt to setup tap interface up to 3 times.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 04 Jun 2007 03:15:43 -0700
Delivery-date: Mon, 04 Jun 2007 03:30:36 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1180016735 -3600
# Node ID 588bd40872ec3fc630079e1402f016d9262dd4f5
# Parent  3ef4a4d8213061fe14d905e89594c99d0b9cb605
ioemu: Attempt to setup tap interface up to 3 times.

As there is a (small) chance that vl.c:tap_open() fails (due to some
sort of race-condition in the Linux kernel, which is noted as a bug in
the source .../net/core/dev.c), we should attempt it again a couple of
times if it doesn't succeed on the first attempt. I think three times
in total is sufficient to avoid the problem.

If tap_open() fails, qemu-dm will exit, which means that the domain
dies - which is not such a good thing when attempting to restore a saved
domain [of course, it would be even worse if it started, but didn't
have networking - because there may not be a way to shut it down
cleanly without network].

Signed-off-by: Mats Petersson <mats.petersson@xxxxxxx>
 tools/ioemu/vl.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff -r 3ef4a4d82130 -r 588bd40872ec tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Thu May 24 15:21:29 2007 +0100
+++ b/tools/ioemu/vl.c  Thu May 24 15:25:35 2007 +0100
@@ -3399,7 +3399,7 @@ static int tap_open(char *ifname, int if
 static int tap_open(char *ifname, int ifname_size)
     struct ifreq ifr;
-    int fd, ret;
+    int fd, ret, retries = 0;
     fd = open("/dev/net/tun", O_RDWR);
     if (fd < 0) {
@@ -3412,7 +3412,9 @@ static int tap_open(char *ifname, int if
         pstrcpy(ifr.ifr_name, IFNAMSIZ, ifname);
         pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
-    ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
+    do {
+        ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
+    } while ((ret != 0) && (retries++ < 3));
     if (ret != 0) {
         fprintf(stderr, "warning: could not configure /dev/net/tun: no virtual 
network emulation\n");

Xen-changelog mailing list

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] ioemu: Attempt to setup tap interface up to 3 times., Xen patchbot-unstable <=