Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_rnd.c
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) | pci_vtrnd_notify(void *vsc, struct vqueue_info *vq) | ||||
{ | { | ||||
struct iovec iov; | struct iovec iov; | ||||
struct pci_vtrnd_softc *sc; | struct pci_vtrnd_softc *sc; | ||||
struct vi_req req; | |||||
int len; | int len; | ||||
uint16_t idx; | |||||
sc = vsc; | sc = vsc; | ||||
if (sc->vrsc_fd < 0) { | if (sc->vrsc_fd < 0) { | ||||
vq_endchains(vq, 0); | vq_endchains(vq, 0); | ||||
return; | return; | ||||
} | } | ||||
while (vq_has_descs(vq)) { | while (vq_has_descs(vq)) { | ||||
vq_getchain(vq, &idx, &iov, 1, NULL); | vq_getchain(vq, &iov, 1, &req); | ||||
len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); | len = read(sc->vrsc_fd, iov.iov_base, iov.iov_len); | ||||
DPRINTF(("vtrnd: vtrnd_notify(): %d", len)); | DPRINTF(("vtrnd: vtrnd_notify(): %d", len)); | ||||
/* Catastrophe if unable to read from /dev/random */ | /* Catastrophe if unable to read from /dev/random */ | ||||
assert(len > 0); | assert(len > 0); | ||||
/* | /* | ||||
* Release this chain and handle more | * Release this chain and handle more | ||||
*/ | */ | ||||
vq_relchain(vq, idx, len); | vq_relchain(vq, req.idx, len); | ||||
} | } | ||||
vq_endchains(vq, 1); /* Generate interrupt if appropriate. */ | vq_endchains(vq, 1); /* Generate interrupt if appropriate. */ | ||||
} | } | ||||
static int | static int | ||||
pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |