If the user has explicitly specified a block driver and thus a protocol,
we have to make sure the URL's protocol prefix matches. Otherwise the
latter will silently override the former which might catch some users by
surprise.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id:
20170331120431.1767-3-mreitz@redhat.com
Signed-off-by: Jeff Cody <jcody@redhat.com>
const char *cookie;
double d;
const char *secretid;
const char *cookie;
double d;
const char *secretid;
+ const char *protocol_delimiter;
+ if (!strstart(file, bs->drv->protocol_name, &protocol_delimiter) ||
+ !strstart(protocol_delimiter, "://", NULL))
+ {
+ error_setg(errp, "%s curl driver cannot handle the URL '%s' (does not "
+ "start with '%s://')", bs->drv->protocol_name, file,
+ bs->drv->protocol_name);
+ goto out_noclean;
+ }
+
s->username = g_strdup(qemu_opt_get(opts, CURL_BLOCK_OPT_USERNAME));
secretid = qemu_opt_get(opts, CURL_BLOCK_OPT_PASSWORD_SECRET);
s->username = g_strdup(qemu_opt_get(opts, CURL_BLOCK_OPT_USERNAME));
secretid = qemu_opt_get(opts, CURL_BLOCK_OPT_PASSWORD_SECRET);