From nobody Wed Apr 24 23:13:57 2024 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=1584987143; cv=none; d=zohomail.com; s=zohoarc; b=LjEa5RMtAZUyEEOPkvDgo9RPJubd5eoCD8beqVy4rNvWkWz6AgmQKKpLpI5lQoD/P7VdMUOiWTNukPt1lFDNQt+BSZ+EKnwARFor6eFoQC2uJxYiGsM880fZl83TUkPGDRZg8z1mo9B/CJYHwk6wkRrs678Rlxj1uDKWyMC7idk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987143; 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=29odkf1bxreRYsdH02PQ9EVW5mjgE15jxlC7Vhj7BAg=; b=G9g6M6Fr55OXw9u2qi9p/gi4UKjET7I2+xFNGckfvcHfm8lEzJtc3swAuzkBaJkrb2JAUwUcR1IeGOQ4R2S7wJesD95q+XNbH7mq0Vc8vI4htuUTc3MIk/8f30HHjPjtSKpe2i9gE7R8iNc3hfKiQi9Dg9xaNMu4U6+JczMNzUo= 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 1584987143464204.03189285268797; Mon, 23 Mar 2020 11:12:23 -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-267-V6MV-CnYMu6KuoIdMujbLg-1; Mon, 23 Mar 2020 14:12:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 696538010CA; Mon, 23 Mar 2020 18:12:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09F9110002AE; Mon, 23 Mar 2020 18:12:13 +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 194D018089CD; Mon, 23 Mar 2020 18:12:11 +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 02NIC9cr009438 for ; Mon, 23 Mar 2020 14:12:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0F218D574; Mon, 23 Mar 2020 18:12:09 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55EE79B934 for ; Mon, 23 Mar 2020 18:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987142; 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=29odkf1bxreRYsdH02PQ9EVW5mjgE15jxlC7Vhj7BAg=; b=ARIuYsQoXHPfYPly6zDsWijCykSoJFuw6QMNYSR8yFhdU3GWsRuka6GQXY/AgJ8E+eiScK uhdj8Sd5XoPNQrGHgPBb5B5INgsYjB8Jxq1KUjycQxuCUHPLF0eWwH5UbvhYIdCc75G9Ob ibmut6aIZJswOZU/qJNPIUmtq1/imOA= X-MC-Unique: V6MV-CnYMu6KuoIdMujbLg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/14] conf: rename 'namespace' property of struct _virStorageSourceNVMeDef Date: Mon, 23 Mar 2020 19:11:51 +0100 Message-Id: <8fa4d1ebebea61d8e3f64c13ec8d343f9f0dea5f.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.84 on 10.5.11.22 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" While 'namespace' is not a reserved word in C, it is in C++. Our compilers are happy with it but syntax-hilighting in some editors hilights is as a keyword. Rename it to prevent confusion. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 12 ++++++------ src/hypervisor/virhostdev.c | 2 +- src/qemu/qemu_block.c | 2 +- src/util/virstoragefile.c | 4 ++-- src/util/virstoragefile.h | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e0432fc47d..f1e4d33a8d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6087,7 +6087,7 @@ virDomainDiskDefValidate(const virDomainDef *def, if (disk->src->type =3D=3D VIR_STORAGE_TYPE_NVME) { /* NVMe namespaces start from 1 */ - if (disk->src->nvme->namespace =3D=3D 0) { + if (disk->src->nvme->namespc =3D=3D 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("NVMe namespace can't be zero")); return -1; @@ -9525,7 +9525,7 @@ virDomainDiskSourceNVMeParse(xmlNodePtr node, { g_autoptr(virStorageSourceNVMeDef) nvme =3D NULL; g_autofree char *type =3D NULL; - g_autofree char *namespace =3D NULL; + g_autofree char *namespc =3D NULL; g_autofree char *managed =3D NULL; xmlNodePtr address; @@ -9544,16 +9544,16 @@ virDomainDiskSourceNVMeParse(xmlNodePtr node, return -1; } - if (!(namespace =3D virXMLPropString(node, "namespace"))) { + if (!(namespc =3D virXMLPropString(node, "namespace"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing 'namespace' attribute to disk source")); return -1; } - if (virStrToLong_ull(namespace, NULL, 10, &nvme->namespace) < 0) { + if (virStrToLong_ull(namespc, NULL, 10, &nvme->namespc) < 0) { virReportError(VIR_ERR_XML_ERROR, _("malformed namespace '%s'"), - namespace); + namespc); return -1; } @@ -24664,7 +24664,7 @@ virDomainDiskSourceNVMeFormat(virBufferPtr attrBuf, virBufferAddLit(attrBuf, " type=3D'pci'"); virBufferAsprintf(attrBuf, " managed=3D'%s'", virTristateBoolTypeToString(nvme->managed)); - virBufferAsprintf(attrBuf, " namespace=3D'%llu'", nvme->namespace); + virBufferAsprintf(attrBuf, " namespace=3D'%llu'", nvme->namespc); virPCIDeviceAddressFormat(childBuf, nvme->pciAddr, false); } diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c index 6565cebe57..9017cc3be8 100644 --- a/src/hypervisor/virhostdev.c +++ b/src/hypervisor/virhostdev.c @@ -2212,7 +2212,7 @@ virHostdevGetNVMeDeviceList(virNVMeDeviceListPtr nvme= Devices, continue; if (!(dev =3D virNVMeDeviceNew(&srcNVMe->pciAddr, - srcNVMe->namespace, + srcNVMe->namespc, srcNVMe->managed))) return -1; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 5c85ddd44c..22ea2fe018 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1008,7 +1008,7 @@ qemuBlockStorageSourceGetNVMeProps(virStorageSourcePt= r src) ignore_value(virJSONValueObjectCreate(&ret, "s:driver", "nvme", "s:device", pciAddr, - "U:namespace", nvme->namespace, + "U:namespace", nvme->namespc, NULL)); return ret; } diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e723cc9410..ca39391379 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2052,7 +2052,7 @@ virStorageSourceNVMeDefCopy(const virStorageSourceNVM= eDef *src) ret =3D g_new0(virStorageSourceNVMeDef, 1); - ret->namespace =3D src->namespace; + ret->namespc =3D src->namespc; ret->managed =3D src->managed; virPCIDeviceAddressCopy(&ret->pciAddr, &src->pciAddr); return ret; @@ -2069,7 +2069,7 @@ virStorageSourceNVMeDefIsEqual(const virStorageSource= NVMeDef *a, if (!a || !b) return false; - if (a->namespace !=3D b->namespace || + if (a->namespc !=3D b->namespc || a->managed !=3D b->managed || !virPCIDeviceAddressEqual(&a->pciAddr, &b->pciAddr)) return false; diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index f2a73feb6a..9427057f94 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -245,7 +245,7 @@ struct _virStorageSourceInitiatorDef { typedef struct _virStorageSourceNVMeDef virStorageSourceNVMeDef; typedef virStorageSourceNVMeDef *virStorageSourceNVMeDefPtr; struct _virStorageSourceNVMeDef { - unsigned long long namespace; + unsigned long long namespc; int managed; /* enum virTristateBool */ virPCIDeviceAddress pciAddr; --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1584987153; cv=none; d=zohomail.com; s=zohoarc; b=cq6bgwK5hsO/iQMOfd9DQu2QgcxjEL8s5IlEIxjQBWEL2tklIHQMFTtgtZ2EnP+Hh3vVwjnz+d6vYZ42FrLCYkqUygtoqH3MEsrS9hJE5vbw9GDKFU4QF4b3cSXFYrYBn2KEd8yTWW16n5j8NSmPQpTPLOekhH6a0xQALMMJmLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987153; 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=tEC0xbXP8VbPJ5Ltj2zgT5kU6OagHOUTaMKpFqlEzMM=; b=Jb5qLnCmRUqiID29cAtG5Q1HUxn1nHMlQf/v55sGJfekHYjfPSyic4UexdGSy8Whne6lB9mSDNWGCMfYqu3SSbfp8AQCy0hHzVRkxj+BRBjCam4J7DFrRiB0lovYmEFxjTbQfXX5mag/FyaFuuhEN2RweasHwWdrl5AgOPKlonk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.74]) by mx.zohomail.com with SMTPS id 1584987153188460.66415662688894; Mon, 23 Mar 2020 11:12:33 -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-452-_YBZMr_zM4a-QtziariGdg-1; Mon, 23 Mar 2020 14:12:29 -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 4A1DA1083E85; Mon, 23 Mar 2020 18:12:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1956E60BE0; Mon, 23 Mar 2020 18:12:24 +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 BD9D618089D7; Mon, 23 Mar 2020 18:12:23 +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 02NICA6m009444 for ; Mon, 23 Mar 2020 14:12:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id A66E29B93A; Mon, 23 Mar 2020 18:12:10 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BA9B9B934 for ; Mon, 23 Mar 2020 18:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987151; 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=tEC0xbXP8VbPJ5Ltj2zgT5kU6OagHOUTaMKpFqlEzMM=; b=A2ukdhzuiizqMC9oZAvbHt0PU4G+nWs/v/oGfdjj4HxX7N6vaEyvH7rvdb+hZZjtcLdDEm f7sQxzFZ86/8XYn9PBsjE0HRTicRt0T+2b7xPYNIZAgPTXVo9QUxUsEp2zen/vJ8Rlqvse 8yTUtY4x6/AO+Ze66mkmgmsIOc46tq4= X-MC-Unique: _YBZMr_zM4a-QtziariGdg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/14] qemublocktest: xml->json: Add test for NVMe Date: Mon, 23 Mar 2020 19:11:52 +0100 Message-Id: <25769368cc32e6b5e635f51d25d3631d2c824964.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" Based on the configuration from the only qemuxml2argv test. Signed-off-by: Peter Krempa --- tests/qemublocktest.c | 2 ++ .../xml2json/nvme-raw-noopts-srconly.json | 5 +++++ .../xml2json/nvme-raw-noopts.json | 14 ++++++++++++++ .../qemublocktestdata/xml2json/nvme-raw-noopts.xml | 13 +++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconl= y.json create mode 100644 tests/qemublocktestdata/xml2json/nvme-raw-noopts.json create mode 100644 tests/qemublocktestdata/xml2json/nvme-raw-noopts.xml diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index fca8939fbb..4c3e05b6b5 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1203,6 +1203,8 @@ mymain(void) TEST_DISK_TO_JSON("block-raw-noopts"); TEST_DISK_TO_JSON("block-raw-reservations"); + TEST_DISK_TO_JSON("nvme-raw-noopts"); + #define TEST_JSON_TO_JSON(nme) \ do { \ jsontojsondata.name =3D nme; \ diff --git a/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json new file mode 100644 index 0000000000..ed55c08cbf --- /dev/null +++ b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json @@ -0,0 +1,5 @@ +{ + "driver": "nvme", + "device": "0000:01:00.0", + "namespace": 1 +} diff --git a/tests/qemublocktestdata/xml2json/nvme-raw-noopts.json b/tests/= qemublocktestdata/xml2json/nvme-raw-noopts.json new file mode 100644 index 0000000000..e18e96099c --- /dev/null +++ b/tests/qemublocktestdata/xml2json/nvme-raw-noopts.json @@ -0,0 +1,14 @@ +{ + "node-name": "0123456789ABCDEF0123456789ABCDE", + "read-only": false, + "driver": "raw", + "file": "0123456789ABCDEF0123456789ABCDE" +} +{ + "driver": "nvme", + "device": "0000:01:00.0", + "namespace": 1, + "node-name": "0123456789ABCDEF0123456789ABCDE", + "auto-read-only": true, + "discard": "unmap" +} diff --git a/tests/qemublocktestdata/xml2json/nvme-raw-noopts.xml b/tests/q= emublocktestdata/xml2json/nvme-raw-noopts.xml new file mode 100644 index 0000000000..1e4dbd6e56 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/nvme-raw-noopts.xml @@ -0,0 +1,13 @@ + + + +
+ + + + + + + + + --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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=1584987157; cv=none; d=zohomail.com; s=zohoarc; b=hzBAZb9ND5rGM/7M9HtKx3m1cpmrDCiZH1uj+8fMG2z9qg/RPorsXcFh8F7oRRoliR3tQfEf7kH7xyYTH1SGKRlBRxtJEtA7GpoT/C7V6aEBWMNsIBHZYzoP7+uuk1PyMH9OhL9diQis/T0jpgdsA1tSZ3VxKB+k/S8ZSd6jr6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987157; 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=2ihiIs4wZKKflAjOShsW084cAesnsKR+u/8QlbE/hsI=; b=EIcETDEdsZ26umqfOec6za58edrIHV7Bxktp7dTcGsUXnf5bRlBnduIVr9piJxCfp68YrDm5Myd5bOUGDeKcQDAPKRVsmn7obsMqIkQbOmLZyJNgfmUueezZMAGvnygGGholPIIuOtwfxNx/kKYrkCEKZ8r1qP/rebqH1vJAfVc= 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 1584987157054244.01786289239897; Mon, 23 Mar 2020 11:12:37 -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-465-_jUA0t6UNG-x9T-MHU8uOw-1; Mon, 23 Mar 2020 14:12:33 -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 AC9FC8010E8; Mon, 23 Mar 2020 18:12:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FBC260BE0; Mon, 23 Mar 2020 18:12:27 +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 1EF1318089D7; Mon, 23 Mar 2020 18:12:27 +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 02NICBif009449 for ; Mon, 23 Mar 2020 14:12:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7B43A9B934; Mon, 23 Mar 2020 18:12:11 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 017919B93C for ; Mon, 23 Mar 2020 18:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987156; 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=2ihiIs4wZKKflAjOShsW084cAesnsKR+u/8QlbE/hsI=; b=PXc6ee7LR2RH3/015HE5MTM5hF/fZSiXkO6LIEj5WGNuYpGOjxiyQhRa7EeI/p6Plao7EU CqmwQisOKEtYRXaBduL0ud+x5gCBihcXgF4ztplzy6g2pR8f5OSEvnKCB3d69/9iLigP1F in5UvxjTEtBubM1XS/tSVHoCuoToVts= X-MC-Unique: _jUA0t6UNG-x9T-MHU8uOw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/14] virDomainDiskSourceNVMeFormat: Format only valid 'managed' values Date: Mon, 23 Mar 2020 19:11:53 +0100 Message-Id: <229554d8a10a0602ba7079eeed09d3b218e2b8c2.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" VIR_TRISTATE_BOOL_ABSENT which maps to the 'default' string would not be parsed back, so we shouldn't format it either. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f1e4d33a8d..f6a225e4e6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -24662,8 +24662,9 @@ virDomainDiskSourceNVMeFormat(virBufferPtr attrBuf, const virStorageSourceNVMeDef *nvme) { virBufferAddLit(attrBuf, " type=3D'pci'"); - virBufferAsprintf(attrBuf, " managed=3D'%s'", - virTristateBoolTypeToString(nvme->managed)); + if (nvme->managed !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(attrBuf, " managed=3D'%s'", + virTristateBoolTypeToString(nvme->managed)); virBufferAsprintf(attrBuf, " namespace=3D'%llu'", nvme->namespc); virPCIDeviceAddressFormat(childBuf, nvme->pciAddr, false); } --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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=1584987146; cv=none; d=zohomail.com; s=zohoarc; b=lw325jWn0ASRwfEmdlkLj16IHmOJDmYCURGJOkIzR6wfJV6LjYGMoSqGISKmyWTNpQbaANjqBM85RpFJoUtVtXMWZ/MkMKZ+TPch81KNdAQPpYLA1bLP4XRv8YBnIBq5k5lyNP6PpPOeptg9uTcIZMx3C18k1faAnFPWOhgn/Ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987146; 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=5a6vvMDgttAUzGMet9BCxakkR43QB9L8swqGYW1FWGc=; b=izlN96H9UzaBbav4KftPVG7nzWJNwMoMRbqWNbkwx5E43w/tv4Jf3JZk6IeDfZlPZSPwnAqir9D/0UIsvGBn0rUfKwB3gTKNBJRovKnrCMS8SafT9qtbGHamaM1NOARfaVKKmomO8/P5fYvPMMbKJc01kgics5ofCc/Oz+rKR1Y= 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 1584987146262271.69834479469057; Mon, 23 Mar 2020 11:12:26 -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-19-YD6wa_mQOueyx9D660uB5g-1; Mon, 23 Mar 2020 14:12:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 772E11083E81; Mon, 23 Mar 2020 18:12:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B9955DA81; Mon, 23 Mar 2020 18:12:16 +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 E95E518089CF; Mon, 23 Mar 2020 18:12:15 +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 02NICCjj009457 for ; Mon, 23 Mar 2020 14:12:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 50FA59B93E; Mon, 23 Mar 2020 18:12:12 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAE369B93C for ; Mon, 23 Mar 2020 18:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987145; 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=5a6vvMDgttAUzGMet9BCxakkR43QB9L8swqGYW1FWGc=; b=fJFe4CTzoyZW5ru1az5EYFbeUI3L2M1qGPRH9mh33Qh6CkamTZkJVAz5EKPVvZ8jnpLTJs FxwcoBnMqW3ys/GIhv1rEfcijJ+ylVgg9WeEYGw94fHOYI3BESPd292iqVBW3vZC0vvJX8 vx7FQ8wEjm3FyeYRXi00JVCjQ3C+//4= X-MC-Unique: YD6wa_mQOueyx9D660uB5g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/14] qemublocktest: xml->json: Refactor cleanup in test case functions Date: Mon, 23 Mar 2020 19:11:54 +0100 Message-Id: <78f8a56b462c20294681a3719592ebe0e913791f.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.14 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" Use automatic variable clearing and remove the cleanup sections of testQemuDiskXMLToProps, testQemuDiskXMLToPropsValidateSchema and testQemuDiskXMLToPropsValidateFile. testQemuDiskXMLToPropsValidateFileSrcOnly already uses new helpers. Signed-off-by: Peter Krempa --- tests/qemublocktest.c | 76 +++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 4c3e05b6b5..dfcf7552c1 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -259,39 +259,38 @@ testQemuDiskXMLToProps(const void *opaque) g_autoptr(virDomainDef) vmdef =3D NULL; virDomainDiskDefPtr disk =3D NULL; virStorageSourcePtr n; - virJSONValuePtr formatProps =3D NULL; - virJSONValuePtr storageProps =3D NULL; + g_autoptr(virJSONValue) formatProps =3D NULL; + g_autoptr(virJSONValue) storageProps =3D NULL; g_autoptr(virJSONValue) storageSrcOnlyProps =3D NULL; - char *xmlpath =3D NULL; - char *xmlstr =3D NULL; - int ret =3D -1; + g_autofree char *xmlpath =3D NULL; + g_autofree char *xmlstr =3D NULL; xmlpath =3D g_strdup_printf("%s%s.xml", testQemuDiskXMLToJSONPath, dat= a->name); if (virTestLoadFile(xmlpath, &xmlstr) < 0) - goto cleanup; + return -1; /* qemu stores node names in the status XML portion */ if (!(disk =3D virDomainDiskDefParse(xmlstr, data->driver->xmlopt, VIR_DOMAIN_DEF_PARSE_STATUS))) - goto cleanup; + return -1; if (!(vmdef =3D virDomainDefNew()) || virDomainDiskInsert(vmdef, disk) < 0) - goto cleanup; + return -1; if (qemuCheckDiskConfig(disk, vmdef, data->qemuCaps) < 0 || qemuDomainDeviceDefValidateDisk(disk, data->qemuCaps) < 0) { VIR_TEST_VERBOSE("invalid configuration for disk"); - goto cleanup; + return -1; } for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { if (testQemuDiskXMLToJSONFakeSecrets(n) < 0) - goto cleanup; + return -1; if (qemuDomainValidateStorageSource(n, data->qemuCaps) < 0) - goto cleanup; + return -1; qemuDomainPrepareDiskSourceData(disk, n); @@ -300,27 +299,20 @@ testQemuDiskXMLToProps(const void *opaque) !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false, true))) { if (!data->fail) { VIR_TEST_VERBOSE("failed to generate qemu blockdev props"); - goto cleanup; + return -1; } } else if (data->fail) { VIR_TEST_VERBOSE("qemu blockdev props should have failed"); - goto cleanup; + return -1; } if (VIR_APPEND_ELEMENT(data->props, data->nprops, formatProps) < 0= || VIR_APPEND_ELEMENT(data->props, data->nprops, storageProps) < = 0 || VIR_APPEND_ELEMENT(data->propssrc, data->npropssrc, storageSrc= OnlyProps) < 0) - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - virJSONValueFree(formatProps); - virJSONValueFree(storageProps); - VIR_FREE(xmlpath); - VIR_FREE(xmlstr); - return ret; + return 0; } @@ -328,9 +320,6 @@ static int testQemuDiskXMLToPropsValidateSchema(const void *opaque) { struct testQemuDiskXMLToJSONData *data =3D (void *) opaque; - virBuffer debug =3D VIR_BUFFER_INITIALIZER; - char *propsstr =3D NULL; - char *debugmsg =3D NULL; int ret =3D 0; size_t i; @@ -338,35 +327,31 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaq= ue) return EXIT_AM_SKIP; for (i =3D 0; i < data->nprops; i++) { + g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; + if (testQEMUSchemaValidate(data->props[i], data->schemaroot, data->schema, &debug) < 0) { - debugmsg =3D virBufferContentAndReset(&debug); - propsstr =3D virJSONValueToString(data->props[i], true); + g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); + g_autofree char *propsstr =3D virJSONValueToString(data->props= [i], true); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", propsstr, NULLSTR(debugmsg)); - VIR_FREE(debugmsg); - VIR_FREE(propsstr); ret =3D -1; } - - virBufferFreeAndReset(&debug); } for (i =3D 0; i < data->npropssrc; i++) { + g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; + if (testQEMUSchemaValidate(data->propssrc[i], data->schemaroot, data->schema, &debug) < 0) { - debugmsg =3D virBufferContentAndReset(&debug); - propsstr =3D virJSONValueToString(data->propssrc[i], true); + g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); + g_autofree char *propsstr =3D virJSONValueToString(data->props= src[i], true); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", propsstr, NULLSTR(debugmsg)); - VIR_FREE(debugmsg); - VIR_FREE(propsstr); ret =3D -1; } - - virBufferFreeAndReset(&debug); } return ret; @@ -378,9 +363,8 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque) { struct testQemuDiskXMLToJSONData *data =3D (void *) opaque; virBuffer buf =3D VIR_BUFFER_INITIALIZER; - char *jsonpath =3D NULL; - char *actual =3D NULL; - int ret =3D -1; + g_autofree char *jsonpath =3D NULL; + g_autofree char *actual =3D NULL; size_t i; if (data->fail) @@ -389,23 +373,17 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque) jsonpath =3D g_strdup_printf("%s%s.json", testQemuDiskXMLToJSONPath, d= ata->name); for (i =3D 0; i < data->nprops; i++) { - char *jsonstr; + g_autofree char *jsonstr =3D NULL; if (!(jsonstr =3D virJSONValueToString(data->props[i], true))) - goto cleanup; + return -1; virBufferAdd(&buf, jsonstr, -1); - VIR_FREE(jsonstr); } actual =3D virBufferContentAndReset(&buf); - ret =3D virTestCompareToFile(actual, jsonpath); - - cleanup: - VIR_FREE(jsonpath); - VIR_FREE(actual); - return ret; + return virTestCompareToFile(actual, jsonpath); } --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1584987251; cv=none; d=zohomail.com; s=zohoarc; b=erPrMpJxvvjm8N6W+vxQbmSXJM0PBdg8XRJWeknw94ttRbygL9iSK+bwDKI0i/AH9B6grDNRAVlNHJmZXuIwdNgiVp/xkPd7riX3rob8QrO93b2Ltsb6vWHOpDvtIgXZRNNd4ghLkazNdzyTV1qfTWBfsEIET/hX3uhs9qCeDZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987251; 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=gJaanq6dTifUJ8SNehMbJ17cR1bj4DdNh+HyAt8BeEg=; b=maJx/HR/5rD9/Tz25ygQxA8Jv+rii4ykFm6LbjgHl3pEI6nNdxPG4dVrXjmeW8MtEIcpW50JC3Lco0PKSQ1XEcUKI3fvejDx2BSSI1q9pLpF2wvpKoLVEH4PHn2ZJndJgxMOFc6mL+HxzX651rVwwS6/wYPkWQMPmN4e+1R1XYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.74]) by mx.zohomail.com with SMTPS id 1584987251833837.1414629762519; Mon, 23 Mar 2020 11:14:11 -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-452-9iw1PrDOMZiXgEjlZpR_fA-1; Mon, 23 Mar 2020 14:12:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4960A107ACCA; Mon, 23 Mar 2020 18:12:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 181A119C4F; Mon, 23 Mar 2020 18:12:24 +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 B979B18089D6; Mon, 23 Mar 2020 18:12:23 +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 02NICD3k009467 for ; Mon, 23 Mar 2020 14:12:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 23CA08D574; Mon, 23 Mar 2020 18:12:13 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F3349B93C for ; Mon, 23 Mar 2020 18:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987250; 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=gJaanq6dTifUJ8SNehMbJ17cR1bj4DdNh+HyAt8BeEg=; b=hhEoQOKRiJGMKcxWoWA5WKb5Yk4NbksYFhQUliKzaaIMonsuIj97OU5RHkrFSJSiZ9S//B ZlkCSG/mmAy0oMTCTTOEDOzIEBZLcQAGWSrxSmaB6LEFfSqW3KY+nDYw0AjRau+H07wnMT ehXFExqGdHJU+2GMKjB6CcxhKo98m8w= X-MC-Unique: 9iw1PrDOMZiXgEjlZpR_fA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/14] testQemuDiskXMLToPropsValidateFileSrcOnly: Move together with rest of xml->json code Date: Mon, 23 Mar 2020 19:11:55 +0100 Message-Id: <1d015915a1a8423d42b6fa2973771db8e5b1a236.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.84 on 10.5.11.23 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" The function was misplaced. Group it together with other helper functions for testing disk XML to qemu JSON props conversion. Signed-off-by: Peter Krempa --- tests/qemublocktest.c | 61 ++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index dfcf7552c1..312af0d962 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -387,6 +387,37 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque) } +static int +testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque) +{ + struct testQemuDiskXMLToJSONData *data =3D (void *) opaque; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + g_autofree char *jsonpath =3D NULL; + g_autofree char *actual =3D NULL; + size_t i; + + if (data->fail) + return EXIT_AM_SKIP; + + jsonpath =3D g_strdup_printf("%s%s-srconly.json", testQemuDiskXMLToJSO= NPath, + data->name); + + for (i =3D 0; i < data->npropssrc; i++) { + g_autofree char *jsonstr =3D NULL; + + if (!(jsonstr =3D virJSONValueToString(data->propssrc[i], true))) + return -1; + + virBufferAdd(&buf, jsonstr, -1); + } + + actual =3D virBufferContentAndReset(&buf); + + return virTestCompareToFile(actual, jsonpath); +} + + + struct testQemuImageCreateData { const char *name; const char *backingname; @@ -515,36 +546,6 @@ testQemuImageCreate(const void *opaque) } -static int -testQemuDiskXMLToPropsValidateFileSrcOnly(const void *opaque) -{ - struct testQemuDiskXMLToJSONData *data =3D (void *) opaque; - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - g_autofree char *jsonpath =3D NULL; - g_autofree char *actual =3D NULL; - size_t i; - - if (data->fail) - return EXIT_AM_SKIP; - - jsonpath =3D g_strdup_printf("%s%s-srconly.json", testQemuDiskXMLToJSO= NPath, - data->name); - - for (i =3D 0; i < data->npropssrc; i++) { - g_autofree char *jsonstr =3D NULL; - - if (!(jsonstr =3D virJSONValueToString(data->propssrc[i], true))) - return -1; - - virBufferAdd(&buf, jsonstr, -1); - } - - actual =3D virBufferContentAndReset(&buf); - - return virTestCompareToFile(actual, jsonpath); -} - - static const char *bitmapDetectPrefix =3D "qemublocktestdata/bitmap/"; static void --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1584987156; cv=none; d=zohomail.com; s=zohoarc; b=HDLsDE1uPYZuzTAu1+fa4kVyx5Kkg0zYksz7Ynbj0E01E5LpuJKt3hsVlUAc5FzWc8ovn8TTB3oKDcSqMA1AWgkv0CDYwwk3GqSG9f2rPVj9b5Q1VFuPmLS90Wp608C2kD1CBvaSo8h14NDuV+FyOLx2JHwB8tR75iRKNA3jMz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987156; 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=qUXRbS2ci33hPEDQeDed6qVa+QwR+OTNFVw4gvVYaNc=; b=MKy2x+wmSU6LQB8AAKmc4G3A1I/Sl+4YetT97ShrxalmIg2t8ZL0HKzCDzRponqNTa3qRakICLGeMcMiQ+Lkf/0ttzjxcxQRa5MMbgyJVocQXQsEDnoHLggcwCl1NwbTdxv5zPO6UVJfrMa4jGAwqWSsEMB/19I0ZsVWzES10w8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.74]) by mx.zohomail.com with SMTPS id 1584987156946741.5687117872874; Mon, 23 Mar 2020 11:12:36 -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-228-pL7v60PIPfiTMR0RbY6OVg-1; Mon, 23 Mar 2020 14:12:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2187A1922963; Mon, 23 Mar 2020 18:12:28 +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 EBDB594B2F; Mon, 23 Mar 2020 18:12:27 +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 98A618639A; Mon, 23 Mar 2020 18:12:27 +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 02NICD3W009477 for ; Mon, 23 Mar 2020 14:12:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id EC2AA8D574; Mon, 23 Mar 2020 18:12:13 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 728DE9B93A for ; Mon, 23 Mar 2020 18:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987155; 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=qUXRbS2ci33hPEDQeDed6qVa+QwR+OTNFVw4gvVYaNc=; b=OhMP6kGMQFFfdWB6KF/PqQ2y6fSqg6LEVptvZ4XTS1r2+q2CgDB1WW2tTrZtpzRMQnqUJ2 OC3+eQqS/VLB0ox/wTMMn7Vhy3q2CamDrfZzP8sl6605GVRAEn+kPQTQQdhFHfW7KxoQGZ fMcftlJbOOgGEvC/u/YbIysDXxLzL2A= X-MC-Unique: pL7v60PIPfiTMR0RbY6OVg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/14] qemuBlockGetBackingStoreString: Add 'pretty' argument Date: Mon, 23 Mar 2020 19:11:56 +0100 Message-Id: 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.15 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" Add support for pretty-printing of the JSON variant of the output for consumption in tests. All current callers pass 'false'. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 8 +++++--- src/qemu/qemu_block.h | 3 ++- src/qemu/qemu_driver.c | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 22ea2fe018..d6cc999a43 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2027,13 +2027,15 @@ qemuBlockStorageGetCopyOnReadProps(virDomainDiskDef= Ptr disk) /** * qemuBlockGetBackingStoreString: * @src: storage source to get the string for + * @pretty: pretty-print the JSON (if applicable, used by tests) * * Formats a string used in the backing store field of a disk image which * supports backing store. Non-local storage may result in use of the json: * pseudo protocol for any complex configuration. */ char * -qemuBlockGetBackingStoreString(virStorageSourcePtr src) +qemuBlockGetBackingStoreString(virStorageSourcePtr src, + bool pretty) { int actualType =3D virStorageSourceGetActualType(src); g_autoptr(virJSONValue) backingProps =3D NULL; @@ -2100,7 +2102,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr sr= c) props =3D sliceProps; } - if (!(backingJSON =3D virJSONValueToString(props, false))) + if (!(backingJSON =3D virJSONValueToString(props, pretty))) return NULL; ret =3D g_strdup_printf("json:%s", backingJSON); @@ -2128,7 +2130,7 @@ qemuBlockStorageSourceCreateAddBacking(virStorageSour= cePtr backing, backingFormatStr =3D virStorageFileFormatTypeToString(backing-= >format); } - if (!(backingFileStr =3D qemuBlockGetBackingStoreString(backing))) + if (!(backingFileStr =3D qemuBlockGetBackingStoreString(backing, false= ))) return -1; if (virJSONValueObjectAdd(props, diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 28475b25c1..9bffe20bfb 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -178,7 +178,8 @@ qemuBlockSnapshotAddBlockdev(virJSONValuePtr actions, virStorageSourcePtr newsrc); char * -qemuBlockGetBackingStoreString(virStorageSourcePtr src) +qemuBlockGetBackingStoreString(virStorageSourcePtr src, + bool pretty) ATTRIBUTE_NONNULL(1); int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8a2cd35fa7..209f8279bd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17499,7 +17499,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, if (baseSource) { nodebase =3D baseSource->nodeformat; if (!backingPath && - !(backingPath =3D qemuBlockGetBackingStoreString(baseSourc= e))) + !(backingPath =3D qemuBlockGetBackingStoreString(baseSourc= e, false))) goto endjob; } device =3D disk->src->nodeformat; @@ -18667,7 +18667,7 @@ qemuDomainBlockCommit(virDomainPtr dom, nodebase =3D baseSource->nodeformat; device =3D qemuDomainDiskGetTopNodename(disk); if (!backingPath && top_parent && - !(backingPath =3D qemuBlockGetBackingStoreString(baseSource))) + !(backingPath =3D qemuBlockGetBackingStoreString(baseSource, f= alse))) goto endjob; if (bitmapDisableActions) { --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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=1584987187; cv=none; d=zohomail.com; s=zohoarc; b=TWgm92aDN2ztezckkG3vjH5s9w3bpxcc2ltnW82OE5Rp8RZiutulJC789UdRtGA6Uxt+LK3GMEF9byOVK5mpUXO8tGmcVGU82NrIZNjWETVK3c515OPBzIN7kBN+RBHvE2Roi4VJkNE1EREMELfhplw5ADeQVe8Vb0iOGQHKoFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987187; 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=3T6+FcmWW1NMSr37Nlu2uIQ3ex6CDhJsLF8jbjM44z4=; b=cd1l4Ul28PbRUcRiQX+0CD2mwhZyJVUSDk5WhVwkqX0Rqx21WUi9T/aFrEQTjVzb3e1K/qhLHIA0Cx+lYGG9glNcBj0xNFrbQk12kReSIpsILK4dlkVBecnSGM1zfQcO34lHUK/b9FLEpxvrnon0HCYi1CwT1CQFxGJIH0LXmpg= 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 1584987187682658.3748045926634; Mon, 23 Mar 2020 11:13:07 -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-354-Pzk0GRKRM-6Xc8a7MI8Y2A-1; Mon, 23 Mar 2020 14:12:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28199800D50; Mon, 23 Mar 2020 18:12:28 +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 F39565C545; Mon, 23 Mar 2020 18:12:27 +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 A532E8639F; Mon, 23 Mar 2020 18:12:27 +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 02NICEG3009484 for ; Mon, 23 Mar 2020 14:12:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF92A91290; Mon, 23 Mar 2020 18:12:14 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46C708D574 for ; Mon, 23 Mar 2020 18:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987186; 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=3T6+FcmWW1NMSr37Nlu2uIQ3ex6CDhJsLF8jbjM44z4=; b=VYbx9vL3zSvkPkvmHnQmBRLnSe/aKrjSxA17Dn1pNeReeg3UtbrvWREb5XOv6HGx9xXgCK RglPlKzqVD8kj9PrVCEoueD8b8CSjSn2D9PgT4xLmOzTy3wqRPPrpEYZAMfRA8WKkvYEDu n0YlF7PlG7o+rS44zGJmlVjCK024Mgk= X-MC-Unique: Pzk0GRKRM-6Xc8a7MI8Y2A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/14] testQemuDiskXMLToProps: Store all per-image data in one structure Date: Mon, 23 Mar 2020 19:11:57 +0100 Message-Id: <808a28077e4ece54a5e24ec26e7bf7b0737c7d64.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.16 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" We had two non-syncrhonized arrays holding the individual data. This was a lazy way to do it when I was adding new tests recently. Since it's hard to extend with new data to test refactor the storage of test data to use a new struct where all per-image data are kept and can be extended easily. Signed-off-by: Peter Krempa --- tests/qemublocktest.c | 90 ++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 36 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 312af0d962..47d08333f7 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -180,6 +180,13 @@ testJSONtoJSON(const void *args) } +struct testQemuDiskXMLToJSONImageData { + virJSONValuePtr formatprops; + virJSONValuePtr storageprops; + virJSONValuePtr storagepropssrc; +}; + + struct testQemuDiskXMLToJSONData { virQEMUDriverPtr driver; virHashTablePtr schema; @@ -187,11 +194,8 @@ struct testQemuDiskXMLToJSONData { const char *name; bool fail; - virJSONValuePtr *props; - size_t nprops; - - virJSONValuePtr *propssrc; - size_t npropssrc; + struct testQemuDiskXMLToJSONImageData *images; + size_t nimages; virQEMUCapsPtr qemuCaps; }; @@ -202,16 +206,13 @@ testQemuDiskXMLToPropsClear(struct testQemuDiskXMLToJ= SONData *data) { size_t i; - for (i =3D 0; i < data->nprops; i++) - virJSONValueFree(data->props[i]); - - for (i =3D 0; i < data->npropssrc; i++) - virJSONValueFree(data->propssrc[i]); - - data->nprops =3D 0; - VIR_FREE(data->props); - data->npropssrc =3D 0; - VIR_FREE(data->propssrc); + for (i =3D 0; i < data->nimages; i++) { + virJSONValueFree(data->images[i].formatprops); + virJSONValueFree(data->images[i].storageprops); + virJSONValueFree(data->images[i].storagepropssrc); + } + data->nimages =3D 0; + VIR_FREE(data->images); } @@ -286,6 +287,7 @@ testQemuDiskXMLToProps(const void *opaque) } for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { + if (testQemuDiskXMLToJSONFakeSecrets(n) < 0) return -1; @@ -306,10 +308,14 @@ testQemuDiskXMLToProps(const void *opaque) return -1; } - if (VIR_APPEND_ELEMENT(data->props, data->nprops, formatProps) < 0= || - VIR_APPEND_ELEMENT(data->props, data->nprops, storageProps) < = 0 || - VIR_APPEND_ELEMENT(data->propssrc, data->npropssrc, storageSrc= OnlyProps) < 0) + if (VIR_REALLOC_N(data->images, data->nimages + 1) < 0) return -1; + + data->images[data->nimages].formatprops =3D g_steal_pointer(&forma= tProps); + data->images[data->nimages].storageprops =3D g_steal_pointer(&stor= ageProps); + data->images[data->nimages].storagepropssrc =3D g_steal_pointer(&s= torageSrcOnlyProps); + + data->nimages++; } return 0; @@ -326,27 +332,37 @@ testQemuDiskXMLToPropsValidateSchema(const void *opaq= ue) if (data->fail) return EXIT_AM_SKIP; - for (i =3D 0; i < data->nprops; i++) { + for (i =3D 0; i < data->nimages; i++) { g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; - if (testQEMUSchemaValidate(data->props[i], data->schemaroot, + if (testQEMUSchemaValidate(data->images[i].formatprops, data->sche= maroot, data->schema, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); - g_autofree char *propsstr =3D virJSONValueToString(data->props= [i], true); + g_autofree char *propsstr =3D virJSONValueToString(data->image= s[i].formatprops, true); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", propsstr, NULLSTR(debugmsg)); ret =3D -1; } - } - for (i =3D 0; i < data->npropssrc; i++) { - g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; + virBufferFreeAndReset(&debug); - if (testQEMUSchemaValidate(data->propssrc[i], data->schemaroot, + if (testQEMUSchemaValidate(data->images[i].storageprops, data->sch= emaroot, data->schema, &debug) < 0) { g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); - g_autofree char *propsstr =3D virJSONValueToString(data->props= src[i], true); + g_autofree char *propsstr =3D virJSONValueToString(data->image= s[i].storageprops, true); + VIR_TEST_VERBOSE("json does not conform to QAPI schema"); + VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", + propsstr, NULLSTR(debugmsg)); + ret =3D -1; + } + + virBufferFreeAndReset(&debug); + + if (testQEMUSchemaValidate(data->images[i].storagepropssrc, data->= schemaroot, + data->schema, &debug) < 0) { + g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); + g_autofree char *propsstr =3D virJSONValueToString(data->image= s[i].storagepropssrc, true); VIR_TEST_VERBOSE("json does not conform to QAPI schema"); VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", propsstr, NULLSTR(debugmsg)); @@ -372,13 +388,17 @@ testQemuDiskXMLToPropsValidateFile(const void *opaque) jsonpath =3D g_strdup_printf("%s%s.json", testQemuDiskXMLToJSONPath, d= ata->name); - for (i =3D 0; i < data->nprops; i++) { - g_autofree char *jsonstr =3D NULL; + for (i =3D 0; i < data->nimages; i++) { + g_autofree char *formatprops =3D NULL; + g_autofree char *storageprops =3D NULL; - if (!(jsonstr =3D virJSONValueToString(data->props[i], true))) + if (!(formatprops =3D virJSONValueToString(data->images[i].formatp= rops, true))) return -1; - virBufferAdd(&buf, jsonstr, -1); + if (!(storageprops =3D virJSONValueToString(data->images[i].storag= eprops, true))) + return -1; + + virBufferStrcat(&buf, formatprops, storageprops, NULL); } actual =3D virBufferContentAndReset(&buf); @@ -402,10 +422,10 @@ testQemuDiskXMLToPropsValidateFileSrcOnly(const void = *opaque) jsonpath =3D g_strdup_printf("%s%s-srconly.json", testQemuDiskXMLToJSO= NPath, data->name); - for (i =3D 0; i < data->npropssrc; i++) { + for (i =3D 0; i < data->nimages; i++) { g_autofree char *jsonstr =3D NULL; - if (!(jsonstr =3D virJSONValueToString(data->propssrc[i], true))) + if (!(jsonstr =3D virJSONValueToString(data->images[i].storageprop= ssrc, true))) return -1; virBufferAdd(&buf, jsonstr, -1); @@ -1117,10 +1137,8 @@ mymain(void) #define TEST_DISK_TO_JSON_FULL(nme, fl) \ do { \ diskxmljsondata.name =3D nme; \ - diskxmljsondata.props =3D NULL; \ - diskxmljsondata.nprops =3D 0; \ - diskxmljsondata.propssrc =3D NULL; \ - diskxmljsondata.npropssrc =3D 0; \ + diskxmljsondata.images =3D NULL; \ + diskxmljsondata.nimages =3D 0; \ diskxmljsondata.fail =3D fl; \ if (virTestRun("disk xml to props " nme, testQemuDiskXMLToProps, \ &diskxmljsondata) < 0) \ --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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=1584987163; cv=none; d=zohomail.com; s=zohoarc; b=il3cqruTjWhBmlEFwl+L6yClAI5TVWSjMLVPikmEWNInLJlNo2R7uNReVp6fecIjiq3Bs4lrg3SBkTm+rPRQP0ZLfc6LUvhosKABXIOKRtB00uRjfsHxXd8rrst3G43aZMCSRqTDenqFVxI/bJIvk3l2uI7Q+folQgRSZMJgPoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987163; 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=0P22BpRHbBkelj8qmwDgQv9h0OZ1SrwyyDJj9mmud+c=; b=iVYfGk5Wo06MWXp8CBVn7px9syKRkocHx8tzsCCJdYk480FpXkKV1wG4Z9xmIXHvejzmDkCR1VWKpWOTNVopUU5HvcV0gXZ3gnwqZfL7IgfmAr8iSatl3+oDkJaSVBuE45RQGadOGUX2ls/GqkIiRcST80odKibd/4uUhfpS32A= 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 1584987163369552.337066229496; Mon, 23 Mar 2020 11:12:43 -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-341-E7E16F7PNAi0-Lcj4hZZVQ-1; Mon, 23 Mar 2020 14:12:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F1D2477; Mon, 23 Mar 2020 18:12:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3ABD15DA84; Mon, 23 Mar 2020 18:12:32 +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 E2AF1180880D; Mon, 23 Mar 2020 18:12:31 +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 02NICFwZ009489 for ; Mon, 23 Mar 2020 14:12:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id E4A7491290; Mon, 23 Mar 2020 18:12:15 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CF9A8D574 for ; Mon, 23 Mar 2020 18:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987162; 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=0P22BpRHbBkelj8qmwDgQv9h0OZ1SrwyyDJj9mmud+c=; b=fWFu94qB2Y0mDxZRTRPFFEUP9ziumUWMVipJ7Lt0dUT2Dq2Jv7ziOjAS1Ck2SRs0CKXZAt sRh7IVVNAFzacPavb/OvUuwwHDvMvXpNuuJcZyRQ+EfLgYagdqvlvuz0EBCvbw7O/ctkwA OyM4wzErJei67SmVHs698OoaSso6SOU= X-MC-Unique: E7E16F7PNAi0-Lcj4hZZVQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/14] qemublocktest: Test backing store strings Date: Mon, 23 Mar 2020 19:11:58 +0100 Message-Id: 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.14 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" With -blockdev libvirt provides the string which is recorded as 'backing store' property of an image to qemu. Add testing for qemuBlockGetBackingStoreString which generates these strings as there's logic which determines which format to use. Signed-off-by: Peter Krempa --- tests/qemublocktest.c | 20 ++- .../xml2json/block-raw-noopts-srconly.json | 13 +- .../block-raw-reservations-srconly.json | 13 +- .../xml2json/dir-fat-cache-srconly.json | 15 +- .../xml2json/dir-fat-floppy-srconly.json | 15 +- .../xml2json/dir-fat-readonly-srconly.json | 15 +- ...ile-backing_basic-aio_threads-srconly.json | 68 +++++---- ...acking_basic-cache-directsync-srconly.json | 68 +++++---- ...file-backing_basic-cache-none-srconly.json | 68 +++++---- ...le-backing_basic-cache-unsafe-srconly.json | 68 +++++---- ...backing_basic-cache-writeback-srconly.json | 68 +++++---- ...king_basic-cache-writethrough-srconly.json | 68 +++++---- .../file-backing_basic-detect-srconly.json | 68 +++++---- .../file-backing_basic-noopts-srconly.json | 52 ++++--- ...le-backing_basic-unmap-detect-srconly.json | 68 +++++---- ...le-backing_basic-unmap-ignore-srconly.json | 68 +++++---- .../file-backing_basic-unmap-srconly.json | 68 +++++---- .../xml2json/file-bochs-noopts-srconly.json | 13 +- .../xml2json/file-cloop-noopts-srconly.json | 13 +- .../xml2json/file-dmg-noopts-srconly.json | 13 +- .../xml2json/file-ploop-noopts-srconly.json | 13 +- ...cow2-backing-chain-encryption-srconly.json | 26 ++-- ...le-qcow2-backing-chain-noopts-srconly.json | 130 ++++++++++++------ ...w2-backing-chain-unterminated-srconly.json | 26 ++-- .../xml2json/file-raw-aio_native-srconly.json | 13 +- .../xml2json/file-raw-luks-srconly.json | 13 +- .../xml2json/file-raw-noopts-srconly.json | 13 +- .../xml2json/file-vdi-noopts-srconly.json | 13 +- .../xml2json/file-vhd-noopts-srconly.json | 13 +- .../xml2json/file-vpc-noopts-srconly.json | 13 +- .../xml2json/network-nbd-tls-srconly.json | 19 ++- ...w2-backing-chain-cache-unsafe-srconly.json | 68 ++++++--- ...backing-chain-encryption_auth-srconly.json | 68 ++++++--- .../xml2json/nvme-raw-noopts-srconly.json | 19 ++- 34 files changed, 876 insertions(+), 433 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 47d08333f7..709d94fd80 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -184,6 +184,7 @@ struct testQemuDiskXMLToJSONImageData { virJSONValuePtr formatprops; virJSONValuePtr storageprops; virJSONValuePtr storagepropssrc; + char *backingstore; }; @@ -210,6 +211,7 @@ testQemuDiskXMLToPropsClear(struct testQemuDiskXMLToJSO= NData *data) virJSONValueFree(data->images[i].formatprops); virJSONValueFree(data->images[i].storageprops); virJSONValueFree(data->images[i].storagepropssrc); + g_free(data->images[i].backingstore); } data->nimages =3D 0; VIR_FREE(data->images); @@ -287,6 +289,7 @@ testQemuDiskXMLToProps(const void *opaque) } for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { + g_autofree char *backingstore =3D NULL; if (testQemuDiskXMLToJSONFakeSecrets(n) < 0) return -1; @@ -298,7 +301,8 @@ testQemuDiskXMLToProps(const void *opaque) if (!(formatProps =3D qemuBlockStorageSourceGetBlockdevProps(n, n-= >backingStore)) || !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProp= s(n, false, true, true)) || - !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false, true))) { + !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, fa= lse, false, true)) || + !(backingstore =3D qemuBlockGetBackingStoreString(n, true))) { if (!data->fail) { VIR_TEST_VERBOSE("failed to generate qemu blockdev props"); return -1; @@ -314,6 +318,7 @@ testQemuDiskXMLToProps(const void *opaque) data->images[data->nimages].formatprops =3D g_steal_pointer(&forma= tProps); data->images[data->nimages].storageprops =3D g_steal_pointer(&stor= ageProps); data->images[data->nimages].storagepropssrc =3D g_steal_pointer(&s= torageSrcOnlyProps); + data->images[data->nimages].backingstore =3D g_steal_pointer(&back= ingstore); data->nimages++; } @@ -425,10 +430,21 @@ testQemuDiskXMLToPropsValidateFileSrcOnly(const void = *opaque) for (i =3D 0; i < data->nimages; i++) { g_autofree char *jsonstr =3D NULL; + virBufferAddLit(&buf, "(\n"); + virBufferAdjustIndent(&buf, 2); + virBufferAddLit(&buf, "source only properties:\n"); + if (!(jsonstr =3D virJSONValueToString(data->images[i].storageprop= ssrc, true))) return -1; - virBufferAdd(&buf, jsonstr, -1); + virBufferAddStr(&buf, jsonstr); + + virBufferAddLit(&buf, "backing store string:\n"); + virBufferAddStr(&buf, data->images[i].backingstore); + + virBufferTrim(&buf, "\n"); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n)\n"); } actual =3D virBufferContentAndReset(&buf); diff --git a/tests/qemublocktestdata/xml2json/block-raw-noopts-srconly.json= b/tests/qemublocktestdata/xml2json/block-raw-noopts-srconly.json index 72f9067353..07f7390433 100644 --- a/tests/qemublocktestdata/xml2json/block-raw-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/block-raw-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "host_device", - "filename": "/dev/blah" -} +( + source only properties: + { + "driver": "host_device", + "filename": "/dev/blah" + } + backing store string: + /dev/blah +) diff --git a/tests/qemublocktestdata/xml2json/block-raw-reservations-srconl= y.json b/tests/qemublocktestdata/xml2json/block-raw-reservations-srconly.js= on index 72f9067353..07f7390433 100644 --- a/tests/qemublocktestdata/xml2json/block-raw-reservations-srconly.json +++ b/tests/qemublocktestdata/xml2json/block-raw-reservations-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "host_device", - "filename": "/dev/blah" -} +( + source only properties: + { + "driver": "host_device", + "filename": "/dev/blah" + } + backing store string: + /dev/blah +) diff --git a/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json b/= tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json index 6ec4f78d7b..8bc58fa033 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json @@ -1,5 +1,10 @@ -{ - "driver": "vvfat", - "dir": "/var/somefiles", - "floppy": false -} +( + source only properties: + { + "driver": "vvfat", + "dir": "/var/somefiles", + "floppy": false + } + backing store string: + /var/somefiles +) diff --git a/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json b= /tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json index 6b0388bc18..043b796435 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json @@ -1,5 +1,10 @@ -{ - "driver": "vvfat", - "dir": "/var/somefiles", - "floppy": true -} +( + source only properties: + { + "driver": "vvfat", + "dir": "/var/somefiles", + "floppy": true + } + backing store string: + /var/somefiles +) diff --git a/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json= b/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json index 6ec4f78d7b..8bc58fa033 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json @@ -1,5 +1,10 @@ -{ - "driver": "vvfat", - "dir": "/var/somefiles", - "floppy": false -} +( + source only properties: + { + "driver": "vvfat", + "dir": "/var/somefiles", + "floppy": false + } + backing store string: + /var/somefiles +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-aio_thread= s-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-aio_th= reads-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-aio_threads-srcon= ly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-aio_threads-srcon= ly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-dire= ctsync-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-c= ache-directsync-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync-= srconly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-directsync-= srconly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none= -srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-n= one-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none-srconl= y.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-none-srconl= y.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsa= fe-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-cache= -unsafe-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe-srco= nly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-unsafe-srco= nly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writ= eback-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-ca= che-writeback-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback-s= rconly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writeback-s= rconly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writ= ethrough-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic= -cache-writethrough-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethroug= h-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-cache-writethroug= h-srconly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-detect-src= only.json b/tests/qemublocktestdata/xml2json/file-backing_basic-detect-srco= nly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-detect-srconly.js= on +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-detect-srconly.js= on @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-noopts-src= only.json b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts-srco= nly.json index dbdf6e563b..35a8c3af37 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-noopts-srconly.js= on +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-noopts-srconly.js= on @@ -1,16 +1,36 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/c" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/c" + } + backing store string: + /var/lib/libvirt/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-dete= ct-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap= -detect-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect-srco= nly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-detect-srco= nly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-igno= re-srconly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap= -ignore-srconly.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore-srco= nly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-ignore-srco= nly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-srco= nly.json b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-srconl= y.json index ea490b0034..65a3773b97 100644 --- a/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-backing_basic-unmap-srconly.json @@ -1,24 +1,44 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} -{ - "driver": "gluster", - "volume": "images", - "path": "c", - "server": [ - { - "type": "inet", - "host": "test.org", - "port": "24007" - } - ] -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/d" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) +( + source only properties: + { + "driver": "gluster", + "volume": "images", + "path": "c", + "server": [ + { + "type": "inet", + "host": "test.org", + "port": "24007" + } + ] + } + backing store string: + gluster://test.org:24007/images/c +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/d" + } + backing store string: + /var/lib/libvirt/images/d +) diff --git a/tests/qemublocktestdata/xml2json/file-bochs-noopts-srconly.jso= n b/tests/qemublocktestdata/xml2json/file-bochs-noopts-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-bochs-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-bochs-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-cloop-noopts-srconly.jso= n b/tests/qemublocktestdata/xml2json/file-cloop-noopts-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-cloop-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-cloop-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-dmg-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-dmg-noopts-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-dmg-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-dmg-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-ploop-noopts-srconly.jso= n b/tests/qemublocktestdata/xml2json/file-ploop-noopts-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-ploop-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-ploop-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encr= yption-srconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-c= hain-encryption-srconly.json index 316dbc9df2..29644f8c0f 100644 --- a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption-= srconly.json +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-encryption-= srconly.json @@ -1,8 +1,18 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/a" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/b" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/a" + } + backing store string: + /var/lib/libvirt/images/a +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/b" + } + backing store string: + /var/lib/libvirt/images/b +) diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noop= ts-srconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain= -noopts-srconly.json index d998acc194..7691609577 100644 --- a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts-srco= nly.json +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-noopts-srco= nly.json @@ -1,40 +1,90 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1507297895" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1484071872" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1483615252" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1483605924" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1483605920" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1483546244" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1483545901" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1483545313" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1483536402" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.qcow2" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1507297895" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1507297895 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1484071872" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1484071872 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483615252" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1483615252 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483605924" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1483605924 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483605920" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1483605920 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483546244" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1483546244 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483545901" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1483545901 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483545313" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1483545313 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483536402" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1483536402 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.qcow2" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.qcow2 +) diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unte= rminated-srconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing= -chain-unterminated-srconly.json index e0bce3bcd2..f2fd81184b 100644 --- a/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminate= d-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-chain-unterminate= d-srconly.json @@ -1,8 +1,18 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1507297895" -} -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/rhel7.3.1484071872" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1507297895" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1507297895 +) +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1484071872" + } + backing store string: + /var/lib/libvirt/images/rhel7.3.1484071872 +) diff --git a/tests/qemublocktestdata/xml2json/file-raw-aio_native-srconly.j= son b/tests/qemublocktestdata/xml2json/file-raw-aio_native-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-raw-aio_native-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-raw-aio_native-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-raw-luks-srconly.json b/= tests/qemublocktestdata/xml2json/file-raw-luks-srconly.json index 6d7088211f..c065e3fab0 100644 --- a/tests/qemublocktestdata/xml2json/file-raw-luks-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-raw-luks-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/luks.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/luks.img" + } + backing store string: + /path/luks.img +) diff --git a/tests/qemublocktestdata/xml2json/file-raw-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-raw-noopts-srconly.json index bb3e8af9eb..a2b32b09e0 100644 --- a/tests/qemublocktestdata/xml2json/file-raw-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-raw-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/var/lib/libvirt/images/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/var/lib/libvirt/images/i.img" + } + backing store string: + /var/lib/libvirt/images/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-vdi-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-vdi-noopts-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-vdi-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-vdi-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-vhd-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-vhd-noopts-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-vhd-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-vhd-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/file-vpc-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/file-vpc-noopts-srconly.json index c50fa903f5..58dd7e1c34 100644 --- a/tests/qemublocktestdata/xml2json/file-vpc-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/file-vpc-noopts-srconly.json @@ -1,4 +1,9 @@ -{ - "driver": "file", - "filename": "/path/to/i.img" -} +( + source only properties: + { + "driver": "file", + "filename": "/path/to/i.img" + } + backing store string: + /path/to/i.img +) diff --git a/tests/qemublocktestdata/xml2json/network-nbd-tls-srconly.json = b/tests/qemublocktestdata/xml2json/network-nbd-tls-srconly.json index 455f4e5140..606e68713a 100644 --- a/tests/qemublocktestdata/xml2json/network-nbd-tls-srconly.json +++ b/tests/qemublocktestdata/xml2json/network-nbd-tls-srconly.json @@ -1,8 +1,13 @@ -{ - "driver": "nbd", - "server": { - "type": "inet", - "host": "host1.example.com", - "port": "10809" +( + source only properties: + { + "driver": "nbd", + "server": { + "type": "inet", + "host": "host1.example.com", + "port": "10809" + } } -} + backing store string: + nbd://host1.example.com:10809 +) diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-c= ache-unsafe-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow2-b= acking-chain-cache-unsafe-srconly.json index 69ca9caf88..2d7eeb3bca 100644 --- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-un= safe-srconly.json +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-un= safe-srconly.json @@ -1,22 +1,46 @@ -{ - "driver": "rbd", - "pool": "rbdpool", - "image": "rbdimg", - "server": [ - { - "host": "host1.example.com", - "port": "0" - }, - { - "host": "host2.example.com", - "port": "0" - } - ] -} -{ - "driver": "iscsi", - "portal": "example.org:3260", - "target": "iscsitarget", - "lun": 1, - "transport": "tcp" -} +( + source only properties: + { + "driver": "rbd", + "pool": "rbdpool", + "image": "rbdimg", + "server": [ + { + "host": "host1.example.com", + "port": "0" + }, + { + "host": "host2.example.com", + "port": "0" + } + ] + } + backing store string: + json:{ + "driver": "rbd", + "pool": "rbdpool", + "image": "rbdimg", + "server": [ + { + "host": "host1.example.com", + "port": "0" + }, + { + "host": "host2.example.com", + "port": "0" + } + ] + } +) +( + source only properties: + { + "driver": "iscsi", + "portal": "example.org:3260", + "target": "iscsitarget", + "lun": 1, + "transport": "tcp" + } + backing store string: + iscsi://example.org:3260/iscsitarget/1 +) diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-e= ncryption_auth-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow= 2-backing-chain-encryption_auth-srconly.json index 6298329812..5679318fbe 100644 --- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encrypti= on_auth-srconly.json +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encrypti= on_auth-srconly.json @@ -1,22 +1,46 @@ -{ - "driver": "rbd", - "pool": "rbdpool", - "image": "rbdimg", - "server": [ - { - "host": "host1.example.com", - "port": "0" - }, - { - "host": "host2.example.com", - "port": "0" - } - ] -} -{ - "driver": "iscsi", - "portal": "example.org:3260", - "target": "iqn.2016-09.com.example:iscsitarget", - "lun": 1, - "transport": "tcp" -} +( + source only properties: + { + "driver": "rbd", + "pool": "rbdpool", + "image": "rbdimg", + "server": [ + { + "host": "host1.example.com", + "port": "0" + }, + { + "host": "host2.example.com", + "port": "0" + } + ] + } + backing store string: + json:{ + "driver": "rbd", + "pool": "rbdpool", + "image": "rbdimg", + "server": [ + { + "host": "host1.example.com", + "port": "0" + }, + { + "host": "host2.example.com", + "port": "0" + } + ] + } +) +( + source only properties: + { + "driver": "iscsi", + "portal": "example.org:3260", + "target": "iqn.2016-09.com.example:iscsitarget", + "lun": 1, + "transport": "tcp" + } + backing store string: + iscsi://example.org:3260/iqn.2016-09.com.example%3Aiscsitarget/1 +) diff --git a/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json index ed55c08cbf..970e1bb8af 100644 --- a/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json @@ -1,5 +1,14 @@ -{ - "driver": "nvme", - "device": "0000:01:00.0", - "namespace": 1 -} +( + source only properties: + { + "driver": "nvme", + "device": "0000:01:00.0", + "namespace": 1 + } + backing store string: + json:{ + "driver": "nvme", + "device": "0000:01:00.0", + "namespace": 1 + } +) --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1584987166; cv=none; d=zohomail.com; s=zohoarc; b=b1gSE71IH7sxXsF0XXCEgkx24SVGkZtxXEe5RaH3oVGbAgemjZ8N9zs5IhVEqTLMw5c9tccDeJgf5MtyYoD3MCfXRPx0Cvwif77bv3pGqW4l3Wh1Ky0a8/WDS0zdvPE66zJ6ZlRU1p4xdwYNJRlYfHI0mStNuiQ0651H7PnvMQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987166; 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=d0X/7KfUWhNnX6KjVRvaYqPsYHmSfj/KTuoBUMejE6o=; b=kxpGcruRtpmOOIf1Xekj0DFTfdailKeHCm+RFoJIOPvXYKpgj2MX7basIldADBiD14RftN4+kgnvec7/f4mO0qB6vtfjSpsWveJg8bvol1ryE1iMC+52yryUCRnvPjHGmuOpDMXGPSbv0IrW8f89+0Qc6s1Drs7SAG+Rz9A6lDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.74]) by mx.zohomail.com with SMTPS id 1584987166723675.4029032209774; Mon, 23 Mar 2020 11:12:46 -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-272-1nh7H1UNOd-wWKuBjuF98Q-1; Mon, 23 Mar 2020 14:12:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92D23800D5E; Mon, 23 Mar 2020 18:12:37 +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 6A7925DA83; Mon, 23 Mar 2020 18:12:37 +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 1D73F86386; Mon, 23 Mar 2020 18:12:37 +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 02NICGbk009497 for ; Mon, 23 Mar 2020 14:12:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id B94418D574; Mon, 23 Mar 2020 18:12:16 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 400F19B93A for ; Mon, 23 Mar 2020 18:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987165; 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=d0X/7KfUWhNnX6KjVRvaYqPsYHmSfj/KTuoBUMejE6o=; b=S8LB+j3NXPvvBKY2hnRLetAvxdz7MxmVT815h3XvJEt6iqnXJ1s5RX7DmEk9pWPnOLxwDX rJcatifq/OZZTX9GZtI1oTPHWojXiHyEDfW3M805YC6Hxx+jL7FXiY5aQjpjoKA0FJTX9g jbjjngibA+6Q5EOxWqmvyhSz/7wXhP0= X-MC-Unique: 1nh7H1UNOd-wWKuBjuF98Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/14] qemuBlockGetBackingStoreString: Remove 'ret' variable Date: Mon, 23 Mar 2020 19:11:59 +0100 Message-Id: <98cff06f42befd90c2b3b624ed89d77c2f171178.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.14 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" We can return the appropriate string directly. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index d6cc999a43..b7c3ba7530 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2043,13 +2043,10 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr = src, virJSONValuePtr props =3D NULL; g_autoptr(virURI) uri =3D NULL; g_autofree char *backingJSON =3D NULL; - char *ret =3D NULL; if (!src->sliceStorage) { - if (virStorageSourceIsLocalStorage(src)) { - ret =3D g_strdup(src->path); - return ret; - } + if (virStorageSourceIsLocalStorage(src)) + return g_strdup(src->path); /* generate simplified URIs for the easy cases */ if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && @@ -2068,10 +2065,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr s= rc, if (!(uri =3D qemuBlockStorageSourceGetURI(src))) return NULL; - if (!(ret =3D virURIFormat(uri))) - return NULL; - - return ret; + return virURIFormat(uri); case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: case VIR_STORAGE_NET_PROTOCOL_RBD: @@ -2105,9 +2099,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr sr= c, if (!(backingJSON =3D virJSONValueToString(props, pretty))) return NULL; - ret =3D g_strdup_printf("json:%s", backingJSON); - - return ret; + return g_strdup_printf("json:%s", backingJSON); } --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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=1584987184; cv=none; d=zohomail.com; s=zohoarc; b=W16RF3esI5wN/JFs4GjKDOlnOIcz7vog8oxOrPBktN+7ooB931o5eZEWpCF1GvzHlP7VCGPQ1iLgBMfiMQ3GhUKRcgtcOTes1E1E0UTzt7Bn8OpldzGL7YzGQt6UBtDaMZUkSefdJxC/CrnxkkVEXMTqitpkHCo2rQdGvgnObb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987184; 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=JfSgW+yA7XcjaiZfHk3J4UxI1VdsUo+E92Lbe7msNSE=; b=VGUZ0KHHXlcd76yKXGk5NuWq7o0UqmHsIznQ4vvCqt1C2A/5Wp37c9USvJdC3DaO4SRN1thNVzTrTNBmsv79ag7hueHAOZCSAsFarHijyFSCYVdjJjZFNAclZCZnXZ/0HrwxChEmY0hSKqHT1FseH09bLt3yMa1hkvkaVkf/2ow= 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 1584987184168968.6604644356471; Mon, 23 Mar 2020 11:13:04 -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-163-PT75Zh-_MwukdLW15PTxxw-1; Mon, 23 Mar 2020 14:12:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9ED6F801E7E; Mon, 23 Mar 2020 18:12:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7974B7E323; Mon, 23 Mar 2020 18:12:33 +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 247B81803C33; Mon, 23 Mar 2020 18:12:33 +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 02NICHQo009512 for ; Mon, 23 Mar 2020 14:12:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8DB428D574; Mon, 23 Mar 2020 18:12:17 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13C229B93A for ; Mon, 23 Mar 2020 18:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987183; 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=JfSgW+yA7XcjaiZfHk3J4UxI1VdsUo+E92Lbe7msNSE=; b=MYeCYBKu8f5OPk2gPPlu5jibtpGhLML8GsevKC9e9QU2b6ByHwIxyNzkcGdAW3zzsV9cT1 qAE9SdWOLa7mGeImfiHF2sKQFaXm9I0wPaHR+7zFdQLF8i1ZCCq+sPiRvipaGFQnUqU3Fu 7/dfbnUdWFoN9hSiVq452fvVhQhBMDE= X-MC-Unique: PT75Zh-_MwukdLW15PTxxw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/14] storage: Implement backing store support for "fat:" prefix Date: Mon, 23 Mar 2020 19:12:00 +0100 Message-Id: <6a6532aae473585aef71907d54c65e51f8fc8063.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.13 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" qemublocktest showed that we don't add the "fat:" prefix for directory storage when formatting the backing store string. While it's unlikely to be used it's simple enough to actually implement the support rather than trying to forbid it. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 7 ++++++- src/util/virstoragefile.c | 9 +++++++++ .../xml2json/dir-fat-cache-srconly.json | 2 +- .../xml2json/dir-fat-floppy-srconly.json | 2 +- .../xml2json/dir-fat-readonly-srconly.json | 2 +- tests/virstoragetest.c | 1 + 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index b7c3ba7530..a44cfeb99c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2045,8 +2045,13 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr s= rc, g_autofree char *backingJSON =3D NULL; if (!src->sliceStorage) { - if (virStorageSourceIsLocalStorage(src)) + if (virStorageSourceIsLocalStorage(src)) { + if (src->type =3D=3D VIR_STORAGE_TYPE_DIR && + src->format =3D=3D VIR_STORAGE_FILE_FAT) + return g_strdup_printf("fat:%s", src->path); + return g_strdup(src->path); + } /* generate simplified URIs for the easy cases */ if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ca39391379..fa04ff74e1 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3922,6 +3922,7 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th, virStorageSourcePtr *src) { const char *json; + const char *dirpath; int rc =3D 0; g_autoptr(virStorageSource) def =3D NULL; @@ -3935,6 +3936,14 @@ virStorageSourceNewFromBackingAbsolute(const char *p= ath, def->path =3D g_strdup(path); } else { + if ((dirpath =3D STRSKIP(path, "fat:"))) { + def->type =3D VIR_STORAGE_TYPE_DIR; + def->format =3D VIR_STORAGE_FILE_FAT; + def->path =3D g_strdup(dirpath); + *src =3D g_steal_pointer(&def); + return 0; + } + def->type =3D VIR_STORAGE_TYPE_NETWORK; VIR_DEBUG("parsing backing store string: '%s'", path); diff --git a/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json b/= tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json index 8bc58fa033..80f866f08b 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-cache-srconly.json @@ -6,5 +6,5 @@ "floppy": false } backing store string: - /var/somefiles + fat:/var/somefiles ) diff --git a/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json b= /tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json index 043b796435..6c86f1da06 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-floppy-srconly.json @@ -6,5 +6,5 @@ "floppy": true } backing store string: - /var/somefiles + fat:/var/somefiles ) diff --git a/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json= b/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json index 8bc58fa033..80f866f08b 100644 --- a/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json +++ b/tests/qemublocktestdata/xml2json/dir-fat-readonly-srconly.json @@ -6,5 +6,5 @@ "floppy": false } backing store string: - /var/somefiles + fat:/var/somefiles ) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 547118951e..209d0c37d3 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1226,6 +1226,7 @@ mymain(void) TEST_BACKING_PARSE_FULL(bck, xml, 0) TEST_BACKING_PARSE("path", "\n"); + TEST_BACKING_PARSE("fat:/somedir", "\n"); TEST_BACKING_PARSE("://", NULL); TEST_BACKING_PARSE("http://example.com", "\n" --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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=1584987171; cv=none; d=zohomail.com; s=zohoarc; b=NyrXFCmITaCLsA6SHjUwqjZCkumK3vWAJ/BYc76Vb4QjpkC6M3EeyHNGaPsEs0BJc2H/r3C/EtGgYriv1P7mZyMZ5Nl1rzaBFuY0a5uhofZz/cvLF13KA9P8Y9A2GBaPw1xTQBHT15DPk/E+TYrZnc4HkFyW7c85o3k2MkmrR/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987171; 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=ltDIuSlM+fyp5jdjWIrpfWCsTZSRL33hdTKGvrfehd4=; b=GkZIN8H0qqjqWIYFYYSIDc5a5hKZaIM6ms1V3kNCMph5AP0Eh2mUvh6BZqZOGDXgnzTWkccHqbWwtDy+QQOZcSOYpJ3bwNGwMfIC+4pLx07zjZpQ7WwF6vXVVZLn/x/xrT13b9+GkZ3yG7QLswr4eox1m+SgN5rxO2NgtBAnxFQ= 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 1584987171551386.41175906473586; Mon, 23 Mar 2020 11:12:51 -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-111-M-MGBHlLPBCgQImR55Pz-w-1; Mon, 23 Mar 2020 14:12:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 469021922965; Mon, 23 Mar 2020 18:12:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DE8A5C1BB; Mon, 23 Mar 2020 18:12:42 +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 CBB601803C41; Mon, 23 Mar 2020 18:12:41 +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 02NICIQT009522 for ; Mon, 23 Mar 2020 14:12:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 60E568D574; Mon, 23 Mar 2020 18:12:18 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBC89A0A60 for ; Mon, 23 Mar 2020 18:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987170; 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=ltDIuSlM+fyp5jdjWIrpfWCsTZSRL33hdTKGvrfehd4=; b=fBvCwW/3hG2+UITXpym4X2jrddN1d63vACs5JwNFnaPDJX3ARWO6Id8ofVPCQjjoTpUbNO dv6u10bJ3iGWkOKGBxb3AHmMziRk8sZHf0F2m/F1wBhbnQaaE+9BGeV4X3aHFuMMaMqohS ZMBGHCuU12a9TaAQ85MldcUhyOzr9DY= X-MC-Unique: M-MGBHlLPBCgQImR55Pz-w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/14] qemuBlockGetBackingStoreString: Add extra wrapping object to JSON strings Date: Mon, 23 Mar 2020 19:12:01 +0100 Message-Id: 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.16 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" QEMU requires an extra wrapper object where only the "file" member is populated. This is basically a placeholder for establishing the format layer. We did the same in qemuDiskSourceGetProps for the old-school JSON usage with -drive but forgot to adopt this for -blockdev. https://bugzilla.redhat.com/show_bug.cgi?id=3D1804617 Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 2 +- .../imagecreate/qcow2-backing-qcow2-slice.json | 2 +- .../qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json | 2 +- .../network-qcow2-backing-chain-cache-unsafe-srconly.json | 3 ++- .../network-qcow2-backing-chain-encryption_auth-srconly.json | 3 ++- tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json | 3 ++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index a44cfeb99c..3365ee677b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2104,7 +2104,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr sr= c, if (!(backingJSON =3D virJSONValueToString(props, pretty))) return NULL; - return g_strdup_printf("json:%s", backingJSON); + return g_strdup_printf("json:{\"file\":%s}", backingJSON); } diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.= json b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json index 2fa27c1933..2526740b9a 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json @@ -10,6 +10,6 @@ format: "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", "size": 8589934590, - "backing-file": "json:{\"driver\":\"raw\",\"offset\":1234,\"size\":5768,= \"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.qcow= 2\"}}", + "backing-file": "json:{\"file\":{\"driver\":\"raw\",\"offset\":1234,\"si= ze\":5768,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/ima= ges/i.qcow2\"}}}", "backing-fmt": "qcow2" } diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.js= on b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json index 761002afd9..e76221da16 100644 --- a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json @@ -10,6 +10,6 @@ format: "driver": "qcow2", "file": "0123456789ABCDEF0123456789ABCDE", "size": 8589934590, - "backing-file": "json:{\"driver\":\"raw\",\"offset\":9876,\"size\":54321= ,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.img= \"}}", + "backing-file": "json:{\"file\":{\"driver\":\"raw\",\"offset\":9876,\"si= ze\":54321,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/im= ages/i.img\"}}}", "backing-fmt": "raw" } diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-c= ache-unsafe-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow2-b= acking-chain-cache-unsafe-srconly.json index 2d7eeb3bca..0fb0b8eff9 100644 --- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-un= safe-srconly.json +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-cache-un= safe-srconly.json @@ -16,7 +16,7 @@ ] } backing store string: - json:{ + json:{"file":{ "driver": "rbd", "pool": "rbdpool", "image": "rbdimg", @@ -31,6 +31,7 @@ } ] } + } ) ( source only properties: diff --git a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-e= ncryption_auth-srconly.json b/tests/qemublocktestdata/xml2json/network-qcow= 2-backing-chain-encryption_auth-srconly.json index 5679318fbe..777a372471 100644 --- a/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encrypti= on_auth-srconly.json +++ b/tests/qemublocktestdata/xml2json/network-qcow2-backing-chain-encrypti= on_auth-srconly.json @@ -16,7 +16,7 @@ ] } backing store string: - json:{ + json:{"file":{ "driver": "rbd", "pool": "rbdpool", "image": "rbdimg", @@ -31,6 +31,7 @@ } ] } + } ) ( source only properties: diff --git a/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json = b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json index 970e1bb8af..26f9557c80 100644 --- a/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json +++ b/tests/qemublocktestdata/xml2json/nvme-raw-noopts-srconly.json @@ -6,9 +6,10 @@ "namespace": 1 } backing store string: - json:{ + json:{"file":{ "driver": "nvme", "device": "0000:01:00.0", "namespace": 1 } + } ) --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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=1584987184; cv=none; d=zohomail.com; s=zohoarc; b=QZSBubR4aLOweNEjE2FWV8mUjw3FYCNORt0u24+31pdCN2VAyH4ff4JvEAxCO5Co/KEu7HAgUn1cgN49nBMDylP6+WEIw102NpG3RxSxp5e/Nz94M25mKUJr2YHhznFZ8Ub8CF3Olw/E1muLxAOr2wn9/eVI0/BzPtkLQ86YlFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987184; 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=of++eBTammkEvWwzxiZIQhz7qeAV08d6v3FyE5yQILU=; b=f1B95AIiOaTPSBU/Ms0WfShSkLBp0Ioh/ol5ZcEPi09cO1SzkVS5wZHtItxos4r+pBp/6UzLz5O88bCsvpg1eBa8okMEUtu0Po8LkMW8EZqbSg0tiz/b8pg2aqWorZKnN8vlN7WzbmOCd53WV+lAtPAKBQF4tsHSRlymGX1wAWw= 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 1584987184103216.54559616223196; Mon, 23 Mar 2020 11:13:04 -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-286--H_UDzq0PoezcoOETm0g_w-1; Mon, 23 Mar 2020 14:12:39 -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 080D71084432; Mon, 23 Mar 2020 18:12:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C766E60C85; Mon, 23 Mar 2020 18:12:32 +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 6A1B5180BACE; Mon, 23 Mar 2020 18:12:32 +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 02NICJTt009532 for ; Mon, 23 Mar 2020 14:12:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 34C9191290; Mon, 23 Mar 2020 18:12:19 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFAA58D574 for ; Mon, 23 Mar 2020 18:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987183; 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=of++eBTammkEvWwzxiZIQhz7qeAV08d6v3FyE5yQILU=; b=Co2dZjIqoWN+VeliWmhP9YhcQQO1i1VQA4C5Smj1nXHz6R5Wn1jsO+2t+bcWY/LM+d+qPK DGc6nCF9t2rGb0bkYws3qHGfvvStpUx469ko/wpX1eS1UkBhYEnH5goPADo6b/imI0trsW ZhfbYwv5M1NfQ9Qfs7xbKBnKWIeIt+0= X-MC-Unique: -H_UDzq0PoezcoOETm0g_w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/14] qemu: block: Extract formatting of cookie string Date: Mon, 23 Mar 2020 19:12:02 +0100 Message-Id: <116f14dc9a6b37c0fb5dadd3cba78435e87812d0.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" Introduce qemuBlockStorageSourceGetCookieString which does the concatenation so that we can reuse it later. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 25 +++++++++++++++++++++++++ src/qemu/qemu_block.h | 3 +++ src/qemu/qemu_domain.c | 13 +------------ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 3365ee677b..d9665ec4a0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3343,3 +3343,28 @@ qemuBlockStorageSourceNeedsStorageSliceLayer(const v= irStorageSource *src) return false; } + + +/** + * qemuBlockStorageSourceGetCookieString: + * @src: storage source + * + * Returns a properly formatted string representing cookies of @src in for= mat + * accepted by qemu. + */ +char * +qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src) +{ + virBuffer buf =3D VIR_BUFFER_INITIALIZER; + size_t i; + + for (i =3D 0; i < src->ncookies; i++) { + virStorageNetCookieDefPtr cookie =3D src->cookies[i]; + + virBufferAsprintf(&buf, "%s=3D%s; ", cookie->name, cookie->value); + } + + virBufferTrim(&buf, "; "); + + return virBufferContentAndReset(&buf); +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 9bffe20bfb..8b57ffd8a5 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -258,3 +258,6 @@ qemuBlockReopenReadOnly(virDomainObjPtr vm, bool qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src); + +char * +qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9cff36cb77..b55765c8ee 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1747,18 +1747,7 @@ qemuDomainSecretStorageSourcePrepareCookies(qemuDoma= inObjPrivatePtr priv, const char *aliasprotocol) { g_autofree char *secretalias =3D qemuAliasForSecret(aliasprotocol, "ht= tpcookie"); - g_autofree char *cookies =3D NULL; - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - size_t i; - - for (i =3D 0; i < src->ncookies; i++) { - virStorageNetCookieDefPtr cookie =3D src->cookies[i]; - - virBufferAsprintf(&buf, "%s=3D%s; ", cookie->name, cookie->value); - } - - virBufferTrim(&buf, "; "); - cookies =3D virBufferContentAndReset(&buf); + g_autofree char *cookies =3D qemuBlockStorageSourceGetCookieString(src= ); return qemuDomainSecretAESSetup(priv, secretalias, NULL, (uint8_t *) cookies, strlen(cookies)); --=20 2.24.1 From nobody Wed Apr 24 23:13:57 2024 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 From nobody Wed Apr 24 23:13:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1584987178; cv=none; d=zohomail.com; s=zohoarc; b=XbUBkV3cXJmbv+Rt+/hchnggZD6z5S9FNPJN9RcRAWk32BAz/KO/XI4F5mjFmihUg0uANlrdRIY7dLlKvMf/wYGX3TDRyVtTFIew6qECSm5El4xwk/25P92RbY4JVrFo6BU5tABW0WyHLI53EIlM7ZTTnmQP0FYh5wy+C5CiXho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584987178; 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=yr3eksglgyRKMkdJrmDnmdTUpY+o+4gX4oQ7BEnQkdA=; b=PO/WrImZ03SuQwakEV6MxzNcokQqkF5sIUCn+g1PeYlGMuYdaE//am6jqs/dq/SQTY2Afh7WzE64FSX7LBRPopBzeDPo4MRMsUcnNxphSznekOz91zebi0Bd+HX8u7/+wLl6pFW2mbP/kNOmqGmV1HGNRFzzKPSEUNtmdtCHyyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.74]) by mx.zohomail.com with SMTPS id 1584987178820931.8239412106526; Mon, 23 Mar 2020 11:12:58 -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-262-uIe7ZEd6No-P8fvoJVNqGg-1; Mon, 23 Mar 2020 14:12:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DAA978010CA; Mon, 23 Mar 2020 18:12:49 +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 B09BD196AE; Mon, 23 Mar 2020 18:12:49 +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 601E4863A8; Mon, 23 Mar 2020 18:12:49 +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 02NICKuJ009545 for ; Mon, 23 Mar 2020 14:12:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id D582491290; 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 5A3D58D574 for ; Mon, 23 Mar 2020 18:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584987177; 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=yr3eksglgyRKMkdJrmDnmdTUpY+o+4gX4oQ7BEnQkdA=; b=AIN4TcbmqjqqAJsXKBLOmX4LpehdfbZYnH6dbCwTlFvkax0CP37Rg6MFFLorerO22+M+Oq ljUbBfInxNJEEi5PegNF7tNWNHDUVh+oIKw8mGUTil9kb1PypkPK07RtelLzrRNtSIKkBH L/a9KimCZuvCE9EGJ7JyePm9Yy7cJPk= X-MC-Unique: uIe7ZEd6No-P8fvoJVNqGg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/14] storage: Parse 'nvme' disk source properties from json:{} pseudo-uri Date: Mon, 23 Mar 2020 19:12:04 +0100 Message-Id: <8d4db0d195ef034676a7a532acfc4c7b7f2ae225.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.84 on 10.5.11.23 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" Our code allows snapshots of NVMe based disks which means we create overlay file with a 'json:{}' pseudo-uri refering to the NVME device. Our parser code doesn't handle them though. Add the parser and test it via the XML->json->XML round-trip and reference data. Signed-off-by: Peter Krempa --- src/util/virstoragefile.c | 30 ++++++++++++++++++++++++++++++ tests/qemublocktest.c | 5 +++++ tests/virstoragetest.c | 9 +++++++++ 3 files changed, 44 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index fa04ff74e1..d81ed70a97 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3806,6 +3806,35 @@ virStorageSourceParseBackingJSONVxHS(virStorageSourc= ePtr src, } +static int +virStorageSourceParseBackingJSONNVMe(virStorageSourcePtr src, + virJSONValuePtr json, + const char *jsonstr G_GNUC_UNUSED, + int opaque G_GNUC_UNUSED) +{ + g_autoptr(virStorageSourceNVMeDef) nvme =3D g_new0(virStorageSourceNVM= eDef, 1); + const char *device =3D virJSONValueObjectGetString(json, "device"); + + if (!device || virPCIDeviceAddressParse((char *) device, &nvme->pciAdd= r) < 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing or malformed 'device' field of 'nvme' st= orage")); + return -1; + } + + if (virJSONValueObjectGetNumberUlong(json, "namespace", &nvme->namespc= ) < 0 || + nvme->namespc =3D=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing or malformed 'namespace' field of 'nvme'= storage")); + return -1; + } + + src->type =3D VIR_STORAGE_TYPE_NVME; + src->nvme =3D g_steal_pointer(&nvme); + + return 0; +} + + struct virStorageSourceJSONDriverParser { const char *drvname; bool formatdriver; @@ -3837,6 +3866,7 @@ static const struct virStorageSourceJSONDriverParser = jsonParsers[] =3D { {"rbd", false, virStorageSourceParseBackingJSONRBD, 0}, {"raw", true, virStorageSourceParseBackingJSONRaw, 0}, {"vxhs", false, virStorageSourceParseBackingJSONVxHS, 0}, + {"nvme", false, virStorageSourceParseBackingJSONNVMe, 0}, }; diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 8640b72116..124eaea752 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1096,6 +1096,11 @@ mymain(void) /* type VIR_STORAGE_TYPE_BLOCK is not tested since it parses back to '= file' */ /* type VIR_STORAGE_TYPE_DIR it is a 'format' driver in qemu */ + TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NVME, + "\n" + "
\n" + "\n"); + TEST_JSON_FORMAT_NET("\n" " \n" "\n"); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 209d0c37d3..10d5421150 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1656,6 +1656,15 @@ mymain(void) " \n" "\n", 0); + TEST_BACKING_PARSE("json:{\"file\":{\"driver\": \"nvme\"," + "\"device\": \"0000:01:00.0\"," + "\"namespace\": 1" + "}" + "}", + "\n" + "
\n" + "\n"); + #endif /* WITH_YAJL */ cleanup: --=20 2.24.1