qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Handle link status in qemu_sendv_packet()
@ 2009-01-16 10:17 Mark McLoughlin
  0 siblings, 0 replies; only message in thread
From: Mark McLoughlin @ 2009-01-16 10:17 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Mark McLoughlin, qemu-devel

If link is down, pretend that the packet has been successfully sent.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 net.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/net.c b/net.c
index 86ee7d5..8d9b3de 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)
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-01-16 10:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-16 10:17 [Qemu-devel] [PATCH] Handle link status in qemu_sendv_packet() Mark McLoughlin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).