From nobody Wed May 14 14:02:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524151660993820.5399639366267; Thu, 19 Apr 2018 08:27:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABE8031325B6; Thu, 19 Apr 2018 15:27:39 +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 7A72E85458; Thu, 19 Apr 2018 15:27:39 +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 1F07D5BBEF; Thu, 19 Apr 2018 15:27:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3JFQCGt022156 for ; Thu, 19 Apr 2018 11:26:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 311C184424; Thu, 19 Apr 2018 15:26:12 +0000 (UTC) Received: from andariel.redhat.com (ovpn-204-221.brq.redhat.com [10.40.204.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A4766F9E8; Thu, 19 Apr 2018 15:26:07 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 19 Apr 2018 17:25:23 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, Peter Krempa Subject: [libvirt] [RFC PATCH 26/30] tests: qemublock: Add test for raw luks disk format 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 19 Apr 2018 15:27:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Apart from adding test data add a function which sets up fake secrets for the test. The top level disk image would generate the following '-drive' cmdline: -drive file=3D/path/luks.img,key-secret=3Dtest1-encalias,format=3Dluks,if= =3Dnone,id=3Ddrive-dummy -device virtio-blk-pci,scsi=3Doff,drive=3Ddrive-dummy,id=3Ddummy Signed-off-by: Peter Krempa --- tests/qemublocktest.c | 42 ++++++++++++++++++= ++++ .../qemublocktestdata/xml2json/file-raw-luks.json | 13 +++++++ tests/qemublocktestdata/xml2json/file-raw-luks.xml | 12 +++++++ 3 files changed, 67 insertions(+) create mode 100644 tests/qemublocktestdata/xml2json/file-raw-luks.json create mode 100644 tests/qemublocktestdata/xml2json/file-raw-luks.xml diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index a79ffa90d8..55d028e9fb 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -145,6 +145,44 @@ testQemuDiskXMLToPropsClear(struct testQemuDiskXMLToJS= ONData *data) } +static int +testQemuDiskXMLToJSONFakeSecrets(virStorageSourcePtr src) +{ + qemuDomainStorageSourcePrivatePtr srcpriv; + + if (!src->privateData && + !(src->privateData =3D qemuDomainStorageSourcePrivateNew())) + return -1; + + srcpriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); + + if (src->auth) { + if (VIR_ALLOC(srcpriv->secinfo) < 0) + return -1; + + srcpriv->secinfo->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_AES; + if (VIR_STRDUP(srcpriv->secinfo->s.aes.username, src->auth->userna= me) < 0) + return -1; + + if (virAsprintf(&srcpriv->secinfo->s.aes.alias, "%s-secalias", + NULLSTR(src->nodestorage)) < 0) + return -1; + } + + if (src->encryption) { + if (VIR_ALLOC(srcpriv->encinfo) < 0) + return -1; + + srcpriv->encinfo->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_AES; + if (virAsprintf(&srcpriv->encinfo->s.aes.alias, "%s-encalias", + NULLSTR(src->nodeformat)) < 0) + return -1; + } + + return 0; +} + + static const char *testQemuDiskXMLToJSONPath =3D abs_srcdir "/qemublocktes= tdata/xml2json/"; static int @@ -180,6 +218,9 @@ testQemuDiskXMLToProps(const void *opaque) goto cleanup; for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { + if (testQemuDiskXMLToJSONFakeSecrets(n) < 0) + goto cleanup; + if (!(props =3D qemuBlockStorageSourceGetBlockdevProps(n))) { if (!data->fail) { VIR_TEST_VERBOSE("failed to generate qemu blockdev props\n= "); @@ -418,6 +459,7 @@ mymain(void) TEST_DISK_TO_JSON("dir-fat-floppy"); TEST_DISK_TO_JSON("file-raw-aio_native"); TEST_DISK_TO_JSON("file-backing_basic-aio_threads"); + TEST_DISK_TO_JSON("file-raw-luks"); cleanup: virHashFree(diskxmljsondata.schema); diff --git a/tests/qemublocktestdata/xml2json/file-raw-luks.json b/tests/qe= mublocktestdata/xml2json/file-raw-luks.json new file mode 100644 index 0000000000..e3d9c4c26b --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-raw-luks.json @@ -0,0 +1,13 @@ +{ + "node-name": "test1", + "read-only": false, + "driver": "luks", + "key-secret": "test1-encalias", + "file": { + "driver": "file", + "filename": "/path/luks.img", + "node-name": "test2", + "read-only": false, + "discard": "unmap" + } +} diff --git a/tests/qemublocktestdata/xml2json/file-raw-luks.xml b/tests/qem= ublocktestdata/xml2json/file-raw-luks.xml new file mode 100644 index 0000000000..1cbff5c83f --- /dev/null +++ b/tests/qemublocktestdata/xml2json/file-raw-luks.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list