aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-07-29 10:37:24 +0300
committerAvi Kivity <avi@redhat.com>2009-07-29 10:37:43 +0300
commit660caae82afbbf8a96c6559ba7580944d0f5f914 (patch)
tree0b1ec9ab2ca6954052f8ed493e199f545ff6954a
parentMerge commit 'baef8a666c137fae513a195c8abeb80e1806d7bd' into upstream-merge (diff)
parentFix broken build (diff)
downloadqemu-kvm-660caae82afbbf8a96c6559ba7580944d0f5f914.tar.gz
qemu-kvm-660caae82afbbf8a96c6559ba7580944d0f5f914.tar.bz2
qemu-kvm-660caae82afbbf8a96c6559ba7580944d0f5f914.zip
Merge commit 'fc5d642fcae392bbc9fed9ac6bc78ac29ed48372' into upstream-merge
* commit 'fc5d642fcae392bbc9fed9ac6bc78ac29ed48372': Fix broken build slirp: Use monotonic clock if available (v2) slirp: Remove UDP protocol emulation (talk, cuseeme) qemu: msix nit: clear msix_entries_nr on error Fix build failure in on_vcpu() Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--hw/msix.c1
-rw-r--r--kvm-all.c21
-rw-r--r--slirp/misc.h5
-rw-r--r--slirp/slirp.c27
-rw-r--r--slirp/slirp.h4
-rw-r--r--slirp/slirp_config.h6
-rw-r--r--slirp/udp.c266
7 files changed, 17 insertions, 313 deletions
diff --git a/hw/msix.c b/hw/msix.c
index b5dfa0bb7..974268d33 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -373,6 +373,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
return 0;
err_config:
+ dev->msix_entries_nr = 0;
cpu_unregister_io_memory(dev->msix_mmio_index);
err_index:
qemu_free(dev->msix_table_page);
diff --git a/kvm-all.c b/kvm-all.c
index f346162f1..6f0bab901 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -156,15 +156,6 @@ static void kvm_reset_vcpu(void *opaque)
}
}
-static void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
-{
- if (env == cpu_single_env) {
- func(data);
- return;
- }
- abort();
-}
-
int kvm_irqchip_in_kernel(void)
{
return kvm_state->irqchip_in_kernel;
@@ -916,6 +907,18 @@ void kvm_setup_guest_memory(void *start, size_t size)
#endif /* KVM_UPSTREAM */
#ifdef KVM_CAP_SET_GUEST_DEBUG
+
+#ifdef KVM_UPSTREAM
+static void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
+{
+ if (env == cpu_single_env) {
+ func(data);
+ return;
+ }
+ abort();
+}
+#endif /* KVM_UPSTREAM */
+
struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env,
target_ulong pc)
{
diff --git a/slirp/misc.h b/slirp/misc.h
index c33539435..da68d0995 100644
--- a/slirp/misc.h
+++ b/slirp/misc.h
@@ -36,11 +36,6 @@ void do_wait(int);
#define EMU_NOCONNECT 0x10 /* Don't connect */
-/* UDP emulations */
-#define EMU_TALK 0x1
-#define EMU_NTALK 0x2
-#define EMU_CUSEEME 0x3
-
struct tos_t {
u_int16_t lport;
u_int16_t fport;
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 9be855313..e883f8263 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "qemu-common.h"
+#include "qemu-timer.h"
#include "qemu-char.h"
#include "slirp.h"
#include "hw/hw.h"
@@ -244,29 +245,6 @@ void slirp_cleanup(Slirp *slirp)
#define CONN_CANFRCV(so) (((so)->so_state & (SS_FCANTRCVMORE|SS_ISFCONNECTED)) == SS_ISFCONNECTED)
#define UPD_NFDS(x) if (nfds < (x)) nfds = (x)
-/*
- * curtime kept to an accuracy of 1ms
- */
-#ifdef _WIN32
-static void updtime(void)
-{
- struct _timeb tb;
-
- _ftime(&tb);
-
- curtime = tb.time * 1000 + tb.millitm;
-}
-#else
-static void updtime(void)
-{
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- curtime = tv.tv_sec * 1000 + tv.tv_usec / 1000;
-}
-#endif
-
void slirp_select_fill(int *pnfds,
fd_set *readfds, fd_set *writefds, fd_set *xfds)
{
@@ -405,8 +383,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
global_writefds = writefds;
global_xfds = xfds;
- /* Update time */
- updtime();
+ curtime = qemu_get_clock(rt_clock);
TAILQ_FOREACH(slirp, &slirp_instances, entry) {
/*
diff --git a/slirp/slirp.h b/slirp/slirp.h
index 22058cd05..020412caf 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -108,10 +108,6 @@ typedef unsigned char u_int8_t;
#include <arpa/inet.h>
#endif
-#ifdef GETTIMEOFDAY_ONE_ARG
-#define gettimeofday(x, y) gettimeofday(x)
-#endif
-
/* Systems lacking strdup() definition in <string.h>. */
#if defined(ultrix)
char *strdup(const char *);
diff --git a/slirp/slirp_config.h b/slirp/slirp_config.h
index dbc8dfd42..e977e77f8 100644
--- a/slirp/slirp_config.h
+++ b/slirp/slirp_config.h
@@ -2,9 +2,6 @@
* User definable configuration options
*/
-/* Undefine if you don't want talk emulation */
-#undef EMULATE_TALK
-
/* Define if you want the connection to be probed */
/* XXX Not working yet, so ignore this for now */
#undef PROBE_CONN
@@ -190,9 +187,6 @@
#define NO_UNIX_SOCKETS
#endif
-/* Define if gettimeofday only takes one argument */
-#undef GETTIMEOFDAY_ONE_ARG
-
/* Define if you have revoke() */
#undef HAVE_REVOKE
diff --git a/slirp/udp.c b/slirp/udp.c
index e0a669359..a88b645cc 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -42,7 +42,6 @@
#include "ip_icmp.h"
static u_int8_t udp_tos(struct socket *so);
-static void udp_emu(struct socket *so, struct mbuf *m);
void
udp_init(Slirp *slirp)
@@ -202,9 +201,6 @@ udp_input(register struct mbuf *m, int iphlen)
/*
* Now we sendto() the packet.
*/
- if (so->so_emu)
- udp_emu(so, m);
-
if(sosendto(so,m) == -1) {
m->m_len += iphlen;
m->m_data -= iphlen;
@@ -306,31 +302,9 @@ int udp_output(struct socket *so, struct mbuf *m,
int
udp_attach(struct socket *so)
{
- struct sockaddr_in addr;
-
if((so->s = socket(AF_INET,SOCK_DGRAM,0)) != -1) {
- /*
- * Here, we bind() the socket. Although not really needed
- * (sendto() on an unbound socket will bind it), it's done
- * here so that emulation of ytalk etc. don't have to do it
- */
- addr.sin_family = AF_INET;
- addr.sin_port = 0;
- addr.sin_addr.s_addr = INADDR_ANY;
- if(bind(so->s, (struct sockaddr *)&addr, sizeof(addr))<0) {
- int lasterrno=errno;
- closesocket(so->s);
- so->s=-1;
-#ifdef _WIN32
- WSASetLastError(lasterrno);
-#else
- errno=lasterrno;
-#endif
- } else {
- /* success, insert in queue */
- so->so_expire = curtime + SO_EXPIRE;
- insque(so, &so->slirp->udb);
- }
+ so->so_expire = curtime + SO_EXPIRE;
+ insque(so, &so->slirp->udb);
}
return(so->s);
}
@@ -344,9 +318,6 @@ udp_detach(struct socket *so)
static const struct tos_t udptos[] = {
{0, 53, IPTOS_LOWDELAY, 0}, /* DNS */
- {517, 517, IPTOS_LOWDELAY, EMU_TALK}, /* talk */
- {518, 518, IPTOS_LOWDELAY, EMU_NTALK}, /* ntalk */
- {0, 7648, IPTOS_LOWDELAY, EMU_CUSEEME}, /* Cu-Seeme */
{0, 0, 0, 0}
};
@@ -367,239 +338,6 @@ udp_tos(struct socket *so)
return 0;
}
-#ifdef EMULATE_TALK
-#include "talkd.h"
-#endif
-
-/*
- * Here, talk/ytalk/ntalk requests must be emulated
- */
-static void
-udp_emu(struct socket *so, struct mbuf *m)
-{
- struct sockaddr_in addr;
- socklen_t addrlen = sizeof(addr);
-#ifdef EMULATE_TALK
- CTL_MSG_OLD *omsg;
- CTL_MSG *nmsg;
- char buff[sizeof(CTL_MSG)];
- u_char type;
-
-struct talk_request {
- struct talk_request *next;
- struct socket *udp_so;
- struct socket *tcp_so;
-} *req;
-
- static struct talk_request *req_tbl = 0;
-
-#endif
-
-struct cu_header {
- uint16_t d_family; // destination family
- uint16_t d_port; // destination port
- uint32_t d_addr; // destination address
- uint16_t s_family; // source family
- uint16_t s_port; // source port
- uint32_t so_addr; // source address
- uint32_t seqn; // sequence number
- uint16_t message; // message
- uint16_t data_type; // data type
- uint16_t pkt_len; // packet length
-} *cu_head;
-
- switch(so->so_emu) {
-
-#ifdef EMULATE_TALK
- case EMU_TALK:
- case EMU_NTALK:
- /*
- * Talk emulation. We always change the ctl_addr to get
- * some answers from the daemon. When an ANNOUNCE comes,
- * we send LEAVE_INVITE to the local daemons. Also when a
- * DELETE comes, we send copies to the local daemons.
- */
- if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
- return;
-
-#define IS_OLD (so->so_emu == EMU_TALK)
-
-#define COPY_MSG(dest, src) { dest->type = src->type; \
- dest->id_num = src->id_num; \
- dest->pid = src->pid; \
- dest->addr = src->addr; \
- dest->ctl_addr = src->ctl_addr; \
- memcpy(&dest->l_name, &src->l_name, NAME_SIZE_OLD); \
- memcpy(&dest->r_name, &src->r_name, NAME_SIZE_OLD); \
- memcpy(&dest->r_tty, &src->r_tty, TTY_SIZE); }
-
-#define OTOSIN(ptr, field) ((struct sockaddr_in *)&ptr->field)
-/* old_sockaddr to sockaddr_in */
-
-
- if (IS_OLD) { /* old talk */
- omsg = mtod(m, CTL_MSG_OLD*);
- nmsg = (CTL_MSG *) buff;
- type = omsg->type;
- OTOSIN(omsg, ctl_addr)->sin_port = addr.sin_port;
- OTOSIN(omsg, ctl_addr)->sin_addr = our_addr;
- pstrcpy(omsg->l_name, NAME_SIZE_OLD, getlogin());
- } else { /* new talk */
- omsg = (CTL_MSG_OLD *) buff;
- nmsg = mtod(m, CTL_MSG *);
- type = nmsg->type;
- OTOSIN(nmsg, ctl_addr)->sin_port = addr.sin_port;
- OTOSIN(nmsg, ctl_addr)->sin_addr = our_addr;
- pstrcpy(nmsg->l_name, NAME_SIZE_OLD, getlogin());
- }
-
- if (type == LOOK_UP)
- return; /* for LOOK_UP this is enough */
-
- if (IS_OLD) { /* make a copy of the message */
- COPY_MSG(nmsg, omsg);
- nmsg->vers = 1;
- nmsg->answer = 0;
- } else
- COPY_MSG(omsg, nmsg);
-
- /*
- * If if is an ANNOUNCE message, we go through the
- * request table to see if a tcp port has already
- * been redirected for this socket. If not, we solisten()
- * a new socket and add this entry to the table.
- * The port number of the tcp socket and our IP
- * are put to the addr field of the message structures.
- * Then a LEAVE_INVITE is sent to both local daemon
- * ports, 517 and 518. This is why we have two copies
- * of the message, one in old talk and one in new talk
- * format.
- */
-
- if (type == ANNOUNCE) {
- int s;
- u_short temp_port;
-
- for(req = req_tbl; req; req = req->next)
- if (so == req->udp_so)
- break; /* found it */
-
- if (!req) { /* no entry for so, create new */
- req = (struct talk_request *)
- malloc(sizeof(struct talk_request));
- req->udp_so = so;
- req->tcp_so = solisten(0,
- OTOSIN(omsg, addr)->sin_addr.s_addr,
- OTOSIN(omsg, addr)->sin_port,
- SS_FACCEPTONCE);
- req->next = req_tbl;
- req_tbl = req;
- }
-
- /* replace port number in addr field */
- addrlen = sizeof(addr);
- getsockname(req->tcp_so->s,
- (struct sockaddr *) &addr,
- &addrlen);
- OTOSIN(omsg, addr)->sin_port = addr.sin_port;
- OTOSIN(omsg, addr)->sin_addr = our_addr;
- OTOSIN(nmsg, addr)->sin_port = addr.sin_port;
- OTOSIN(nmsg, addr)->sin_addr = our_addr;
-
- /* send LEAVE_INVITEs */
- temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
- OTOSIN(omsg, ctl_addr)->sin_port = 0;
- OTOSIN(nmsg, ctl_addr)->sin_port = 0;
- omsg->type = nmsg->type = LEAVE_INVITE;
-
- s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
- addr.sin_addr = our_addr;
- addr.sin_family = AF_INET;
- addr.sin_port = htons(517);
- sendto(s, (char *)omsg, sizeof(*omsg), 0,
- (struct sockaddr *)&addr, sizeof(addr));
- addr.sin_port = htons(518);
- sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
- (struct sockaddr *) &addr, sizeof(addr));
- closesocket(s) ;
-
- omsg->type = nmsg->type = ANNOUNCE;
- OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
- OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
- }
-
- /*
- * If it is a DELETE message, we send a copy to the
- * local daemons. Then we delete the entry corresponding
- * to our socket from the request table.
- */
-
- if (type == DELETE) {
- struct talk_request *temp_req, *req_next;
- int s;
- u_short temp_port;
-
- temp_port = OTOSIN(omsg, ctl_addr)->sin_port;
- OTOSIN(omsg, ctl_addr)->sin_port = 0;
- OTOSIN(nmsg, ctl_addr)->sin_port = 0;
-
- s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
- addr.sin_addr = our_addr;
- addr.sin_family = AF_INET;
- addr.sin_port = htons(517);
- sendto(s, (char *)omsg, sizeof(*omsg), 0,
- (struct sockaddr *)&addr, sizeof(addr));
- addr.sin_port = htons(518);
- sendto(s, (char *)nmsg, sizeof(*nmsg), 0,
- (struct sockaddr *)&addr, sizeof(addr));
- closesocket(s);
-
- OTOSIN(omsg, ctl_addr)->sin_port = temp_port;
- OTOSIN(nmsg, ctl_addr)->sin_port = temp_port;
-
- /* delete table entry */
- if (so == req_tbl->udp_so) {
- temp_req = req_tbl;
- req_tbl = req_tbl->next;
- free(temp_req);
- } else {
- temp_req = req_tbl;
- for(req = req_tbl->next; req; req = req_next) {
- req_next = req->next;
- if (so == req->udp_so) {
- temp_req->next = req_next;
- free(req);
- break;
- } else {
- temp_req = req;
- }
- }
- }
- }
-
- return;
-#endif
-
- case EMU_CUSEEME:
-
- /*
- * Cu-SeeMe emulation.
- * Hopefully the packet is more that 16 bytes long. We don't
- * do any other tests, just replace the address and port
- * fields.
- */
- if (m->m_len >= sizeof (*cu_head)) {
- if (getsockname(so->s, (struct sockaddr *)&addr, &addrlen) < 0)
- return;
- cu_head = mtod(m, struct cu_header *);
- cu_head->s_port = addr.sin_port;
- cu_head->so_addr = our_addr.s_addr;
- }
-
- return;
- }
-}
-
struct socket *
udp_listen(Slirp *slirp, u_int32_t haddr, u_int hport, u_int32_t laddr,
u_int lport, int flags)