connect to redirected port on localhost
PATCH 1/1 connect to redirected port on localhost
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<----------------------------------------------------
slirp/misc.c Wed Sep 8 16:12:14 2004 renamed from slirp/misc.c Mon Sep 6 01:10:26 2004 +6 -7
@@ -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
slirp/slirp.c Wed Sep 8 16:13:00 2004 renamed from slirp/slirp.c Mon Sep 6 01:10:26 2004 +1 -1
@@ -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.
Signature · 1 line
:wq
sdl.c +9 -1
@@ -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 ; + } }
slirp/misc.c +6 -7
@@ -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
slirp/slirp.c +1 -1
@@ -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)
slirp/udp.c +2 -0
@@ -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;
vl.c +7 -1
@@ -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
vl.h +1 -1
@@ -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
[Qemu-devel] Perl script to help write savevm handlers
Hi,
while investigating why Win98 after loadvm'ing is no longer able to use slirp networking, I wrote this simple script. Given the name of a struct and a name for the handler and a file containing the struct, it outputs a load and a save function, and a line you have to add in your init function. It is a very dumb script, but it works for me.
Just try it:
perl struct2savevm.pl NE2000State ne2000 hw/ne2000.c
and you'll see what I mean.
Ciao,
Dscho
P.S.: Inserting that handler didn't help the networking problem, it still persists.