From nobody Sun Feb 8 18:58:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1725719683; cv=none; d=zohomail.com; s=zohoarc; b=h1AT6ItcMd0Cf15aQr34W3SRvNaG3jvMPQVqYtGIgBF/cVnSBpPF7TMv1abs0KJk7MyqJn6m4BS391Nk2llODBFFw6/GdKDFhyZ6WNt3LlxE3iIc0rjWa9uKQbLL2UZQvHlp1jXr+7mAGJYCWMTAIXpo+uKNFaKmWZQ0mxyeAQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725719683; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=l0Scm8WcH+4YrhZrOHETZ1O2/PetAA2yAqirIDftFIE=; b=DdH41LqGEVF+EEdTMJDGN/Nx+s0844IfNIZgRr2a3A2RI0Xkz/17e8eGr9npEoTupkIRPqujKpD9QbBpXUzcwVZ6Y1L5tnIDd8I2tu/YmcXGqWuj4Ke+fCn4YWPYUdvwdVeekxq30tpzIlA/K94iW2c16yq8J1Z2O34JpNS24Rs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1725719683002382.4342198519282; Sat, 7 Sep 2024 07:34:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E998E193D; Sat, 7 Sep 2024 10:34:41 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DBE4C1953; Sat, 7 Sep 2024 10:33:25 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 25CCFE90; Sat, 7 Sep 2024 10:33:20 -0400 (EDT) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3BDD218AB for ; Sat, 7 Sep 2024 10:33:02 -0400 (EDT) Received: from [130.117.225.1] (helo=vz9-barybin-2.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1smwSB-001ZxE-2H; Sat, 07 Sep 2024 16:32:50 +0200 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=V7yJ5xuESDS+cKHpgU6aGZpcNuAPkPQqAvVdQTNwUek=; b=sAj23Q7e7Vs7 qi8dKc1n7ZlFcx3czQuw4GMrO3diOn3+p+xzZpt3CzpCMOXpc9ZJXJ9xDkNMKx82NX9BsRANEsOs4 C5JYB7OiR3P8tiEXMBLTAH6dCOyl2QJI2lXw7KNGN22eI9ghPuq4yMHbob+HCP6Yi/0ceiulw3ZOv DCHvbIM0q3ryyfSk45cxjZzLlTBZ9afTCJNpSMyRnJkYIArRs2dukdYOvFogA3wuI9LJIvjLOAbe1 kAxaCojUNWt9GoujS8BOpmdls8XdTSgzr30a/atgSvxBpcC9mRcq+tqJyw+y5YB4B44JQKEUgMljB pURqWD2Igy0WldzkA07a+A==; To: devel@lists.libvirt.org Subject: [PATCH v2 13/13] tests: add qcow2 data-file basic tests to qemublocktest Date: Sat, 7 Sep 2024 17:15:42 +0300 Message-ID: <20240907143006.50677-28-nikolai.barybin@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240907143006.50677-1-nikolai.barybin@virtuozzo.com> References: <20240907143006.50677-1-nikolai.barybin@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VN3AFO7GKJVI5IQVKBDMPJIQ42UVINKK X-Message-ID-Hash: VN3AFO7GKJVI5IQVKBDMPJIQ42UVINKK X-MailFrom: nikolai.barybin@virtuozzo.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: den@openvz.org, Nikolai Barybin X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Nikolai Barybin via Devel Reply-To: Nikolai Barybin X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1725719683296116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Nikolai Barybin --- tests/qemublocktest.c | 78 +++++++++++-------- ...backing-with-data-file-noopts-srconly.json | 27 +++++++ ...e-qcow2-backing-with-data-file-noopts.json | 41 ++++++++++ ...le-qcow2-backing-with-data-file-noopts.xml | 35 +++++++++ .../file-qcow2-data-file-noopts-srconly.json | 18 +++++ .../xml2json/file-qcow2-data-file-noopts.json | 27 +++++++ .../xml2json/file-qcow2-data-file-noopts.xml | 24 ++++++ 7 files changed, 219 insertions(+), 31 deletions(-) create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-wit= h-data-file-noopts-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-wit= h-data-file-noopts.json create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-backing-wit= h-data-file-noopts.xml create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-data-file-n= oopts-srconly.json create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-data-file-n= oopts.json create mode 100644 tests/qemublocktestdata/xml2json/file-qcow2-data-file-n= oopts.xml diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index c581bd1748..46c080fb3b 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -247,6 +247,48 @@ testQemuDiskXMLToJSONFakeSecrets(virStorageSource *src) =20 static const char *testQemuDiskXMLToJSONPath =3D abs_srcdir "/qemublocktes= tdata/xml2json/"; =20 +static int +testQemuDiskXMLToPropsCollectDataOne(virStorageSource *src, + virDomainDiskDef *disk, + struct testQemuDiskXMLToJSONData *dat= a) +{ + g_autofree char *backingstore =3D NULL; + g_autoptr(virJSONValue) formatProps =3D NULL; + g_autoptr(virJSONValue) storageProps =3D NULL; + g_autoptr(virJSONValue) storageSrcOnlyProps =3D NULL; + + if (testQemuDiskXMLToJSONFakeSecrets(src) < 0) + return -1; + + if (qemuDomainValidateStorageSource(src, data->qemuCaps) < 0) + return -1; + + qemuDomainPrepareDiskSourceData(disk, src); + + if (!(formatProps =3D qemuBlockStorageSourceGetFormatProps(src, src->b= ackingStore)) || + !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProps(sr= c, QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY)) || + !(storageProps =3D qemuBlockStorageSourceGetBackendProps(src, 0)) = || + !(backingstore =3D qemuBlockGetBackingStoreString(src, true))) { + if (!data->fail) { + VIR_TEST_VERBOSE("failed to generate qemu blockdev props"); + return -1; + } + } else if (data->fail) { + VIR_TEST_VERBOSE("qemu blockdev props should have failed"); + return -1; + } + + VIR_REALLOC_N(data->images, data->nimages + 1); + + data->images[data->nimages].formatprops =3D g_steal_pointer(&formatPro= ps); + data->images[data->nimages].storageprops =3D g_steal_pointer(&storageP= rops); + data->images[data->nimages].storagepropssrc =3D g_steal_pointer(&stora= geSrcOnlyProps); + data->images[data->nimages].backingstore =3D g_steal_pointer(&backings= tore); + + data->nimages++; + return 0; +} + static int testQemuDiskXMLToProps(const void *opaque) { @@ -254,9 +296,6 @@ testQemuDiskXMLToProps(const void *opaque) g_autoptr(virDomainDef) vmdef =3D NULL; virDomainDiskDef *disk =3D NULL; virStorageSource *n; - g_autoptr(virJSONValue) formatProps =3D NULL; - g_autoptr(virJSONValue) storageProps =3D NULL; - g_autoptr(virJSONValue) storageSrcOnlyProps =3D NULL; g_autofree char *xmlpath =3D NULL; g_autofree char *xmlstr =3D NULL; =20 @@ -284,37 +323,12 @@ testQemuDiskXMLToProps(const void *opaque) } =20 for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { - g_autofree char *backingstore =3D NULL; - - if (testQemuDiskXMLToJSONFakeSecrets(n) < 0) - return -1; - - if (qemuDomainValidateStorageSource(n, data->qemuCaps) < 0) + if (testQemuDiskXMLToPropsCollectDataOne(n, disk, data) < 0) return -1; =20 - qemuDomainPrepareDiskSourceData(disk, n); - - if (!(formatProps =3D qemuBlockStorageSourceGetFormatProps(n, n->b= ackingStore)) || - !(storageSrcOnlyProps =3D qemuBlockStorageSourceGetBackendProp= s(n, QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_TARGET_ONLY)) || - !(storageProps =3D qemuBlockStorageSourceGetBackendProps(n, 0)= ) || - !(backingstore =3D qemuBlockGetBackingStoreString(n, true))) { - if (!data->fail) { - VIR_TEST_VERBOSE("failed to generate qemu blockdev props"); - return -1; - } - } else if (data->fail) { - VIR_TEST_VERBOSE("qemu blockdev props should have failed"); + if (n->dataFileStore && + testQemuDiskXMLToPropsCollectDataOne(n->dataFileStore, disk, d= ata) < 0) return -1; - } - - VIR_REALLOC_N(data->images, data->nimages + 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->images[data->nimages].backingstore =3D g_steal_pointer(&back= ingstore); - - data->nimages++; } =20 return 0; @@ -1123,6 +1137,8 @@ mymain(void) TEST_DISK_TO_JSON("file-qcow2-backing-chain-unterminated"); TEST_DISK_TO_JSON("file-qcow2-backing-chain-encryption"); TEST_DISK_TO_JSON("network-qcow2-backing-chain-encryption_auth"); + TEST_DISK_TO_JSON("file-qcow2-data-file-noopts"); + TEST_DISK_TO_JSON("file-qcow2-backing-with-data-file-noopts"); =20 TEST_DISK_TO_JSON("file-backing_basic-unmap"); TEST_DISK_TO_JSON("file-backing_basic-unmap-detect"); diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-with-data-= file-noopts-srconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-back= ing-with-data-file-noopts-srconly.json new file mode 100644 index 0000000000..1621b4b0fc --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-with-data-file-no= opts-srconly.json @@ -0,0 +1,27 @@ +( + 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 +) diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-with-data-= file-noopts.json b/tests/qemublocktestdata/xml2json/file-qcow2-backing-with= -data-file-noopts.json new file mode 100644 index 0000000000..b78848ddea --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-with-data-file-no= opts.json @@ -0,0 +1,41 @@ +{ + "node-name": "#block126", + "read-only": false, + "driver": "qcow2", + "file": "#block004", + "backing": "#block313" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1507297895", + "node-name": "#block004", + "auto-read-only": true, + "discard": "unmap" +} +{ + "node-name": "#block313", + "read-only": true, + "driver": "qcow2", + "data-file": "#block556", + "file": "#block256" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1484071872", + "node-name": "#block256", + "auto-read-only": true, + "discard": "unmap" +} +{ + "node-name": "#block556", + "read-only": true, + "driver": "raw", + "file": "#block418" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1483615252", + "node-name": "#block418", + "auto-read-only": true, + "discard": "unmap" +} diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-backing-with-data-= file-noopts.xml b/tests/qemublocktestdata/xml2json/file-qcow2-backing-with-= data-file-noopts.xml new file mode 100644 index 0000000000..4fd561b8bf --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-backing-with-data-file-no= opts.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts-s= rconly.json b/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts-= srconly.json new file mode 100644 index 0000000000..f2fd81184b --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts-srconly.= json @@ -0,0 +1,18 @@ +( + 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-qcow2-data-file-noopts.j= son b/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts.json new file mode 100644 index 0000000000..ed7782b4f6 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts.json @@ -0,0 +1,27 @@ +{ + "node-name": "#block126", + "read-only": false, + "driver": "qcow2", + "data-file": "#block313", + "file": "#block004" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1507297895", + "node-name": "#block004", + "auto-read-only": true, + "discard": "unmap" +} +{ + "node-name": "#block313", + "read-only": false, + "driver": "raw", + "file": "#block256" +} +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/rhel7.3.1484071872", + "node-name": "#block256", + "auto-read-only": true, + "discard": "unmap" +} diff --git a/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts.x= ml b/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts.xml new file mode 100644 index 0000000000..6d4c9fd174 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-qcow2-data-file-noopts.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file --=20 2.43.5