]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block/curl: set User-Agent header
authorVladimir Lobanov <lobanov-vla@yandex.ru>
Wed, 17 Jun 2026 09:44:56 +0000 (12:44 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 23 Jul 2026 15:03:24 +0000 (18:03 +0300)
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>
block/curl.c

index 684c677ef7185eb0e5ff8e1c077b78ff159efe36..1958eb80d12a13fc79e1dbc63b5d4ea5585b9ca0 100644 (file)
@@ -482,6 +482,8 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
             }
         }
         if (curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, (long)s->timeout) ||
+            curl_easy_setopt(state->curl, CURLOPT_USERAGENT,
+                             "QEMU/" QEMU_VERSION) ||
             curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
                              (void *)curl_read_cb) ||
             curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state) ||