ia64/xen-unstable

changeset 15213:588bd40872ec

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@amd.com>
author kfraser@localhost.localdomain
date Thu May 24 15:25:35 2007 +0100 (2007-05-24)
parents 3ef4a4d82130
children 4c2124aac598
files tools/ioemu/vl.c
line diff
     1.1 --- a/tools/ioemu/vl.c	Thu May 24 15:21:29 2007 +0100
     1.2 +++ b/tools/ioemu/vl.c	Thu May 24 15:25:35 2007 +0100
     1.3 @@ -3399,7 +3399,7 @@ static int tap_open(char *ifname, int if
     1.4  static int tap_open(char *ifname, int ifname_size)
     1.5  {
     1.6      struct ifreq ifr;
     1.7 -    int fd, ret;
     1.8 +    int fd, ret, retries = 0;
     1.9      
    1.10      fd = open("/dev/net/tun", O_RDWR);
    1.11      if (fd < 0) {
    1.12 @@ -3412,7 +3412,9 @@ static int tap_open(char *ifname, int if
    1.13          pstrcpy(ifr.ifr_name, IFNAMSIZ, ifname);
    1.14      else
    1.15          pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d");
    1.16 -    ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
    1.17 +    do {
    1.18 +        ret = ioctl(fd, TUNSETIFF, (void *) &ifr);
    1.19 +    } while ((ret != 0) && (retries++ < 3));
    1.20      if (ret != 0) {
    1.21          fprintf(stderr, "warning: could not configure /dev/net/tun: no virtual network emulation\n");
    1.22          close(fd);