From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1C55B8-0002Fv-QB for qemu-devel@nongnu.org; Wed, 08 Sep 2004 12:20:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1C55B7-0002FS-Qy for qemu-devel@nongnu.org; Wed, 08 Sep 2004 12:20:14 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1C55B7-0002FM-Ng for qemu-devel@nongnu.org; Wed, 08 Sep 2004 12:20:13 -0400 Received: from [195.238.2.204] (helo=outmx023.isp.belgacom.be) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1C555d-00073z-3f for qemu-devel@nongnu.org; Wed, 08 Sep 2004 12:14:33 -0400 Received: from outmx023.isp.belgacom.be (localhost [127.0.0.1]) by outmx023.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with ESMTP id i88GETYp021470 for ; Wed, 8 Sep 2004 18:14:29 +0200 (envelope-from ) Received: from easynet.be (185-178.242.81.adsl.skynet.be [81.242.178.185]) by outmx023.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with ESMTP id i88GENPa021439 for ; Wed, 8 Sep 2004 18:14:23 +0200 (envelope-from ) Message-ID: <413F2FD9.4030809@easynet.be> Date: Wed, 08 Sep 2004 18:14:17 +0200 From: Mark Jonckheere MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050609060000080403080809" Subject: [Qemu-devel] [PATCH] connect to redirected port on localhost Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------050609060000080403080809 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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 --------------050609060000080403080809 Content-Type: text/plain; name="my_patches.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="my_patches.diff" 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 --------------050609060000080403080809--