From nobody Sun Feb 8 22:07:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1702546481533482.32878743163224; Thu, 14 Dec 2023 01:34:41 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 723E719AF; Thu, 14 Dec 2023 04:34:40 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9D0161932; Thu, 14 Dec 2023 04:21:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5F43C17E3; Thu, 14 Dec 2023 04:20:44 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 954D61946 for ; Thu, 14 Dec 2023 04:19:55 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-256-OJT07A4YNcybjYe9jO9FeA-1; Thu, 14 Dec 2023 04:19:53 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74BF6863B88 for ; Thu, 14 Dec 2023 09:19:53 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id F08EB40C6EB9 for ; Thu, 14 Dec 2023 09:19:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: OJT07A4YNcybjYe9jO9FeA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 08/10] qemu: block: Format storage slice properties optionally Date: Thu, 14 Dec 2023 10:19:43 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: CFNMVWKTKV2UUAX3G65XKGSIDMJCKQBJ X-Message-ID-Hash: CFNMVWKTKV2UUAX3G65XKGSIDMJCKQBJ X-MailFrom: pkrempa@redhat.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 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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1702546482969100001 Prepare the blockdev props formatter to skip formatting the slice props in case they are not applicable. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 19 ++++++++++++++----- .../disk-slices.x86_64-latest.args | 10 +++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index fd914d2e70..8e2da95139 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1434,22 +1434,31 @@ qemuBlockStorageSourceGetFormatProps(virStorageSour= ce *src, * qemuBlockStorageSourceGetBlockdevStorageSliceProps: * @src: storage source object * @effective: Whether this blockdev will be the 'effective' layer of @src + * @resize: If true, the 'size' and 'offset' parameters are not formatted * * Formats the JSON object representing -blockdev configuration required to * configure a 'slice' of @src. If @effective is true, the slice layer is = the - * topmost/effective blockdev layer of @src. + * topmost/effective blockdev layer of @src. If @resize is true the 'size'= and + * 'offset' are not formatted, which is used to remove a slice restriction + * to resize the image. */ static virJSONValue * qemuBlockStorageSourceGetBlockdevStorageSliceProps(virStorageSource *src, - bool effective) + bool effective, + bool resize) { g_autoptr(virJSONValue) props =3D NULL; if (virJSONValueObjectAdd(&props, "s:driver", "raw", + "s:file", qemuBlockStorageSourceGetStorageNo= dename(src), + NULL) < 0) + return NULL; + + if (!resize && + virJSONValueObjectAdd(&props, "U:offset", src->sliceStorage->offset, "U:size", src->sliceStorage->size, - "s:file", qemuBlockStorageSourceGetStorageNo= dename(src), NULL) < 0) return NULL; @@ -1530,7 +1539,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSource *src, } if ((data->storageSliceNodeName =3D qemuBlockStorageSourceGetSliceNode= name(src))) { - if (!(data->storageSliceProps =3D qemuBlockStorageSourceGetBlockde= vStorageSliceProps(src, effective))) + if (!(data->storageSliceProps =3D qemuBlockStorageSourceGetBlockde= vStorageSliceProps(src, effective, false))) return NULL; effective =3D false; @@ -3150,7 +3159,7 @@ qemuBlockReopenAccess(virDomainObj *vm, if (!(srcprops =3D qemuBlockStorageSourceGetFormatProps(src, src->= backingStore))) return -1; } else if (qemuBlockStorageSourceGetSliceNodename(src)) { - if (!(srcprops =3D qemuBlockStorageSourceGetBlockdevStorageSlicePr= ops(src, true))) + if (!(srcprops =3D qemuBlockStorageSourceGetBlockdevStorageSlicePr= ops(src, true, false))) return -1; } else { if (!(srcprops =3D qemuBlockStorageSourceGetBackendProps(src, diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-slices.x86_64-latest.args index c28eeb827e..658391c477 100644 --- a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args @@ -28,25 +28,25 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUG= uest1/.config \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img","= node-name":"libvirt-6-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"driver":"raw","offset":0,"size":321,"file":"libvirt-6-storage= ","node-name":"libvirt-6-slice-sto","read-only":false}' \ +-blockdev '{"driver":"raw","file":"libvirt-6-storage","offset":0,"size":32= 1,"node-name":"libvirt-6-slice-sto","read-only":false}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"li= bvirt-6-slice-sto","id":"virtio-disk0","bootindex":1}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/raw.img","= node-name":"libvirt-5-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"driver":"raw","offset":9876,"size":123456789,"file":"libvirt-= 5-storage","node-name":"libvirt-5-slice-sto","auto-read-only":true,"discard= ":"unmap"}' \ +-blockdev '{"driver":"raw","file":"libvirt-5-storage","offset":9876,"size"= :123456789,"node-name":"libvirt-5-slice-sto","auto-read-only":true,"discard= ":"unmap"}' \ -blockdev '{"node-name":"libvirt-5-format","read-only":true,"driver":"qcow= 2","file":"libvirt-5-slice-sto","backing":null}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/overlay.qc= ow2","node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap= "}' \ -blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"qco= w2","file":"libvirt-4-storage","backing":"libvirt-5-format"}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"li= bvirt-4-format","id":"virtio-disk1"}' \ -object '{"qom-type":"secret","id":"libvirt-3-format-encryption-secret0","= data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","k= eyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw=3D=3D","format":"base64"}' \ -blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/luks.img",= "node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"driver":"raw","offset":1234,"size":321,"file":"libvirt-3-stor= age","node-name":"libvirt-3-slice-sto","auto-read-only":true,"discard":"unm= ap"}' \ +-blockdev '{"driver":"raw","file":"libvirt-3-storage","offset":1234,"size"= :321,"node-name":"libvirt-3-slice-sto","auto-read-only":true,"discard":"unm= ap"}' \ -blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"luk= s","key-secret":"libvirt-3-format-encryption-secret0","file":"libvirt-3-sli= ce-sto"}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"li= bvirt-3-format","id":"virtio-disk2"}' \ -blockdev '{"driver":"nvme","device":"0000:02:00.0","namespace":1,"node-na= me":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ --blockdev '{"driver":"raw","offset":1234,"size":321,"file":"libvirt-2-stor= age","node-name":"libvirt-2-slice-sto","read-only":false}' \ +-blockdev '{"driver":"raw","file":"libvirt-2-storage","offset":1234,"size"= :321,"node-name":"libvirt-2-slice-sto","read-only":false}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"li= bvirt-2-slice-sto","id":"virtio-disk3"}' \ -object '{"qom-type":"secret","id":"libvirt-1-format-encryption-secret0","= data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","k= eyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw=3D=3D","format":"base64"}' \ -blockdev '{"driver":"nvme","device":"0001:02:00.0","namespace":2,"node-na= me":"libvirt-1-storage","auto-read-only":true,"discard":"unmap","cache":{"d= irect":true,"no-flush":false}}' \ --blockdev '{"driver":"raw","offset":1234,"size":321,"file":"libvirt-1-stor= age","node-name":"libvirt-1-slice-sto","auto-read-only":true,"discard":"unm= ap","cache":{"direct":true,"no-flush":false}}' \ +-blockdev '{"driver":"raw","file":"libvirt-1-storage","offset":1234,"size"= :321,"node-name":"libvirt-1-slice-sto","auto-read-only":true,"discard":"unm= ap","cache":{"direct":true,"no-flush":false}}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"cache":{"dir= ect":true,"no-flush":false},"driver":"qcow2","encrypt":{"format":"luks","ke= y-secret":"libvirt-1-format-encryption-secret0"},"file":"libvirt-1-slice-st= o"}' \ -device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x7","drive":"li= bvirt-1-format","id":"virtio-disk4","write-cache":"on"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org