Add RUMPSP_RAISE: the kernel sends a signal to the client.

This commit is contained in:
pooka 2011-01-14 13:12:14 +00:00
parent cf864401d0
commit 9fba158b8b
3 changed files with 48 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpclient.c,v 1.15 2011/01/10 19:49:43 pooka Exp $ */
/* $NetBSD: rumpclient.c,v 1.16 2011/01/14 13:12:15 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@ -343,6 +343,7 @@ static void
handlereq(struct spclient *spc)
{
struct rsp_copydata *copydata;
struct rsp_hdr *rhdr = &spc->spc_hdr;
void *mapaddr;
size_t maplen;
int reqtype = spc->spc_hdr.rsp_type;
@ -378,6 +379,14 @@ handlereq(struct spclient *spc)
DPRINTF(("rump_sp handlereq: anonmmap: %p\n", mapaddr));
send_anonmmap_resp(spc, spc->spc_hdr.rsp_reqno, mapaddr);
break;
case RUMPSP_RAISE:
DPRINTF(("rump_sp handlereq: raise sig %d\n", rhdr->rsp_signo));
raise(rhdr->rsp_signo);
/*
* We most likely have signals blocked, but the signal
* will be handled soon enough when we return.
*/
break;
default:
printf("PANIC: INVALID TYPE %d\n", reqtype);
abort();

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpuser_sp.c,v 1.35 2011/01/12 12:52:16 pooka Exp $ */
/* $NetBSD: rumpuser_sp.c,v 1.36 2011/01/14 13:12:14 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: rumpuser_sp.c,v 1.35 2011/01/12 12:52:16 pooka Exp $");
__RCSID("$NetBSD: rumpuser_sp.c,v 1.36 2011/01/14 13:12:14 pooka Exp $");
#include <sys/types.h>
#include <sys/atomic.h>
@ -411,6 +411,24 @@ anonmmap_req(struct spclient *spc, size_t howmuch, void **resp)
return rv;
}
static int
send_raise_req(struct spclient *spc, int signo)
{
struct rsp_hdr rhdr;
int rv;
rhdr.rsp_len = sizeof(rhdr);
rhdr.rsp_class = RUMPSP_REQ;
rhdr.rsp_type = RUMPSP_RAISE;
rhdr.rsp_signo = signo;
sendlock(spc);
rv = dosend(spc, &rhdr, sizeof(rhdr));
sendunlock(spc);
return rv;
}
static void
spcref(struct spclient *spc)
{
@ -718,6 +736,19 @@ rumpuser_sp_anonmmap(void *arg, size_t howmuch, void **addr)
return 0;
}
int
rumpuser_sp_raise(void *arg, int signo)
{
struct spclient *spc = arg;
int rv, nlocks;
rumpuser__kunlock(0, &nlocks, NULL);
rv = send_raise_req(spc, signo);
rumpuser__klock(nlocks, NULL);
return rv;
}
/*
*
* Startup routines and mainloop for server.

View File

@ -1,4 +1,4 @@
/* $NetBSD: sp_common.c,v 1.23 2011/01/10 19:49:43 pooka Exp $ */
/* $NetBSD: sp_common.c,v 1.24 2011/01/14 13:12:14 pooka Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@ -88,7 +88,8 @@ enum { RUMPSP_HANDSHAKE,
RUMPSP_COPYIN, RUMPSP_COPYINSTR,
RUMPSP_COPYOUT, RUMPSP_COPYOUTSTR,
RUMPSP_ANONMMAP,
RUMPSP_PREFORK };
RUMPSP_PREFORK,
RUMPSP_RAISE };
enum { HANDSHAKE_GUEST, HANDSHAKE_AUTH, HANDSHAKE_FORK };
@ -107,12 +108,14 @@ struct rsp_hdr {
uint32_t sysnum;
uint32_t error;
uint32_t handshake;
uint32_t signo;
} u;
};
#define HDRSZ sizeof(struct rsp_hdr)
#define rsp_sysnum u.sysnum
#define rsp_error u.error
#define rsp_handshake u.handshake
#define rsp_signo u.signo
#define MAXBANNER 96