aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-26 15:37:44 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-26 15:37:44 +0000
commite0e7877a0a522d12d0fa6afd7959d3ca5cac73ff (patch)
tree90fe230eae6c2c64033c3158eb6e6c174c875ca1
parent1b0f9cc26bf2ebc13067a42a4caed84833f72a7c (diff)
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
-rw-r--r--net.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/net.c b/net.c
index 86ee7d540d..8d9b3de253 100644
--- a/net.c
+++ b/net.c
@@ -421,6 +421,16 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov,
return offset;
}
+static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt)
+{
+ size_t offset = 0;
+ int i;
+
+ for (i = 0; i < iovcnt; i++)
+ offset += iov[i].iov_len;
+ return offset;
+}
+
ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov,
int iovcnt)
{
@@ -428,12 +438,17 @@ ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov,
VLANClientState *vc;
ssize_t max_len = 0;
+ if (vc1->link_down)
+ return calc_iov_length(iov, iovcnt);
+
for (vc = vlan->first_client; vc != NULL; vc = vc->next) {
ssize_t len = 0;
if (vc == vc1)
continue;
+ if (vc->link_down)
+ len = calc_iov_length(iov, iovcnt);
if (vc->fd_readv)
len = vc->fd_readv(vc->opaque, iov, iovcnt);
else if (vc->fd_read)