ia64/xen-unstable

changeset 15069:a6308744caae

[qemu] Remove -vnclisten option since the same functionality is now
available using the -vnc option.

Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Thu May 10 15:17:20 2007 +0100 (2007-05-10)
parents 5040a3ff50ee
children a4467c0971ba
files tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c
line diff
     1.1 --- a/tools/ioemu/vl.c	Thu May 10 15:10:16 2007 +0100
     1.2 +++ b/tools/ioemu/vl.c	Thu May 10 15:17:20 2007 +0100
     1.3 @@ -133,7 +133,6 @@ static DisplayState display_state;
     1.4  int nographic;
     1.5  int vncviewer;
     1.6  int vncunused;
     1.7 -struct sockaddr_in vnclisten_addr;
     1.8  const char* keyboard_layout = NULL;
     1.9  int64_t ticks_per_sec;
    1.10  char *boot_device = NULL;
    1.11 @@ -3020,22 +3019,10 @@ fail:
    1.12      return -1;
    1.13  }
    1.14  
    1.15 -int parse_host(struct sockaddr_in *saddr, const char *buf)
    1.16 -{
    1.17 -    struct hostent *he;
    1.18 -
    1.19 -    if ((he = gethostbyname(buf)) != NULL) {
    1.20 -        saddr->sin_addr = *(struct in_addr *)he->h_addr;
    1.21 -    } else {
    1.22 -        if (!inet_aton(buf, &saddr->sin_addr))
    1.23 -            return -1;
    1.24 -    }
    1.25 -    return 0;
    1.26 -}
    1.27 -
    1.28  int parse_host_port(struct sockaddr_in *saddr, const char *str)
    1.29  {
    1.30      char buf[512];
    1.31 +    struct hostent *he;
    1.32      const char *p, *r;
    1.33      int port;
    1.34  
    1.35 @@ -3046,8 +3033,14 @@ int parse_host_port(struct sockaddr_in *
    1.36      if (buf[0] == '\0') {
    1.37          saddr->sin_addr.s_addr = 0;
    1.38      } else {
    1.39 -        if (parse_host(saddr, buf) == -1)
    1.40 -            return -1;
    1.41 +        if (isdigit(buf[0])) {
    1.42 +            if (!inet_aton(buf, &saddr->sin_addr))
    1.43 +                return -1;
    1.44 +        } else {
    1.45 +            if ((he = gethostbyname(buf)) == NULL)
    1.46 +                return - 1;
    1.47 +            saddr->sin_addr = *(struct in_addr *)he->h_addr;
    1.48 +        }
    1.49      }
    1.50      port = strtol(p, (char **)&r, 0);
    1.51      if (r == p)
    1.52 @@ -6333,7 +6326,6 @@ void help(void)
    1.53  	   "-vnc display    start a VNC server on display\n"
    1.54             "-vncviewer      start a vncviewer process for this domain\n"
    1.55             "-vncunused      bind the VNC server to an unused port\n"
    1.56 -           "-vnclisten      bind the VNC server to this address\n"
    1.57             "-timeoffset     time offset (in seconds) from local time\n"
    1.58  #ifndef _WIN32
    1.59  	   "-daemonize      daemonize QEMU after initializing\n"
    1.60 @@ -6435,7 +6427,6 @@ enum {
    1.61      QEMU_OPTION_acpi,
    1.62      QEMU_OPTION_vncviewer,
    1.63      QEMU_OPTION_vncunused,
    1.64 -    QEMU_OPTION_vnclisten,
    1.65  };
    1.66  
    1.67  typedef struct QEMUOption {
    1.68 @@ -6518,7 +6509,6 @@ const QEMUOption qemu_options[] = {
    1.69      { "vnc", HAS_ARG, QEMU_OPTION_vnc },
    1.70      { "vncviewer", 0, QEMU_OPTION_vncviewer },
    1.71      { "vncunused", 0, QEMU_OPTION_vncunused },
    1.72 -    { "vnclisten", HAS_ARG, QEMU_OPTION_vnclisten },
    1.73  
    1.74      /* temporary options */
    1.75      { "usb", 0, QEMU_OPTION_usb },
    1.76 @@ -7086,8 +7076,6 @@ int main(int argc, char **argv)
    1.77  
    1.78      nb_nics = 0;
    1.79      /* default mac address of the first network interface */
    1.80 -
    1.81 -    memset(&vnclisten_addr.sin_addr, 0, sizeof(vnclisten_addr.sin_addr));
    1.82      
    1.83      /* init debug */
    1.84      sprintf(qemu_dm_logfilename, "/var/log/xen/qemu-dm.%ld.log", (long)getpid());
    1.85 @@ -7492,9 +7480,6 @@ int main(int argc, char **argv)
    1.86              case QEMU_OPTION_vncunused:
    1.87                  vncunused++;
    1.88                  break;
    1.89 -            case QEMU_OPTION_vnclisten:
    1.90 -                parse_host(&vnclisten_addr, optarg);
    1.91 -                break;
    1.92              }
    1.93          }
    1.94      }
    1.95 @@ -7794,8 +7779,7 @@ int main(int argc, char **argv)
    1.96          dumb_display_init(ds);
    1.97      } else if (vnc_display != NULL || vncunused != 0) {
    1.98  	int vnc_display_port;
    1.99 -	vnc_display_port = vnc_display_init(ds, vnc_display, vncunused,
   1.100 -					    &vnclisten_addr);
   1.101 +	vnc_display_port = vnc_display_init(ds, vnc_display, vncunused);
   1.102  	if (vncviewer)
   1.103  	    vnc_start_viewer(vnc_display_port);
   1.104  	xenstore_write_vncport(vnc_display_port);
     2.1 --- a/tools/ioemu/vl.h	Thu May 10 15:10:16 2007 +0100
     2.2 +++ b/tools/ioemu/vl.h	Thu May 10 15:17:20 2007 +0100
     2.3 @@ -37,8 +37,6 @@
     2.4  #include <unistd.h>
     2.5  #include <fcntl.h>
     2.6  #include <sys/stat.h>
     2.7 -#include <sys/socket.h>
     2.8 -#include <sys/types.h>
     2.9  #include "xenctrl.h"
    2.10  #include "xs.h"
    2.11  #include <xen/hvm/e820.h>
    2.12 @@ -956,7 +954,7 @@ void sdl_display_init(DisplayState *ds, 
    2.13  void cocoa_display_init(DisplayState *ds, int full_screen);
    2.14  
    2.15  /* vnc.c */
    2.16 -int vnc_display_init(DisplayState *ds, const char *display, int find_unused, struct sockaddr_in *iaddr);
    2.17 +int vnc_display_init(DisplayState *ds, const char *display, int find_unused);
    2.18  void do_info_vnc(void);
    2.19  int vnc_start_viewer(int port);
    2.20  
     3.1 --- a/tools/ioemu/vnc.c	Thu May 10 15:10:16 2007 +0100
     3.2 +++ b/tools/ioemu/vnc.c	Thu May 10 15:17:20 2007 +0100
     3.3 @@ -1393,9 +1393,10 @@ static void vnc_listen_read(void *opaque
     3.4  
     3.5  extern int parse_host_port(struct sockaddr_in *saddr, const char *str);
     3.6  
     3.7 -int vnc_display_init(DisplayState *ds, const char *arg, int find_unused, struct sockaddr_in *iaddr)
     3.8 +int vnc_display_init(DisplayState *ds, const char *arg, int find_unused)
     3.9  {
    3.10      struct sockaddr *addr;
    3.11 +    struct sockaddr_in iaddr;
    3.12  #ifndef _WIN32
    3.13      struct sockaddr_un uaddr;
    3.14  #endif
    3.15 @@ -1456,8 +1457,8 @@ int vnc_display_init(DisplayState *ds, c
    3.16      } else
    3.17  #endif
    3.18      {
    3.19 -	addr = (struct sockaddr *)iaddr;
    3.20 -	addrlen = sizeof(*iaddr);
    3.21 +	addr = (struct sockaddr *)&iaddr;
    3.22 +	addrlen = sizeof(iaddr);
    3.23  
    3.24  	vs->lsock = socket(PF_INET, SOCK_STREAM, 0);
    3.25  	if (vs->lsock == -1) {
    3.26 @@ -1465,12 +1466,12 @@ int vnc_display_init(DisplayState *ds, c
    3.27  	    exit(1);
    3.28  	}
    3.29  
    3.30 -	if (parse_host_port(iaddr, arg) < 0) {
    3.31 +	if (parse_host_port(&iaddr, arg) < 0) {
    3.32  	    fprintf(stderr, "Could not parse VNC address\n");
    3.33  	    exit(1);
    3.34  	}
    3.35  	    
    3.36 -	iaddr->sin_port = htons(ntohs(iaddr->sin_port) + 5900);
    3.37 +	iaddr.sin_port = htons(ntohs(iaddr.sin_port) + 5900);
    3.38  
    3.39  	reuse_addr = 1;
    3.40  	ret = setsockopt(vs->lsock, SOL_SOCKET, SO_REUSEADDR,
    3.41 @@ -1483,7 +1484,7 @@ int vnc_display_init(DisplayState *ds, c
    3.42  
    3.43      while (bind(vs->lsock, addr, addrlen) == -1) {
    3.44  	if (find_unused && errno == EADDRINUSE) {
    3.45 -	    iaddr->sin_port = htons(ntohs(iaddr->sin_port) + 1);
    3.46 +	    iaddr.sin_port = htons(ntohs(iaddr.sin_port) + 1);
    3.47  	    continue;
    3.48  	}
    3.49  	fprintf(stderr, "bind() failed\n");
    3.50 @@ -1500,7 +1501,7 @@ int vnc_display_init(DisplayState *ds, c
    3.51  	exit(1);
    3.52      }
    3.53  
    3.54 -    return ntohs(iaddr->sin_port);
    3.55 +    return ntohs(iaddr.sin_port);
    3.56  }
    3.57  
    3.58  int vnc_start_viewer(int port)