[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/22] curl: Remove broken parsing of options from ur
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 12/22] curl: Remove broken parsing of options from url |
Date: |
Mon, 19 May 2014 16:22:30 +0200 |
From: Matthew Booth <address@hidden>
The block layer now supports a generic json syntax for passing option parameters
explicitly, making parsing of options from the url redundant.
Signed-off-by: Matthew Booth <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/curl.c | 52 ++++++++++------------------------------------------
1 file changed, 10 insertions(+), 42 deletions(-)
diff --git a/block/curl.c b/block/curl.c
index f3c797a..1b9f2f2 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -61,12 +61,15 @@ static CURLMcode __curl_multi_socket_action(CURLM
*multi_handle,
#define CURL_NUM_STATES 8
#define CURL_NUM_ACB 8
#define SECTOR_SIZE 512
-#define READ_AHEAD_SIZE (256 * 1024)
+#define READ_AHEAD_DEFAULT (256 * 1024)
#define FIND_RET_NONE 0
#define FIND_RET_OK 1
#define FIND_RET_WAIT 2
+#define CURL_BLOCK_OPT_URL "url"
+#define CURL_BLOCK_OPT_READAHEAD "readahead"
+
struct BDRVCURLState;
typedef struct CURLAIOCB {
@@ -411,43 +414,7 @@ static void curl_clean_state(CURLState *s)
static void curl_parse_filename(const char *filename, QDict *options,
Error **errp)
{
-
- #define RA_OPTSTR ":readahead="
- char *file;
- char *ra;
- const char *ra_val;
- int parse_state = 0;
-
- file = g_strdup(filename);
-
- /* Parse a trailing ":readahead=#:" param, if present. */
- ra = file + strlen(file) - 1;
- while (ra >= file) {
- if (parse_state == 0) {
- if (*ra == ':') {
- parse_state++;
- } else {
- break;
- }
- } else if (parse_state == 1) {
- if (*ra > '9' || *ra < '0') {
- char *opt_start = ra - strlen(RA_OPTSTR) + 1;
- if (opt_start > file &&
- strncmp(opt_start, RA_OPTSTR, strlen(RA_OPTSTR)) == 0) {
- ra_val = ra + 1;
- ra -= strlen(RA_OPTSTR) - 1;
- *ra = '\0';
- qdict_put(options, "readahead", qstring_from_str(ra_val));
- }
- break;
- }
- }
- ra--;
- }
-
- qdict_put(options, "url", qstring_from_str(file));
-
- g_free(file);
+ qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename));
}
static QemuOptsList runtime_opts = {
@@ -455,12 +422,12 @@ static QemuOptsList runtime_opts = {
.head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
.desc = {
{
- .name = "url",
+ .name = CURL_BLOCK_OPT_URL,
.type = QEMU_OPT_STRING,
.help = "URL to open",
},
{
- .name = "readahead",
+ .name = CURL_BLOCK_OPT_READAHEAD,
.type = QEMU_OPT_SIZE,
.help = "Readahead size",
},
@@ -492,14 +459,15 @@ static int curl_open(BlockDriverState *bs, QDict
*options, int flags,
goto out_noclean;
}
- s->readahead_size = qemu_opt_get_size(opts, "readahead", READ_AHEAD_SIZE);
+ s->readahead_size = qemu_opt_get_size(opts, CURL_BLOCK_OPT_READAHEAD,
+ READ_AHEAD_DEFAULT);
if ((s->readahead_size & 0x1ff) != 0) {
error_setg(errp, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512",
s->readahead_size);
goto out_noclean;
}
- file = qemu_opt_get(opts, "url");
+ file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL);
if (file == NULL) {
error_setg(errp, "curl block driver requires an 'url' option");
goto out_noclean;
--
1.8.3.1
- [Qemu-devel] [PULL 05/22] qdict: Add qdict_join(), (continued)
- [Qemu-devel] [PULL 05/22] qdict: Add qdict_join(), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 06/22] check-qdict: Add test for qdict_join(), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 04/22] block: add test for vhdx image created by Disk2VHD, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 01/22] block: Fix bdrv_is_allocated() for short backing files, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 03/22] block: vhdx - account for identical header sections, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 08/22] iotests: Add test for the JSON protocol, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 09/22] qemu-iotests: Fix core dump suppression in test 039, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 07/22] block: Allow JSON filenames, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 10/22] qemu-iotests: Fix blkdebug in VM drive in 030, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 14/22] curl: Add usage documentation, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 12/22] curl: Remove broken parsing of options from url,
Kevin Wolf <=
- [Qemu-devel] [PULL 11/22] curl: Fix build when curl_multi_socket_action isn't available, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 15/22] qcow1: Make padding in the header explicit, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 16/22] qcow1: Check maximum cluster size, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 13/22] curl: Add sslverify option, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 17/22] qcow1: Validate L2 table size (CVE-2014-0222), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 19/22] qcow1: Stricter backing file length check, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 18/22] qcow1: Validate image size (CVE-2014-0223), Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 20/22] util: add qemu_iovec_is_zero, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 21/22] blockdev: add a function to parse enum ids from strings, Kevin Wolf, 2014/05/19
- [Qemu-devel] [PULL 22/22] block: optimize zero writes with bdrv_write_zeroes, Kevin Wolf, 2014/05/19