Skip to content

Commit

Permalink
Merge pull request #313 from fredericdalleau/various-fixes
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
djs55 authored Jun 24, 2021
2 parents cf1581b + af5eba2 commit acbc2d1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/lib/pci_virtio_rnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq)
{
struct iovec iov;
struct pci_vtrnd_softc *sc;
int len;
int len, n;
uint16_t idx;

sc = vsc;
Expand All @@ -111,7 +111,11 @@ pci_vtrnd_notify(void *vsc, struct vqueue_info *vq)
}

while (vq_has_descs(vq)) {
vq_getchain(vq, &idx, &iov, 1, NULL);
n = vq_getchain(vq, &idx, &iov, 1, NULL);
if (n < 0) {
fprintf(stderr, "vtrnd: vtrnd_notify(): n %d\r\n", n);
return;
}

len = (int) read(sc->vrsc_fd, iov.iov_base, iov.iov_len);

Expand Down
5 changes: 5 additions & 0 deletions src/lib/pci_virtio_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,11 @@ static void pci_vtsock_proc_tx(struct pci_vtsock_softc *sc,
size_t pulled;

iovec_len = vq_getchain(vq, &idx, iov, VTSOCK_MAXSEGS, flags);
if (iovec_len < 0) {
fprintf(stderr, "TX: failed to get chain at idx %"PRIx16"\n", idx);
return;
}

assert(iovec_len <= VTSOCK_MAXSEGS);

DPRINTF(("TX: chain with %d buffers at idx %"PRIx16"\n",
Expand Down
12 changes: 9 additions & 3 deletions src/lib/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,10 @@ vi_pci_read(UNUSED int vcpu, struct pci_devinst *pi, int baridx,
max = vc->vc_cfgsize ? vc->vc_cfgsize : 0x100000000;
if ((newoff + ((unsigned) size)) > max)
goto bad;
error = (*vc->vc_cfgread)(DEV_SOFTC(vs), ((int) newoff), size, &value);
if (vc->vc_cfgread != NULL)
error = (*vc->vc_cfgread)(DEV_SOFTC(vs), ((int) newoff), size, &value);
else
error = 0;
if (!error)
goto done;
}
Expand Down Expand Up @@ -678,8 +681,11 @@ vi_pci_write(UNUSED int vcpu, struct pci_devinst *pi, int baridx,
max = vc->vc_cfgsize ? vc->vc_cfgsize : 0x100000000;
if ((newoff + ((unsigned) size)) > max)
goto bad;
error = (*vc->vc_cfgwrite)(DEV_SOFTC(vs), ((int) newoff), size,
((uint32_t) value));
if (vc->vc_cfgwrite != NULL)
error = (*vc->vc_cfgwrite)(DEV_SOFTC(vs), ((int) newoff), size,
((uint32_t) value));
else
error = 0;
if (!error)
goto done;
}
Expand Down

0 comments on commit acbc2d1

Please sign in to comment.