From nobody Fri Apr 19 02:12:20 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=1584635775; cv=none; d=zohomail.com; s=zohoarc; b=ETvZi2B/08redvi9x4DiYXG1sQh6C9myO5l7AlDhau0iPsEfBWRaFzkw0y4n1MRykxrpOuKz1B16Vw+UhHGviK1Gh1dmTzx0+WnaCYaXX7nL/rRYVzig1t8OXTuGllWvH5x6gp9oJl+VNzXj2nPBO+EYdQUwqhKL3oLTaSqHuvQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584635775; 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=jMHfo0HwFcMZkzTPrsLR323JXUS9COsJW2Z6DMyq19w=; b=bX41y9lrF5eGUUi7JgkQPHjI8XAKiLLUjCyixhePxNe5u1dQF0IT1bWu9z09h2sXn32mInCEqK5OOxU6pYP7IHONPEzwuhBXGRIk3NqUf6i6BF1CnsxXAs07Wd7EIbdoD9/pYRfP6iQyLLNQdPjGnJKGGxdZJh7/bEp5+uL3n7A= 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 1584635775014758.0262770181803; Thu, 19 Mar 2020 09:36:15 -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-196-uf5-SyK9NECbQAAIbRKUGg-1; Thu, 19 Mar 2020 12:36:11 -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 129A11857BF2; Thu, 19 Mar 2020 16:36:05 +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 D8F665C1CD; Thu, 19 Mar 2020 16:36:04 +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 7224A9428D; Thu, 19 Mar 2020 16:36:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02JGZk77015360 for ; Thu, 19 Mar 2020 12:35:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB9416EFAE; Thu, 19 Mar 2020 16:35:46 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B6B562673 for ; Thu, 19 Mar 2020 16:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584635773; 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=jMHfo0HwFcMZkzTPrsLR323JXUS9COsJW2Z6DMyq19w=; b=UTSX7VxnnpXlI6jDkPHNoR2qX7OJ+ePL4PXbn/IRXayGZP4W/bVjXWO3Cj3qoIgjvgS6SB qdJ1754cW2ZCvVRR9MsDt+EiDnDStIpHYqsGFv6pjRUkA0vONsCEGtVFFBGW9TZstO2X+o gy4I3qaQb8/ZjaHGC/0o+ee3mfzaQb4= X-MC-Unique: uf5-SyK9NECbQAAIbRKUGg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/4] qemuxml2argvdata/disk-slices: Add test case for 'luks' encryption Date: Thu, 19 Mar 2020 17:35:38 +0100 Message-Id: <2b386b8400e696e2bc430eeb989fb09afc5cc3dd.1584635655.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" Since libvirt handles the luks encryption in a weird special way (raw+encryption) we should really test that case with slices as well. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- .../disk-slices.x86_64-latest.args | 38 ++++++++++++------- tests/qemuxml2argvdata/disk-slices.xml | 13 +++++++ .../disk-slices.x86_64-latest.xml | 16 +++++++- 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-slices.x86_64-latest.args index 49daa293a4..75485c17a7 100644 --- a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args @@ -29,25 +29,35 @@ file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -boot strict=3Don \ -device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img",\ -"node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"raw= ",\ -"offset":1234,"size":321,"file":"libvirt-3-storage"}' \ --device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x2,drive=3Dlibvirt-3= -format,\ +"node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"raw= ",\ +"offset":1234,"size":321,"file":"libvirt-4-storage"}' \ +-device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x2,drive=3Dlibvirt-4= -format,\ id=3Dvirtio-disk0,bootindex=3D1 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img",\ -"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"driver":"raw","node-name":"libvirt-2-slice-sto","offset":9876= ,\ -"size":123456789,"file":"libvirt-2-storage","auto-read-only":true,\ +"node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"driver":"raw","node-name":"libvirt-3-slice-sto","offset":9876= ,\ +"size":123456789,"file":"libvirt-3-storage","auto-read-only":true,\ "discard":"unmap"}' \ --blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"qcow= 2",\ -"file":"libvirt-2-slice-sto","backing":null}' \ +-blockdev '{"node-name":"libvirt-3-format","read-only":true,"driver":"qcow= 2",\ +"file":"libvirt-3-slice-sto","backing":null}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/overlay.qc= ow2",\ -"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qco= w2",\ -"file":"libvirt-1-storage","backing":"libvirt-2-format"}' \ --device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x3,drive=3Dlibvirt-1= -format,\ +"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"qco= w2",\ +"file":"libvirt-2-storage","backing":"libvirt-3-format"}' \ +-device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x3,drive=3Dlibvirt-2= -format,\ id=3Dvirtio-disk1 \ --device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 \ +-object secret,id=3Dlibvirt-1-format-encryption-secret0,\ +data=3D9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ +keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/luks.img",\ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"luk= s",\ +"key-secret":"libvirt-1-format-encryption-secret0","offset":1234,"size":32= 1,\ +"file":"libvirt-1-storage"}' \ +-device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x4,drive=3Dlibvirt-1= -format,\ +id=3Dvirtio-disk2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x5 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ resourcecontrol=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/disk-slices.xml b/tests/qemuxml2argvdat= a/disk-slices.xml index cff7cc7ee4..5c6f29d154 100644 --- a/tests/qemuxml2argvdata/disk-slices.xml +++ b/tests/qemuxml2argvdata/disk-slices.xml @@ -38,6 +38,19 @@ + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml b/tests= /qemuxml2xmloutdata/disk-slices.x86_64-latest.xml index 65590df417..4f4abcda1f 100644 --- a/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml @@ -43,6 +43,20 @@
+ + + + + + + + + + + + +
+
@@ -50,7 +64,7 @@ -
+
--=20 2.24.1 From nobody Fri Apr 19 02:12:20 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=1584635763; cv=none; d=zohomail.com; s=zohoarc; b=EXOfl6DuY0tjgm3zWD2Oxm1pKqqiY7v6PBJh0rKC0IKdMfVYL6wmk1RxCQJaRGVBk7GKTiHaRHBjR9P4vYcWAFxPRXsxJc4rBUCWl3Sdc7ftv7xhhRwpsExE/DMO4AAYXpGi7IqmtzyKE4pIJxV4gIi+MXrDL0w2u0MG3pfhTq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584635763; 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=uXnpD/9TU+R23JpZ8qd7nggNkqZAYAmn1dON+oJkAm8=; b=CoLicY3NvttMq3QrV5Bdt2xkLMFOO4bdpXb0PB49Zmq7BWq+b19OF5K4p7AxEHb8AhyFPAfE30UHpYGCPi/CG86tjf0438VDe6qBUqxjhSq/GaxmLR3MU68lZ/uvMKTB2HWFlEZZFZDF2WzyHjwrCe6Hw9N8b5LIvn893u7ub7o= 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 1584635763309294.4245138526122; Thu, 19 Mar 2020 09:36:03 -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-99-UNLHVOQeM1KrTfPlLi3SKQ-1; Thu, 19 Mar 2020 12:36:00 -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 B00E5800D5A; Thu, 19 Mar 2020 16:35:53 +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 5B1BE29159; Thu, 19 Mar 2020 16:35:53 +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 65DB287015; Thu, 19 Mar 2020 16:35:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02JGZnT5015371 for ; Thu, 19 Mar 2020 12:35:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B85F73869; Thu, 19 Mar 2020 16:35:49 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id C541873865 for ; Thu, 19 Mar 2020 16:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584635762; 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=uXnpD/9TU+R23JpZ8qd7nggNkqZAYAmn1dON+oJkAm8=; b=ZmFWF+u8et7OSSCdYLr9UzXZdgPhpbcw4L9wjDAJHLXDU78YRhFFsq9SMCAtiUlXswcN4T XPknXTCjf4RMFrGBXuyYnWyySJz8rZUfCAfxQREysklmHravw4d+DCDrJxjlIrxNED9ZFR 2vwY41k6QZfe4n5h8xyAvG/h8PXhzU0= X-MC-Unique: UNLHVOQeM1KrTfPlLi3SKQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu: block: Extract logic decision when to use a separate 'raw' layer for slice Date: Thu, 19 Mar 2020 17:35:39 +0100 Message-Id: <3473060d6e25b4283778705a849a4b142f3e772d.1584635655.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" Introduce qemuBlockStorageSourceNeedsStorageSliceLayer which will hold the decision logic and fix all places that open-code it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 24 +++++++++++++++++++++--- src/qemu/qemu_block.h | 3 +++ src/qemu/qemu_domain.c | 3 +-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4ed17b6df3..b5b34ab441 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1446,8 +1446,7 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSour= cePtr src, g_autoptr(virJSONValue) props =3D NULL; const char *storagenode =3D src->nodestorage; - if (src->sliceStorage && - src->format !=3D VIR_STORAGE_FILE_RAW) + if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) storagenode =3D src->sliceStorage->nodename; if (!(props =3D qemuBlockStorageSourceGetBlockdevFormatProps(src))) @@ -1568,7 +1567,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSourcePtr src, data->storageNodeName =3D src->nodestorage; data->formatNodeName =3D src->nodeformat; - if (src->sliceStorage && src->format !=3D VIR_STORAGE_FILE_RAW) { + if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) { if (!(data->storageSliceProps =3D qemuBlockStorageSourceGetBlockde= vStorageSliceProps(src))) return NULL; @@ -3308,3 +3307,22 @@ qemuBlockReopenReadOnly(virDomainObjPtr vm, return 0; } + +/** + * qemuBlockStorageSourceNeedSliceLayer: + * @src: source to inspect + * + * Returns true if @src requires an extra 'raw' layer for handling of the = storage + * slice. + */ +bool +qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src) +{ + if (!src->sliceStorage) + return false; + + if (src->format !=3D VIR_STORAGE_FILE_RAW) + return true; + + return false; +} diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index 75b25bfea5..28475b25c1 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -254,3 +254,6 @@ int qemuBlockReopenReadOnly(virDomainObjPtr vm, virStorageSourcePtr src, qemuDomainAsyncJob asyncJob); + +bool +qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0e2252f6cf..7dda986e3a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -16590,8 +16590,7 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDis= kDefPtr disk, src->nodestorage =3D g_strdup_printf("libvirt-%u-storage", src->id); src->nodeformat =3D g_strdup_printf("libvirt-%u-format", src->id); - if (src->sliceStorage && - src->format !=3D VIR_STORAGE_FILE_RAW) + if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) src->sliceStorage->nodename =3D g_strdup_printf("libvirt-%u-slice-= sto", src->id); if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0) --=20 2.24.1 From nobody Fri Apr 19 02:12:20 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=1584635780; cv=none; d=zohomail.com; s=zohoarc; b=GGy2byah4WUDoEiR3TTux3EoO6DG2eMHzcW8uvj0xizuQsjPlIetVeofLKzIDxkvxvhh0h/hBRn7J8P07vnOaGER+55TYc3A/RviNJRHiM4F7Cr50h9FcN4ES1Hn5gzYZbeDULYBjEjc3mVqnalHtwFVl94hViyDPGFkv4r1HZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584635780; 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=/juKdzA+lRQhZw96Wf0QjJg7zORB3OyDF1uBDgeDPQA=; b=bY+X50y+sDkm5QT5cg9DAEjgITKLFUN5jt+F9mtj039CbRCw6+OuHsaKeGo9EIZZ3CbO0ntdUoDWLd+87k6owNvL8RmVAOp0ZsG/fjsyPsNDHDApEhFO2Xji+892ulrJoYeERY/8sGgm6MYwnTeMEWFtrKfLlL2ooCV07yikFBs= 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 1584635780169737.6812480151442; Thu, 19 Mar 2020 09:36:20 -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-487-EoMY4dF-MiGQJmhS_b3pLA-1; Thu, 19 Mar 2020 12:36:16 -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 B022B801E53; Thu, 19 Mar 2020 16:36:09 +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 85A8F5C1D5; Thu, 19 Mar 2020 16:36:09 +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 3169C18089CE; Thu, 19 Mar 2020 16:36:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02JGZp5i015381 for ; Thu, 19 Mar 2020 12:35:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1B57F73897; Thu, 19 Mar 2020 16:35:51 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 951FB7387A for ; Thu, 19 Mar 2020 16:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584635778; 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=/juKdzA+lRQhZw96Wf0QjJg7zORB3OyDF1uBDgeDPQA=; b=R5SOztC90S1aMIIE1/F+7MLVe1UIABNgZEM24xAzkwEYe+Y0kHEbKU2C0vxz2UQhVVohUg lqc8xWmExzA1Bux0pNS2g+p878WS442az9BDzC/vbSPEeQizrSNIoce2lzmOMQA5+rC5Ih sPfLxRKfyZdgy9JcAo/ODGnc+U06se0= X-MC-Unique: EoMY4dF-MiGQJmhS_b3pLA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/4] qemuBlockStorageSourceNeedsStorageSliceLayer: Deal with 'luks' files Date: Thu, 19 Mar 2020 17:35:40 +0100 Message-Id: <2fa684df1b760b83b8d8b7305a92652de5501c03.1584635655.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" The 'luks' driver in qemu is as any other non-raw format driver and thus doesn't support the properties for 'slice'. Since libvirt considers luks files to be raw+encryption we need to special case them when dealing with the slice. https://bugzilla.redhat.com/show_bug.cgi?id=3D1814975 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 4 ++++ tests/qemuxml2argvdata/disk-slices.x86_64-latest.args | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index b5b34ab441..ee15167215 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3324,5 +3324,9 @@ qemuBlockStorageSourceNeedsStorageSliceLayer(const vi= rStorageSource *src) if (src->format !=3D VIR_STORAGE_FILE_RAW) return true; + if (src->encryption && + src->encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) + return true; + return false; } diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-slices.x86_64-latest.args index 75485c17a7..63bdaa58be 100644 --- a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args @@ -52,9 +52,12 @@ data=3D9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8= wBYM91uEHCn6j/1,\ keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,format=3Dbase64 \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/luks.img",\ "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"driver":"raw","node-name":"libvirt-1-slice-sto","offset":1234= ,\ +"size":321,"file":"libvirt-1-storage","auto-read-only":true,\ +"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"luk= s",\ "key-secret":"libvirt-1-format-encryption-secret0","offset":1234,"size":32= 1,\ -"file":"libvirt-1-storage"}' \ +"file":"libvirt-1-slice-sto"}' \ -device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x4,drive=3Dlibvirt-1= -format,\ id=3Dvirtio-disk2 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x5 \ --=20 2.24.1 From nobody Fri Apr 19 02:12:20 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=1584635783; cv=none; d=zohomail.com; s=zohoarc; b=I8DwPFcc6Iuk20B16+igD7iLn/T9nVWEe5THC8nZXeX+BtqUcuIO1j9stCS4/nqsB68yFdbx928hFTbmbaSr50lJuRmS4syXI823ZS6KtTGChDQSoD7YnWQvOPKROgl5Sq3S7tycRUw8NUtupJcBX7kdqGj0SjgyNTHMay0LSzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584635783; 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=9NkqDOa3swYq3/AXEnMfqRdEyp75P+Holkwmakhkzjs=; b=gUgA6UmEUWEfc3PTYsBIMhNj1wrk5ftBkZ20B2UU71r+1s3eabSJfMjgHaragDKMHmdh1ovegtuet7qI9fnqrww1cJs3RMFuEvugbKD682dNEIeY/aRc4KEMwebxozF7URwI79bnM01nnKQbl4w3s0tEtpZjVwhBhQt/4A0qJcI= 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 1584635783217904.2624093686564; Thu, 19 Mar 2020 09:36: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-203-p7OBIOSvPLmhLKfxrZhxxA-1; Thu, 19 Mar 2020 12:36:20 -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 00F48800D5E; Thu, 19 Mar 2020 16:36:14 +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 C01569495C; Thu, 19 Mar 2020 16:36: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 64A0418089D0; Thu, 19 Mar 2020 16:36:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02JGZsJO015397 for ; Thu, 19 Mar 2020 12:35:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA5CE790DA; Thu, 19 Mar 2020 16:35:54 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EF10790D7 for ; Thu, 19 Mar 2020 16:35:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584635782; 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=9NkqDOa3swYq3/AXEnMfqRdEyp75P+Holkwmakhkzjs=; b=coZO0DTJErg523lTXSLB4YfJJAx8H/NF+sZnkbmIOhVQb0Jv6vQUzLm6udfFXgovjXBXJf 7kSfyZzeS9udbEiWV1X7/kw6mFbW1ykVQZlCYLMg2g/+7jDABDqUMx+wXndHSdrz2QV5Mp rdYvg/RgjFzT7bAAPTTuezxExDmjpa0= X-MC-Unique: p7OBIOSvPLmhLKfxrZhxxA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu: block: Split up formatting of JSON props for 'raw' and 'luks' drivers Date: Thu, 19 Mar 2020 17:35:41 +0100 Message-Id: <30feb74a53e6ce24ab76a27fb6904c7b1f59d66a.1584635655.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" qemuBlockStorageSourceGetFormatRawProps aggregated both formats but since we now have props specific for either of those formats it's unwanted to aggregate the code such way. Split out the 'luks' props formatter into qemuBlockStorageSourceGetFormatLUKSProps. The wrong separation demonstrates istself on formatting of the 'size' and 'offset' attributes for the 'luks' driver which does not conform to the qapi schema. https://bugzilla.redhat.com/show_bug.cgi?id=3D1814975 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 42 ++++++++++++------- .../disk-slices.x86_64-latest.args | 2 +- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index ee15167215..5c85ddd44c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1200,24 +1200,32 @@ qemuBlockStorageSourceGetBackendProps(virStorageSou= rcePtr src, static int -qemuBlockStorageSourceGetFormatRawProps(virStorageSourcePtr src, - virJSONValuePtr props) +qemuBlockStorageSourceGetFormatLUKSProps(virStorageSourcePtr src, + virJSONValuePtr props) { qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); - const char *driver =3D "raw"; - const char *secretalias =3D NULL; - if (src->encryption && - src->encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS = && - srcPriv && - srcPriv->encinfo) { - driver =3D "luks"; - secretalias =3D srcPriv->encinfo->s.aes.alias; + if (!srcPriv || !srcPriv->encinfo || !srcPriv->encinfo->s.aes.alias) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing secret info for 'luks' driver")); + return -1; } if (virJSONValueObjectAdd(props, - "s:driver", driver, - "S:key-secret", secretalias, NULL) < 0) + "s:driver", "luks", + "s:key-secret", srcPriv->encinfo->s.aes.alia= s, + NULL) < 0) + return -1; + + return 0; +} + + +static int +qemuBlockStorageSourceGetFormatRawProps(virStorageSourcePtr src, + virJSONValuePtr props) +{ + if (virJSONValueObjectAdd(props, "s:driver", "raw", NULL) < 0) return -1; /* Currently only storage slices are supported. We'll have to calculate @@ -1371,8 +1379,14 @@ qemuBlockStorageSourceGetBlockdevFormatProps(virStor= ageSourcePtr src) /* The fat layer is emulated by the storage access layer, so we ne= ed to * put a raw layer on top */ case VIR_STORAGE_FILE_RAW: - if (qemuBlockStorageSourceGetFormatRawProps(src, props) < 0) - return NULL; + if (src->encryption && + src->encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_L= UKS) { + if (qemuBlockStorageSourceGetFormatLUKSProps(src, props) < 0) + return NULL; + } else { + if (qemuBlockStorageSourceGetFormatRawProps(src, props) < 0) + return NULL; + } break; case VIR_STORAGE_FILE_QCOW2: diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-slices.x86_64-latest.args index 63bdaa58be..869b4c0af0 100644 --- a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args @@ -56,7 +56,7 @@ keyid=3DmasterKey0,iv=3DAAECAwQFBgcICQoLDA0ODw=3D=3D,form= at=3Dbase64 \ "size":321,"file":"libvirt-1-storage","auto-read-only":true,\ "discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"luk= s",\ -"key-secret":"libvirt-1-format-encryption-secret0","offset":1234,"size":32= 1,\ +"key-secret":"libvirt-1-format-encryption-secret0",\ "file":"libvirt-1-slice-sto"}' \ -device virtio-blk-pci,scsi=3Doff,bus=3Dpci.0,addr=3D0x4,drive=3Dlibvirt-1= -format,\ id=3Dvirtio-disk2 \ --=20 2.24.1