block/curl: set User-Agent header
Some HTTP servers and WAFs (e.g. Amazon CloudFront) reject requests without a User-Agent header with 403 Forbidden. This makes qemu-img info and other curl-based operations fail on such URLs without any obvious indication of the root cause. Set a "QEMU/<version>" User-Agent string on all curl handles to ensure compatibility with these endpoints. Signed-off-by: Vladimir Lobanov <lobanov-vla@yandex.ru> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Vladimir Lobanov committed
Jun 17, 2026 at 12:44 UTC
68dd6989abe5212fc89ef0fcb6fedc460bfd1cb7
1 file changed
+2
block/curl.c
+2
@@ -482,6 +482,8 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
482
}
483
}
484
if (curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, (long)s->timeout) ||
485
+ curl_easy_setopt(state->curl, CURLOPT_USERAGENT,
486
+ "QEMU/" QEMU_VERSION) ||
487
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
488
(void *)curl_read_cb) ||
489
curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state) ||