Commit bb6834cfae238e342da966557d7d24423efe18ab
1 parent
d34ca590
Fix windows build after virtio changes
Windows does not have sys/uio.h and does not have err.h. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5877 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
34 additions
and
15 deletions
hw/virtio.c
| @@ -12,7 +12,6 @@ | @@ -12,7 +12,6 @@ | ||
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <inttypes.h> | 14 | #include <inttypes.h> |
| 15 | -#include <err.h> | ||
| 16 | 15 | ||
| 17 | #include "virtio.h" | 16 | #include "virtio.h" |
| 18 | #include "sysemu.h" | 17 | #include "sysemu.h" |
| @@ -331,9 +330,11 @@ static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx) | @@ -331,9 +330,11 @@ static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx) | ||
| 331 | uint16_t num_heads = vring_avail_idx(vq) - idx; | 330 | uint16_t num_heads = vring_avail_idx(vq) - idx; |
| 332 | 331 | ||
| 333 | /* Check it isn't doing very strange things with descriptor numbers. */ | 332 | /* Check it isn't doing very strange things with descriptor numbers. */ |
| 334 | - if (num_heads > vq->vring.num) | ||
| 335 | - errx(1, "Guest moved used index from %u to %u", | ||
| 336 | - idx, vring_avail_idx(vq)); | 333 | + if (num_heads > vq->vring.num) { |
| 334 | + fprintf(stderr, "Guest moved used index from %u to %u", | ||
| 335 | + idx, vring_avail_idx(vq)); | ||
| 336 | + exit(1); | ||
| 337 | + } | ||
| 337 | 338 | ||
| 338 | return num_heads; | 339 | return num_heads; |
| 339 | } | 340 | } |
| @@ -347,8 +348,10 @@ static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx) | @@ -347,8 +348,10 @@ static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx) | ||
| 347 | head = vring_avail_ring(vq, idx % vq->vring.num); | 348 | head = vring_avail_ring(vq, idx % vq->vring.num); |
| 348 | 349 | ||
| 349 | /* If their number is silly, that's a fatal mistake. */ | 350 | /* If their number is silly, that's a fatal mistake. */ |
| 350 | - if (head >= vq->vring.num) | ||
| 351 | - errx(1, "Guest says index %u is available", head); | 351 | + if (head >= vq->vring.num) { |
| 352 | + fprintf(stderr, "Guest says index %u is available", head); | ||
| 353 | + exit(1); | ||
| 354 | + } | ||
| 352 | 355 | ||
| 353 | return head; | 356 | return head; |
| 354 | } | 357 | } |
| @@ -366,8 +369,10 @@ static unsigned virtqueue_next_desc(VirtQueue *vq, unsigned int i) | @@ -366,8 +369,10 @@ static unsigned virtqueue_next_desc(VirtQueue *vq, unsigned int i) | ||
| 366 | /* Make sure compiler knows to grab that: we don't want it changing! */ | 369 | /* Make sure compiler knows to grab that: we don't want it changing! */ |
| 367 | wmb(); | 370 | wmb(); |
| 368 | 371 | ||
| 369 | - if (next >= vq->vring.num) | ||
| 370 | - errx(1, "Desc next is %u", next); | 372 | + if (next >= vq->vring.num) { |
| 373 | + fprintf(stderr, "Desc next is %u", next); | ||
| 374 | + exit(1); | ||
| 375 | + } | ||
| 371 | 376 | ||
| 372 | return next; | 377 | return next; |
| 373 | } | 378 | } |
| @@ -386,8 +391,10 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes) | @@ -386,8 +391,10 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes) | ||
| 386 | i = virtqueue_get_head(vq, idx++); | 391 | i = virtqueue_get_head(vq, idx++); |
| 387 | do { | 392 | do { |
| 388 | /* If we've got too many, that implies a descriptor loop. */ | 393 | /* If we've got too many, that implies a descriptor loop. */ |
| 389 | - if (++num_bufs > vq->vring.num) | ||
| 390 | - errx(1, "Looped descriptor"); | 394 | + if (++num_bufs > vq->vring.num) { |
| 395 | + fprintf(stderr, "Looped descriptor"); | ||
| 396 | + exit(1); | ||
| 397 | + } | ||
| 391 | 398 | ||
| 392 | if (vring_desc_flags(vq, i) & VRING_DESC_F_WRITE) { | 399 | if (vring_desc_flags(vq, i) & VRING_DESC_F_WRITE) { |
| 393 | if (in_bytes > 0 && | 400 | if (in_bytes > 0 && |
| @@ -447,12 +454,16 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) | @@ -447,12 +454,16 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) | ||
| 447 | sg->iov_len); | 454 | sg->iov_len); |
| 448 | } | 455 | } |
| 449 | #endif | 456 | #endif |
| 450 | - if (sg->iov_base == NULL) | ||
| 451 | - errx(1, "Invalid mapping\n"); | 457 | + if (sg->iov_base == NULL) { |
| 458 | + fprintf(stderr, "Invalid mapping\n"); | ||
| 459 | + exit(1); | ||
| 460 | + } | ||
| 452 | 461 | ||
| 453 | /* If we've got too many, that implies a descriptor loop. */ | 462 | /* If we've got too many, that implies a descriptor loop. */ |
| 454 | - if ((elem->in_num + elem->out_num) > vq->vring.num) | ||
| 455 | - errx(1, "Looped descriptor"); | 463 | + if ((elem->in_num + elem->out_num) > vq->vring.num) { |
| 464 | + fprintf(stderr, "Looped descriptor"); | ||
| 465 | + exit(1); | ||
| 466 | + } | ||
| 456 | } while ((i = virtqueue_next_desc(vq, i)) != vq->vring.num); | 467 | } while ((i = virtqueue_next_desc(vq, i)) != vq->vring.num); |
| 457 | 468 | ||
| 458 | elem->index = head; | 469 | elem->index = head; |
hw/virtio.h
| @@ -14,10 +14,18 @@ | @@ -14,10 +14,18 @@ | ||
| 14 | #ifndef _QEMU_VIRTIO_H | 14 | #ifndef _QEMU_VIRTIO_H |
| 15 | #define _QEMU_VIRTIO_H | 15 | #define _QEMU_VIRTIO_H |
| 16 | 16 | ||
| 17 | -#include <sys/uio.h> | ||
| 18 | #include "hw.h" | 17 | #include "hw.h" |
| 19 | #include "pci.h" | 18 | #include "pci.h" |
| 20 | 19 | ||
| 20 | +#ifdef _WIN32 | ||
| 21 | +struct iovec { | ||
| 22 | + void *iov_base; | ||
| 23 | + size_t iov_len; | ||
| 24 | +}; | ||
| 25 | +#else | ||
| 26 | +#include <sys/uio.h> | ||
| 27 | +#endif | ||
| 28 | + | ||
| 21 | /* from Linux's linux/virtio_config.h */ | 29 | /* from Linux's linux/virtio_config.h */ |
| 22 | 30 | ||
| 23 | /* Status byte for guest to report progress, and synchronize features. */ | 31 | /* Status byte for guest to report progress, and synchronize features. */ |