Diff for /qemu/net/tap.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2018/04/24 18:05:48 version 1.1.1.3, 2018/04/24 18:32:53
Line 38 Line 38
 #include "sysemu.h"  #include "sysemu.h"
 #include "qemu-char.h"  #include "qemu-char.h"
 #include "qemu-common.h"  #include "qemu-common.h"
   #include "qemu-error.h"
   
 #include "net/tap-linux.h"  #include "net/tap-linux.h"
   
   #include "hw/vhost_net.h"
   
 /* Maximum GSO packet size (64k) plus plenty of room for  /* Maximum GSO packet size (64k) plus plenty of room for
  * the ethernet and virtio_net headers   * the ethernet and virtio_net headers
  */   */
Line 57  typedef struct TAPState { Line 60  typedef struct TAPState {
     unsigned int has_vnet_hdr : 1;      unsigned int has_vnet_hdr : 1;
     unsigned int using_vnet_hdr : 1;      unsigned int using_vnet_hdr : 1;
     unsigned int has_ufo: 1;      unsigned int has_ufo: 1;
       VHostNetState *vhost_net;
 } TAPState;  } TAPState;
   
 static int launch_script(const char *setup_script, const char *ifname, int fd);  static int launch_script(const char *setup_script, const char *ifname, int fd);
Line 252  static void tap_cleanup(VLANClientState  Line 256  static void tap_cleanup(VLANClientState 
 {  {
     TAPState *s = DO_UPCAST(TAPState, nc, nc);      TAPState *s = DO_UPCAST(TAPState, nc, nc);
   
       if (s->vhost_net) {
           vhost_net_cleanup(s->vhost_net);
       }
   
     qemu_purge_queued_packets(nc);      qemu_purge_queued_packets(nc);
   
     if (s->down_script[0])      if (s->down_script[0])
Line 262  static void tap_cleanup(VLANClientState  Line 270  static void tap_cleanup(VLANClientState 
     close(s->fd);      close(s->fd);
 }  }
   
   static void tap_poll(VLANClientState *nc, bool enable)
   {
       TAPState *s = DO_UPCAST(TAPState, nc, nc);
       tap_read_poll(s, enable);
       tap_write_poll(s, enable);
   }
   
   int tap_get_fd(VLANClientState *nc)
   {
       TAPState *s = DO_UPCAST(TAPState, nc, nc);
       assert(nc->info->type == NET_CLIENT_TYPE_TAP);
       return s->fd;
   }
   
 /* fd support */  /* fd support */
   
 static NetClientInfo net_tap_info = {  static NetClientInfo net_tap_info = {
Line 270  static NetClientInfo net_tap_info = { Line 292  static NetClientInfo net_tap_info = {
     .receive = tap_receive,      .receive = tap_receive,
     .receive_raw = tap_receive_raw,      .receive_raw = tap_receive_raw,
     .receive_iov = tap_receive_iov,      .receive_iov = tap_receive_iov,
       .poll = tap_poll,
     .cleanup = tap_cleanup,      .cleanup = tap_cleanup,
 };  };
   
Line 292  static TAPState *net_tap_fd_init(VLANSta Line 315  static TAPState *net_tap_fd_init(VLANSta
     s->has_ufo = tap_probe_has_ufo(s->fd);      s->has_ufo = tap_probe_has_ufo(s->fd);
     tap_set_offload(&s->nc, 0, 0, 0, 0, 0);      tap_set_offload(&s->nc, 0, 0, 0, 0, 0);
     tap_read_poll(s, 1);      tap_read_poll(s, 1);
       s->vhost_net = NULL;
     return s;      return s;
 }  }
   
Line 322  static int launch_script(const char *set Line 346  static int launch_script(const char *set
         parg = args;          parg = args;
         *parg++ = (char *)setup_script;          *parg++ = (char *)setup_script;
         *parg++ = (char *)ifname;          *parg++ = (char *)ifname;
         *parg++ = NULL;          *parg = NULL;
         execv(setup_script, args);          execv(setup_script, args);
         _exit(1);          _exit(1);
     } else if (pid > 0) {      } else if (pid > 0) {
Line 385  int net_init_tap(QemuOpts *opts, Monitor Line 409  int net_init_tap(QemuOpts *opts, Monitor
             qemu_opt_get(opts, "script") ||              qemu_opt_get(opts, "script") ||
             qemu_opt_get(opts, "downscript") ||              qemu_opt_get(opts, "downscript") ||
             qemu_opt_get(opts, "vnet_hdr")) {              qemu_opt_get(opts, "vnet_hdr")) {
             qemu_error("ifname=, script=, downscript= and vnet_hdr= is invalid with fd=\n");              error_report("ifname=, script=, downscript= and vnet_hdr= is invalid with fd=");
             return -1;              return -1;
         }          }
   
Line 441  int net_init_tap(QemuOpts *opts, Monitor Line 465  int net_init_tap(QemuOpts *opts, Monitor
         }          }
     }      }
   
       if (qemu_opt_get_bool(opts, "vhost", !!qemu_opt_get(opts, "vhostfd"))) {
           int vhostfd, r;
           if (qemu_opt_get(opts, "vhostfd")) {
               r = net_handle_fd_param(mon, qemu_opt_get(opts, "vhostfd"));
               if (r == -1) {
                   return -1;
               }
               vhostfd = r;
           } else {
               vhostfd = -1;
           }
           s->vhost_net = vhost_net_init(&s->nc, vhostfd);
           if (!s->vhost_net) {
               error_report("vhost-net requested but could not be initialized");
               return -1;
           }
       } else if (qemu_opt_get(opts, "vhostfd")) {
           error_report("vhostfd= is not valid without vhost");
           return -1;
       }
   
     return 0;      return 0;
 }  }
   
   VHostNetState *tap_get_vhost_net(VLANClientState *nc)
   {
       TAPState *s = DO_UPCAST(TAPState, nc, nc);
       assert(nc->info->type == NET_CLIENT_TYPE_TAP);
       return s->vhost_net;
   }

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


unix.superglobalmegacorp.com