Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #313

Merged
merged 4 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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