From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1581530641630659.7869619521198; Wed, 12 Feb 2020 10:04:01 -0800 (PST) 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-216-y0K2-cB8OgOq19jAkw6C4Q-1; Wed, 12 Feb 2020 13:03:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CBAFC107ACCC; Wed, 12 Feb 2020 18:03:51 +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 A252A1001B07; Wed, 12 Feb 2020 18:03:51 +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 60E1F18089CE; Wed, 12 Feb 2020 18:03:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3UpQ004239 for ; Wed, 12 Feb 2020 13:03:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id A3DC310002B8; Wed, 12 Feb 2020 18:03:30 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28CB11001281 for ; Wed, 12 Feb 2020 18:03:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530640; 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=tI5rjJjZEH5AEfarTSBdtt2r3CT8RJvEp32C1gfXh7c=; b=OLvrWhZv5ZH/m2bKWbXFTRszhnT8/q6GXdTEFL+IKgScwR8NUyOKZkq4kVQf50dfFxNoFV yAEhzUcME9w0fpz50/8g2rL1VSGsGPlHu5DNl2ArnpBpWbBnEoR7rbrK9Ow/oiUhekZBdJ Y0RYZ8MyFgqNTqS7eVKZ1uTKbPPoTS0= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 01/15] qemu: domain: Refactor formatting of node names into status XML Date: Wed, 12 Feb 2020 19:03:12 +0100 Message-Id: <9b52b5dfc26e8342f070b39bf1d37cf81fc6e14e.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 X-MC-Unique: y0K2-cB8OgOq19jAkw6C4Q-1 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" Use virXMLFormatElement to simplify the logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6fc0bd4e68..139496307f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2370,15 +2370,12 @@ qemuStorageSourcePrivateDataFormat(virStorageSource= Ptr src, { g_auto(virBuffer) tmp =3D VIR_BUFFER_INIT_CHILD(buf); qemuDomainStorageSourcePrivatePtr srcPriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); + g_auto(virBuffer) nodenamesChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); - if (src->nodestorage || src->nodeformat) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "\n", src->nodestorage); - virBufferEscapeString(buf, "\n", src->nodeformat); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + virBufferEscapeString(&nodenamesChildBuf, "\n", src->nodestorage); + virBufferEscapeString(&nodenamesChildBuf, "\n", src->nodeformat); + + virXMLFormatElement(buf, "nodenames", NULL, &nodenamesChildBuf); if (src->pr) virBufferAsprintf(buf, "\n", src->p= r->mgralias); --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1581530630047338.1552736133374; Wed, 12 Feb 2020 10:03:50 -0800 (PST) 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-64-RoYGeM7GMGy24qgeXFAigw-1; Wed, 12 Feb 2020 13:03:44 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1442218CA240; Wed, 12 Feb 2020 18:03:37 +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 3A67D2632C; Wed, 12 Feb 2020 18:03:36 +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 CAAC68B2A7; Wed, 12 Feb 2020 18:03:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3Vbi004246 for ; Wed, 12 Feb 2020 13:03:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7AAB41001281; Wed, 12 Feb 2020 18:03:31 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id F39C510002B8 for ; Wed, 12 Feb 2020 18:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530628; 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=s3A+tP5LQG1G1wxHXShW5J6ZD59VEHjEqRG9LKApLfg=; b=DYKS0gi4kvQ4VN2EI0QIU5mP3x59WZPcnFLphjJj7+/gL/3W5FGSqLYmtPu7idCBdYBjSj L2vp+6wyGiaJ6oxDBaq2enY4AKHbEVY6yHIcWUSIntAK2V/3gxeEg3/8xTxskslWWZjPHh pQseHuJNdpt/EHlUqnW65DLgCz8nYvA= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 02/15] docs: formatdomain: Close on one of disk examples Date: Wed, 12 Feb 2020 19:03:13 +0100 Message-Id: <88c4fec1aa4a8ee98f6decbb70d79b5c1401e1b8.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.23 X-MC-Unique: RoYGeM7GMGy24qgeXFAigw-1 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" Signed-off-by: Peter Krempa --- docs/formatdomain.html.in | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 5ccf39abd1..200a9cb79a 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2881,6 +2881,7 @@ <reservations managed=3D'no'> <source type=3D'unix' path=3D'/path/to/qemu-pr-helper' mode=3D'= client'/> </reservations> + </source> <target dev=3D'sda' bus=3D'scsi'/> <address type=3D'drive' controller=3D'0' bus=3D'0' target=3D'3' uni= t=3D'0'/> </disk> --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1581530634483946.7437518350891; Wed, 12 Feb 2020 10:03:54 -0800 (PST) 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-174-b98tlzXjM5SoWlKaFuOTMg-1; Wed, 12 Feb 2020 13:03:44 -0500 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 150C2100550E; Wed, 12 Feb 2020 18:03:37 +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 61BBA5C101; Wed, 12 Feb 2020 18:03:36 +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 49E0E8B2A5; Wed, 12 Feb 2020 18:03:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3WqP004255 for ; Wed, 12 Feb 2020 13:03:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 522E51001DDE; Wed, 12 Feb 2020 18:03:32 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB7C61001281 for ; Wed, 12 Feb 2020 18:03:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530633; 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=l9EVpTVkfv5Pqj2+zkp30KtGcBRJ++PudU3B5jvn2CM=; b=N3wfqeXcPmPrOaWyyhJPaaw41C1Rra8Poox6fzwjAoNvWnbwPN3IkVLjn2D0Wg9Qwrk01C FZNQDl8ZAl0kgNTaP8E6oDW4vN6fIAOC0jYAsSxzyER2/OhWIbz0oM6DESjI8gKDZKXVwM USefpwradxz7rCaXVXgym7cdv6KK5PA= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 03/15] tests: virstorage: Add test data for json specified raw image with offset/size Date: Wed, 12 Feb 2020 19:03:14 +0100 Message-Id: <396f0ccd421b157ae5f974b18a8b6cd76ff6d456.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-MC-Unique: b98tlzXjM5SoWlKaFuOTMg-1 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" QEMU allows specifying the offset and size into a raw file to expose a sub-slice of the image to the guest with the raw driver. Libvirt currently doesn't support it but we can add test case for future reference. Signed-off-by: Peter Krempa --- tests/virstoragetest.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 6d62aab654..25d41f0de4 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1593,6 +1593,15 @@ mymain(void) "\n" " \n" "\n"); + TEST_BACKING_PARSE_FULL("json:{ \"driver\": \"raw\"," + "\"offset\": 10752," + "\"size\": 4063232," + "\"file\": { \"driver\": \"file\"," + "\"filename\": \"/tmp/test= fle\"" + "}" + "}", + "\n", 0); + #endif /* WITH_YAJL */ cleanup: --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581530646936536.6917465599881; Wed, 12 Feb 2020 10:04:06 -0800 (PST) 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-419-zZ9RzHY0NH2AUbUyzuwFdw-1; Wed, 12 Feb 2020 13:04:02 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C703A100551C; Wed, 12 Feb 2020 18:03:55 +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 A0B235C1BB; Wed, 12 Feb 2020 18:03:55 +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 554BB8B2A5; Wed, 12 Feb 2020 18:03:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3XZv004268 for ; Wed, 12 Feb 2020 13:03:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2A5CE1001281; Wed, 12 Feb 2020 18:03:33 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A32C71001DDE for ; Wed, 12 Feb 2020 18:03:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530645; 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=1AUfd304w86cwE/qOniY3g0JrEk/8eXqwnW7jPqbjV0=; b=WU06bHLzYnTeVuRtV2nwQQtDmnYyRbIuMwtCT5TbNgxz2ki/GUm5fhf87owIfYpsO5Vta2 FKlPKc3NafTEE9ia/cuXPolL42RM3Fa6q/1DCUW52k0Ora5lhmOi7x/xGahkEWdQvpvA0I sRB6aX8ZXP9cfQwiGx8/BdY343k/9A0= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 04/15] util: virstoragefile: Add data structure for storing storage source slices Date: Wed, 12 Feb 2020 19:03:15 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 X-MC-Unique: zZ9RzHY0NH2AUbUyzuwFdw-1 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 virStorageSourceSlice which will store the 'offset' and 'size' of a virStorageSource and declare it as 'sliceStorage' and 'sliceFormat' attributes of a virStorageSource. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 29 +++++++++++++++++++++++++++++ src/util/virstoragefile.h | 12 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7ffb2cdcf4..890ec69929 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2248,6 +2248,30 @@ virStorageSourcePoolDefCopy(const virStorageSourcePo= olDef *src) } +static virStorageSourceSlicePtr +virStorageSourceSliceCopy(const virStorageSourceSlice *src) +{ + virStorageSourceSlicePtr ret =3D g_new0(virStorageSourceSlice, 1); + + ret->offset =3D src->offset; + ret->size =3D src->size; + ret->nodename =3D g_strdup(src->nodename); + + return ret; +} + + +static void +virStorageSourceSliceFree(virStorageSourceSlicePtr slice) +{ + if (!slice) + return; + + g_free(slice->nodename); + g_free(slice); +} + + /** * virStorageSourcePtr: * @@ -2302,6 +2326,9 @@ virStorageSourceCopy(const virStorageSource *src, def->tlsAlias =3D g_strdup(src->tlsAlias); def->tlsCertdir =3D g_strdup(src->tlsCertdir); + if (src->sliceStorage) + def->sliceStorage =3D virStorageSourceSliceCopy(src->sliceStorage); + if (src->nhosts) { if (!(def->hosts =3D virStorageNetHostDefCopy(src->nhosts, src->ho= sts))) return NULL; @@ -2581,6 +2608,8 @@ virStorageSourceClear(virStorageSourcePtr def) VIR_FREE(def->timestamps); VIR_FREE(def->externalDataStoreRaw); + virStorageSourceSliceFree(def->sliceStorage); + virObjectUnref(def->externalDataStore); def->externalDataStore =3D NULL; diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 39e50a989d..1f41e6e357 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -242,6 +242,16 @@ struct _virStorageSourceNVMeDef { /* Don't forget to update virStorageSourceNVMeDefCopy */ }; + +typedef struct _virStorageSourceSlice virStorageSourceSlice; +typedef virStorageSourceSlice *virStorageSourceSlicePtr; +struct _virStorageSourceSlice { + unsigned long long offset; + unsigned long long size; + char *nodename; +}; + + typedef struct _virStorageDriverData virStorageDriverData; typedef virStorageDriverData *virStorageDriverDataPtr; @@ -286,6 +296,8 @@ struct _virStorageSource { bool nocow; bool sparse; + virStorageSourceSlicePtr sliceStorage; + virStoragePermsPtr perms; virStorageTimestampsPtr timestamps; unsigned long long capacity; /* in bytes, 0 if unknown */ --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1581530642479911.857107804312; Wed, 12 Feb 2020 10:04:02 -0800 (PST) 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-351-BQzB_xdyOS-FIrs9f044rQ-1; Wed, 12 Feb 2020 13:03:58 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3BE8800E21; Wed, 12 Feb 2020 18:03:51 +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 AF6838B547; Wed, 12 Feb 2020 18:03:51 +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 6847E18089D0; Wed, 12 Feb 2020 18:03:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3YK4004275 for ; Wed, 12 Feb 2020 13:03:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 08831100034E; Wed, 12 Feb 2020 18:03:34 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 821B71001281 for ; Wed, 12 Feb 2020 18:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530641; 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=6wV7RsqefJy5+3XXKLQI73fVoV59TtKrTyknZb0zrxY=; b=JEakCqaHYAcDM7pUzBemqtZkIgJIr6Au//hJYCgZc/IFU3QnAnE1yjs0oEEorE/z+h/BRt VssQ75tar0Hxb5mNUWHUp240wUifhb50VFENgml+eSgpiiV9xA2yKh+2ltBG9WD0tCvBjJ 7BqnPtqJbL7B4CTXQbljhhmWvALkgdE= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 05/15] qemuBlockStorageSourceGetFormatRawProps: format 'offset' and 'size' for slice Date: Wed, 12 Feb 2020 19:03:16 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 X-MC-Unique: BQzB_xdyOS-FIrs9f044rQ-1 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" If we have a 'format' type slice for a raw driver we can directly format the values. Signed-off-by: Peter Krempa --- src/qemu/qemu_block.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 710ddfd2cf..6ac1d34281 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1194,16 +1194,21 @@ qemuBlockStorageSourceGetFormatRawProps(virStorageS= ourcePtr src, secretalias =3D srcPriv->encinfo->s.aes.alias; } - /* currently unhandled properties for the 'raw' driver: - * 'offset' - * 'size' - */ - if (virJSONValueObjectAdd(props, "s:driver", driver, "S:key-secret", secretalias, NULL) < 0) return -1; + /* Currently only storage slices are supported. We'll have to calculate + * the union of the slices here if we don't want to be adding needless + * 'raw' nodes. */ + if (src->sliceStorage && + virJSONValueObjectAdd(props, + "p:offset", src->sliceStorage->offset, + "p:size", src->sliceStorage->size, + NULL) < 0) + return -1; + return 0; } --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581530647139456.5298796881897; Wed, 12 Feb 2020 10:04:07 -0800 (PST) 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-216-IVZNxQhwNZSiYp6vRAMsPw-1; Wed, 12 Feb 2020 13:03:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D73FF801E6D; Wed, 12 Feb 2020 18:03:51 +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 B1FA85C1BB; Wed, 12 Feb 2020 18:03:51 +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 66A3F18089CF; Wed, 12 Feb 2020 18:03:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3YLG004282 for ; Wed, 12 Feb 2020 13:03:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id D39A6100034E; Wed, 12 Feb 2020 18:03:34 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5899510002B8 for ; Wed, 12 Feb 2020 18:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530645; 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=7eyDqYQ06oWo4OzQFUrQiIRV7AcoGkboqWwvPMZae5Q=; b=huhMxfAJ9n2rfXcer5IPD0XbIwLc2E4mCAJ1SZNlIuRyLOpZ3k8CVPYqSoEhynI4z5n053 53cYF0n7Bc+8bJc649g048D/BiG/nRq8fvE5CW5baiSy7BjCC0FFT5UARgC4Io9Ij846C9 oJZT2lYdwIjv6xyrWy9X+xynzlhJqkw= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 06/15] qemuDomainValidateStorageSource: Reject unsupported slices Date: Wed, 12 Feb 2020 19:03:17 +0100 Message-Id: <90e34c046f8604cdd95e7031386fd3af58ac9837.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 X-MC-Unique: IVZNxQhwNZSiYp6vRAMsPw-1 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" We will currently support slice only for the 'raw' format slice reject any other option. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 139496307f..d24d1c81db 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6821,6 +6821,18 @@ qemuDomainValidateStorageSource(virStorageSourcePtr = src, return -1; } + if (src->sliceStorage) { + /* In pre-blockdev era we can't configure the slice so we can allo= w them + * only for detected backing store entries as they are populated + * from a place that qemu would be able to read */ + if (!src->detected && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("storage slice is not supported by this QEMU = binary")); + return -1; + } + } + return 0; } --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1581530662951112.32092040159444; Wed, 12 Feb 2020 10:04:22 -0800 (PST) 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-209-DGCC62OIOHOUY1A2sXT9bA-1; Wed, 12 Feb 2020 13:04:01 -0500 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 F4028800D41; Wed, 12 Feb 2020 18:03:55 +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 CA6948EA1A; Wed, 12 Feb 2020 18:03:55 +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 7D9368B2A7; Wed, 12 Feb 2020 18:03:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3ZBR004294 for ; Wed, 12 Feb 2020 13:03:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id AAEAD100034E; Wed, 12 Feb 2020 18:03:35 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 308531001281 for ; Wed, 12 Feb 2020 18:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530661; 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=ExAoRIXDtQcTWZcj+sI08w5kRlf3NKaU72Dm2RVxq6g=; b=dhv4yUH+vf+6IgvBSKHO+lMhGW+xzaXkNjuKmM34RD/1tOAflviLKNNhHDyrwk5OoZ4kDH Mx3UYxRt3HUqA5bfSHaVyp9us7wRyfS0S+MF4S6pLXFhSAZhF54wqOqstXrDVeodst8MGu PMIz0hVUhSWs0ei1VDiaoMXHSBMxHFc= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 07/15] qemu: block: forbid creation of storage sources with Date: Wed, 12 Feb 2020 19:03:18 +0100 Message-Id: <4ceee205f30705324113c7945aa3e4d3dea53f03.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-MC-Unique: DGCC62OIOHOUY1A2sXT9bA-1 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" Specifically creating such images via libvirt during blockjobs would be much more hassle than it's worth. Just forbid them for now. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 6ac1d34281..b23a4baae6 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2529,6 +2529,12 @@ qemuBlockStorageSourceCreate(virDomainObjPtr vm, int ret =3D -1; int rc; + if (src->sliceStorage) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("creation of images with slice type=3D'storage' i= s not supported")); + return -1; + } + if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0) goto cleanup; --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1581530778920473.9038859198662; Wed, 12 Feb 2020 10:06:18 -0800 (PST) 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-134-rMA825D1PhC-XeH8fz-QBQ-1; Wed, 12 Feb 2020 13:04:09 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACCA413FB; Wed, 12 Feb 2020 18:03:59 +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 88EF426FDB; Wed, 12 Feb 2020 18:03:59 +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 4408718089D5; Wed, 12 Feb 2020 18:03:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3apT004309 for ; Wed, 12 Feb 2020 13:03:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 82A411001281; Wed, 12 Feb 2020 18:03:36 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 071E9100034E for ; Wed, 12 Feb 2020 18:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530777; 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=YfBtfTlKX5pv3PuZWlbfuC6nMHgRmELq+S6ewPjgFBg=; b=AtIcoWKZYmjEkd5dsnwkyJQ2Gs7Guf94IMbrUK2iEGcGDdsITmhFT1J9b19NbTLAjuXC0d fCEgN8GP2biPXpFY717SIKbirghhA65yIvOiBSCBhgnPQTTqqck/mqasPiSD1aNu0hK+qY Bw54o4MYg3up8BCYUCtc6FgQhjBapaI= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 08/15] docs: Document the new sub-element of disk's Date: Wed, 12 Feb 2020 19:03:19 +0100 Message-Id: <0239ec7b8e69c90d2c992ac1145ddd5482755d95.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.23 X-MC-Unique: rMA825D1PhC-XeH8fz-QBQ-1 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" We are going to add support for specifying offset and size attributes which will allow controling where the image and where the guest data itself starts in the source of the disk. This will be represented by a element filled with either a for the offset of the image format itself. then controls where the guest data starts in the image. Add the XML documentation and RNG schema. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.html.in | 13 +++++++++++++ docs/schemas/domaincommon.rng | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 200a9cb79a..717cbd026f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2878,6 +2878,9 @@ <disk type=3D'block' device=3D'lun'> <driver name=3D'qemu' type=3D'raw'/> <source dev=3D'/dev/sda'> + <slices> + <slice type=3D'format' offset=3D'12345' size=3D'123'/> + </slices> <reservations managed=3D'no'> <source type=3D'unix' path=3D'/path/to/qemu-pr-helper' mode=3D'= client'/> </reservations> @@ -3360,6 +3363,16 @@ controller. Since 6.0.0 +
slices
+
The slices element using its slice + sub-elements allows configuring offset and size of either the + location of the image format (slice type=3D'storage') + inside the storage source or the guest data inside the image f= ormat + container (future expansion). + + The offset and size values are in by= tes. + Since 6.1.0 +

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 9577d26c2a..093e9f2aaf 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1595,12 +1595,31 @@ + + + + + + + + + + + + + + storage + + + + + --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1581530646171890.2866300053129; Wed, 12 Feb 2020 10:04:06 -0800 (PST) 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-396-c9m1GQinO5yNDAc1ijZYPg-1; Wed, 12 Feb 2020 13:04:01 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5C20801F74; Wed, 12 Feb 2020 18:03:56 +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 AFA0A8AC36; Wed, 12 Feb 2020 18:03:56 +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 66FEB8B2B0; Wed, 12 Feb 2020 18:03:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3bHU004318 for ; Wed, 12 Feb 2020 13:03:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5E6FD1001B07; Wed, 12 Feb 2020 18:03:37 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id D42231001281 for ; Wed, 12 Feb 2020 18:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530644; 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=FbzibgTHwfPeFje4pTXiekv//bMpD1osjzAJxCyMC0Y=; b=HtOrmxFmSenEDgzEqMyz4zk1zoAUanusD9Zs1YlZEzhknRRi7k2BAJg/bb6+is6YOJ8wjg 5bDOUvf+qYT8ER1htBAig98DTVEFM6N3Bm6ljX/g/7aAH7UHPXGiVFNd6PZZO/GrVK60+x 2oG9pZl57uylb32p3DJP5MkYyW0E0kI= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 09/15] conf: Implement support for of disk source Date: Wed, 12 Feb 2020 19:03:20 +0100 Message-Id: <214fb497381c908d840a00ac3a928f7e3299ea76.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 X-MC-Unique: c9m1GQinO5yNDAc1ijZYPg-1 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" Implement parsing and formatting of the 'source' and 'format' slices. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index de74a2a2d5..c0f58f8f5e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9469,6 +9469,57 @@ virDomainStorageSourceParseBase(const char *type, } +static virStorageSourceSlicePtr +virDomainStorageSourceParseSlice(xmlNodePtr node, + xmlXPathContextPtr ctxt) +{ + VIR_XPATH_NODE_AUTORESTORE(ctxt); + g_autofree char *offset =3D NULL; + g_autofree char *size =3D NULL; + g_autofree virStorageSourceSlicePtr ret =3D g_new0(virStorageSourceSli= ce, 1); + + ctxt->node =3D node; + + if (!(offset =3D virXPathString("string(./@offset)", ctxt)) || + !(size =3D virXPathString("string(./@size)", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing offset or size attribute of slice")); + return NULL; + } + + if (virStrToLong_ullp(offset, NULL, 10, &ret->offset) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("malformed value '%s' of 'offset' attribute of sl= ice"), + offset); + return NULL; + } + + if (virStrToLong_ullp(size, NULL, 10, &ret->size) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("malformed value '%s' of 'size' attribute of slic= e"), + size); + return NULL; + } + + return g_steal_pointer(&ret); +} + + +static int +virDomainStorageSourceParseSlices(virStorageSourcePtr src, + xmlXPathContextPtr ctxt) +{ + xmlNodePtr node; + + if ((node =3D virXPathNode("./slices/slice[@type=3D'storage']", ctxt))= ) { + if (!(src->sliceStorage =3D virDomainStorageSourceParseSlice(node,= ctxt))) + return -1; + } + + return 0; +} + + /** * virDomainStorageSourceParse: * @node: XML node pointing to the source element to parse @@ -9534,6 +9585,9 @@ virDomainStorageSourceParse(xmlNodePtr node, if (virDomainDiskSourcePRParse(node, ctxt, &src->pr) < 0) return -1; + if (virDomainStorageSourceParseSlices(src, ctxt) < 0) + return -1; + if (virSecurityDeviceLabelDefParseXML(&src->seclabels, &src->nseclabel= s, ctxt, flags) < 0) return -1; @@ -24375,6 +24429,36 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr = buf, } +static void +virDomainDiskSourceFormatSlice(virBufferPtr buf, + const char *slicetype, + virStorageSourceSlicePtr slice) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + + if (!slice) + return; + + virBufferAsprintf(&attrBuf, " type=3D'%s'", slicetype); + virBufferAsprintf(&attrBuf, " offset=3D'%llu'", slice->offset); + virBufferAsprintf(&attrBuf, " size=3D'%llu'", slice->size); + + virXMLFormatElement(buf, "slice", &attrBuf, NULL); +} + + +static void +virDomainDiskSourceFormatSlices(virBufferPtr buf, + virStorageSourcePtr src) +{ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + + virDomainDiskSourceFormatSlice(&childBuf, "storage", src->sliceStorage= ); + + virXMLFormatElement(buf, "slices", NULL, &childBuf); +} + + /** * virDomainDiskSourceFormat: * @buf: output buffer @@ -24445,6 +24529,8 @@ virDomainDiskSourceFormat(virBufferPtr buf, return -1; } + virDomainDiskSourceFormatSlices(&childBuf, src); + if (src->type !=3D VIR_STORAGE_TYPE_NETWORK) virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, src->seclabels, flags); --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1581530717122445.5647057128223; Wed, 12 Feb 2020 10:05:17 -0800 (PST) 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-251-8G7h3XLJOMWeN6Hh1p9KhA-1; Wed, 12 Feb 2020 13:04:11 -0500 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 5F69313F9; Wed, 12 Feb 2020 18:04:04 +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 27BBB5C11E; Wed, 12 Feb 2020 18:04: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 A03F7180880D; Wed, 12 Feb 2020 18:04:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3cNa004326 for ; Wed, 12 Feb 2020 13:03:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 37E861001B0B; Wed, 12 Feb 2020 18:03:38 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF53F1001B07 for ; Wed, 12 Feb 2020 18:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530715; 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=4ho422cQaZqzHnDEI7Y3jd79jnJI4DZpT/MAlQzv0NQ=; b=Am33Zk6tmYrbQRoxz4MNTyA/pbIyvmnSHYlMgRrZ1VRpNwMZpI2DnUxwJOwHzrHJCjj67Z KMvtvlNsVZjRAdafuTHKzq3dZSYnkqkFNmsUI5t0acmWruB/tZ/XcsZLY3lrHksJTfx1tc UL/ZVMtiz6dje9P8JWeW9GP6IJ3jQLk= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 10/15] qemu: domain: Store nodenames of slice in status XML Date: Wed, 12 Feb 2020 19:03:21 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-MC-Unique: 8G7h3XLJOMWeN6Hh1p9KhA-1 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 storage slice will require a specific node name in cases when the image format is not raw. Store and format them in the status XML. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 7 +++++++ tests/qemustatusxml2xmldata/modern-in.xml | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d24d1c81db..534a91cf82 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2322,6 +2322,9 @@ qemuStorageSourcePrivateDataParse(xmlXPathContextPtr = ctxt, src->nodeformat =3D virXPathString("string(./nodenames/nodename[@type= =3D'format']/@name)", ctxt); src->tlsAlias =3D virXPathString("string(./objects/TLSx509/@alias)", c= txt); + if (src->sliceStorage) + src->sliceStorage->nodename =3D virXPathString("string(./nodenames= /nodename[@type=3D'slice-storage']/@name)", ctxt); + if (src->pr) src->pr->mgralias =3D virXPathString("string(./reservations/@mgral= ias)", ctxt); @@ -2375,6 +2378,10 @@ qemuStorageSourcePrivateDataFormat(virStorageSourceP= tr src, virBufferEscapeString(&nodenamesChildBuf, "\n", src->nodestorage); virBufferEscapeString(&nodenamesChildBuf, "\n", src->nodeformat); + if (src->sliceStorage) + virBufferEscapeString(&nodenamesChildBuf, "\n", + src->sliceStorage->nodename); + virXMLFormatElement(buf, "nodenames", NULL, &nodenamesChildBuf); if (src->pr) diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index 8a2718293f..c8d21ceada 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -312,6 +312,9 @@ + + + @@ -322,6 +325,7 @@ + base.qcow2 --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158153070790439.57462024313884; Wed, 12 Feb 2020 10:05:07 -0800 (PST) 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-79-3XoIDA4OMzGwXyPJgAnlXA-1; Wed, 12 Feb 2020 13:04:09 -0500 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 9114A18FF668; Wed, 12 Feb 2020 18:04:01 +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 6B0BB5DA83; Wed, 12 Feb 2020 18:04:01 +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 1EACE180887A; Wed, 12 Feb 2020 18:04:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3eqX004349 for ; Wed, 12 Feb 2020 13:03:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0EF7B10027A3; Wed, 12 Feb 2020 18:03:40 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87E671001B07 for ; Wed, 12 Feb 2020 18:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530706; 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=65uTUjQkRsbUw+T/VrSvmMTZXXYN1vg5cJPbjoHR0fA=; b=f6GE6dOGwbUO/KgzzgJey3yG+8i6ckf4H2eAcu5A6ailgnA9m9Q8EFLFhRSuYh6U9CyRmC Yue952JasE3TSMt3R6rq6vc8phVnTVSBive57uGEADwx/IaUdCONXEUuFH5ESsu/Wkn/Bg VRRFv80CGqTbSaZBZ17BRMi0eDc6gbU= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 11/15] qemu: block: Properly format storage slice into backing store strings Date: Wed, 12 Feb 2020 19:03:22 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-MC-Unique: 3XoIDA4OMzGwXyPJgAnlXA-1 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" When creating overlay images e.g. for snapshots or when merging snapshots we often specify the backing store string to use. Make the formatter aware of backing chain entries which have a configured so that we record it properly. Otherwise such images would not work without the XML (when detecting the backing chain). Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 80 ++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index b23a4baae6..8b94365c68 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1930,44 +1930,48 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr = src) { int actualType =3D virStorageSourceGetActualType(src); g_autoptr(virJSONValue) backingProps =3D NULL; + g_autoptr(virJSONValue) sliceProps =3D NULL; + virJSONValuePtr props =3D NULL; g_autoptr(virURI) uri =3D NULL; g_autofree char *backingJSON =3D NULL; char *ret =3D NULL; - if (virStorageSourceIsLocalStorage(src)) { - ret =3D g_strdup(src->path); - return ret; - } + if (!src->sliceStorage) { + if (virStorageSourceIsLocalStorage(src)) { + ret =3D g_strdup(src->path); + return ret; + } - /* generate simplified URIs for the easy cases */ - if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && - src->nhosts =3D=3D 1 && - src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { + /* generate simplified URIs for the easy cases */ + if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && + src->nhosts =3D=3D 1 && + src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { + + switch ((virStorageNetProtocol) src->protocol) { + case VIR_STORAGE_NET_PROTOCOL_NBD: + case VIR_STORAGE_NET_PROTOCOL_HTTP: + case VIR_STORAGE_NET_PROTOCOL_HTTPS: + case VIR_STORAGE_NET_PROTOCOL_FTP: + case VIR_STORAGE_NET_PROTOCOL_FTPS: + case VIR_STORAGE_NET_PROTOCOL_TFTP: + case VIR_STORAGE_NET_PROTOCOL_ISCSI: + case VIR_STORAGE_NET_PROTOCOL_GLUSTER: + if (!(uri =3D qemuBlockStorageSourceGetURI(src))) + return NULL; - switch ((virStorageNetProtocol) src->protocol) { - case VIR_STORAGE_NET_PROTOCOL_NBD: - case VIR_STORAGE_NET_PROTOCOL_HTTP: - case VIR_STORAGE_NET_PROTOCOL_HTTPS: - case VIR_STORAGE_NET_PROTOCOL_FTP: - case VIR_STORAGE_NET_PROTOCOL_FTPS: - case VIR_STORAGE_NET_PROTOCOL_TFTP: - case VIR_STORAGE_NET_PROTOCOL_ISCSI: - case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - if (!(uri =3D qemuBlockStorageSourceGetURI(src))) - return NULL; + if (!(ret =3D virURIFormat(uri))) + return NULL; - if (!(ret =3D virURIFormat(uri))) - return NULL; + return ret; - return ret; - - case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: - case VIR_STORAGE_NET_PROTOCOL_RBD: - case VIR_STORAGE_NET_PROTOCOL_VXHS: - case VIR_STORAGE_NET_PROTOCOL_SSH: - case VIR_STORAGE_NET_PROTOCOL_LAST: - case VIR_STORAGE_NET_PROTOCOL_NONE: - break; + case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: + case VIR_STORAGE_NET_PROTOCOL_RBD: + case VIR_STORAGE_NET_PROTOCOL_VXHS: + case VIR_STORAGE_NET_PROTOCOL_SSH: + case VIR_STORAGE_NET_PROTOCOL_LAST: + case VIR_STORAGE_NET_PROTOCOL_NONE: + break; + } } } @@ -1975,7 +1979,21 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr s= rc) if (!(backingProps =3D qemuBlockStorageSourceGetBackendProps(src, fals= e, true, false))) return NULL; - if (!(backingJSON =3D virJSONValueToString(backingProps, false))) + props =3D backingProps; + + if (src->sliceStorage) { + if (virJSONValueObjectCreate(&sliceProps, + "s:driver", "raw", + "U:offset", src->sliceStorage->offset, + "U:size", src->sliceStorage->size, + "a:file", &backingProps, + NULL) < 0) + return NULL; + + props =3D sliceProps; + } + + if (!(backingJSON =3D virJSONValueToString(props, false))) return NULL; ret =3D g_strdup_printf("json:%s", backingJSON); --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581530765215197.66192685657586; Wed, 12 Feb 2020 10:06:05 -0800 (PST) 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-434-5ETv6wE7NK-aAyytO6_-0Q-1; Wed, 12 Feb 2020 13:04:15 -0500 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 DEF81800D55; Wed, 12 Feb 2020 18:04:08 +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 B173B5DA85; Wed, 12 Feb 2020 18:04:08 +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 60D5E8B2AE; Wed, 12 Feb 2020 18:04:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3e3l004358 for ; Wed, 12 Feb 2020 13:03:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id D9F3E1001B07; Wed, 12 Feb 2020 18:03:40 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F6691001281 for ; Wed, 12 Feb 2020 18:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530762; 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=hoYAHks7HCljEjfrLkr20jemjrZ/t1pFdu7ZO1lA1KA=; b=hP/9ARSXdgdYPrCCPQ+skRUGdU5FCnV5CBf61bdrxssaSDAD3Ni0T7LtKkD2tSs38HkRA5 aR/YrnlYEG7rmlP95lmBzuEgsafWH6Wqvdn6tCznVtI7wGz4mx6Jw4dlwBHliUwPmOJDEe 9opTjgqrUnaniPGPm2Gvqz9Y85CZ3UY= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 12/15] tests: qemublock: Add cases for creating image overlays on top of disks with Date: Wed, 12 Feb 2020 19:03:23 +0100 Message-Id: <3d51cbedaec539050ecc2dff42dd5badb9232116.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-MC-Unique: 5ETv6wE7NK-aAyytO6_-0Q-1 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" Add a set of test data to see whether the backing store strings are formatted reasonably. Note that we don't support direct creation of such images so those tests are not enabled. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 2 ++ .../imagecreate/qcow2-backing-qcow2-slice.json | 15 +++++++++++++++ .../imagecreate/qcow2-backing-qcow2-slice.xml | 1 + .../imagecreate/qcow2-backing-raw-slice.json | 15 +++++++++++++++ .../imagecreate/qcow2-backing-raw-slice.xml | 1 + .../qemublocktestdata/imagecreate/qcow2-slice.xml | 14 ++++++++++++++ tests/qemublocktestdata/imagecreate/raw-slice.xml | 14 ++++++++++++++ 7 files changed, 62 insertions(+) create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2= -slice.json create mode 120000 tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2= -slice.xml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-backing-raw-s= lice.json create mode 120000 tests/qemublocktestdata/imagecreate/qcow2-backing-raw-s= lice.xml create mode 100644 tests/qemublocktestdata/imagecreate/qcow2-slice.xml create mode 100644 tests/qemublocktestdata/imagecreate/raw-slice.xml diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index ada83a0fde..5a564b71df 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -1064,6 +1064,8 @@ mymain(void) TEST_IMAGE_CREATE("qcow2-backing-raw-nbd", "raw-nbd"); TEST_IMAGE_CREATE("qcow2-backing-luks", "luks-noopts"); TEST_IMAGE_CREATE("qcow2-luks-encopts-backing", "qcow2"); + TEST_IMAGE_CREATE("qcow2-backing-raw-slice", "raw-slice"); + TEST_IMAGE_CREATE("qcow2-backing-qcow2-slice", "qcow2-slice"); TEST_IMAGE_CREATE("network-gluster-qcow2", NULL); TEST_IMAGE_CREATE("network-rbd-qcow2", NULL); diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.= json b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json new file mode 100644 index 0000000000..2fa27c1933 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.json @@ -0,0 +1,15 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 4294967296 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 8589934590, + "backing-file": "json:{\"driver\":\"raw\",\"offset\":1234,\"size\":5768,= \"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.qcow= 2\"}}", + "backing-fmt": "qcow2" +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.= xml b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.xml new file mode 120000 index 0000000000..5769c2c866 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-qcow2-slice.xml @@ -0,0 +1 @@ +qcow2.xml \ No newline at end of file diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.js= on b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json new file mode 100644 index 0000000000..761002afd9 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.json @@ -0,0 +1,15 @@ +protocol: +{ + "driver": "file", + "filename": "/var/lib/libvirt/images/i.qcow2", + "size": 4294967296 +} + +format: +{ + "driver": "qcow2", + "file": "0123456789ABCDEF0123456789ABCDE", + "size": 8589934590, + "backing-file": "json:{\"driver\":\"raw\",\"offset\":9876,\"size\":54321= ,\"file\":{\"driver\":\"file\",\"filename\":\"/var/lib/libvirt/images/i.img= \"}}", + "backing-fmt": "raw" +} diff --git a/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.xm= l b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.xml new file mode 120000 index 0000000000..5769c2c866 --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-backing-raw-slice.xml @@ -0,0 +1 @@ +qcow2.xml \ No newline at end of file diff --git a/tests/qemublocktestdata/imagecreate/qcow2-slice.xml b/tests/qe= mublocktestdata/imagecreate/qcow2-slice.xml new file mode 100644 index 0000000000..6c5ae3107b --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/qcow2-slice.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/qemublocktestdata/imagecreate/raw-slice.xml b/tests/qemu= blocktestdata/imagecreate/raw-slice.xml new file mode 100644 index 0000000000..adc7a175ce --- /dev/null +++ b/tests/qemublocktestdata/imagecreate/raw-slice.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581530707843904.7427064855028; Wed, 12 Feb 2020 10:05:07 -0800 (PST) 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-154-WzVu1vnbPQ-iCr1bP9UNKg-1; Wed, 12 Feb 2020 13:04:06 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 848DE801E78; Wed, 12 Feb 2020 18:04:00 +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 62BB21001B23; Wed, 12 Feb 2020 18:04:00 +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 246A218089D8; Wed, 12 Feb 2020 18:04:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3fl9004374 for ; Wed, 12 Feb 2020 13:03:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id B09081001281; Wed, 12 Feb 2020 18:03:41 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35C4F1001B07 for ; Wed, 12 Feb 2020 18:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530706; 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=lLFBJuJtxn09l3TOgjmt/6BmiFGyn+rFSVdCpUoMXmY=; b=FalqyxWQOPVO/FdK4qcJ/FDt6ReEB81NtjKKWeFTuBQ3CXsVmBCAS3Z1av+LGRJJQOJd7L 4Rw6bAj5WhZlb7h9M12rdx+eBRlIko9Iydtc+P/LUSTccdsHgbps1HM7bfeZe917qCr2Qg 9C8Cle3Itu/4i11xLl76Y/N8qyKtFvg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 13/15] qemu: Add support for slices of type 'storage' Date: Wed, 12 Feb 2020 19:03:24 +0100 Message-Id: <47d91124be62e86aaa7025a2db0d6918028979d5.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 X-MC-Unique: WzVu1vnbPQ-iCr1bP9UNKg-1 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" Implement support for the slice of type 'storage' which allows to set the offset and size which modifies where qemu should look for the start of the format container inside the image. Since slicing is done using the 'raw' driver we need to add another layer into the blockdev tree if there's any non-raw image format driver used to access the data. This patch adds the blockdev integration and setup of the image data so that we can use the slices for any backing image. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 68 +++++++++++++++++++++++++++++++++++++++- src/qemu/qemu_block.h | 4 +++ src/qemu/qemu_blockjob.c | 1 + src/qemu/qemu_command.c | 8 +++++ src/qemu/qemu_domain.c | 4 +++ 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 8b94365c68..36b61e5355 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1423,11 +1423,16 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSo= urcePtr src, virStorageSourcePtr backingStore) { g_autoptr(virJSONValue) props =3D NULL; + const char *storagenode =3D src->nodestorage; + + if (src->sliceStorage && + src->format !=3D VIR_STORAGE_FILE_RAW) + storagenode =3D src->sliceStorage->nodename; if (!(props =3D qemuBlockStorageSourceGetBlockdevFormatProps(src))) return NULL; - if (virJSONValueObjectAppendString(props, "file", src->nodestorage) < = 0) + if (virJSONValueObjectAppendString(props, "file", storagenode) < 0) return NULL; if (backingStore) { @@ -1456,6 +1461,32 @@ qemuBlockStorageSourceGetBlockdevProps(virStorageSou= rcePtr src, } +static virJSONValuePtr +qemuBlockStorageSourceGetBlockdevStorageSliceProps(virStorageSourcePtr src) +{ + g_autoptr(virJSONValue) props =3D NULL; + + if (qemuBlockNodeNameValidate(src->sliceStorage->nodename) < 0) + return NULL; + + if (virJSONValueObjectCreate(&props, + "s:driver", "raw", + "s:node-name", src->sliceStorage->nodenam= e, + "U:offset", src->sliceStorage->offset, + "U:size", src->sliceStorage->size, + "s:file", src->nodestorage, + "b:auto-read-only", true, + "s:discard", "unmap", + NULL) < 0) + return NULL; + + if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, props) < 0) + return NULL; + + return g_steal_pointer(&props); +} + + void qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachDataPtr d= ata) { @@ -1463,6 +1494,7 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorage= SourceAttachDataPtr data) return; virJSONValueFree(data->storageProps); + virJSONValueFree(data->storageSliceProps); virJSONValueFree(data->formatProps); virJSONValueFree(data->prmgrProps); virJSONValueFree(data->authsecretProps); @@ -1513,6 +1545,13 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStora= geSourcePtr src, data->storageNodeName =3D src->nodestorage; data->formatNodeName =3D src->nodeformat; + if (src->sliceStorage && src->format !=3D VIR_STORAGE_FILE_RAW) { + if (!(data->storageSliceProps =3D qemuBlockStorageSourceGetBlockde= vStorageSliceProps(src))) + return NULL; + + data->storageSliceNodeName =3D src->sliceStorage->nodename; + } + return g_steal_pointer(&data); } @@ -1581,6 +1620,21 @@ qemuBlockStorageSourceAttachApplyFormat(qemuMonitorP= tr mon, } +static int +qemuBlockStorageSourceAttachApplyStorageSlice(qemuMonitorPtr mon, + qemuBlockStorageSourceAttach= DataPtr data) +{ + if (data->storageSliceProps) { + if (qemuMonitorBlockdevAdd(mon, &data->storageSliceProps) < 0) + return -1; + + data->storageSliceAttached =3D true; + } + + return 0; +} + + /** * qemuBlockStorageSourceAttachApply: * @mon: monitor object @@ -1600,6 +1654,7 @@ qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon, { if (qemuBlockStorageSourceAttachApplyStorageDeps(mon, data) < 0 || qemuBlockStorageSourceAttachApplyStorage(mon, data) < 0 || + qemuBlockStorageSourceAttachApplyStorageSlice(mon, data) < 0 || qemuBlockStorageSourceAttachApplyFormatDeps(mon, data) < 0 || qemuBlockStorageSourceAttachApplyFormat(mon, data) < 0) return -1; @@ -1642,6 +1697,9 @@ qemuBlockStorageSourceAttachRollback(qemuMonitorPtr m= on, if (data->formatAttached) ignore_value(qemuMonitorBlockdevDel(mon, data->formatNodeName)); + if (data->storageSliceAttached) + ignore_value(qemuMonitorBlockdevDel(mon, data->storageSliceNodeNam= e)); + if (data->storageAttached) ignore_value(qemuMonitorBlockdevDel(mon, data->storageNodeName)); @@ -1689,6 +1747,14 @@ qemuBlockStorageSourceDetachPrepare(virStorageSource= Ptr src, data->formatAttached =3D true; data->storageNodeName =3D src->nodestorage; data->storageAttached =3D true; + + /* 'raw' format doesn't need the extra 'raw' layer when slicing, t= hus + * the nodename is NULL */ + if (src->sliceStorage && + src->sliceStorage->nodename) { + data->storageSliceNodeName =3D src->sliceStorage->nodename; + data->storageSliceAttached =3D true; + } } if (src->pr && diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index a816190bb7..eab0128d5d 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -82,6 +82,10 @@ struct qemuBlockStorageSourceAttachData { const char *storageNodeName; bool storageAttached; + virJSONValuePtr storageSliceProps; + const char *storageSliceNodeName; + bool storageSliceAttached; + virJSONValuePtr formatProps; const char *formatNodeName; bool formatAttached; diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 6b59bbeb2c..71df0d1ab2 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1316,6 +1316,7 @@ qemuBlockJobProcessEventConcludedCreate(virQEMUDriver= Ptr driver, backend->formatAttached =3D false; if (job->data.create.storage) { backend->storageAttached =3D false; + backend->storageSliceAttached =3D false; VIR_FREE(backend->encryptsecretAlias); } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0dbd78124b..6c26e7bb7d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2411,6 +2411,14 @@ qemuBuildBlockStorageSourceAttachDataCommandline(vir= CommandPtr cmd, VIR_FREE(tmp); } + if (data->storageSliceProps) { + if (!(tmp =3D virJSONValueToString(data->storageSliceProps, false)= )) + return -1; + + virCommandAddArgList(cmd, "-blockdev", tmp, NULL); + VIR_FREE(tmp); + } + if (data->formatProps) { if (!(tmp =3D virJSONValueToString(data->formatProps, false))) return -1; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 534a91cf82..f8d034c382 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -16224,6 +16224,10 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDi= skDefPtr 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) + src->sliceStorage->nodename =3D g_strdup_printf("libvirt-%u-slice-= sto", src->id); + if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0) return -1; --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581530659158571.3586550612099; Wed, 12 Feb 2020 10:04:19 -0800 (PST) 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-117--qQ_EobyPAepGmTmfyPxnQ-1; Wed, 12 Feb 2020 13:04:14 -0500 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 9EA0718FF667; Wed, 12 Feb 2020 18:04: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 6F08E5DA85; Wed, 12 Feb 2020 18:04:05 +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 05DA18B2B1; Wed, 12 Feb 2020 18:04:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3gf4004388 for ; Wed, 12 Feb 2020 13:03:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 867141001B07; Wed, 12 Feb 2020 18:03:42 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1EB1001281 for ; Wed, 12 Feb 2020 18:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530657; 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=+FbyGyilShE72wtIkqIGyX2TtMmrEw0crDiayiszhBE=; b=IW+6NERijTF5Wzaul5Ncms8WHihuQ2XkgH3D3SoUwdgX5yPEi9fB61PE6rTZ4h8642Yo0R CzCsY4hzSgoMqbHaJLNBa+RuVkUuqVAxh5QTSdY1isUbweNvAg8JoHWe5cF5u9xbgyJbtL STyeJ26hB2rpalyiGPGQMm9DFdRqL7o= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 14/15] tests: qemu: Add test data for the new element Date: Wed, 12 Feb 2020 19:03:25 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-MC-Unique: -qQ_EobyPAepGmTmfyPxnQ-1 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" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- .../disk-slices.x86_64-latest.args | 53 ++++++++++++++++++ tests/qemuxml2argvdata/disk-slices.xml | 45 +++++++++++++++ tests/qemuxml2argvtest.c | 2 + .../disk-slices.x86_64-latest.xml | 56 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 5 files changed, 158 insertions(+) create mode 100644 tests/qemuxml2argvdata/disk-slices.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/disk-slices.xml create mode 100644 tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml diff --git a/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args b/tests/= qemuxml2argvdata/disk-slices.x86_64-latest.args new file mode 100644 index 0000000000..49daa293a4 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-slices.x86_64-latest.args @@ -0,0 +1,53 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-cpu qemu64 \ +-m 214 \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-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,\ +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,\ +"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"qcow= 2",\ +"file":"libvirt-2-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,\ +id=3Dvirtio-disk1 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x4 \ +-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 new file mode 100644 index 0000000000..cff7cc7ee4 --- /dev/null +++ b/tests/qemuxml2argvdata/disk-slices.xml @@ -0,0 +1,45 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 028364a06c..0dbaab4c32 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1165,6 +1165,8 @@ mymain(void) DO_TEST_CAPS_VER("disk-backing-chains-noindex", "2.12.0"); DO_TEST_CAPS_LATEST("disk-backing-chains-noindex"); + DO_TEST_CAPS_LATEST("disk-slices"); + DO_TEST("graphics-egl-headless", QEMU_CAPS_EGL_HEADLESS, QEMU_CAPS_DEVICE_CIRRUS_VGA); diff --git a/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml b/tests= /qemuxml2xmloutdata/disk-slices.x86_64-latest.xml new file mode 100644 index 0000000000..65590df417 --- /dev/null +++ b/tests/qemuxml2xmloutdata/disk-slices.x86_64-latest.xml @@ -0,0 +1,56 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + + + + + + +

+ + + + + + + + + + + + + + +
+ + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index ecd12c3d30..b6072075c7 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -530,6 +530,8 @@ mymain(void) DO_TEST("pci-rom-disabled-invalid", NONE); DO_TEST("pci-serial-dev-chardev", NONE); + DO_TEST_CAPS_LATEST("disk-slices"); + DO_TEST("encrypted-disk", QEMU_CAPS_QCOW2_LUKS); DO_TEST("encrypted-disk-usage", QEMU_CAPS_QCOW2_LUKS); DO_TEST("luks-disks", NONE); --=20 2.24.1 From nobody Thu Apr 25 21:57:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1581530713980748.4621449494426; Wed, 12 Feb 2020 10:05:13 -0800 (PST) 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-132-Npy_MkU6O56NAkYhfqgXcw-1; Wed, 12 Feb 2020 13:04:17 -0500 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 9606B800D41; Wed, 12 Feb 2020 18:04:10 +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 6DF0A5C101; Wed, 12 Feb 2020 18:04:10 +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 18A611803C32; Wed, 12 Feb 2020 18:04:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01CI3mbp004416 for ; Wed, 12 Feb 2020 13:03:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5FCB91001B07; Wed, 12 Feb 2020 18:03:48 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8FAE100EBA4 for ; Wed, 12 Feb 2020 18:03:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581530712; 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=8wgwDQFPx7D+dK+kOcDMz+KM4nTRqUg2KJBmZAdTizo=; b=LgcdRUpOXuDLjaOla5sb7gmw021eJG0jGdL6MSES5AC3Yd8LICoYWCrBUedXeQg0QpFnD6 DrXUkgakJuBSa2e8a1o9z+6GUO0+pka6mf2+nsPTJoxOSKIBXeLl7LoGVMv9cz8O1MVuoZ piWq6DXLKw2nAwVmTdI9OnoCzauK1nU= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 15/15] virStorageSourceParseBackingJSONRaw: Parse 'offset' and 'size' attributes Date: Wed, 12 Feb 2020 19:03:26 +0100 Message-Id: <519c03babbd1066e3a495fe967f7168018a52ade.1581530481.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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-MC-Unique: Npy_MkU6O56NAkYhfqgXcw-1 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" If the parsed 'raw' format JSON string has 'offset' or 'size' attributes parse them as the format slice. https://bugzilla.redhat.com/show_bug.cgi?id=3D1791788 Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 20 ++++++++++++++++++++ tests/virstoragetest.c | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 890ec69929..9347c7ab30 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3551,8 +3551,28 @@ virStorageSourceParseBackingJSONRaw(virStorageSource= Ptr src, const char *jsonstr, int opaque G_GNUC_UNUSED) { + bool has_offset =3D virJSONValueObjectHasKey(json, "offset"); + bool has_size =3D virJSONValueObjectHasKey(json, "size"); virJSONValuePtr file; + if (has_offset || has_size) { + src->sliceStorage =3D g_new0(virStorageSourceSlice, 1); + + if (has_offset && + virJSONValueObjectGetNumberUlong(json, "offset", &src->sliceSt= orage->offset) < 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("malformed 'offset' property of 'raw' driver"= )); + return -1; + } + + if (has_size && + virJSONValueObjectGetNumberUlong(json, "size", &src->sliceStor= age->size) < 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("malformed 'size' property of 'raw' driver")); + return -1; + } + } + /* 'raw' is a format driver so it can have protocol driver children */ if (!(file =3D virJSONValueObjectGetObject(json, "file"))) { virReportError(VIR_ERR_INVALID_ARG, diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 25d41f0de4..39040bf4cb 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1600,7 +1600,11 @@ mymain(void) "\"filename\": \"/tmp/test= fle\"" "}" "}", - "\n", 0); + "\n" + " \n" + " \n" + " \n" + "\n", 0); #endif /* WITH_YAJL */ --=20 2.24.1