From nobody Mon Feb 9 03:52:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=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 --- 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