From nobody Mon Feb 9 09:15:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584987176; cv=none; d=zohomail.com; s=zohoarc; b=goxF2B+WGIxTZ5nJy+scjzu4Lli09fO7oYrZYznsoOmvW7Jxq0DKPK0XK4Yz9vCond81i8KNaFBCL7qGwB8MzQEa0+ikcJAm4cqfM0Rp0xEj+kZ530mRPH8BqI7A6VctCKm3tt/dlq0AKiJjx80piAxgmD5rJOPdjlitgMPYs+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987176; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bA8zCiw+4wo8nhoCuEpJQWyoPVWdNr/vT1740uy6GsY=; b=TIAFQPc3k/UQF21ULpiTnWxDjFxot/8sDCOHsUpPf3CNYYIuzqNed4gdk2sz2LZxCiFFBYuzHTKjadstTVh6d33zLe/0HBpSUjIAE+hIOBOrN5ndkc0CzkwZ0p/gnwhGDdRFMiICMBXBkvpETuCuxVV4VVTsbkGAx5vpjRXeTvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1584987176374894.0343527875972; Mon, 23 Mar 2020 11:12:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-4xfkTbtMOb27FJ3zq2mObQ-1; Mon, 23 Mar 2020 14:12:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DA351084424; Mon, 23 Mar 2020 18:12:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3F3060BE0; Mon, 23 Mar 2020 18:12:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8924586385; Mon, 23 Mar 2020 18:12:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02NICKIL009540 for ; Mon, 23 Mar 2020 14:12:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 098CC8D574; Mon, 23 Mar 2020 18:12:20 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83ED89B918 for ; Mon, 23 Mar 2020 18:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987174; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bA8zCiw+4wo8nhoCuEpJQWyoPVWdNr/vT1740uy6GsY=; b=OubzEPZz7ImnP3FNDP2xZs+c+N44k5zgOdDXtEXSp6MOMmbD59sun/lRczytE6teBL5Omn vAGqtxfCn6msmhavDjwWPiiLKYlW5VIGIC2mXXuFgDOQiCGvGr9sYkcSgGHXNzDCjQPqe8 9ewpheH7EKEz8TSnl2S23lwBC1IFeCo= X-MC-Unique: 4xfkTbtMOb27FJ3zq2mObQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/14] qemuBlockGetBackingStoreString: Properly handle 'http/s' with cookies and others Date: Mon, 23 Mar 2020 19:12:03 +0100 Message-Id: <7a686dfbeac9998a4aecf6b0832c7bd8ef0e4460.1584986997.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Format cookies into the backing store string without encryption as they will not be visible on the command line when formatting a 'target' only string. In cases when cookies or other options are used we must use the JSON format rather than pure URI. Add tests to validate the scenario. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 12 ++++++++++- tests/qemublocktest.c | 2 ++ .../network-http-curlopts-srconly.json | 17 ++++++++++++++++ .../xml2json/network-http-curlopts.json | 15 ++++++++++++++ .../xml2json/network-http-curlopts.xml | 20 +++++++++++++++++++ .../xml2json/network-http-noopts-srconly.json | 9 +++++++++ .../xml2json/network-http-noopts.json | 14 +++++++++++++ .../xml2json/network-http-noopts.xml | 15 ++++++++++++++ 8 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 tests/qemublocktestdata/xml2json/network-http-curlopts-= srconly.json create mode 100644 tests/qemublocktestdata/xml2json/network-http-curlopts.= json create mode 100644 tests/qemublocktestdata/xml2json/network-http-curlopts.= xml create mode 100644 tests/qemublocktestdata/xml2json/network-http-noopts-sr= conly.json create mode 100644 tests/qemublocktestdata/xml2json/network-http-noopts.js= on create mode 100644 tests/qemublocktestdata/xml2json/network-http-noopts.xml diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index d9665ec4a0..648c3f1026 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -685,6 +685,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src, virJSONValuePtr ret =3D NULL; g_autoptr(virURI) uri =3D NULL; g_autofree char *uristr =3D NULL; + g_autofree char *cookiestr =3D NULL; /** * Common options: @@ -714,6 +715,9 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src, if (srcPriv && srcPriv->httpcookie) cookiealias =3D srcPriv->httpcookie->s.aes.alias; + } else { + /* format target string along with cookies */ + cookiestr =3D qemuBlockStorageSourceGetCookieString(src); } ignore_value(virJSONValueObjectCreate(&ret, @@ -721,6 +725,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr = src, "S:username", username, "S:password-secret", passwordali= as, "T:sslverify", src->sslverify, + "S:cookie", cookiestr, "S:cookie-secret", cookiealias, "P:timeout", src->timeout, "P:readahead", src->readahead, @@ -2056,7 +2061,12 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr s= rc, /* generate simplified URIs for the easy cases */ if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && src->nhosts =3D=3D 1 && - src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { + src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP && + src->timeout =3D=3D 0 && + src->ncookies =3D=3D 0 && + src->sslverify =3D=3D VIR_TRISTATE_BOOL_ABSENT && + src->timeout =3D=3D 0 && + src->readahead =3D=3D 0) { switch ((virStorageNetProtocol) src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NBD: diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 709d94fd80..8640b72116 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1212,6 +1212,8 @@ mymain(void) TEST_DISK_TO_JSON("network-qcow2-backing-chain-cache-unsafe"); TEST_DISK_TO_JSON("dir-fat-cache"); TEST_DISK_TO_JSON("network-nbd-tls"); + TEST_DISK_TO_JSON("network-http-noopts"); + TEST_DISK_TO_JSON("network-http-curlopts"); TEST_DISK_TO_JSON("block-raw-noopts"); TEST_DISK_TO_JSON("block-raw-reservations"); diff --git a/tests/qemublocktestdata/xml2json/network-http-curlopts-srconly= .json b/tests/qemublocktestdata/xml2json/network-http-curlopts-srconly.json new file mode 100644 index 0000000000..f5645ac2a6 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-http-curlopts-srconly.json @@ -0,0 +1,17 @@ +( + source only properties: + { + "driver": "https", + "url": "https://host1.example.com:443/something", + "sslverify": false, + "cookie": "test=3D123456; blurb=3Dhere" + } + backing store string: + json:{"file":{ + "driver": "https", + "url": "https://host1.example.com:443/something", + "sslverify": false, + "cookie": "test=3D123456; blurb=3Dhere" + } + } +) diff --git a/tests/qemublocktestdata/xml2json/network-http-curlopts.json b/= tests/qemublocktestdata/xml2json/network-http-curlopts.json new file mode 100644 index 0000000000..08dfd1b300 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-http-curlopts.json @@ -0,0 +1,15 @@ +{ + "node-name": "node-b-f", + "read-only": false, + "driver": "qcow2", + "file": "node-a-s", + "backing": null +} +{ + "driver": "https", + "url": "https://host1.example.com:443/something", + "sslverify": false, + "node-name": "node-a-s", + "auto-read-only": true, + "discard": "unmap" +} diff --git a/tests/qemublocktestdata/xml2json/network-http-curlopts.xml b/t= ests/qemublocktestdata/xml2json/network-http-curlopts.xml new file mode 100644 index 0000000000..a656247e2e --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-http-curlopts.xml @@ -0,0 +1,20 @@ + + + + + + + 123456 + here + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/xml2json/network-http-noopts-srconly.j= son b/tests/qemublocktestdata/xml2json/network-http-noopts-srconly.json new file mode 100644 index 0000000000..1303623036 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-http-noopts-srconly.json @@ -0,0 +1,9 @@ +( + source only properties: + { + "driver": "https", + "url": "https://host1.example.com:443/something" + } + backing store string: + https://host1.example.com:443/something +) diff --git a/tests/qemublocktestdata/xml2json/network-http-noopts.json b/te= sts/qemublocktestdata/xml2json/network-http-noopts.json new file mode 100644 index 0000000000..d577858236 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-http-noopts.json @@ -0,0 +1,14 @@ +{ + "node-name": "node-b-f", + "read-only": false, + "driver": "qcow2", + "file": "node-a-s", + "backing": null +} +{ + "driver": "https", + "url": "https://host1.example.com:443/something", + "node-name": "node-a-s", + "auto-read-only": true, + "discard": "unmap" +} diff --git a/tests/qemublocktestdata/xml2json/network-http-noopts.xml b/tes= ts/qemublocktestdata/xml2json/network-http-noopts.xml new file mode 100644 index 0000000000..f09ff7ba67 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-http-noopts.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + --=20 2.24.1