All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christopher Olsen <cwolsen@domainatlantic.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] QEMU: VNC
Date: Sun, 18 Feb 2007 15:36:18 -0500	[thread overview]
Message-ID: <200702181536.18429.cwolsen@domainatlantic.com> (raw)
In-Reply-To: <200702161402.23660.cwolsen@domainatlantic.com>

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

I didn't see a way so here is a patch for it work on 0.9.0

-Christopher

On Friday 16 February 2007 14:02, Christopher Olsen wrote:
> Anyone here know if there is a way to append to the VNC display header?
>
> -Christopher

-- 
Christopher Olsen
cwolsen@domainatlantic.com
Tel: 631-676-4877
Fax: 631-249-3036

[-- Attachment #2: qemu.patch --]
[-- Type: text/x-diff, Size: 14944 bytes --]

*** vl.c	Fri Feb 16 13:27:06 2007
--- /home/reddawg/qemu/work/qemu-0.9.0/vl.c	Fri Feb 16 13:30:09 2007
***************
*** 1,9 ****
--- 1,10 ----
  /*
   * QEMU System Emulator
   * 
   * Copyright (c) 2003-2007 Fabrice Bellard
+  * Copyright (C) 2007 Christopher Olsen <cwolsen@ubixos.com>
   * 
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
***************
*** 45,54 ****
--- 46,60 ----
  #ifdef _BSD
  #include <sys/stat.h>
  #ifndef __APPLE__
  #include <libutil.h>
  #endif
+ #ifdef __FreeBSD__
+ #include <sys/module.h>
+ #include <dev/ppbus/ppi.h>
+ #include <dev/ppbus/ppbconf.h>
+ #endif
  #else
  #ifndef __sun__
  #include <linux/if.h>
  #include <linux/if_tun.h>
  #include <pty.h>
***************
*** 87,101 ****
--- 93,109 ----
  #include "disas.h"
  
  #include "exec-all.h"
  
  #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
+ #ifndef SMBD_COMMAND
  #ifdef __sun__
  #define SMBD_COMMAND "/usr/sfw/sbin/smbd"
  #else
  #define SMBD_COMMAND "/usr/sbin/smbd"
  #endif
+ #endif
  
  //#define DEBUG_UNUSED_IOPORT
  //#define DEBUG_IOPORT
  
  #define PHYS_RAM_MAX_SIZE (2047 * 1024 * 1024)
***************
*** 156,165 ****
--- 164,174 ----
  #endif
  int usb_enabled = 0;
  static VLANState *first_vlan;
  int smp_cpus = 1;
  const char *vnc_display;
+ const char *vnc_name;
  #if defined(TARGET_SPARC)
  #define MAX_CPUS 16
  #elif defined(TARGET_I386)
  #define MAX_CPUS 255
  #else
***************
*** 626,636 ****
  static int use_rt_clock;
  
  static void init_get_clock(void)
  {
      use_rt_clock = 0;
! #if defined(__linux__)
      {
          struct timespec ts;
          if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
              use_rt_clock = 1;
          }
--- 635,645 ----
  static int use_rt_clock;
  
  static void init_get_clock(void)
  {
      use_rt_clock = 0;
! #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
      {
          struct timespec ts;
          if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
              use_rt_clock = 1;
          }
***************
*** 638,648 ****
  #endif
  }
  
  static int64_t get_clock(void)
  {
! #if defined(__linux__)
      if (use_rt_clock) {
          struct timespec ts;
          clock_gettime(CLOCK_MONOTONIC, &ts);
          return ts.tv_sec * 1000000000LL + ts.tv_nsec;
      } else 
--- 647,657 ----
  #endif
  }
  
  static int64_t get_clock(void)
  {
! #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000)
      if (use_rt_clock) {
          struct timespec ts;
          clock_gettime(CLOCK_MONOTONIC, &ts);
          return ts.tv_sec * 1000000000LL + ts.tv_nsec;
      } else 
***************
*** 1639,1649 ****
          term_init();
      }
      return chr;
  }
  
! #if defined(__linux__)
  static CharDriverState *qemu_chr_open_pty(void)
  {
      struct termios tty;
      char slave_name[1024];
      int master_fd, slave_fd;
--- 1648,1658 ----
          term_init();
      }
      return chr;
  }
  
! #if defined(__linux__) || defined(__FreeBSD__)
  static CharDriverState *qemu_chr_open_pty(void)
  {
      struct termios tty;
      char slave_name[1024];
      int master_fd, slave_fd;
***************
*** 1718,1731 ****
  
      cfsetispeed(&tty, spd);
      cfsetospeed(&tty, spd);
  
      tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
!                           |INLCR|IGNCR|ICRNL|IXON);
!     tty.c_oflag |= OPOST;
      tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG);
      tty.c_cflag &= ~(CSIZE|PARENB|PARODD|CRTSCTS|CSTOPB);
      switch(data_bits) {
      default:
      case 8:
          tty.c_cflag |= CS8;
          break;
--- 1727,1743 ----
  
      cfsetispeed(&tty, spd);
      cfsetospeed(&tty, spd);
  
      tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
!                           |INLCR|IGNCR|ICRNL|IXON|IMAXBEL);
!     tty.c_oflag &= ~OPOST; /* Don't do any output processing! */
      tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN|ISIG);
      tty.c_cflag &= ~(CSIZE|PARENB|PARODD|CRTSCTS|CSTOPB);
+ #ifdef __FreeBSD__
+     cfmakeraw(&tty);
+ #endif
      switch(data_bits) {
      default:
      case 8:
          tty.c_cflag |= CS8;
          break;
***************
*** 1797,1806 ****
--- 1809,1819 ----
      chr->chr_ioctl = tty_serial_ioctl;
      qemu_chr_reset(chr);
      return chr;
  }
  
+ #if defined(__linux__)
  static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
  {
      int fd = (int)chr->opaque;
      uint8_t b;
  
***************
*** 1861,1870 ****
--- 1874,1941 ----
  
      qemu_chr_reset(chr);
  
      return chr;
  }
+ #elif defined(__FreeBSD__)
+ static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
+ {
+     int fd = (int)chr->opaque;
+     uint8_t b;
+ 
+     switch(cmd) {
+     case CHR_IOCTL_PP_READ_DATA:
+         if (ioctl(fd, PPIGDATA, &b) < 0)
+             return -ENOTSUP;
+         *(uint8_t *)arg = b;
+         break;
+     case CHR_IOCTL_PP_WRITE_DATA:
+         b = *(uint8_t *)arg;
+         if (ioctl(fd, PPISDATA, &b) < 0)
+             return -ENOTSUP;
+         break;
+     case CHR_IOCTL_PP_READ_CONTROL:
+         if (ioctl(fd, PPIGCTRL, &b) < 0)
+             return -ENOTSUP;
+         *(uint8_t *)arg = b;
+         break;
+     case CHR_IOCTL_PP_WRITE_CONTROL:
+         b = *(uint8_t *)arg;
+         if (ioctl(fd, PPISCTRL, &b) < 0)
+             return -ENOTSUP;
+         break;
+     case CHR_IOCTL_PP_READ_STATUS:
+         if (ioctl(fd, PPIGSTATUS, &b) < 0)
+             return -ENOTSUP;
+         *(uint8_t *)arg = b;
+         break;
+     default:
+         return -ENOTSUP;
+     }
+     return 0;
+ }
+ 
+ CharDriverState *qemu_chr_open_pp(const char *filename)
+ {
+     CharDriverState *chr;
+     int fd;
+ 
+     fd = open(filename, O_RDWR);
+     if (fd < 0)
+         return NULL;
+ 
+     chr = qemu_mallocz(sizeof(CharDriverState));
+     if (!chr) {
+         close(fd);
+         return NULL;
+     }
+     chr->opaque = (void *)fd;
+     chr->chr_write = null_chr_write;
+     chr->chr_ioctl = pp_ioctl;
+     return chr;
+ }
+ #endif
  
  #else
  static CharDriverState *qemu_chr_open_pty(void)
  {
      return NULL;
***************
*** 2737,2746 ****
--- 2808,2824 ----
          return qemu_chr_open_pp(filename);
      } else 
      if (strstart(filename, "/dev/", NULL)) {
          return qemu_chr_open_tty(filename);
      } else 
+ #elif defined(__FreeBSD__)
+     if (strstart(filename, "/dev/ppi", NULL)) {
+         return qemu_chr_open_pp(filename);
+     } else 
+     if (strstart(filename, "/dev/", NULL)) {
+         return qemu_chr_open_tty(filename);
+     } else 
  #endif
  #ifdef _WIN32
      if (strstart(filename, "COM", NULL)) {
          return qemu_chr_open_win(filename);
      } else
***************
*** 3169,3178 ****
--- 3247,3284 ----
  
  #endif /* !defined(_WIN32) */
  
  #endif /* CONFIG_SLIRP */
  
+ #ifdef __FreeBSD__
+ #define LOAD_QUIETLY	1
+ #define LOAD_VERBOSLY	2
+ 
+ int
+ loadmodules(int how, const char *module, ...)
+ {
+   int loaded = 0;
+   va_list ap;
+ 
+   va_start(ap, module);
+ #ifndef NO_MODULES
+   while (module != NULL) {
+     if (modfind(module) == -1) {
+       if (kldload(module) == -1) {
+         if (how == LOAD_VERBOSLY)
+           fprintf(stderr, "%s: Cannot load module\n", module);
+       } else
+         loaded++;
+     }
+     module = va_arg(ap, const char *);
+   }
+   va_end(ap);
+ #endif
+   return loaded;
+ }
+ #endif
+ 
  #if !defined(_WIN32)
  
  typedef struct TAPState {
      VLANClientState *vc;
      int fd;
***************
*** 3224,3238 ****
  {
      int fd;
      char *dev;
      struct stat s;
  
      fd = open("/dev/tap", O_RDWR);
      if (fd < 0) {
!         fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
          return -1;
      }
  
      fstat(fd, &s);
      dev = devname(s.st_rdev, S_IFCHR);
      pstrcpy(ifname, ifname_size, dev);
  
--- 3330,3388 ----
  {
      int fd;
      char *dev;
      struct stat s;
  
+ #ifdef __FreeBSD__
+     int i, kldtried = 0, enoentcount = 0, err = 0;
+     char dname[100];
+ #ifdef USE_DEVTAP
+     /*
+      * 5.x has /dev/tap, but that seems to just blindly increase its
+      * couter on every open() for some people(??), i.e. on every qemu run.
+      */
+     i = -1;
+ #else
+     i = 0;
+ #endif
+     for (; i < 10; i++) {
+         if (i == -1)
+ 	    strcpy(dname, "/dev/tap");
+         else
+ 	    snprintf(dname, sizeof dname, "%s%d",
+ 		     "/dev/tap", i);
+         fd = open(dname, O_RDWR);
+         if (fd >= 0)
+             break;
+         else if (errno == ENXIO || errno == ENOENT) {
+             if (i == 0 && !kldtried++) {
+                 /*
+                  * Attempt to load the tunnel interface KLD if it isn't loaded
+                  * already.
+                  */
+                 if (loadmodules(LOAD_VERBOSLY, "if_tap", NULL))
+                     i = -1;
+                 continue;
+             }
+             if (errno != ENOENT || ++enoentcount > 3) {
+                 err = errno;
+ 	        break;
+             }
+         } else
+             err = errno;
+     }
+     if (fd < 0) {
+         fprintf(stderr, "warning: could not open %s (%s): no virtual network emulation\n", dname, strerror(err));
+         return -1;
+     }
+ #else
      fd = open("/dev/tap", O_RDWR);
      if (fd < 0) {
!         fprintf(stderr, "warning: could not open /dev/tap (%s): no virtual network emulation\n", strerror(errno));
          return -1;
      }
+ #endif
  
      fstat(fd, &s);
      dev = devname(s.st_rdev, S_IFCHR);
      pstrcpy(ifname, ifname_size, dev);
  
***************
*** 6199,6208 ****
--- 6349,6359 ----
      QEMU_OPTION_win2k_hack,
      QEMU_OPTION_usb,
      QEMU_OPTION_usbdevice,
      QEMU_OPTION_smp,
      QEMU_OPTION_vnc,
+     QEMU_OPTION_vncname,
      QEMU_OPTION_no_acpi,
      QEMU_OPTION_no_reboot,
      QEMU_OPTION_daemonize,
      QEMU_OPTION_option_rom,
      QEMU_OPTION_semihosting
***************
*** 6279,6288 ****
--- 6430,6440 ----
      { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
      { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
      { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
      { "smp", HAS_ARG, QEMU_OPTION_smp },
      { "vnc", HAS_ARG, QEMU_OPTION_vnc },
+     { "vncname", HAS_ARG, QEMU_OPTION_vncname },
  
      /* temporary options */
      { "usb", 0, QEMU_OPTION_usb },
      { "cirrusvga", 0, QEMU_OPTION_cirrusvga },
      { "no-acpi", 0, QEMU_OPTION_no_acpi },
***************
*** 6704,6713 ****
--- 6856,6866 ----
                  }
                  break;
              case QEMU_OPTION_nographic:
                  pstrcpy(monitor_device, sizeof(monitor_device), "stdio");
                  pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "stdio");
+                 pstrcpy(parallel_devices[0], sizeof(parallel_devices[0]), "null");
                  nographic = 1;
                  break;
              case QEMU_OPTION_kernel:
                  kernel_filename = optarg;
                  break;
***************
*** 6936,6945 ****
--- 7089,7101 ----
                  }
                  break;
  	    case QEMU_OPTION_vnc:
  		vnc_display = optarg;
  		break;
+             case QEMU_OPTION_vncname:
+                 vnc_name = optarg;
+                 break;
              case QEMU_OPTION_no_acpi:
                  acpi_enabled = 0;
                  break;
              case QEMU_OPTION_no_reboot:
                  no_reboot = 1;
*** vl.h	Fri Feb 16 13:27:06 2007
--- /home/reddawg/qemu/work/qemu-0.9.0/vl.h	Fri Feb 16 13:30:23 2007
***************
*** 1,9 ****
--- 1,10 ----
  /*
   * QEMU System Emulator header
   * 
   * Copyright (c) 2003 Fabrice Bellard
+  * Copyright (C) 2007 Christopher Olsen <cwolsen@ubixos.com>
   * 
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
***************
*** 28,37 ****
--- 29,44 ----
  #include <stdlib.h>
  #include <stdio.h>
  #include <stdarg.h>
  #include <string.h>
  #include <inttypes.h>
+ #ifndef PRId64
+ #define	PRId64	"lld"	/* int64_t */
+ #define	PRIo64	"llo"	/* int64_t */
+ #define	PRIx64	"llx"	/* int64_t */
+ #define	PRIu64	"llu"	/* int64_t */
+ #endif
  #include <limits.h>
  #include <time.h>
  #include <ctype.h>
  #include <errno.h>
  #include <unistd.h>
***************
*** 110,119 ****
--- 117,129 ----
  uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
  
  void hw_error(const char *fmt, ...);
  
  extern const char *bios_dir;
+ 
+ //UBU
+ extern const char *vnc_name;
  
  extern int vm_running;
  
  typedef struct vm_change_state_entry VMChangeStateEntry;
  typedef void VMChangeStateHandler(void *opaque, int running);
*** vnc.c	Fri Feb 16 13:27:06 2007
--- /home/reddawg/qemu/work/qemu-0.9.0/vnc.c	Fri Feb 16 13:29:13 2007
***************
*** 1,10 ****
--- 1,11 ----
  /*
   * QEMU VNC display driver
   * 
   * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
   * Copyright (C) 2006 Fabrice Bellard
+  * Copyright (C) 2007 Christopher Olsen <cwolsen@ubixos.com>
   * 
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
***************
*** 1054,1063 ****
--- 1055,1065 ----
  }
  
  static int protocol_client_init(VncState *vs, char *data, size_t len)
  {
      char pad[3] = { 0, 0, 0 };
+     char name[64];
  
      vs->width = vs->ds->width;
      vs->height = vs->ds->height;
      vnc_write_u16(vs, vs->ds->width);
      vnc_write_u16(vs, vs->ds->height);
***************
*** 1098,1109 ****
      }
      vs->write_pixels = vnc_write_pixels_copy;
  	
      vnc_write(vs, pad, 3);           /* padding */
  
!     vnc_write_u32(vs, 4);        
!     vnc_write(vs, "QEMU", 4);
      vnc_flush(vs);
  
      vnc_read_when(vs, protocol_client_msg, 1);
  
      return 0;
--- 1100,1115 ----
      }
      vs->write_pixels = vnc_write_pixels_copy;
  	
      vnc_write(vs, pad, 3);           /* padding */
  
!     if (vnc_name == 0x0)
!       sprintf(name, "QEMU: Unknown");
!     else
!       sprintf(name, "QEMU: %s",vnc_name);
!     vnc_write_u32(vs, strlen(name));
!     vnc_write(vs, name, strlen(name));
      vnc_flush(vs);
  
      vnc_read_when(vs, protocol_client_msg, 1);
  
      return 0;

  parent reply	other threads:[~2007-02-18 20:38 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 19:02 [Qemu-devel] QEMU: VNC Christopher Olsen
2007-02-16 20:57 ` Anthony Liguori
2007-02-18 20:36 ` Christopher Olsen [this message]
2007-02-18 23:08   ` Anthony Liguori
2007-02-18 23:53     ` Christopher Olsen
2007-02-19  0:14       ` Johannes Schindelin
2007-02-19  0:30         ` Christopher Olsen
2007-02-19  0:41           ` Johannes Schindelin
2007-02-19  2:01           ` Anthony Liguori
2007-02-19  2:11             ` Johannes Schindelin
2007-02-19  2:48               ` Anthony Liguori
2007-02-19 12:19                 ` Christopher Olsen
2007-02-19 14:53                   ` Johannes Schindelin
2007-02-19 17:16                     ` Christopher Olsen
2007-02-19 17:30               ` Daniel P. Berrange
2007-02-19 17:41                 ` Christopher Olsen
2007-02-19 19:09                   ` Daniel P. Berrange
2007-02-19 19:29                     ` Christopher Olsen
2007-02-19 22:52                     ` Fabrice Bellard
2007-02-19 23:37                       ` Christopher Olsen
2007-02-20  0:36                         ` Daniel P. Berrange
2007-02-20  0:45                           ` Anthony Liguori
2007-02-20  0:53                             ` Christopher Olsen
2007-02-20  1:05                             ` Daniel P. Berrange
2007-02-20  1:11                               ` Johannes Schindelin
2007-02-20  1:18                                 ` Christopher Olsen
2007-02-20 19:46                                 ` Joe Batt
2007-02-20  1:15                               ` [Qemu-devel] FreeBSD Support Christopher Olsen
2007-02-20  1:46                                 ` Paul Brook
2007-02-20  2:10                                   ` Christopher Olsen
2007-02-20  2:41                                     ` Paul Brook
2007-02-20  3:26                                       ` Christopher Olsen
2007-02-24 19:08                                         ` Juergen Lock
2007-02-24 20:54                                           ` Leonardo Reiter
2007-02-26  0:12                                         ` andrzej zaborowski
2007-03-03 22:12                                           ` Thiemo Seufer
2007-03-05  7:38                                             ` andrzej zaborowski
2007-02-19 23:58                       ` [Qemu-devel] QEMU: VNC Johannes Schindelin
2007-02-19  0:11   ` Johannes Schindelin
2007-02-19  0:25     ` Christopher Olsen
2007-02-22  5:19 Luke-Jr
2007-02-22 16:22 ` Johannes Schindelin
2007-02-22 16:35   ` Anthony Liguori
2007-02-22 16:39     ` Christopher Olsen
2007-02-22 17:18     ` Johannes Schindelin
2007-02-22 17:29       ` Anthony Liguori
2007-02-22 17:35         ` Johannes Schindelin
2007-02-22 17:55           ` Leonardo Reiter
     [not found]     ` <200702221044.48581.luke@dashjr.org>
2007-02-22 17:27       ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200702181536.18429.cwolsen@domainatlantic.com \
    --to=cwolsen@domainatlantic.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.