Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:kernel-2.6.32
kvm
kvm-qemu-pre11-redir-3.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kvm-qemu-pre11-redir-3.patch of Package kvm
From b2f988b17528424730fedeae59434978ca225aea Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 26 May 2009 12:34:06 +0200 Subject: [PATCH] User networking: Show active connections In case you're wondering what connections exactly you have open or maybe redir'ed in the past, you can't really find out from qemu right now. This patch enables you to see all current connections the host only networking holds open, so you can kill them using the previous patch. Signed-off-by: Alexander Graf <agraf@suse.de> --- monitor.c | 3 ++- vl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ slirp/libslirp.h | 4 ++++ slirp/slirp.c | 24 ++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletions(-) Index: qemu-kvm-0.10.5/monitor.c =================================================================== --- qemu-kvm-0.10.5.orig/monitor.c +++ qemu-kvm-0.10.5/monitor.c @@ -1600,7 +1600,8 @@ static const term_cmd_t term_cmds[] = { #endif { "host_net_redir", "ss?", net_slirp_redir, "[tcp|udp]:host-port:[guest-host]:guest-port", "redirect TCP or UDP connections from host to guest (requires -net user)\n" - "host_net_redir remove [tcp:|udp:]host-port -- remove redirection" }, + "host_net_redir remove [tcp:|udp:]host-port -- remove redirection\n" + "host_net_redir list -- show all redirections" }, { "balloon", "i", do_balloon, "target", "request VM to change it's memory allocation (in MB)" }, { "set_link", "ss", do_set_link, Index: qemu-kvm-0.10.5/net.c =================================================================== --- qemu-kvm-0.10.5.orig/net.c +++ qemu-kvm-0.10.5/net.c @@ -536,6 +536,45 @@ static int net_slirp_init(VLANState *vla return 0; } +static void net_slirp_redir_print(void *opaque, int is_udp, + struct in_addr *laddr, u_int lport, + struct in_addr *faddr, u_int fport) +{ + + uint32_t h_addr; + uint32_t g_addr; + char buf[16]; + + h_addr = ntohl(faddr->s_addr); + g_addr = ntohl(laddr->s_addr); + + term_printf(" %s |", is_udp ? "udp" : "tcp" ); + snprintf(buf, 15, "%d.%d.%d.%d", (h_addr >> 24) & 0xff, + (h_addr >> 16) & 0xff, + (h_addr >> 8) & 0xff, + (h_addr) & 0xff); + term_printf(" %15s |", buf); + term_printf(" %5d |", fport); + + snprintf(buf, 15, "%d.%d.%d.%d", (g_addr >> 24) & 0xff, + (g_addr >> 16) & 0xff, + (g_addr >> 8) & 0xff, + (g_addr) & 0xff); + term_printf(" %15s |", buf); + term_printf(" %5d\n", lport); + +} + +static void net_slirp_redir_list(void) +{ + + + + term_printf(" Prot | Host Addr | HPort | Guest Addr | GPort\n"); + term_printf(" | | | | \n"); + slirp_redir_loop(net_slirp_redir_print, NULL); +} + static void net_slirp_redir_rm(const char *port_str) { int host_port; @@ -590,6 +629,11 @@ void net_slirp_redir(const char *redir_s return; } + if (!strcmp(redir_str, "list")) { + net_slirp_redir_list(); + return; + } + p = redir_str; if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) goto fail_syntax; Index: qemu-kvm-0.10.5/slirp/libslirp.h =================================================================== --- qemu-kvm-0.10.5.orig/slirp/libslirp.h +++ qemu-kvm-0.10.5/slirp/libslirp.h @@ -18,6 +18,10 @@ void slirp_input(const uint8_t *pkt, int int slirp_can_output(void); void slirp_output(const uint8_t *pkt, int pkt_len); +void slirp_redir_loop(void (*func)(void *opaque, int is_udp, + struct in_addr *laddr, u_int lport, + struct in_addr *faddr, u_int fport), + void *opaque); int slirp_redir_rm(int is_udp, int host_port); int slirp_redir(int is_udp, int host_port, struct in_addr guest_addr, int guest_port); Index: qemu-kvm-0.10.5/slirp/slirp.c =================================================================== --- qemu-kvm-0.10.5.orig/slirp/slirp.c +++ qemu-kvm-0.10.5/slirp/slirp.c @@ -734,6 +734,30 @@ void if_encap(const uint8_t *ip_data, in } } +static void _slirp_redir_loop(void (*func)(void *opaque, int is_udp, + struct in_addr *laddr, u_int lport, + struct in_addr *faddr, u_int fport), + void *opaque, int is_udp) +{ + struct socket *head = (is_udp ? &udb : &tcb); + struct socket *so; + + for (so = head->so_next; so != head; so = so->so_next) { + func(opaque, is_udp, + &so->so_laddr, ntohs(so->so_lport), + &so->so_faddr, ntohs(so->so_fport)); + } +} + +void slirp_redir_loop(void (*func)(void *opaque, int is_udp, + struct in_addr *laddr, u_int lport, + struct in_addr *faddr, u_int fport), + void *opaque) +{ + _slirp_redir_loop(func, opaque, 0); + _slirp_redir_loop(func, opaque, 1); +} + /* Unlistens a redirection * * Return value: number of redirs removed */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor