]> Git Repo - qemu.git/blob - block/curl.c
curl: Fix long line
[qemu.git] / block / curl.c
1 /*
2  * QEMU Block driver for CURL images
3  *
4  * Copyright (c) 2009 Alexander Graf <[email protected]>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #include "qemu-common.h"
25 #include "block/block_int.h"
26 #include <curl/curl.h>
27
28 // #define DEBUG
29 // #define DEBUG_VERBOSE
30
31 #ifdef DEBUG_CURL
32 #define DPRINTF(fmt, ...) do { printf(fmt, ## __VA_ARGS__); } while (0)
33 #else
34 #define DPRINTF(fmt, ...) do { } while (0)
35 #endif
36
37 #if LIBCURL_VERSION_NUM >= 0x071000
38 /* The multi interface timer callback was introduced in 7.16.0 */
39 #define NEED_CURL_TIMER_CALLBACK
40 #endif
41
42 #define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
43                    CURLPROTO_FTP | CURLPROTO_FTPS | \
44                    CURLPROTO_TFTP)
45
46 #define CURL_NUM_STATES 8
47 #define CURL_NUM_ACB    8
48 #define SECTOR_SIZE     512
49 #define READ_AHEAD_SIZE (256 * 1024)
50
51 #define FIND_RET_NONE   0
52 #define FIND_RET_OK     1
53 #define FIND_RET_WAIT   2
54
55 struct BDRVCURLState;
56
57 typedef struct CURLAIOCB {
58     BlockDriverAIOCB common;
59     QEMUBH *bh;
60     QEMUIOVector *qiov;
61
62     int64_t sector_num;
63     int nb_sectors;
64
65     size_t start;
66     size_t end;
67 } CURLAIOCB;
68
69 typedef struct CURLState
70 {
71     struct BDRVCURLState *s;
72     CURLAIOCB *acb[CURL_NUM_ACB];
73     CURL *curl;
74     char *orig_buf;
75     size_t buf_start;
76     size_t buf_off;
77     size_t buf_len;
78     char range[128];
79     char errmsg[CURL_ERROR_SIZE];
80     char in_use;
81 } CURLState;
82
83 typedef struct BDRVCURLState {
84     CURLM *multi;
85     QEMUTimer timer;
86     size_t len;
87     CURLState states[CURL_NUM_STATES];
88     char *url;
89     size_t readahead_size;
90     bool accept_range;
91 } BDRVCURLState;
92
93 static void curl_clean_state(CURLState *s);
94 static void curl_multi_do(void *arg);
95
96 #ifdef NEED_CURL_TIMER_CALLBACK
97 static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque)
98 {
99     BDRVCURLState *s = opaque;
100
101     DPRINTF("CURL: timer callback timeout_ms %ld\n", timeout_ms);
102     if (timeout_ms == -1) {
103         timer_del(&s->timer);
104     } else {
105         int64_t timeout_ns = (int64_t)timeout_ms * 1000 * 1000;
106         timer_mod(&s->timer,
107                   qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + timeout_ns);
108     }
109     return 0;
110 }
111 #endif
112
113 static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action,
114                         void *s, void *sp)
115 {
116     DPRINTF("CURL (AIO): Sock action %d on fd %d\n", action, fd);
117     switch (action) {
118         case CURL_POLL_IN:
119             qemu_aio_set_fd_handler(fd, curl_multi_do, NULL, s);
120             break;
121         case CURL_POLL_OUT:
122             qemu_aio_set_fd_handler(fd, NULL, curl_multi_do, s);
123             break;
124         case CURL_POLL_INOUT:
125             qemu_aio_set_fd_handler(fd, curl_multi_do, curl_multi_do, s);
126             break;
127         case CURL_POLL_REMOVE:
128             qemu_aio_set_fd_handler(fd, NULL, NULL, NULL);
129             break;
130     }
131
132     return 0;
133 }
134
135 static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
136 {
137     BDRVCURLState *s = opaque;
138     size_t realsize = size * nmemb;
139     const char *accept_line = "Accept-Ranges: bytes";
140
141     if (realsize >= strlen(accept_line)
142         && strncmp((char *)ptr, accept_line, strlen(accept_line)) == 0) {
143         s->accept_range = true;
144     }
145
146     return realsize;
147 }
148
149 static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque)
150 {
151     CURLState *s = ((CURLState*)opaque);
152     size_t realsize = size * nmemb;
153     int i;
154
155     DPRINTF("CURL: Just reading %zd bytes\n", realsize);
156
157     if (!s || !s->orig_buf)
158         goto read_end;
159
160     if (s->buf_off >= s->buf_len) {
161         /* buffer full, read nothing */
162         return 0;
163     }
164     realsize = MIN(realsize, s->buf_len - s->buf_off);
165     memcpy(s->orig_buf + s->buf_off, ptr, realsize);
166     s->buf_off += realsize;
167
168     for(i=0; i<CURL_NUM_ACB; i++) {
169         CURLAIOCB *acb = s->acb[i];
170
171         if (!acb)
172             continue;
173
174         if ((s->buf_off >= acb->end)) {
175             qemu_iovec_from_buf(acb->qiov, 0, s->orig_buf + acb->start,
176                                 acb->end - acb->start);
177             acb->common.cb(acb->common.opaque, 0);
178             qemu_aio_release(acb);
179             s->acb[i] = NULL;
180         }
181     }
182
183 read_end:
184     return realsize;
185 }
186
187 static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len,
188                          CURLAIOCB *acb)
189 {
190     int i;
191     size_t end = start + len;
192
193     for (i=0; i<CURL_NUM_STATES; i++) {
194         CURLState *state = &s->states[i];
195         size_t buf_end = (state->buf_start + state->buf_off);
196         size_t buf_fend = (state->buf_start + state->buf_len);
197
198         if (!state->orig_buf)
199             continue;
200         if (!state->buf_off)
201             continue;
202
203         // Does the existing buffer cover our section?
204         if ((start >= state->buf_start) &&
205             (start <= buf_end) &&
206             (end >= state->buf_start) &&
207             (end <= buf_end))
208         {
209             char *buf = state->orig_buf + (start - state->buf_start);
210
211             qemu_iovec_from_buf(acb->qiov, 0, buf, len);
212             acb->common.cb(acb->common.opaque, 0);
213
214             return FIND_RET_OK;
215         }
216
217         // Wait for unfinished chunks
218         if ((start >= state->buf_start) &&
219             (start <= buf_fend) &&
220             (end >= state->buf_start) &&
221             (end <= buf_fend))
222         {
223             int j;
224
225             acb->start = start - state->buf_start;
226             acb->end = acb->start + len;
227
228             for (j=0; j<CURL_NUM_ACB; j++) {
229                 if (!state->acb[j]) {
230                     state->acb[j] = acb;
231                     return FIND_RET_WAIT;
232                 }
233             }
234         }
235     }
236
237     return FIND_RET_NONE;
238 }
239
240 static void curl_multi_read(BDRVCURLState *s)
241 {
242     int msgs_in_queue;
243
244     /* Try to find done transfers, so we can free the easy
245      * handle again. */
246     do {
247         CURLMsg *msg;
248         msg = curl_multi_info_read(s->multi, &msgs_in_queue);
249
250         if (!msg)
251             break;
252         if (msg->msg == CURLMSG_NONE)
253             break;
254
255         switch (msg->msg) {
256             case CURLMSG_DONE:
257             {
258                 CURLState *state = NULL;
259                 curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE,
260                                   (char **)&state);
261
262                 /* ACBs for successful messages get completed in curl_read_cb */
263                 if (msg->data.result != CURLE_OK) {
264                     int i;
265                     for (i = 0; i < CURL_NUM_ACB; i++) {
266                         CURLAIOCB *acb = state->acb[i];
267
268                         if (acb == NULL) {
269                             continue;
270                         }
271
272                         acb->common.cb(acb->common.opaque, -EIO);
273                         qemu_aio_release(acb);
274                         state->acb[i] = NULL;
275                     }
276                 }
277
278                 curl_clean_state(state);
279                 break;
280             }
281             default:
282                 msgs_in_queue = 0;
283                 break;
284         }
285     } while(msgs_in_queue);
286 }
287
288 static void curl_multi_do(void *arg)
289 {
290     BDRVCURLState *s = (BDRVCURLState *)arg;
291     int running;
292     int r;
293
294     if (!s->multi) {
295         return;
296     }
297
298     do {
299         r = curl_multi_socket_all(s->multi, &running);
300     } while(r == CURLM_CALL_MULTI_PERFORM);
301
302     curl_multi_read(s);
303 }
304
305 static void curl_multi_timeout_do(void *arg)
306 {
307 #ifdef NEED_CURL_TIMER_CALLBACK
308     BDRVCURLState *s = (BDRVCURLState *)arg;
309     int running;
310
311     if (!s->multi) {
312         return;
313     }
314
315     curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running);
316
317     curl_multi_read(s);
318 #else
319     abort();
320 #endif
321 }
322
323 static CURLState *curl_init_state(BDRVCURLState *s)
324 {
325     CURLState *state = NULL;
326     int i, j;
327
328     do {
329         for (i=0; i<CURL_NUM_STATES; i++) {
330             for (j=0; j<CURL_NUM_ACB; j++)
331                 if (s->states[i].acb[j])
332                     continue;
333             if (s->states[i].in_use)
334                 continue;
335
336             state = &s->states[i];
337             state->in_use = 1;
338             break;
339         }
340         if (!state) {
341             g_usleep(100);
342             curl_multi_do(s);
343         }
344     } while(!state);
345
346     if (state->curl)
347         goto has_curl;
348
349     state->curl = curl_easy_init();
350     if (!state->curl)
351         return NULL;
352     curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
353     curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
354     curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION, (void *)curl_read_cb);
355     curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
356     curl_easy_setopt(state->curl, CURLOPT_PRIVATE, (void *)state);
357     curl_easy_setopt(state->curl, CURLOPT_AUTOREFERER, 1);
358     curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
359     curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
360     curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
361     curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
362
363     /* Restrict supported protocols to avoid security issues in the more
364      * obscure protocols.  For example, do not allow POP3/SMTP/IMAP see
365      * CVE-2013-0249.
366      *
367      * Restricting protocols is only supported from 7.19.4 upwards.
368      */
369 #if LIBCURL_VERSION_NUM >= 0x071304
370     curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS);
371     curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS);
372 #endif
373
374 #ifdef DEBUG_VERBOSE
375     curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
376 #endif
377
378 has_curl:
379
380     state->s = s;
381
382     return state;
383 }
384
385 static void curl_clean_state(CURLState *s)
386 {
387     if (s->s->multi)
388         curl_multi_remove_handle(s->s->multi, s->curl);
389     s->in_use = 0;
390 }
391
392 static void curl_parse_filename(const char *filename, QDict *options,
393                                 Error **errp)
394 {
395
396     #define RA_OPTSTR ":readahead="
397     char *file;
398     char *ra;
399     const char *ra_val;
400     int parse_state = 0;
401
402     file = g_strdup(filename);
403
404     /* Parse a trailing ":readahead=#:" param, if present. */
405     ra = file + strlen(file) - 1;
406     while (ra >= file) {
407         if (parse_state == 0) {
408             if (*ra == ':') {
409                 parse_state++;
410             } else {
411                 break;
412             }
413         } else if (parse_state == 1) {
414             if (*ra > '9' || *ra < '0') {
415                 char *opt_start = ra - strlen(RA_OPTSTR) + 1;
416                 if (opt_start > file &&
417                     strncmp(opt_start, RA_OPTSTR, strlen(RA_OPTSTR)) == 0) {
418                     ra_val = ra + 1;
419                     ra -= strlen(RA_OPTSTR) - 1;
420                     *ra = '\0';
421                     qdict_put(options, "readahead", qstring_from_str(ra_val));
422                 }
423                 break;
424             }
425         }
426         ra--;
427     }
428
429     qdict_put(options, "url", qstring_from_str(file));
430
431     g_free(file);
432 }
433
434 static QemuOptsList runtime_opts = {
435     .name = "curl",
436     .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
437     .desc = {
438         {
439             .name = "url",
440             .type = QEMU_OPT_STRING,
441             .help = "URL to open",
442         },
443         {
444             .name = "readahead",
445             .type = QEMU_OPT_SIZE,
446             .help = "Readahead size",
447         },
448         { /* end of list */ }
449     },
450 };
451
452 static int curl_open(BlockDriverState *bs, QDict *options, int flags,
453                      Error **errp)
454 {
455     BDRVCURLState *s = bs->opaque;
456     CURLState *state = NULL;
457     QemuOpts *opts;
458     Error *local_err = NULL;
459     const char *file;
460     double d;
461
462     static int inited = 0;
463
464     if (flags & BDRV_O_RDWR) {
465         error_setg(errp, "curl block device does not support writes");
466         return -EROFS;
467     }
468
469     opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
470     qemu_opts_absorb_qdict(opts, options, &local_err);
471     if (local_err) {
472         error_propagate(errp, local_err);
473         goto out_noclean;
474     }
475
476     s->readahead_size = qemu_opt_get_size(opts, "readahead", READ_AHEAD_SIZE);
477     if ((s->readahead_size & 0x1ff) != 0) {
478         error_setg(errp, "HTTP_READAHEAD_SIZE %zd is not a multiple of 512",
479                    s->readahead_size);
480         goto out_noclean;
481     }
482
483     file = qemu_opt_get(opts, "url");
484     if (file == NULL) {
485         error_setg(errp, "curl block driver requires an 'url' option");
486         goto out_noclean;
487     }
488
489     if (!inited) {
490         curl_global_init(CURL_GLOBAL_ALL);
491         inited = 1;
492     }
493
494     DPRINTF("CURL: Opening %s\n", file);
495     s->url = g_strdup(file);
496     state = curl_init_state(s);
497     if (!state)
498         goto out_noclean;
499
500     // Get file size
501
502     s->accept_range = false;
503     curl_easy_setopt(state->curl, CURLOPT_NOBODY, 1);
504     curl_easy_setopt(state->curl, CURLOPT_HEADERFUNCTION,
505                      curl_header_cb);
506     curl_easy_setopt(state->curl, CURLOPT_HEADERDATA, s);
507     if (curl_easy_perform(state->curl))
508         goto out;
509     curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d);
510     if (d)
511         s->len = (size_t)d;
512     else if(!s->len)
513         goto out;
514     if ((!strncasecmp(s->url, "http://", strlen("http://"))
515         || !strncasecmp(s->url, "https://", strlen("https://")))
516         && !s->accept_range) {
517         pstrcpy(state->errmsg, CURL_ERROR_SIZE,
518                 "Server does not support 'range' (byte ranges).");
519         goto out;
520     }
521     DPRINTF("CURL: Size = %zd\n", s->len);
522
523     curl_clean_state(state);
524     curl_easy_cleanup(state->curl);
525     state->curl = NULL;
526
527     aio_timer_init(bdrv_get_aio_context(bs), &s->timer,
528                    QEMU_CLOCK_REALTIME, SCALE_NS,
529                    curl_multi_timeout_do, s);
530
531     // Now we know the file exists and its size, so let's
532     // initialize the multi interface!
533
534     s->multi = curl_multi_init();
535     curl_multi_setopt(s->multi, CURLMOPT_SOCKETDATA, s);
536     curl_multi_setopt(s->multi, CURLMOPT_SOCKETFUNCTION, curl_sock_cb);
537 #ifdef NEED_CURL_TIMER_CALLBACK
538     curl_multi_setopt(s->multi, CURLMOPT_TIMERDATA, s);
539     curl_multi_setopt(s->multi, CURLMOPT_TIMERFUNCTION, curl_timer_cb);
540 #endif
541     curl_multi_do(s);
542
543     qemu_opts_del(opts);
544     return 0;
545
546 out:
547     error_setg(errp, "CURL: Error opening file: %s", state->errmsg);
548     curl_easy_cleanup(state->curl);
549     state->curl = NULL;
550 out_noclean:
551     g_free(s->url);
552     qemu_opts_del(opts);
553     return -EINVAL;
554 }
555
556 static void curl_aio_cancel(BlockDriverAIOCB *blockacb)
557 {
558     // Do we have to implement canceling? Seems to work without...
559 }
560
561 static const AIOCBInfo curl_aiocb_info = {
562     .aiocb_size         = sizeof(CURLAIOCB),
563     .cancel             = curl_aio_cancel,
564 };
565
566
567 static void curl_readv_bh_cb(void *p)
568 {
569     CURLState *state;
570
571     CURLAIOCB *acb = p;
572     BDRVCURLState *s = acb->common.bs->opaque;
573
574     qemu_bh_delete(acb->bh);
575     acb->bh = NULL;
576
577     size_t start = acb->sector_num * SECTOR_SIZE;
578     size_t end;
579
580     // In case we have the requested data already (e.g. read-ahead),
581     // we can just call the callback and be done.
582     switch (curl_find_buf(s, start, acb->nb_sectors * SECTOR_SIZE, acb)) {
583         case FIND_RET_OK:
584             qemu_aio_release(acb);
585             // fall through
586         case FIND_RET_WAIT:
587             return;
588         default:
589             break;
590     }
591
592     // No cache found, so let's start a new request
593     state = curl_init_state(s);
594     if (!state) {
595         acb->common.cb(acb->common.opaque, -EIO);
596         qemu_aio_release(acb);
597         return;
598     }
599
600     acb->start = 0;
601     acb->end = (acb->nb_sectors * SECTOR_SIZE);
602
603     state->buf_off = 0;
604     if (state->orig_buf)
605         g_free(state->orig_buf);
606     state->buf_start = start;
607     state->buf_len = acb->end + s->readahead_size;
608     end = MIN(start + state->buf_len, s->len) - 1;
609     state->orig_buf = g_malloc(state->buf_len);
610     state->acb[0] = acb;
611
612     snprintf(state->range, 127, "%zd-%zd", start, end);
613     DPRINTF("CURL (AIO): Reading %d at %zd (%s)\n",
614             (acb->nb_sectors * SECTOR_SIZE), start, state->range);
615     curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);
616
617     curl_multi_add_handle(s->multi, state->curl);
618     curl_multi_do(s);
619
620 }
621
622 static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,
623         int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
624         BlockDriverCompletionFunc *cb, void *opaque)
625 {
626     CURLAIOCB *acb;
627
628     acb = qemu_aio_get(&curl_aiocb_info, bs, cb, opaque);
629
630     acb->qiov = qiov;
631     acb->sector_num = sector_num;
632     acb->nb_sectors = nb_sectors;
633
634     acb->bh = qemu_bh_new(curl_readv_bh_cb, acb);
635     qemu_bh_schedule(acb->bh);
636     return &acb->common;
637 }
638
639 static void curl_close(BlockDriverState *bs)
640 {
641     BDRVCURLState *s = bs->opaque;
642     int i;
643
644     DPRINTF("CURL: Close\n");
645     for (i=0; i<CURL_NUM_STATES; i++) {
646         if (s->states[i].in_use)
647             curl_clean_state(&s->states[i]);
648         if (s->states[i].curl) {
649             curl_easy_cleanup(s->states[i].curl);
650             s->states[i].curl = NULL;
651         }
652         if (s->states[i].orig_buf) {
653             g_free(s->states[i].orig_buf);
654             s->states[i].orig_buf = NULL;
655         }
656     }
657     if (s->multi)
658         curl_multi_cleanup(s->multi);
659
660     timer_del(&s->timer);
661
662     g_free(s->url);
663 }
664
665 static int64_t curl_getlength(BlockDriverState *bs)
666 {
667     BDRVCURLState *s = bs->opaque;
668     return s->len;
669 }
670
671 static BlockDriver bdrv_http = {
672     .format_name            = "http",
673     .protocol_name          = "http",
674
675     .instance_size          = sizeof(BDRVCURLState),
676     .bdrv_parse_filename    = curl_parse_filename,
677     .bdrv_file_open         = curl_open,
678     .bdrv_close             = curl_close,
679     .bdrv_getlength         = curl_getlength,
680
681     .bdrv_aio_readv         = curl_aio_readv,
682 };
683
684 static BlockDriver bdrv_https = {
685     .format_name            = "https",
686     .protocol_name          = "https",
687
688     .instance_size          = sizeof(BDRVCURLState),
689     .bdrv_parse_filename    = curl_parse_filename,
690     .bdrv_file_open         = curl_open,
691     .bdrv_close             = curl_close,
692     .bdrv_getlength         = curl_getlength,
693
694     .bdrv_aio_readv         = curl_aio_readv,
695 };
696
697 static BlockDriver bdrv_ftp = {
698     .format_name            = "ftp",
699     .protocol_name          = "ftp",
700
701     .instance_size          = sizeof(BDRVCURLState),
702     .bdrv_parse_filename    = curl_parse_filename,
703     .bdrv_file_open         = curl_open,
704     .bdrv_close             = curl_close,
705     .bdrv_getlength         = curl_getlength,
706
707     .bdrv_aio_readv         = curl_aio_readv,
708 };
709
710 static BlockDriver bdrv_ftps = {
711     .format_name            = "ftps",
712     .protocol_name          = "ftps",
713
714     .instance_size          = sizeof(BDRVCURLState),
715     .bdrv_parse_filename    = curl_parse_filename,
716     .bdrv_file_open         = curl_open,
717     .bdrv_close             = curl_close,
718     .bdrv_getlength         = curl_getlength,
719
720     .bdrv_aio_readv         = curl_aio_readv,
721 };
722
723 static BlockDriver bdrv_tftp = {
724     .format_name            = "tftp",
725     .protocol_name          = "tftp",
726
727     .instance_size          = sizeof(BDRVCURLState),
728     .bdrv_parse_filename    = curl_parse_filename,
729     .bdrv_file_open         = curl_open,
730     .bdrv_close             = curl_close,
731     .bdrv_getlength         = curl_getlength,
732
733     .bdrv_aio_readv         = curl_aio_readv,
734 };
735
736 static void curl_block_init(void)
737 {
738     bdrv_register(&bdrv_http);
739     bdrv_register(&bdrv_https);
740     bdrv_register(&bdrv_ftp);
741     bdrv_register(&bdrv_ftps);
742     bdrv_register(&bdrv_tftp);
743 }
744
745 block_init(curl_block_init);
This page took 0.064965 seconds and 4 git commands to generate.