qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] connect to redirected port on localhost
@ 2004-09-08 16:14 Mark Jonckheere
  2004-09-10 10:16 ` [Qemu-devel] Perl script to help write savevm handlers Johannes Schindelin
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Jonckheere @ 2004-09-08 16:14 UTC (permalink / raw)
  To: qemu-devel

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

I had some problems with the -redir option and localhost.

My environment:

Qemu:    latest CVS (06-sep-2004) with my full-screen and no-broadcast patches applied
          (see also my messages from 20-jul-2004 and 31-aug-2004) using slirp networking.

Host OS: RedHat 7.3 ip-address 192.168.1.2
Client:  Knoppix 3.3 started with the command line:

          qemu -cdrom /dev/cdrom -boot d -localtime -redir tcp:8139::139 &

After startup I enabled the samba server on the client with the standard config file
and an empty password for user knoppix.

The following commands did work from any computer on my network including the host:

smbclient -L 192.168.1.2 -p 8139 -U knoppix -N
mkdir /mnt/knoppix
smbmount //KNOPPIX/knoppix /mnt/knoppix -o workgroup=WORKGROUP,port=8139,ip=192.168.1.2,username=knoppix,password=

but on the host OS the commands:

smbclient -L 127.0.0.1 -p 8139 -U knoppix -N
smbmount //KNOPPIX/knoppix /mnt/knoppix -o workgroup=WORKGROUP,port=8139,ip=127.0.0.1,username=knoppix,password=

resulted in a time-out.

What happened was that the code in slirp that replaced the source address
'loopback_addr' with 'our_addr' in packets sent to the client didn't expect the
case that in an installation without network card 'our_addr' contains 127.0.0.1.

My patch tests if 'our_addr' contains 127.0.0.1 and then replaces it with the address 10.0.2.2.

----8<----------------------------------------------------
diff -ur qemu/slirp/misc.c qemu-patched/slirp/misc.c
--- qemu/slirp/misc.c   Mon Sep  6 01:10:26 2004
+++ qemu-patched/slirp/misc.c   Wed Sep  8 16:12:14 2004
@@ -90,13 +90,12 @@
         char buff[256];
         struct hostent *he;

-       if (gethostname(buff,256) < 0)
-          return;
-
-       if ((he = gethostbyname(buff)) == NULL)
-          return;
-
-       our_addr = *(struct in_addr *)he->h_addr;
+       if (gethostname(buff,256) == 0)
+               if ((he = gethostbyname(buff)) != NULL)
+                       our_addr = *(struct in_addr *)he->h_addr;
+
+       if (our_addr.s_addr == 0 || our_addr.s_addr == loopback_addr.s_addr)
+               our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
  }

  #if SIZEOF_CHAR_P == 8
diff -ur qemu/slirp/slirp.c qemu-patched/slirp/slirp.c
--- qemu/slirp/slirp.c  Mon Sep  6 01:10:26 2004
+++ qemu-patched/slirp/slirp.c  Wed Sep  8 16:13:00 2004
@@ -144,7 +144,6 @@
      m_init();

      /* set default addresses */
-    getouraddr();
      inet_aton("127.0.0.1", &loopback_addr);

      if (get_dns_addr(&dns_addr) < 0) {
@@ -153,6 +152,7 @@
      }

      inet_aton(CTL_SPECIAL, &special_addr);
+    getouraddr();
  }

  #define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
----8<----------------------------------------------------


If you want to run qemu on a stand-alone host, don't forget to also look at the
no-sdl patch from Laurant Amon sent on 6-sep-2004 on this mailing list.

For those interested I include my current cumulative patchfile as an attachment

groeten,
Mark.
-- 
:wq

[-- Attachment #2: my_patches.diff --]
[-- Type: text/plain, Size: 4082 bytes --]

diff -ur qemu/sdl.c qemu-patched/sdl.c
--- qemu/sdl.c	Wed Jul 14 19:22:33 2004
+++ qemu-patched/sdl.c	Mon Sep  6 10:44:11 2004
@@ -45,6 +45,10 @@
 {
     //    printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
     SDL_UpdateRect(screen, x, y, w, h);
+    /* FIXME: next two lines are a quick fix, to make
+     * sure grab is always on in fullscreen mode */
+    if (gui_fullscreen)
+        sdl_grab_start();
 }
 
 static void sdl_resize(DisplayState *ds, int w, int h)
@@ -540,7 +544,7 @@
     SDL_Quit();
 }
 
-void sdl_display_init(DisplayState *ds)
+void sdl_display_init(DisplayState *ds, int full)
 {
     int flags;
 
@@ -566,4 +570,8 @@
     gui_grab = 0;
 
     atexit(sdl_cleanup);
+
+    if (full) {
+        gui_fullscreen = 1;
+    }
 }
diff -ur qemu/slirp/misc.c qemu-patched/slirp/misc.c
--- qemu/slirp/misc.c	Mon Sep  6 01:10:26 2004
+++ qemu-patched/slirp/misc.c	Wed Sep  8 16:12:14 2004
@@ -90,13 +90,12 @@
 	char buff[256];
 	struct hostent *he;
 	
-	if (gethostname(buff,256) < 0)
-	   return;
-	
-	if ((he = gethostbyname(buff)) == NULL)
-	   return;
-	
-	our_addr = *(struct in_addr *)he->h_addr;
+	if (gethostname(buff,256) == 0)
+		if ((he = gethostbyname(buff)) != NULL)
+			our_addr = *(struct in_addr *)he->h_addr;
+
+	if (our_addr.s_addr == 0 || our_addr.s_addr == loopback_addr.s_addr)
+		our_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
 }
 
 #if SIZEOF_CHAR_P == 8
diff -ur qemu/slirp/slirp.c qemu-patched/slirp/slirp.c
--- qemu/slirp/slirp.c	Mon Sep  6 01:10:26 2004
+++ qemu-patched/slirp/slirp.c	Wed Sep  8 16:13:00 2004
@@ -144,7 +144,6 @@
     m_init();
 
     /* set default addresses */
-    getouraddr();
     inet_aton("127.0.0.1", &loopback_addr);
 
     if (get_dns_addr(&dns_addr) < 0) {
@@ -153,6 +152,7 @@
     }
 
     inet_aton(CTL_SPECIAL, &special_addr);
+    getouraddr();
 }
 
 #define CONN_CANFSEND(so) (((so)->so_state & (SS_FCANTSENDMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
diff -ur qemu/slirp/udp.c qemu-patched/slirp/udp.c
--- qemu/slirp/udp.c	Tue Aug 24 23:57:12 2004
+++ qemu-patched/slirp/udp.c	Mon Sep  6 10:44:11 2004
@@ -314,6 +314,8 @@
     saddr = *addr;
     if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr)
         saddr.sin_addr.s_addr = so->so_faddr.s_addr;
+    if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff))
+        saddr.sin_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS);
     daddr.sin_addr = so->so_laddr;
     daddr.sin_port = so->so_lport;
     
diff -ur qemu/vl.c qemu-patched/vl.c
--- qemu/vl.c	Mon Sep  6 02:14:04 2004
+++ qemu-patched/vl.c	Mon Sep  6 10:44:11 2004
@@ -128,6 +128,7 @@
 int graphic_width = 800;
 int graphic_height = 600;
 int graphic_depth = 15;
+int full_screen = 0;
 TextConsole *vga_console;
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
 
@@ -2586,6 +2587,7 @@
     QEMU_OPTION_std_vga,
     QEMU_OPTION_monitor,
     QEMU_OPTION_serial,
+    QEMU_OPTION_full_screen,
 };
 
 typedef struct QEMUOption {
@@ -2642,6 +2644,7 @@
     { "std-vga", 0, QEMU_OPTION_std_vga },
     { "monitor", 1, QEMU_OPTION_monitor },
     { "serial", 1, QEMU_OPTION_serial },
+    { "full-screen", 0, QEMU_OPTION_full_screen },
     
     /* temporary options */
     { "pci", 0, QEMU_OPTION_pci },
@@ -3040,6 +3043,9 @@
                         sizeof(serial_devices[0]), optarg);
                 serial_device_index++;
                 break;
+            case QEMU_OPTION_full_screen:
+                full_screen = 1;
+		break; 
             }
         }
     }
@@ -3224,7 +3230,7 @@
         dumb_display_init(ds);
     } else {
 #ifdef CONFIG_SDL
-        sdl_display_init(ds);
+        sdl_display_init(ds, full_screen);
 #else
         dumb_display_init(ds);
 #endif
diff -ur qemu/vl.h qemu-patched/vl.h
--- qemu/vl.h	Tue Aug 24 23:13:40 2004
+++ qemu-patched/vl.h	Mon Sep  6 10:44:11 2004
@@ -536,7 +536,7 @@
                          unsigned long vga_ram_offset, int vga_ram_size);
 
 /* sdl.c */
-void sdl_display_init(DisplayState *ds);
+void sdl_display_init(DisplayState *ds, int full);
 
 /* ide.c */
 #define MAX_DISKS 4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-10 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-08 16:14 [Qemu-devel] [PATCH] connect to redirected port on localhost Mark Jonckheere
2004-09-10 10:16 ` [Qemu-devel] Perl script to help write savevm handlers Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).