qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, eblake@redhat.com, den@openvz.org,
	vsementsov@virtuozzo.com
Subject: [Qemu-devel] [PATCH v2 02/12] nbd: make nbd_drop public
Date: Fri,  2 Jun 2017 18:01:40 +0300	[thread overview]
Message-ID: <20170602150150.258222-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20170602150150.258222-1-vsementsov@virtuozzo.com>

Following commit will reuse it for nbd server too.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 nbd/client.c       | 26 --------------------------
 nbd/common.c       | 26 ++++++++++++++++++++++++++
 nbd/nbd-internal.h |  2 ++
 3 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/nbd/client.c b/nbd/client.c
index 08050c39b3..215857f65d 100644
--- a/nbd/client.c
+++ b/nbd/client.c
@@ -86,32 +86,6 @@ static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);
 
 */
 
-/* Discard length bytes from channel.  Return -errno on failure and 0 on
- * success*/
-static int nbd_drop(QIOChannel *ioc, size_t size, Error **errp)
-{
-    ssize_t ret = 0;
-    char small[1024];
-    char *buffer;
-
-    buffer = sizeof(small) >= size ? small : g_malloc(MIN(65536, size));
-    while (size > 0) {
-        ssize_t count = MIN(65536, size);
-        ret = nbd_read(ioc, buffer, MIN(65536, size), errp);
-
-        if (ret < 0) {
-            goto cleanup;
-        }
-        size -= count;
-    }
-
- cleanup:
-    if (buffer != small) {
-        g_free(buffer);
-    }
-    return ret;
-}
-
 /* Send an option request.
  *
  * The request is for option @opt, with @data containing @len bytes of
diff --git a/nbd/common.c b/nbd/common.c
index d6b719ddaa..6b5c1b7b02 100644
--- a/nbd/common.c
+++ b/nbd/common.c
@@ -65,6 +65,32 @@ ssize_t nbd_rwv(QIOChannel *ioc, struct iovec *iov, size_t niov, size_t length,
     return done;
 }
 
+/* Discard length bytes from channel.  Return -errno on failure and 0 on
+ * success */
+int nbd_drop(QIOChannel *ioc, size_t size, Error **errp)
+{
+    ssize_t ret = 0;
+    char small[1024];
+    char *buffer;
+
+    buffer = sizeof(small) >= size ? small : g_malloc(MIN(65536, size));
+    while (size > 0) {
+        ssize_t count = MIN(65536, size);
+        ret = nbd_read(ioc, buffer, MIN(65536, size), errp);
+
+        if (ret < 0) {
+            goto cleanup;
+        }
+        size -= count;
+    }
+
+ cleanup:
+    if (buffer != small) {
+        g_free(buffer);
+    }
+    return ret;
+}
+
 
 void nbd_tls_handshake(QIOTask *task,
                        void *opaque)
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h
index 753cb9d9c5..39bfed177c 100644
--- a/nbd/nbd-internal.h
+++ b/nbd/nbd-internal.h
@@ -153,4 +153,6 @@ struct NBDTLSHandshakeData {
 void nbd_tls_handshake(QIOTask *task,
                        void *opaque);
 
+int nbd_drop(QIOChannel *ioc, size_t size, Error **errp);
+
 #endif
-- 
2.11.1

  parent reply	other threads:[~2017-06-02 15:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 15:01 [Qemu-devel] [PATCH v2 00/12] nbd refactoring part 1 Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 01/12] nbd: rename read_sync and friends Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` Vladimir Sementsov-Ogievskiy [this message]
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 03/12] nbd/server: get rid of nbd_negotiate_read " Vladimir Sementsov-Ogievskiy
2017-07-18 12:04   ` Eric Blake
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 04/12] nbd/server: get rid of ssize_t Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 05/12] nbd/server: refactor nbd_co_send_reply Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 06/12] nbd/server: get rid of EAGAIN dead code Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 07/12] nbd/server: refactor nbd_co_receive_request Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 08/12] nbd/server: remove NBDClientNewData Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 09/12] nbd/server: nbd_negotiate: fix error path Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 10/12] nbd/server: get rid of fail: return rc Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 11/12] nbd/server: rename rc to ret Vladimir Sementsov-Ogievskiy
2017-06-02 15:01 ` [Qemu-devel] [PATCH v2 12/12] nbd/server: refactor nbd_trip Vladimir Sementsov-Ogievskiy
2017-06-13 18:04   ` Paolo Bonzini
2017-06-13 14:10 ` [Qemu-devel] ping Re: [PATCH v2 00/12] nbd refactoring part 1 Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170602150150.258222-3-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).