thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-curl-Remove-broken-parsing-of-options-from-url.patch

05bba0
From d935f2a3eafd649a2b40c27c8b6f8536a2e486e5 Mon Sep 17 00:00:00 2001
05bba0
From: Richard Jones <rjones@redhat.com>
05bba0
Date: Thu, 11 Jun 2015 11:40:20 +0200
05bba0
Subject: [PATCH 20/30] curl: Remove broken parsing of options from url
05bba0
05bba0
Message-id: <1434022828-13037-14-git-send-email-rjones@redhat.com>
05bba0
Patchwork-id: 65848
05bba0
O-Subject: [RHEL-7.2 qemu-kvm v3 PATCH 13/21] curl: Remove broken parsing of options from url
05bba0
Bugzilla: 1226684
05bba0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
05bba0
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
05bba0
05bba0
From: Matthew Booth <mbooth@redhat.com>
05bba0
05bba0
The block layer now supports a generic json syntax for passing option parameters
05bba0
explicitly, making parsing of options from the url redundant.
05bba0
05bba0
Signed-off-by: Matthew Booth <mbooth@redhat.com>
05bba0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
05bba0
05bba0
Upstream-status: e3542c67af4cb4fd90e3be912630be9acd97b9c0
05bba0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
05bba0
---
05bba0
 block/curl.c | 52 ++++++++++------------------------------------------
05bba0
 1 file changed, 10 insertions(+), 42 deletions(-)
05bba0
05bba0
diff --git a/block/curl.c b/block/curl.c
05bba0
index be2d3f4..67ea05f 100644
05bba0
--- a/block/curl.c
05bba0
+++ b/block/curl.c
05bba0
@@ -61,12 +61,15 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
05bba0
 #define CURL_NUM_STATES 8
05bba0
 #define CURL_NUM_ACB    8
05bba0
 #define SECTOR_SIZE     512
05bba0
-#define READ_AHEAD_SIZE (256 * 1024)
05bba0
+#define READ_AHEAD_DEFAULT (256 * 1024)
05bba0
 
05bba0
 #define FIND_RET_NONE   0
05bba0
 #define FIND_RET_OK     1
05bba0
 #define FIND_RET_WAIT   2
05bba0
 
05bba0
+#define CURL_BLOCK_OPT_URL       "url"
05bba0
+#define CURL_BLOCK_OPT_READAHEAD "readahead"
05bba0
+
05bba0
 struct BDRVCURLState;
05bba0
 
05bba0
 typedef struct CURLAIOCB {
05bba0
@@ -411,43 +414,7 @@ static void curl_clean_state(CURLState *s)
05bba0
 static void curl_parse_filename(const char *filename, QDict *options,
05bba0
                                 Error **errp)
05bba0
 {
05bba0
-
05bba0
-    #define RA_OPTSTR ":readahead="
05bba0
-    char *file;
05bba0
-    char *ra;
05bba0
-    const char *ra_val;
05bba0
-    int parse_state = 0;
05bba0
-
05bba0
-    file = g_strdup(filename);
05bba0
-
05bba0
-    /* Parse a trailing ":readahead=#:" param, if present. */
05bba0
-    ra = file + strlen(file) - 1;
05bba0
-    while (ra >= file) {
05bba0
-        if (parse_state == 0) {
05bba0
-            if (*ra == ':') {
05bba0
-                parse_state++;
05bba0
-            } else {
05bba0
-                break;
05bba0
-            }
05bba0
-        } else if (parse_state == 1) {
05bba0
-            if (*ra > '9' || *ra < '0') {
05bba0
-                char *opt_start = ra - strlen(RA_OPTSTR) + 1;
05bba0
-                if (opt_start > file &&
05bba0
-                    strncmp(opt_start, RA_OPTSTR, strlen(RA_OPTSTR)) == 0) {
05bba0
-                    ra_val = ra + 1;
05bba0
-                    ra -= strlen(RA_OPTSTR) - 1;
05bba0
-                    *ra = '\0';
05bba0
-                    qdict_put(options, "readahead", qstring_from_str(ra_val));
05bba0
-                }
05bba0
-                break;
05bba0
-            }
05bba0
-        }
05bba0
-        ra--;
05bba0
-    }
05bba0
-
05bba0
-    qdict_put(options, "url", qstring_from_str(file));
05bba0
-
05bba0
-    g_free(file);
05bba0
+    qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename));
05bba0
 }
05bba0
 
05bba0
 static QemuOptsList runtime_opts = {
05bba0
@@ -455,12 +422,12 @@ static QemuOptsList runtime_opts = {
05bba0
     .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
05bba0
     .desc = {
05bba0
         {
05bba0
-            .name = "url",
05bba0
+            .name = CURL_BLOCK_OPT_URL,
05bba0
             .type = QEMU_OPT_STRING,
05bba0
             .help = "URL to open",
05bba0
         },
05bba0
         {
05bba0
-            .name = "readahead",
05bba0
+            .name = CURL_BLOCK_OPT_READAHEAD,
05bba0
             .type = QEMU_OPT_SIZE,
05bba0
             .help = "Readahead size",
05bba0
         },
05bba0
@@ -488,14 +455,15 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
05bba0
         goto out_noclean;
05bba0
     }
05bba0
 
05bba0
-    s->readahead_size = qemu_opt_get_size(opts, "readahead", READ_AHEAD_SIZE);
05bba0
+    s->readahead_size = qemu_opt_get_size(opts, CURL_BLOCK_OPT_READAHEAD,
05bba0
+                                          READ_AHEAD_DEFAULT);
05bba0
     if ((s->readahead_size & 0x1ff) != 0) {
05bba0
         fprintf(stderr, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512\n",
05bba0
                 s->readahead_size);
05bba0
         goto out_noclean;
05bba0
     }
05bba0
 
05bba0
-    file = qemu_opt_get(opts, "url");
05bba0
+    file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL);
05bba0
     if (file == NULL) {
05bba0
         qerror_report(ERROR_CLASS_GENERIC_ERROR, "curl block driver requires "
05bba0
                       "an 'url' option");
05bba0
-- 
05bba0
1.8.3.1
05bba0