Commit e0e7877a0a522d12d0fa6afd7959d3ca5cac73ff
1 parent
1b0f9cc2
Handle link status in qemu_sendv_packet() (Mark McLoughlin)
If link is down, pretend that the packet has been successfully sent. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6444 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
15 additions
and
0 deletions
net.c
... | ... | @@ -421,6 +421,16 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov, |
421 | 421 | return offset; |
422 | 422 | } |
423 | 423 | |
424 | +static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt) | |
425 | +{ | |
426 | + size_t offset = 0; | |
427 | + int i; | |
428 | + | |
429 | + for (i = 0; i < iovcnt; i++) | |
430 | + offset += iov[i].iov_len; | |
431 | + return offset; | |
432 | +} | |
433 | + | |
424 | 434 | ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, |
425 | 435 | int iovcnt) |
426 | 436 | { |
... | ... | @@ -428,12 +438,17 @@ ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, |
428 | 438 | VLANClientState *vc; |
429 | 439 | ssize_t max_len = 0; |
430 | 440 | |
441 | + if (vc1->link_down) | |
442 | + return calc_iov_length(iov, iovcnt); | |
443 | + | |
431 | 444 | for (vc = vlan->first_client; vc != NULL; vc = vc->next) { |
432 | 445 | ssize_t len = 0; |
433 | 446 | |
434 | 447 | if (vc == vc1) |
435 | 448 | continue; |
436 | 449 | |
450 | + if (vc->link_down) | |
451 | + len = calc_iov_length(iov, iovcnt); | |
437 | 452 | if (vc->fd_readv) |
438 | 453 | len = vc->fd_readv(vc->opaque, iov, iovcnt); |
439 | 454 | else if (vc->fd_read) | ... | ... |