Displaying 20 results from an estimated 158 matches for "exportsize".
2019 May 23
0
[PATCH libnbd 1/3] states: Factor out common code for setting export size and eflags.
...tes-newstyle-opt-export-name.c b/generator/states-newstyle-opt-export-name.c
index 8ff1c1c..07b6c9e 100644
--- a/generator/states-newstyle-opt-export-name.c
+++ b/generator/states-newstyle-opt-export-name.c
@@ -58,13 +58,13 @@
return 0;
NEWSTYLE.OPT_EXPORT_NAME.CHECK_REPLY:
- conn->h->exportsize = be64toh (conn->sbuf.export_name_reply.exportsize);
- conn->h->eflags = be16toh (conn->sbuf.export_name_reply.eflags);
- debug (conn->h, "exportsize: %" PRIu64 " eflags: 0x%" PRIx16,
- conn->h->exportsize, conn->h->eflags);
- if (conn->h...
2019 Aug 30
0
[nbdkit PATCH 5/9] server: Cache per-connection size
...--git a/server/internal.h b/server/internal.h
index 9bf84022..ec8a894c 100644
--- a/server/internal.h
+++ b/server/internal.h
@@ -151,7 +151,7 @@ typedef void (*connection_close_function) (struct connection *)
struct b_conn_handle {
void *handle;
- // TODO add per-backend caching
+ uint64_t exportsize;
};
struct connection {
@@ -168,7 +168,6 @@ struct connection {
size_t nr_handles;
uint32_t cflags;
- uint64_t exportsize;
uint16_t eflags;
bool readonly;
bool can_flush;
diff --git a/server/backend.c b/server/backend.c
index b2054aa2..374d8540 100644
--- a/server/backend.c
+++...
2019 May 23
5
[PATCH libnbd 0/3] Prevent some misuse of multi-conn.
Per recent discussion here:
https://www.redhat.com/archives/libguestfs/2019-May/thread.html#00175
2016 Sep 26
1
[PATCH] nbdkit: flags are 32 bits for oldstyle connections
...0226ec2ce5
nbdkit: Fix flags in old-style connection
diff -r d7d5078d08c7 -r dbd1ea0a401c src/connections.c
--- a/src/connections.c Sun Sep 25 05:04:02 2016 +0200
+++ b/src/connections.c Mon Sep 26 17:28:54 2016 +0200
@@ -155,7 +155,7 @@
struct old_handshake handshake;
int64_t r;
uint64_t exportsize;
- uint16_t gflags, eflags;
+ uint32_t flags;
int fl;
r = plugin_get_size (conn);
@@ -169,14 +169,13 @@
exportsize = (uint64_t) r;
conn->exportsize = exportsize;
- gflags = 0;
- eflags = NBD_FLAG_HAS_FLAGS;
+ flags = NBD_FLAG_HAS_FLAGS;
fl = plugin_can_write (conn);...
2020 Sep 04
0
[libnbd PATCH 2/2] api: Add STRICT_BOUNDS to nbd_set_strict_mode
...lib/rw.c
+++ b/lib/rw.c
@@ -278,6 +278,18 @@ nbd_unlocked_aio_pread (struct nbd_handle *h, void *buf,
}
}
+ if (h->strict & LIBNBD_STRICT_BOUNDS) {
+ if (count == 0) {
+ set_error (EINVAL, "count cannot be 0");
+ return -1;
+ }
+
+ if (offset > h->exportsize || offset + count > h->exportsize) {
+ set_error (EINVAL, "request out of bounds");
+ return -1;
+ }
+ }
+
return nbd_internal_command_common (h, 0, NBD_CMD_READ, offset, count,
buf, &cb);
}
@@ -305,6 +317,18 @@ nbd_unlock...
2017 Nov 15
1
[nbdkit PATCH] connections: Extract common export flag computation code
...trim (conn);
+ if (fl == -1)
+ return -1;
+ if (fl) {
+ eflags |= NBD_FLAG_SEND_TRIM;
+ conn->can_trim = 1;
+ }
+
+ *flags = eflags;
+ return 0;
+}
+
+static int
_negotiate_handshake_oldstyle (struct connection *conn)
{
struct old_handshake handshake;
int64_t r;
uint64_t exportsize;
uint16_t gflags, eflags;
- int fl;
/* In --tls=require / FORCEDTLS mode, old style handshakes are
* rejected because they cannot support TLS.
@@ -265,43 +309,8 @@ _negotiate_handshake_oldstyle (struct connection *conn)
conn->exportsize = exportsize;
gflags = 0;
- eflags = NB...
2018 Aug 06
0
[PATCH nbdkit v2] protocol: Implement NBD_OPT_GO.
...+--
2 files changed, 209 insertions(+), 51 deletions(-)
diff --git a/src/connections.c b/src/connections.c
index ba6e91d..4e9b191 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -75,7 +75,9 @@ struct connection {
void **handles;
size_t nr_handles;
+ uint32_t cflags;
uint64_t exportsize;
+ uint16_t eflags;
int readonly;
int can_flush;
int is_rotational;
@@ -572,6 +574,55 @@ send_newstyle_option_reply_exportname (struct connection *conn,
return 0;
}
+static int
+send_newstyle_option_reply_info_export (struct connection *conn,
+...
2020 Jan 07
3
[PATCH] Fix lossy conversion of Content-Length
...gt;
---
plugins/curl/curl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c
index 031bd32..fe1330e 100644
--- a/plugins/curl/curl.c
+++ b/plugins/curl/curl.c
@@ -389,7 +389,7 @@ curl_open (int readonly)
goto err;
}
- h->exportsize = (size_t) d;
+ h->exportsize = (int64_t) d;
nbdkit_debug ("content length: %" PRIi64, h->exportsize);
if (strncasecmp (url, "http://", strlen ("http://")) == 0 ||
--
2.17.1
2018 Aug 06
3
[PATCH nbdkit v2] protocol: Implement NBD_OPT_GO.
There's no substantial difference over v1, I simply fixed a few
whitespace issues, moved one struct around and tidied up the comments.
Rich.
2018 Aug 04
3
[PATCH nbdkit] protocol: Implement NBD_OPT_GO.
This is only lightly tested (against just qemu NBD client), and the
code might be structured a little better as the
_negotiate_handshake_newstyle_options function has now grown to be
huge. Anyway works for me.
Rich.
2020 Jan 09
2
Re: [PATCH] Fix lossy conversion of Content-Length
...>
> >diff --git a/plugins/curl/curl.c b/plugins/curl/curl.c
> >index 031bd32..fe1330e 100644
> >--- a/plugins/curl/curl.c
> >+++ b/plugins/curl/curl.c
> >@@ -389,7 +389,7 @@ curl_open (int readonly)
> > goto err;
> > }
> >
> >- h->exportsize = (size_t) d;
> >+ h->exportsize = (int64_t) d;
>
> Why is a cast needed at all?
> This is C, an implicit conversion
> works just as well.
Present since the initial commit, but not present in the qemu
block/curl.c driver which is where most of this code was derived from,
so...
2020 Jan 08
1
[nbdkit PATCH] curl: use CURLINFO_CONTENT_LENGTH_DOWNLOAD_T when available
...OK) {
+ display_curl_error (h, r, "could not get length of remote file [%s]", url);
+ goto err;
+ }
+
+ if (o == -1) {
+ nbdkit_error ("could not get length of remote file [%s], "
+ "is the URL correct?", url);
+ goto err;
+ }
+
+ h->exportsize = o;
+#else
r = curl_easy_getinfo (h->c, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
if (r != CURLE_OK) {
display_curl_error (h, r, "could not get length of remote file [%s]", url);
@@ -390,6 +412,7 @@ curl_open (int readonly)
}
h->exportsize = (size_t) d;
+#endif...
2019 Sep 24
0
[PATCH nbdkit 3/4] common/protocol: Update nbd-protocol.h so it matches libnbd’s copy.
...G 4096 /* Maximum length of a string field */
+
/* Old-style handshake. */
-struct old_handshake {
+struct nbd_old_handshake {
char nbdmagic[8]; /* "NBDMAGIC" */
- uint64_t version; /* OLD_VERSION */
+ uint64_t version; /* NBD_OLD_VERSION */
uint64_t exportsize;
uint16_t gflags; /* global flags */
uint16_t eflags; /* per-export flags */
char zeroes[124]; /* must be sent as zero bytes */
} __attribute__((packed));
-#define OLD_VERSION UINT64_C(0x420281861253)
+#define NBD_OLD_VERSION UINT64_C(0x420281861253)
/...
2019 May 28
0
[libnbd PATCH 2/4] api: Rearrange flags argument to block_status
...erver";
longdesc = "\
diff --git a/interop/dirty-bitmap.c b/interop/dirty-bitmap.c
index 0a808b2..e096868 100644
--- a/interop/dirty-bitmap.c
+++ b/interop/dirty-bitmap.c
@@ -106,13 +106,13 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
- if (nbd_block_status (nbd, exportsize, 0, 0, NULL, cb) == -1) {
+ if (nbd_block_status (nbd, exportsize, 0, NULL, cb, 0) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
assert (calls == 0x11);
- if (nbd_block_status (nbd, exportsize, 0, LIBNBD_CMD_FLAG_REQ_ONE,
-...
2017 Nov 15
1
[nbdkit PATCH] connections: Improve error responses
...ions.c b/src/connections.c
index 8dc1925..264037d 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -666,7 +666,7 @@ negotiate_handshake (struct connection *conn)
return r;
}
-static int
+static bool
valid_range (struct connection *conn, uint64_t offset, uint32_t count)
{
uint64_t exportsize = conn->exportsize;
@@ -674,27 +674,34 @@ valid_range (struct connection *conn, uint64_t offset, uint32_t count)
return count > 0 && offset <= exportsize && offset + count <= exportsize;
}
-static int
+static bool
validate_request (struct connection *conn,...
2019 Jun 04
0
[libnbd PATCH 2/2] api: Recover from block status callback failure
...oid *data, const char *metacontext, uint64_t offset,
exit (EXIT_FAILURE);
}
+ if (data->fail) {
+ errno = EPROTO; /* Something NBD servers can't send */
+ return -1;
+ }
return 0;
}
@@ -80,6 +97,8 @@ main (int argc, char *argv[])
{
struct nbd_handle *nbd;
int64_t exportsize;
+ struct data data;
+ char c;
if (argc != 3) {
fprintf (stderr, "%s unixsocket bitmap\n", argv[0]);
@@ -108,17 +127,37 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
- if (nbd_block_status (nbd, exportsize, 0, NULL, cb, 0) == -1) {
+ data = (struct data) {...
2019 Jun 04
0
[PATCH libnbd v2 1/4] examples, tests: Remove want_to_send / ready logic, increase limit on cmds in flight.
...libnbd/blob/master/examples/threaded-reads-and-writes.c>
diff --git a/examples/threaded-reads-and-writes.c b/examples/threaded-reads-and-writes.c
index 5d0d2bd..bb82641 100644
--- a/examples/threaded-reads-and-writes.c
+++ b/examples/threaded-reads-and-writes.c
@@ -41,20 +41,16 @@ static int64_t exportsize;
/* Number of commands that can be "in flight" at the same time on each
* connection. (Therefore the total number of requests in flight may
- * be up to NR_MULTI_CONN * MAX_IN_FLIGHT). qemu's NBD client can
- * have up to 16 requests in flight.
- *
- * Some servers do not suppo...
2023 Aug 04
2
[libnbd PATCH v4 01/25] block_status: Add some sanity checking of server lengths
...ier for future patches to
> do orthogonal support for a server's 32- or 64-bit reply, vs. a
> client's 32- or 64-bit API call. Once 64-bit replies are in play, we
> will additionally have to worry about a 64-bit reply that overflows a
> 32-bit API callback without exceeding the exportsize. Similarly,
> since nbd_get_size() already caps export size at 63 bits (based on
> off_t limitations), we have guaranteed that a 64-bit API callback will
> never see an extent length that could appear negative in a 64-bit
> signed type (at least OCaml benefits from that guarantee, sinc...
2020 Jan 09
2
Re: [PATCH] Fix lossy conversion of Content-Length
...t; >>> index 031bd32..fe1330e 100644
> >>> --- a/plugins/curl/curl.c
> >>> +++ b/plugins/curl/curl.c
> >>> @@ -389,7 +389,7 @@ curl_open (int readonly)
> >>> goto err;
> >>> }
> >>>
> >>> - h->exportsize = (size_t) d;
> >>> + h->exportsize = (int64_t) d;
> >>
> >> Why is a cast needed at all?
> >> This is C, an implicit conversion
> >> works just as well.
> >
> > Present since the initial commit, but not present in the qemu
> >...
2019 Jun 29
0
[libnbd PATCH 6/6] examples: New example for strict read validations
...otal_success++;
+ ret = 0;
+
+ cleanup:
+ while (data->remaining) {
+ struct range *r = data->remaining;
+ data->remaining = r->next;
+ free (r);
+ }
+ free (data);
+ return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+ struct nbd_handle *nbd;
+ size_t i;
+ int64_t exportsize;
+ int64_t maxsize = MAX_BUF;
+ uint64_t offset;
+
+ srand (time (NULL));
+
+ if (argc != 2) {
+ fprintf (stderr, "%s socket|uri\n", argv[0]);
+ exit (EXIT_FAILURE);
+ }
+
+ nbd = nbd_create ();
+ if (nbd == NULL) {
+ fprintf (stderr, "%s\n", nbd_get_error ());
+...