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,6 +421,16 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov, | ||
421 | return offset; | 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 | ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, | 434 | ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, |
425 | int iovcnt) | 435 | int iovcnt) |
426 | { | 436 | { |
@@ -428,12 +438,17 @@ ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, | @@ -428,12 +438,17 @@ ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, | ||
428 | VLANClientState *vc; | 438 | VLANClientState *vc; |
429 | ssize_t max_len = 0; | 439 | ssize_t max_len = 0; |
430 | 440 | ||
441 | + if (vc1->link_down) | ||
442 | + return calc_iov_length(iov, iovcnt); | ||
443 | + | ||
431 | for (vc = vlan->first_client; vc != NULL; vc = vc->next) { | 444 | for (vc = vlan->first_client; vc != NULL; vc = vc->next) { |
432 | ssize_t len = 0; | 445 | ssize_t len = 0; |
433 | 446 | ||
434 | if (vc == vc1) | 447 | if (vc == vc1) |
435 | continue; | 448 | continue; |
436 | 449 | ||
450 | + if (vc->link_down) | ||
451 | + len = calc_iov_length(iov, iovcnt); | ||
437 | if (vc->fd_readv) | 452 | if (vc->fd_readv) |
438 | len = vc->fd_readv(vc->opaque, iov, iovcnt); | 453 | len = vc->fd_readv(vc->opaque, iov, iovcnt); |
439 | else if (vc->fd_read) | 454 | else if (vc->fd_read) |