From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484978; cv=none; d=zoho.com; s=zohoarc; b=gLj4zcRlYuW6oJCkANX076PwczKQ73n9obbvniX3X1jyPgTjNt2xbSx/JJf5zYJ680n8+DArTWLZmTUUaw99flM27/VgT5jCPZ9wTGGrP84JGs91k9sh4aJ/hNOiNOlPuLeTSGfotHRxUSwmkD452XqB8LkwfFvm+1Oyj7b4qSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484978; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7ts8cqzcvDPehDS++7zhERPB43EKIsUt7lYTiYUZ6nQ=; b=lJ533WhFkYhX3hveBVTWlEgyVAPqYqb0J/rrrkBW9JCLjop9Vmju+KQRhod6Mf2pMXhjuT6HohzKKOTqmryINzcyKpiw6XwecghSEbse5WT3QLrIQZvlsyd9X9scuBvCZxFl3TUklMWutbOFadxo9/ukpyXGxdhYCv8XAwIVQbo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484978986302.6012272580509; Mon, 7 Oct 2019 14:49:38 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id EF3F02A09CD; Mon, 7 Oct 2019 21:49:36 +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 CC1875DA8C; Mon, 7 Oct 2019 21:49: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 8B9F81803B4D; Mon, 7 Oct 2019 21:49:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnMTm014511 for ; Mon, 7 Oct 2019 17:49:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2EA365C219; Mon, 7 Oct 2019 21:49:22 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id C68155C1D4; Mon, 7 Oct 2019 21:49:21 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:15 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/30] storagefile: Make GetMetadataInternal static 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 07 Oct 2019 21:49:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It is only used in virstoragefile.c Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 - src/util/virstoragefile.c | 2 +- src/util/virstoragefile.h | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index eeab820eca..ca9581bd94 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2988,7 +2988,6 @@ virStorageFileGetLVMKey; virStorageFileGetMetadata; virStorageFileGetMetadataFromBuf; virStorageFileGetMetadataFromFD; -virStorageFileGetMetadataInternal; virStorageFileGetNPIVKey; virStorageFileGetRelativeBackingPath; virStorageFileGetSCSIKey; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3201f57e62..51726006e7 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -970,7 +970,7 @@ virStorageFileGetEncryptionPayloadOffset(const struct F= ileEncryptionInfo *info, * Note that this function may be called repeatedly on @meta, so it must * clean up any existing allocated memory which would be overwritten. */ -int +static int virStorageFileGetMetadataInternal(virStorageSourcePtr meta, char *buf, size_t len, diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 81b83a53ef..2472d89c85 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -346,12 +346,6 @@ struct _virStorageSource { =20 int virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid); =20 -int virStorageFileGetMetadataInternal(virStorageSourcePtr meta, - char *buf, - size_t len, - int *backingFormat) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - virStorageSourcePtr virStorageFileGetMetadataFromFD(const char *path, int fd, int format, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484969; cv=none; d=zoho.com; s=zohoarc; b=CaW4kcD2YL0vcGBc4iRFk0ZjBLgDlb7b/oxBtz8wsd8c0nS3KK2pBgVNC8rDYSpW462cgg+66VWvG85CCSGE7tGfjjugHXxAm2Bz9CNxzXSs10mSChOGbhhvoFKvq1ppSTCVxl9MgRvgrODsClgXdOlAaXKZE6uHGREXd4rcL2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484969; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=cL130Jc0gPyOA1itsk7pXvvLN8eIyhVL1Gx6MfHFImo=; b=I0qoPHlBdBzwwhfle4aUC6TR2hi1u03RPxj1g2JQr9FA0+4Bp/w8rea4toSdi+jhS6JpjUI0ZD/zfo4taIO5nkLfKNnxLf7NfTV/AmsLTDmcmEeYgXeno4B6G1wwZ+EOcQVRfLrIAFaFY4lkDlamHophrHkYNQLJTYEA+HcJoYU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15704849693405.423224754358671; Mon, 7 Oct 2019 14:49:29 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8A21A81F31; Mon, 7 Oct 2019 21:49:26 +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 55C4160A9F; Mon, 7 Oct 2019 21:49:26 +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 5CDE44E58A; Mon, 7 Oct 2019 21:49:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnMVk014519 for ; Mon, 7 Oct 2019 17:49:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA4C95C223; Mon, 7 Oct 2019 21:49:22 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BEA05C1D4; Mon, 7 Oct 2019 21:49:22 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:16 -0400 Message-Id: <0a700c71217660dfd47ee117e174635aefb5618a.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/30] storagefile: qcow1: Check for BACKING_STORE_OK 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Oct 2019 21:49:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Check explicitly for BACKING_STORE_OK and not its 0 value Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 51726006e7..1549067c48 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -578,7 +578,7 @@ qcow1GetBackingStore(char **res, * used to store backing format */ *format =3D VIR_STORAGE_FILE_AUTO; ret =3D qcowXGetBackingStore(res, NULL, buf, buf_size, false); - if (ret =3D=3D 0 && *buf =3D=3D '\0') + if (ret =3D=3D BACKING_STORE_OK && *buf =3D=3D '\0') *format =3D VIR_STORAGE_FILE_NONE; return ret; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484977; cv=none; d=zoho.com; s=zohoarc; b=Ix3AdeqXqK8R6XH7W3Q201xKnW60Nr686S7t8kG0kaJ3gcrye5O3Hm7yZQwzdWxGtSrCsCaJhpYOwT6uUiUdA3B5wCQoj/xql5KLn9CrLWFQS4kfZPOxVFUII7j6WTMZijgMuqeYIOIsj9NMKN0Y43K6rSpz++HP7iitQck8P4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484977; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=wSFofZ0ACqVXSiFp8wCl2F/P87ioVhl58AmY0kmYSbA=; b=hu4zrXA5Wnjd2jKoSF9hEd+FiGERKpOxZkGlmiNYaAbCSfeskC2BFM2/7LKgfW8ocjKGKEPZd+lWhbF3gGscQeMlnvqLqM1sE3qE5ShuQYIoFlNA3p44oHFhI9+qwwx+26iHvkB+8CDtxYcdUYFA/id2iQJHUentFO2ssCuq7L4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484977495186.43157325588993; Mon, 7 Oct 2019 14:49:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C43AB300DA2E; Mon, 7 Oct 2019 21:49:35 +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 A2C345DA8C; Mon, 7 Oct 2019 21:49:35 +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 658E74EBDD; Mon, 7 Oct 2019 21:49:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnNj6014526 for ; Mon, 7 Oct 2019 17:49:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 50DE15C219; Mon, 7 Oct 2019 21:49:23 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id E77FE5C1D4; Mon, 7 Oct 2019 21:49:22 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:17 -0400 Message-Id: <9a71f43d7538443901fe5cd70df7e052447fb5a0.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/30] storagefile: qcow1: Fix check for empty backing file 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 07 Oct 2019 21:49:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" >From f772b3d91fd the intention of this code seems to be to set format=3DNONE when the image does not have a backing file. However 'buf' here is the whole qcow1 file header. What we want to be checking is 'res' which is the parsed backing file path. qcowXGetBackingStore sets this to NULL when there's no backing file. Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 1549067c48..016c8f0799 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -578,7 +578,7 @@ qcow1GetBackingStore(char **res, * used to store backing format */ *format =3D VIR_STORAGE_FILE_AUTO; ret =3D qcowXGetBackingStore(res, NULL, buf, buf_size, false); - if (ret =3D=3D BACKING_STORE_OK && *buf =3D=3D '\0') + if (ret =3D=3D BACKING_STORE_OK && !*res) *format =3D VIR_STORAGE_FILE_NONE; return ret; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484981; cv=none; d=zoho.com; s=zohoarc; b=HzHIQXCHQLzr30DvRxVhrKTY+1gZiKH7Bo82RerF5LvYT79Xsvb3PsREJlBmRR7MT4PsVzFetV41AnmWCFY3RAb5OoIO1Qy8TzBHL7i2OoF/rktg0fhD5gGZuRyOqWxjKmDvhzkNK0pFb+t74UOU8mAuilifo/eSOq7wGJwh9kU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484981; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HRCVMCZIT1Bc69Lneq5240E70lCr2QFF9swB2o7p9GM=; b=YXD9vmGHWZ23G9o166tZe63I+x1iP4WFHafiMMY4a1/snizswv4KAvlJUMGMf7Sb8q66h23BHRfY1lk6TAb7Zs4TVSc5qt7eNKk8NTOrlqL9+iHnNVPaZQqxeIPGiUQPyEEgWexbk3xcPcNwfisTa3FIQO7MY7Ruzp67Afe1G4k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484981937740.4540590879102; Mon, 7 Oct 2019 14:49:41 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 6F5F6302C08B; Mon, 7 Oct 2019 21:49:40 +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 474125D9CD; Mon, 7 Oct 2019 21:49:40 +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 0A3C8180BA9A; Mon, 7 Oct 2019 21:49:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnN4f014532 for ; Mon, 7 Oct 2019 17:49:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id D97FA5C219; Mon, 7 Oct 2019 21:49:23 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D0C35C1D4; Mon, 7 Oct 2019 21:49:23 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:18 -0400 Message-Id: <49563de9ab9c17295ecc2a4894b49ae14afe901e.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/30] storagefile: qcow1: Let qcowXGetBackingStore fill in format X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 07 Oct 2019 21:49:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Letting qcowXGetBackingStore fill in format gives the same behavior we were opencoding in qcow1GetBackingStore Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 016c8f0799..905e70b1a9 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -494,8 +494,7 @@ qcowXGetBackingStore(char **res, int version; =20 *res =3D NULL; - if (format) - *format =3D VIR_STORAGE_FILE_AUTO; + *format =3D VIR_STORAGE_FILE_AUTO; =20 if (buf_size < QCOWX_HDR_BACKING_FILE_OFFSET+8+4) return BACKING_STORE_INVALID; @@ -504,15 +503,13 @@ qcowXGetBackingStore(char **res, return BACKING_STORE_INVALID; =20 if (offset =3D=3D 0) { - if (format) - *format =3D VIR_STORAGE_FILE_NONE; + *format =3D VIR_STORAGE_FILE_NONE; return BACKING_STORE_OK; } =20 size =3D virReadBufInt32BE(buf + QCOWX_HDR_BACKING_FILE_SIZE); if (size =3D=3D 0) { - if (format) - *format =3D VIR_STORAGE_FILE_NONE; + *format =3D VIR_STORAGE_FILE_NONE; return BACKING_STORE_OK; } if (size > 1023) @@ -551,7 +548,7 @@ qcowXGetBackingStore(char **res, * for qcow2 v3 images, the length of the header * is stored at QCOW2v3_HDR_SIZE */ - if (isQCow2 && format) { + if (isQCow2) { version =3D virReadBufInt32BE(buf + QCOWX_HDR_VERSION); if (version =3D=3D 2) start =3D QCOW2_HDR_TOTAL_SIZE; @@ -572,15 +569,9 @@ qcow1GetBackingStore(char **res, const char *buf, size_t buf_size) { - int ret; - /* QCow1 doesn't have the extensions capability * used to store backing format */ - *format =3D VIR_STORAGE_FILE_AUTO; - ret =3D qcowXGetBackingStore(res, NULL, buf, buf_size, false); - if (ret =3D=3D BACKING_STORE_OK && !*res) - *format =3D VIR_STORAGE_FILE_NONE; - return ret; + return qcowXGetBackingStore(res, format, buf, buf_size, false); } =20 static int --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484969; cv=none; d=zoho.com; s=zohoarc; b=JdZOACl7V2dKzkaT8+HXYVanp6Mhb1jkmt3SQA/TWd6H9lcY0OfD0Q5c/LMHQ81A31FUeInEnexxxRFVGFpTgJEbjgf6vIBObIDURCirnrbaTUSP576ekx9Has3hMIx51y5idbL3JF4EjUcD1F53dd/109IENnu5Gtwur/OOoHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484969; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Er7dLCQZnHUE3ARe80J8CoLvCLvKRgQaPRwdOUpajZw=; b=K/uhX5/NcpGmzVjKFG9o1irilArnEBwilBsdtIi2Z0UrFZBmfwhBi8MfSeUTK/o+5NJdulm8/7TTQcuslMuBPf4eOV5axHD+GHRyLZlEq4VME4CdQOY7FomidbyIE4Nqt0SMFjJ7w7TCGSl8yP5GAOszEsPCyBb+29jvENCsioE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484969400530.6826380438771; Mon, 7 Oct 2019 14:49:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2793D30089A1; Mon, 7 Oct 2019 21:49:27 +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 BB3AC60BF4; Mon, 7 Oct 2019 21:49:26 +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 657CC4E58C; Mon, 7 Oct 2019 21:49:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnOKt014545 for ; Mon, 7 Oct 2019 17:49:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 705C15C219; Mon, 7 Oct 2019 21:49:24 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12A185C1D4; Mon, 7 Oct 2019 21:49:23 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:19 -0400 Message-Id: <79f92e315686e90a7247bb40ef5dc2e50d5d3977.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/30] storagefile: Check version to determine if qcow2 or not 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 07 Oct 2019 21:49:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rather than require a boolean to be passed in Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 905e70b1a9..9bf4c1178b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -486,7 +486,7 @@ qcowXGetBackingStore(char **res, int *format, const char *buf, size_t buf_size, - bool isQCow2) + bool isQCow2 ATTRIBUTE_UNUSED) { unsigned long long offset; unsigned int size; @@ -548,8 +548,11 @@ qcowXGetBackingStore(char **res, * for qcow2 v3 images, the length of the header * is stored at QCOW2v3_HDR_SIZE */ - if (isQCow2) { - version =3D virReadBufInt32BE(buf + QCOWX_HDR_VERSION); + + version =3D virReadBufInt32BE(buf + QCOWX_HDR_VERSION); + if (version >=3D 2) { + /* QCow1 doesn't have the extensions capability + * used to store backing format */ if (version =3D=3D 2) start =3D QCOW2_HDR_TOTAL_SIZE; else @@ -569,8 +572,6 @@ qcow1GetBackingStore(char **res, const char *buf, size_t buf_size) { - /* QCow1 doesn't have the extensions capability - * used to store backing format */ return qcowXGetBackingStore(res, format, buf, buf_size, false); } =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484985; cv=none; d=zoho.com; s=zohoarc; b=PtwJyDbbKKJhhim229atcVhpzipq42lTHYejp+9b7EktZcf8AgW1iyLleDqGz3I7v8ATcRfCJaiYPbrDC0+KWyIn7c83bP78HbOMwWcvwmgEbBKfsZXkBL61b9diH97RS+PojPVoKoaXGUY72twd3jP956vX5PgLZASOYFHjCN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484985; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ayS8Vwl+OPKTFfvVQYsBcpOmyBIl2+IE1swBiDhgXvM=; b=ct4/7vnvyiTWn8zfqPZOEvHQ6W9HYwp3zAkMbzIdbxRAdFh6dXI9sdl5CvhflCCx1cHb2dY+zaFZPqbR9R/8sjbk0AYQdc5Hmy6e9n4yonBKJA4NoaxS6U/9l4DCgWb20yr3aqQ96u5Urp1O6LbWI292155KbSPaJgYxyBZVqH4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484985536564.8185769543134; Mon, 7 Oct 2019 14:49:45 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B6892772CC; Mon, 7 Oct 2019 21:49:43 +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 94DE2100EBA5; Mon, 7 Oct 2019 21:49:43 +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 57D714EE6E; Mon, 7 Oct 2019 21:49:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnPOE014555 for ; Mon, 7 Oct 2019 17:49:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 080145C219; Mon, 7 Oct 2019 21:49:25 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CE545C1D4; Mon, 7 Oct 2019 21:49:24 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:20 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/30] storagefile: Drop now unused isQCow2 argument 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 07 Oct 2019 21:49:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 9bf4c1178b..14551af4d2 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -485,8 +485,7 @@ static int qcowXGetBackingStore(char **res, int *format, const char *buf, - size_t buf_size, - bool isQCow2 ATTRIBUTE_UNUSED) + size_t buf_size) { unsigned long long offset; unsigned int size; @@ -572,7 +571,7 @@ qcow1GetBackingStore(char **res, const char *buf, size_t buf_size) { - return qcowXGetBackingStore(res, format, buf, buf_size, false); + return qcowXGetBackingStore(res, format, buf, buf_size); } =20 static int @@ -581,7 +580,7 @@ qcow2GetBackingStore(char **res, const char *buf, size_t buf_size) { - return qcowXGetBackingStore(res, format, buf, buf_size, true); + return qcowXGetBackingStore(res, format, buf, buf_size); } =20 =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484990; cv=none; d=zoho.com; s=zohoarc; b=YrP8iN5GtJE+lvdFauTk9WZ1Hs2omUEGY6fb+kRykS5RJbxZkF1D6mNQq0j//+YpQFDbecRfymPZruVCdq7SJPObrYBLOFUD+Bv6wuwQv1kkW+yvLNFl6LmWPsWBCLmkGxGNoG4EcthiaWESLgmLI0i9s9gd53XqytokY3eDrj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484990; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2s2KKWOOpoje/szkXhm5hdVYxfRXFp7WhPj4pWxV6Fc=; b=j1LGYdL79h/zh29wu7cjpWV/JeeDVK8oEibwFOHK6MPyrL+Uiq++SH2M/Y5aaVOcw9PSIIYOP3z5+4NvPpVH5oea6Eo8/eYowaHUEtY+hBxxx6aJZcAviF2Yccg1n7upuDS+U8FjDNyLVUZLHm0gFRzz/cjYS5AsM3WGNLApTYM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484990244799.0761231008348; Mon, 7 Oct 2019 14:49:50 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 9FAE5302C07C; Mon, 7 Oct 2019 21:49:48 +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 78A3119C68; Mon, 7 Oct 2019 21:49:48 +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 3CDC94EE71; Mon, 7 Oct 2019 21:49:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnRNG014578 for ; Mon, 7 Oct 2019 17:49:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id C98D35C223; Mon, 7 Oct 2019 21:49:27 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 100EC5C1D4; Mon, 7 Oct 2019 21:49:25 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:21 -0400 Message-Id: <753e01b3ed570fb49fe0d294cb34ad7bf49d9a2a.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/30] storagefile: Use qcowXGetBackingStore directly 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 07 Oct 2019 21:49:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The qcow1 and qcow2 variants are identical, so remove the wrappers Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 14551af4d2..a9a6c3e132 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -180,9 +180,7 @@ struct FileTypeInfo { =20 static int cowGetBackingStore(char **, int *, const char *, size_t); -static int qcow1GetBackingStore(char **, int *, - const char *, size_t); -static int qcow2GetBackingStore(char **, int *, +static int qcowXGetBackingStore(char **, int *, const char *, size_t); static int qcow2GetFeatures(virBitmapPtr *features, int format, char *buf, ssize_t len); @@ -366,14 +364,14 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { LV_BIG_ENDIAN, 4, 4, {1}, QCOWX_HDR_IMAGE_SIZE, 8, 1, qcow1EncryptionInfo, - qcow1GetBackingStore, NULL + qcowXGetBackingStore, NULL }, [VIR_STORAGE_FILE_QCOW2] =3D { 0, "QFI", NULL, LV_BIG_ENDIAN, 4, 4, {2, 3}, QCOWX_HDR_IMAGE_SIZE, 8, 1, qcow2EncryptionInfo, - qcow2GetBackingStore, + qcowXGetBackingStore, qcow2GetFeatures }, [VIR_STORAGE_FILE_QED] =3D { @@ -565,25 +563,6 @@ qcowXGetBackingStore(char **res, } =20 =20 -static int -qcow1GetBackingStore(char **res, - int *format, - const char *buf, - size_t buf_size) -{ - return qcowXGetBackingStore(res, format, buf, buf_size); -} - -static int -qcow2GetBackingStore(char **res, - int *format, - const char *buf, - size_t buf_size) -{ - return qcowXGetBackingStore(res, format, buf, buf_size); -} - - static int vmdk4GetBackingStore(char **res, int *format, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484980; cv=none; d=zoho.com; s=zohoarc; b=YE6U/40cbljxVnI54G24bh5Le1sL1Jepgh/KEVMVh4wmDb7YlVq23LX6697FqAZmCijm7QCh0w4VmAnOrJtNBnwupmeYlAyCxbl6TJMsh1H39dCI4Wgu6xHo2LcB2IKwm2EdiFwK/730R9/iTy+4j0Mg1rG9m/jnnJ5H/y0xdQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484980; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=l1XIbidfq4Hv0ypGR9hk6RgE9rMDC9wTu608dd9IQrM=; b=EvCy09CEivkKhnA7IqX9FXJT5GJrAOZqeCZwrEAnGL5bTRzOOUAX653dgOzdiITa6klh90qoro3KBP0WkJIOwLUsW60uTD3iMHTvsvNwG1LFly6hknM8r62Dw8FHF/FlJoCqkDYqJVRKpIv2KZuq3IupEKTAfjW5BfW/PTDe/9M= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484980594804.8036181249471; Mon, 7 Oct 2019 14:49:40 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F29B118CB8F7; Mon, 7 Oct 2019 21:49:38 +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 CB3475DAAD; Mon, 7 Oct 2019 21:49:38 +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 8F0144EE68; Mon, 7 Oct 2019 21:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnT73014587 for ; Mon, 7 Oct 2019 17:49:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4660D5C240; Mon, 7 Oct 2019 21:49:29 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 378C25C1D4; Mon, 7 Oct 2019 21:49:28 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:22 -0400 Message-Id: <8f91d8e24e5076b4909516b7dc155e171a248f2e.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/30] storagefile: Push 'start' into qcow2GetBackingStoreFormat 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Mon, 07 Oct 2019 21:49:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is a step towards making this qcow2GetBackingStoreFormat into a generic qcow2 extensions parser Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a9a6c3e132..4a3c9df7a2 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -430,10 +430,22 @@ static int qcow2GetBackingStoreFormat(int *format, const char *buf, size_t buf_size, - size_t extension_start, size_t extension_end) { - size_t offset =3D extension_start; + size_t offset; + size_t extension_start; + int version =3D virReadBufInt32BE(buf + QCOWX_HDR_VERSION); + + if (version < 2) { + /* QCow1 doesn't have the extensions capability + * used to store backing format */ + return 0; + } + + if (version =3D=3D 2) + extension_start =3D QCOW2_HDR_TOTAL_SIZE; + else + extension_start =3D virReadBufInt32BE(buf + QCOW2v3_HDR_SIZE); =20 /* * The extensions take format of @@ -445,6 +457,7 @@ qcow2GetBackingStoreFormat(int *format, * Unknown extensions can be ignored by skipping * over "length" bytes in the data stream. */ + offset =3D extension_start; while (offset < (buf_size-8) && offset < (extension_end-8)) { unsigned int magic =3D virReadBufInt32BE(buf + offset); @@ -487,8 +500,6 @@ qcowXGetBackingStore(char **res, { unsigned long long offset; unsigned int size; - unsigned long long start; - int version; =20 *res =3D NULL; *format =3D VIR_STORAGE_FILE_AUTO; @@ -546,18 +557,8 @@ qcowXGetBackingStore(char **res, * is stored at QCOW2v3_HDR_SIZE */ =20 - version =3D virReadBufInt32BE(buf + QCOWX_HDR_VERSION); - if (version >=3D 2) { - /* QCow1 doesn't have the extensions capability - * used to store backing format */ - if (version =3D=3D 2) - start =3D QCOW2_HDR_TOTAL_SIZE; - else - start =3D virReadBufInt32BE(buf + QCOW2v3_HDR_SIZE); - if (qcow2GetBackingStoreFormat(format, buf, buf_size, - start, offset) < 0) - return BACKING_STORE_INVALID; - } + if (qcow2GetBackingStoreFormat(format, buf, buf_size, offset) < 0) + return BACKING_STORE_INVALID; =20 return BACKING_STORE_OK; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484984; cv=none; d=zoho.com; s=zohoarc; b=XWnZpJ6H7NYtDOL30O0zpKTHypmz22jhOF7bo/TV413KaMQTU96B/Tf4GLpgZuO31UUK3Ny2tXvTkIQprmu4oouESd4Z7VN/W1nSR0wmZIDa1e2gqBrIeDoyOzMTW7Masi0aGMXNNKgQ6Ow909O5XW3x9dY9mfj2CNvp75NtsVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484984; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=U1z+J10VwAc3k7vr8zcf4inHijU4Koauhlw/iQST78Y=; b=cPab4ATOQ5jnC/tOD3LFKRvt0NC6xrsXKoYXynQe1oy+BMgzVc/TJO9Dznt3cR6jsqfvEtyNI3k033K4W6jqZgf6tuA++Rofk7jBywH5xFQ86cdRhoUG9hhls8/bXdLfRppcnGsVGs6lKRVXdQc1/qOxw5XCh/0BuW4yPsweD6A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484984114210.9783536818228; Mon, 7 Oct 2019 14:49:44 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8513C308624A; Mon, 7 Oct 2019 21:49:42 +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 613E05C240; Mon, 7 Oct 2019 21:49:42 +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 228964EE68; Mon, 7 Oct 2019 21:49:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnU3p014594 for ; Mon, 7 Oct 2019 17:49:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 31F355C223; Mon, 7 Oct 2019 21:49:30 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 825765C1D4; Mon, 7 Oct 2019 21:49:29 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:23 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/30] storagefile: Push extension_end calc to qcow2GetBackingStoreFormat 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 07 Oct 2019 21:49:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is a step towards making this qcow2GetBackingStoreFormat into a generic qcow2 extensions parser Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 66 +++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 4a3c9df7a2..b8f7faf580 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -429,11 +429,11 @@ cowGetBackingStore(char **res, static int qcow2GetBackingStoreFormat(int *format, const char *buf, - size_t buf_size, - size_t extension_end) + size_t buf_size) { size_t offset; size_t extension_start; + size_t extension_end; int version =3D virReadBufInt32BE(buf + QCOWX_HDR_VERSION); =20 if (version < 2) { @@ -447,6 +447,37 @@ qcow2GetBackingStoreFormat(int *format, else extension_start =3D virReadBufInt32BE(buf + QCOW2v3_HDR_SIZE); =20 + /* + * Traditionally QCow2 files had a layout of + * + * [header] + * [backingStoreName] + * + * Although the backingStoreName typically followed + * the header immediately, this was not required by + * the format. By specifying a higher byte offset for + * the backing file offset in the header, it was + * possible to leave space between the header and + * start of backingStore. + * + * This hack is now used to store extensions to the + * qcow2 format: + * + * [header] + * [extensions] + * [backingStoreName] + * + * Thus the file region to search for extensions is + * between the end of the header (QCOW2_HDR_TOTAL_SIZE) + * and the start of the backingStoreName (offset) + * + * for qcow2 v3 images, the length of the header + * is stored at QCOW2v3_HDR_SIZE + */ + extension_end =3D virReadBufInt64BE(buf + QCOWX_HDR_BACKING_FILE_OFFSE= T); + if (extension_end > buf_size) + return -1; + /* * The extensions take format of * @@ -506,6 +537,7 @@ qcowXGetBackingStore(char **res, =20 if (buf_size < QCOWX_HDR_BACKING_FILE_OFFSET+8+4) return BACKING_STORE_INVALID; + offset =3D virReadBufInt64BE(buf + QCOWX_HDR_BACKING_FILE_OFFSET); if (offset > buf_size) return BACKING_STORE_INVALID; @@ -529,35 +561,7 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] =3D '\0'; =20 - /* - * Traditionally QCow2 files had a layout of - * - * [header] - * [backingStoreName] - * - * Although the backingStoreName typically followed - * the header immediately, this was not required by - * the format. By specifying a higher byte offset for - * the backing file offset in the header, it was - * possible to leave space between the header and - * start of backingStore. - * - * This hack is now used to store extensions to the - * qcow2 format: - * - * [header] - * [extensions] - * [backingStoreName] - * - * Thus the file region to search for extensions is - * between the end of the header (QCOW2_HDR_TOTAL_SIZE) - * and the start of the backingStoreName (offset) - * - * for qcow2 v3 images, the length of the header - * is stored at QCOW2v3_HDR_SIZE - */ - - if (qcow2GetBackingStoreFormat(format, buf, buf_size, offset) < 0) + if (qcow2GetBackingStoreFormat(format, buf, buf_size) < 0) return BACKING_STORE_INVALID; =20 return BACKING_STORE_OK; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484993; cv=none; d=zoho.com; s=zohoarc; b=UHAashUiDQ2v3FD1wT/ZMbrOg2coTFRK+gyOXRMGWd+YvELArgYJySn5rA+7mZOkzCwCxhHE0FPLXNjBezkcCHmrRrp4skT5oqWK3tXLc9t8blCB/a8ROq+P0V1zk4rdLjXqtpFO+EkgcOAsapuuSpJTX7V99HCzvMFkSi0LmG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484993; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qdC76TJnDtWZ/BSqrUYA6+WME5fqhvv1KP5J/G7TEYo=; b=kjqtjUBxLEYcCp+6PrUG31ESqZDURwnH1Eezt1wZa7k71aypQK4yVxDI0KlQd6cNr+umaEtMgvepZBLQ+F3GkVs30xg0sQIM6tjxGtrDsDVHpBTqM9z0pPemHsPvZsB6GCiCpBuJQSkHSBZhhh/wXfga+hxeLzATrSkEH/qo5ww= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484993758301.86656552619013; Mon, 7 Oct 2019 14:49:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2273CC00A167; Mon, 7 Oct 2019 21:49:52 +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 F390460166; Mon, 7 Oct 2019 21:49: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 AEBBB180BA9C; Mon, 7 Oct 2019 21:49:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnUkp014602 for ; Mon, 7 Oct 2019 17:49:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id BBF9C5C219; Mon, 7 Oct 2019 21:49:30 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E0295C1D4; Mon, 7 Oct 2019 21:49:30 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:24 -0400 Message-Id: <01bc2d20b5b73ba4f28c405f99af62d7f23569a3.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/30] storagefile: Rename qcow2GetBackingStoreFormat 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 07 Oct 2019 21:49:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" ...to qcow2GetExtensions. We will extend it for more extension parsing in future patches Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index b8f7faf580..d6bd38777b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -427,9 +427,9 @@ cowGetBackingStore(char **res, =20 =20 static int -qcow2GetBackingStoreFormat(int *format, - const char *buf, - size_t buf_size) +qcow2GetExtensions(int *format, + const char *buf, + size_t buf_size) { size_t offset; size_t extension_start; @@ -561,7 +561,7 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] =3D '\0'; =20 - if (qcow2GetBackingStoreFormat(format, buf, buf_size) < 0) + if (qcow2GetExtensions(format, buf, buf_size) < 0) return BACKING_STORE_INVALID; =20 return BACKING_STORE_OK; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484977; cv=none; d=zoho.com; s=zohoarc; b=atPWmib9vhWMlP+TJMfXT84Kc4jT9o4ShIcbXwWmDcI+v/PMS65pWFsNlH5lFM+AkxGLX0012t0PeMc8ZuriiHHUrExfCVHmipZriuqdseVp4GPSIy6FIk3873jLUnchjH0DuSodLxwaLqtydWbS9sfxHyhNiWEMg+djqp1211Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484977; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=678rrsui4JWFZ/rdaq3meOUymjbbvzhP0mk2rQNwUMo=; b=XSXnAfeBsIH2Y2QHRKlHdYjxIUtmwHgPiyg1bghbDK9nrI8ZnWNusGjvH0swJCotW8oWHKDNpFFfHl8CJ1+LWB6f04jxSidb3XFLF5dqzlZPnF0Qsn04WJ78ZdDn8W4Ue1r6vhTQCojn+0HAj5yJBHKZB5OyoSIMGCXPdNmYHxc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484977634920.0437051867119; Mon, 7 Oct 2019 14:49:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D55AE307D983; Mon, 7 Oct 2019 21:49:35 +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 AF05119C68; Mon, 7 Oct 2019 21:49:35 +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 6E3881803B4A; Mon, 7 Oct 2019 21:49:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnV7s014609 for ; Mon, 7 Oct 2019 17:49:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 505445C219; Mon, 7 Oct 2019 21:49:31 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8B8D5C1D4; Mon, 7 Oct 2019 21:49:30 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:25 -0400 Message-Id: <5b141b336816fb546417579055a8edfe8f5cc0eb.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/30] storagefile: Rename qcow2GetExtensions 'format' argument 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 07 Oct 2019 21:49:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" To backingFormat, which makes it more clear. Move it to the end of the argument list which will scale nicer with future patches Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index d6bd38777b..8cd576a463 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -427,9 +427,9 @@ cowGetBackingStore(char **res, =20 =20 static int -qcow2GetExtensions(int *format, - const char *buf, - size_t buf_size) +qcow2GetExtensions(const char *buf, + size_t buf_size, + int *backingFormat) { size_t offset; size_t extension_start; @@ -509,8 +509,8 @@ qcow2GetExtensions(int *format, case QCOW2_HDR_EXTENSION_BACKING_FORMAT: if (buf[offset+len] !=3D '\0') break; - *format =3D virStorageFileFormatTypeFromString(buf+offset); - if (*format <=3D VIR_STORAGE_FILE_NONE) + *backingFormat =3D virStorageFileFormatTypeFromString(buf+offs= et); + if (*backingFormat <=3D VIR_STORAGE_FILE_NONE) return -1; } =20 @@ -561,7 +561,7 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] =3D '\0'; =20 - if (qcow2GetExtensions(format, buf, buf_size) < 0) + if (qcow2GetExtensions(buf, buf_size, format) < 0) return BACKING_STORE_INVALID; =20 return BACKING_STORE_OK; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484997; cv=none; d=zoho.com; s=zohoarc; b=TJGOuNFEeVzIFqh/6lNOmnfYBy2leQEJTYBxnsu9g1b2sNKBIgCRZWyGelWzA3gQFXiYnRNyk2AfdNojL37oawWYlcGafWpikGNa3e0IuOzenLGjJu/oqG8nVVrQK7QalurwBM01uNbmjcTLDWWZ+VRiE6on7rOemdE2A7wV+tM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484997; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WElK69WwTq5tW09hwRCCPa6mz5lhrDBfTZ5pUXY1PIQ=; b=YZD2ibXkQo4mkKr8qFLoV069CjDVTe33sWzCm0fY4YJsFM4rotn3Qa7ST8PviYEpmtobXBt1SuK4x1lhXxdTN+pvlp7HdIg3pdoOQ0myNVtTQqlJd4MQQpM8QNiQQoXVSLjl2b0+ShnnfY3LNjkO856QlWYHmuUxW4AEOP6WCGU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484997056564.1058193076917; Mon, 7 Oct 2019 14:49:57 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3F7EB308FC22; Mon, 7 Oct 2019 21:49: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 1CA9E5C240; Mon, 7 Oct 2019 21:49: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 D3E8A4EE75; Mon, 7 Oct 2019 21:49:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnVoD014614 for ; Mon, 7 Oct 2019 17:49:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB0185C219; Mon, 7 Oct 2019 21:49:31 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D2D05C1D4; Mon, 7 Oct 2019 21:49:31 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:26 -0400 Message-Id: <16d9ed51f14f1c74afce25c58aeedd85b0ec6daa.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/30] storagefile: Fix backing format \0 check 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 07 Oct 2019 21:49:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" >From qemu.git docs/interop/qcow2.txt =3D=3D String header extensions =3D=3D Some header extensions (such as the backing file format name and the external data file name) are just a single string. In this case, the header extension length is the string length and the string is not '\0' terminated. (The header extension padding can make it look like a string is '\0' terminated, but neither is padding always necessary nor is there a guarantee that zero bytes are used for padding.) So we shouldn't be checking for a \0 byte at the end of the backing format section. I think in practice there always is a \0 but we shouldn't depend on that. Signed-off-by: Cole Robinson Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 8cd576a463..5a4e4b24ae 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -506,13 +506,18 @@ qcow2GetExtensions(const char *buf, case QCOW2_HDR_EXTENSION_END: goto done; =20 - case QCOW2_HDR_EXTENSION_BACKING_FORMAT: - if (buf[offset+len] !=3D '\0') - break; - *backingFormat =3D virStorageFileFormatTypeFromString(buf+offs= et); + case QCOW2_HDR_EXTENSION_BACKING_FORMAT: { + VIR_AUTOFREE(char *) tmp =3D NULL; + if (VIR_ALLOC_N(tmp, len + 1) < 0) + return -1; + memcpy(tmp, buf + offset, len); + tmp[len] =3D '\0'; + + *backingFormat =3D virStorageFileFormatTypeFromString(tmp); if (*backingFormat <=3D VIR_STORAGE_FILE_NONE) return -1; } + } =20 offset +=3D len; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570484980; cv=none; d=zoho.com; s=zohoarc; b=Tz2cIL/ZojUCniCv8mlURRsQhq2Rc1/WVgkqUS3t2x0mZ/BSCrc6WCNfipBwdPKixLRqSCohGp6OdxfRztYT8cT7D85ZeQSmVaJtf12w5VH2KeIsxUKURpj0/1DZhecLx09hSLzaN4zR5iVvR65yqAAQuWjwZFzFFwJ2DpDBkWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570484980; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Mubs0GLh1rcpHXBMvKaTntU6dv9FxY8xGdAaUcK3pDI=; b=E0vqVCnx1CaSUpAq7G2M+qK5wUxp2FyrPjyx9VX2zBdw2f6Dlq47/3W+CX6ebJVM/D3wud7pjZ6axe5h9goSwcZcr+pg7xWDJzGp/h9GdN7G3WUXd0VYrhZcyqsqQF6VXEKuna0JNJoMP+ATG8BKkWoVbfru4n7V1uBeRv+B0Oo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570484980813228.55220674719726; Mon, 7 Oct 2019 14:49:40 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 14EB718C4269; Mon, 7 Oct 2019 21:49:39 +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 DE29C5B681; Mon, 7 Oct 2019 21:49:38 +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 98E85180B761; Mon, 7 Oct 2019 21:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnbY4014641 for ; Mon, 7 Oct 2019 17:49:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 099DF5C224; Mon, 7 Oct 2019 21:49:37 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D33F5C223; Mon, 7 Oct 2019 21:49:31 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:27 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/30] storagefile: Add externalDataStoreRaw member 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Mon, 07 Oct 2019 21:49:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add the plumbing to track a qcow2 external data file path in virStorageSource Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 2 ++ src/util/virstoragefile.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 5a4e4b24ae..621cc56e87 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2258,6 +2258,7 @@ virStorageSourceCopy(const virStorageSource *src, VIR_STRDUP(def->volume, src->volume) < 0 || VIR_STRDUP(def->relPath, src->relPath) < 0 || VIR_STRDUP(def->backingStoreRaw, src->backingStoreRaw) < 0 || + VIR_STRDUP(def->externalDataStoreRaw, src->externalDataStoreRaw) <= 0 || VIR_STRDUP(def->snapshot, src->snapshot) < 0 || VIR_STRDUP(def->configFile, src->configFile) < 0 || VIR_STRDUP(def->nodeformat, src->nodeformat) < 0 || @@ -2533,6 +2534,7 @@ virStorageSourceClear(virStorageSourcePtr def) virStorageSourceSeclabelsClear(def); virStoragePermsFree(def->perms); VIR_FREE(def->timestamps); + VIR_FREE(def->externalDataStoreRaw); =20 virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageAuthDefFree(def->auth); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2472d89c85..bbff511657 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -302,6 +302,8 @@ struct _virStorageSource { /* Name of the child backing store recorded in metadata of the * current file. */ char *backingStoreRaw; + /* Name of the child data file recorded in metadata of the current fil= e. */ + char *externalDataStoreRaw; =20 /* metadata that allows identifying given storage source */ char *nodeformat; /* name of the format handler object */ --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485224; cv=none; d=zoho.com; s=zohoarc; b=hI8grOFiOCaMwUqTOoBIohcTWXitc2AKMqz4j8Yi/yK3rYtGT7nqk/Y88m9Jfy/gBFeOt3eoxdTfcJYjyE0v4Z9wKJj2tN+BQKuD673LSHjyw3PEUE7crfI6JaHPxUtNGPKNBWBX1cAkCInKmNEANTb2piycj8FuEu9DhSWJ93w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485224; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iJlpkK6IRSaU2ztojwhT0w5FVG4m/kZXidOfDpIiETM=; b=MMrvSn9uJeawfGVIHhx2Q+XpqVqqZ0GqH3zce3Ir8JVl+hOxnJhNOG1NT9cfcLeaUrByaSOPGlni9DGxT8oaMPpNxQdFExLOhFOs5g3EIy90ZePHykgSNeZ6dEhvdN6ibo/53Vr1yGFml6N0dZf8GJFEa1S/INBw+w3W963FevI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485224566824.7425423321818; Mon, 7 Oct 2019 14:53:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1767B30832E9; Mon, 7 Oct 2019 21:53:43 +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 E68A5600CE; Mon, 7 Oct 2019 21:53:42 +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 AAA7C180B536; Mon, 7 Oct 2019 21:53:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97Lnium014663 for ; Mon, 7 Oct 2019 17:49:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0FEF35C224; Mon, 7 Oct 2019 21:49:44 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 574725C223; Mon, 7 Oct 2019 21:49:37 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:28 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/30] storagefile: Parse qcow2 external data file 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 07 Oct 2019 21:53:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is tracked as a qcow2 extension, like backing store format Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 621cc56e87..7e32d7619e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -202,6 +202,7 @@ qedGetBackingStore(char **, int *, const char *, size_t= ); =20 #define QCOW2_HDR_EXTENSION_END 0 #define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA +#define QCOW2_HDR_EXTENSION_DATA_FILE 0x44415441 =20 #define QCOW2v3_HDR_FEATURES_INCOMPATIBLE (QCOW2_HDR_TOTAL_SIZE) #define QCOW2v3_HDR_FEATURES_COMPATIBLE (QCOW2v3_HDR_FEATURES_INCOMPATIBLE= +8) @@ -429,7 +430,8 @@ cowGetBackingStore(char **res, static int qcow2GetExtensions(const char *buf, size_t buf_size, - int *backingFormat) + int *backingFormat, + char **externalDataStoreRaw) { size_t offset; size_t extension_start; @@ -508,6 +510,9 @@ qcow2GetExtensions(const char *buf, =20 case QCOW2_HDR_EXTENSION_BACKING_FORMAT: { VIR_AUTOFREE(char *) tmp =3D NULL; + if (!backingFormat) + break; + if (VIR_ALLOC_N(tmp, len + 1) < 0) return -1; memcpy(tmp, buf + offset, len); @@ -516,6 +521,19 @@ qcow2GetExtensions(const char *buf, *backingFormat =3D virStorageFileFormatTypeFromString(tmp); if (*backingFormat <=3D VIR_STORAGE_FILE_NONE) return -1; + break; + } + + case QCOW2_HDR_EXTENSION_DATA_FILE: { + if (!externalDataStoreRaw) + break; + + if (VIR_ALLOC_N(*externalDataStoreRaw, len + 1) < 0) + return -1; + memcpy(*externalDataStoreRaw, buf + offset, len); + (*externalDataStoreRaw)[len] =3D '\0'; + VIR_DEBUG("parsed externalDataStoreRaw=3D'%s'", *externalDataS= toreRaw); + break; } } =20 @@ -566,7 +584,7 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] =3D '\0'; =20 - if (qcow2GetExtensions(buf, buf_size, format) < 0) + if (qcow2GetExtensions(buf, buf_size, format, NULL) < 0) return BACKING_STORE_INVALID; =20 return BACKING_STORE_OK; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485173; cv=none; d=zoho.com; s=zohoarc; b=HQouOjzfXi0qtoCaOzrfIon6pTC4IFoijEYgQDCLk/I8ciigMCefE77aMzWDZ5h+h3GjK4S6k3f97QPbwGaBfU7ExWKjYL48oEdb9A4xCBaD3L764sF+pi7e/C4GIZAF6Znrx18gvEgGb15FuAeHJRl0HPRBvY9y8hcSa+j2sXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485173; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Vwu9moFWTtO+soP8ymvgEbaCTf028eYT0ZfaF5Kr5+I=; b=jED4I4Qj0CvD6RjaVe/qJYqoh7VVwHvjuMvezCBEQkz5NEaGmPDPaj17OWnmZG8lLNIK73uqR/dIM9sQXBAPQ547DBiAHeQqFqy0labC3qijoptgIN9P+jgBQfBszLNQ4SYLbbptJY66q7G2wwfsASp4c9pIzWJZIXIrVGFNbJY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485173287350.5290229503587; Mon, 7 Oct 2019 14:52:53 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 9AB5D8553B; Mon, 7 Oct 2019 21:52: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 73F3360605; Mon, 7 Oct 2019 21:52: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 334F31803518; Mon, 7 Oct 2019 21:52:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnmXf014682 for ; Mon, 7 Oct 2019 17:49:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC63C5C224; Mon, 7 Oct 2019 21:49:48 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A55C5C223; Mon, 7 Oct 2019 21:49:44 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:29 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/30] storagefile: Fill in meta->externalDataStoreRaw 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 07 Oct 2019 21:52:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Call qcow2GetExtensions to actually fill in the virStorageSource externalDataStoreRaw member Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7e32d7619e..53fe4590b4 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1060,6 +1060,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePt= r meta, fileTypeInfo[meta->format].getFeatures(&meta->features, meta->form= at, buf, len) < 0) return -1; =20 + VIR_FREE(meta->externalDataStoreRaw); + if (meta->format =3D=3D VIR_STORAGE_FILE_QCOW2 && + qcow2GetExtensions(buf, len, NULL, &meta->externalDataStoreRaw) < = 0) { + return -1; + } + VIR_FREE(meta->compat); if (meta->format =3D=3D VIR_STORAGE_FILE_QCOW2 && meta->features && VIR_STRDUP(meta->compat, "1.1") < 0) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485228; cv=none; d=zoho.com; s=zohoarc; b=nG4dibdgNqQ2sdNr8Rz7OxGRcSJke8wIZRu7ibLbZVjG7wq3WNi2PYRTnGlr6xubXUVyi4ERUXhJwzgIyvrNnuNVVGCrvuK8FjCOIo4LIsp27D8C+2tjeK4f03VoN+5CKdzW1Idw80cH8/CQ969x1v4/VpfoFm6phnHTFvm8wuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485228; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=k33Ixq2WgBBYpYV8nwIKQFQkdNXjO215KEDqFVc2DoQ=; b=XLzbC5nI5PA+gdjQ6UyrsZms6CerhHxkp9xfVF90dlMTO2m9EVjOSI5VDd2tHm4Fzp5y0q2z8DvdrPR0Z7wVA0JjLrLv39svWNhFC92FG5SswoUE9xx9xS1rHW04NdxCg3LONB2SB31xY5B4Iegg6JnHATfSga9nteVLMdIx+rg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485228013358.2569858946698; Mon, 7 Oct 2019 14:53:48 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 79A95315C03D; Mon, 7 Oct 2019 21:53:46 +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 5652219C77; Mon, 7 Oct 2019 21:53:46 +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 1AF68180B536; Mon, 7 Oct 2019 21:53:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnrNP014765 for ; Mon, 7 Oct 2019 17:49:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84B655C224; Mon, 7 Oct 2019 21:49:53 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4FD45C223; Mon, 7 Oct 2019 21:49:48 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:30 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/30] storagefile: Don't access backingStoreRaw directly in FromBackingRelative 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 07 Oct 2019 21:53:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" For the only usage, the rel =3D=3D parent->backingStoreRaw, so drop the direct access Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 53fe4590b4..c47df6c200 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2625,7 +2625,7 @@ virStorageSourceNewFromBackingRelative(virStorageSour= cePtr parent, return NULL; =20 /* store relative name */ - if (VIR_STRDUP(def->relPath, parent->backingStoreRaw) < 0) + if (VIR_STRDUP(def->relPath, rel) < 0) return NULL; =20 if (!(dirname =3D mdir_name(parent->path))) { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485177; cv=none; d=zoho.com; s=zohoarc; b=Z/9t0z7ndzD9kResqCUTLwd+Ma0d3QRTfSS7Mr41nvKol2/Zt1VV9Fk/jcw5z1RpskvZ2alq1pQQ4fHytWERqt4QNTmouDopmmv88XF1OB350lhiAFS+juYd5LQOrwVQjA7l0nVtEh6KlnoBKah+PA1xrlmwgZX6Y0AAykYYG3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485177; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/SDGbiUQRTjd7zaxMk87iIwTMBUvqVmNG7EFO/uTLWA=; b=WC94WyNxFdhMEUChh9j/gq7w9JGbfAALDEzSKbyilN8kFwXReP2lGrzTfDrszFVFPvSGL4fCCra7PAfGMDXCwFFTNSaouo83mEI9prb1fM5FE1ONDhCaYRJGALoTvWOV+uCBw/4bbnkazZMfsDVjiW/OVp6nzlE05xdDlqbj+vQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485177397826.935395135741; Mon, 7 Oct 2019 14:52:57 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id DC79585362; Mon, 7 Oct 2019 21:52: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 BEBEC5D9C9; Mon, 7 Oct 2019 21:52: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 7F6024EEB7; Mon, 7 Oct 2019 21:52:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LnwTc014877 for ; Mon, 7 Oct 2019 17:49:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E2015C231; Mon, 7 Oct 2019 21:49:58 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07175C224; Mon, 7 Oct 2019 21:49:53 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:31 -0400 Message-Id: <024031653c027c12a7cc627493aa93c83eceb87d.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/30] storagefile: Split out virStorageSourceNewFromChild 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 07 Oct 2019 21:52:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Future patches will use this for external data file handling Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c47df6c200..7ae6719dd6 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3716,38 +3716,38 @@ virStorageSourceNewFromBackingAbsolute(const char *= path, =20 =20 /** - * virStorageSourceNewFromBacking: + * virStorageSourceNewFromChild: * @parent: storage source parent - * @backing: returned backing store definition + * @child: returned child/backing store definition + * @parentRaw: raw child string (backingStoreRaw) * * Creates a storage source which describes the backing image of @parent a= nd - * fills it into @backing depending on the 'backingStoreRaw' property of @= parent + * fills it into @backing depending on the passed parentRaw (backingStoreR= aw) * and other data. Note that for local storage this function accesses the = file - * to update the actual type of the backing store. + * to update the actual type of the child store. * - * Returns 0 on success, 1 if we could parse all location data but the bac= kinig + * Returns 0 on success, 1 if we could parse all location data but the chi= ld * store specification contained other data unrepresentable by libvirt (e.= g. * inline authentication). * In both cases @src is filled. On error -1 is returned @src is NULL and = an * error is reported. */ -int -virStorageSourceNewFromBacking(virStorageSourcePtr parent, - virStorageSourcePtr *backing) +static int +virStorageSourceNewFromChild(virStorageSourcePtr parent, + const char *parentRaw, + virStorageSourcePtr *child) { struct stat st; VIR_AUTOUNREF(virStorageSourcePtr) def =3D NULL; int rc =3D 0; =20 - *backing =3D NULL; + *child =3D NULL; =20 - if (virStorageIsRelative(parent->backingStoreRaw)) { - if (!(def =3D virStorageSourceNewFromBackingRelative(parent, - parent->backing= StoreRaw))) + if (virStorageIsRelative(parentRaw)) { + if (!(def =3D virStorageSourceNewFromBackingRelative(parent, paren= tRaw))) return -1; } else { - if ((rc =3D virStorageSourceNewFromBackingAbsolute(parent->backing= StoreRaw, - &def)) < 0) + if ((rc =3D virStorageSourceNewFromBackingAbsolute(parentRaw, &def= )) < 0) return -1; } =20 @@ -3767,10 +3767,25 @@ virStorageSourceNewFromBacking(virStorageSourcePtr = parent, if (virStorageSourceInitChainElement(def, parent, true) < 0) return -1; =20 - def->readonly =3D true; def->detected =3D true; =20 - VIR_STEAL_PTR(*backing, def); + VIR_STEAL_PTR(*child, def); + return rc; +} + + +int +virStorageSourceNewFromBacking(virStorageSourcePtr parent, + virStorageSourcePtr *backing) +{ + int rc; + + if ((rc =3D virStorageSourceNewFromChild(parent, + parent->backingStoreRaw, + backing)) < 0) + return rc; + + (*backing)->readonly =3D true; return rc; } =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485232; cv=none; d=zoho.com; s=zohoarc; b=JgRDaM/FhS7czOkLGAVFMvEl7ZHAvF2hcBw7y610TTEMkB1cVxd7BMHyl+eI0yagdOBGEEtUHoMsdjvJs5EfMx6Xjmw9fugfNMcTL93RVnmFp5FOmzHoXPVNBhz+m+SCSewyuTu/ZGSPzpgYrN9MIheorHu/8TE8YHdYUr/qnps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485232; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=xej1xLcS4uGqhQQois+fdJyo3DobfbQL5u4d3PVMb+w=; b=BMpXDK3vLUcy+BhjGv7mBeVZYwrUKgqA6n7JTJgcbDxSx5hmigGHDeoHRiDo1FCYbjYns2/LQiL9J/IlzkufWCsjB64mSglyMj7L4Lro0MXSe3rjuCPqwYKhnvE/KOOcIJ+AFU4ZW4G8tzUcpf4qYYp1bnCsTMQI7yeeACMg3V4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485232399448.9190354057532; Mon, 7 Oct 2019 14:53:52 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C1D3D51EE6; Mon, 7 Oct 2019 21:53:49 +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 99F645D71C; Mon, 7 Oct 2019 21:53:49 +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 471614EE97; Mon, 7 Oct 2019 21:53:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LoOS7015037 for ; Mon, 7 Oct 2019 17:50:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92ED55C224; Mon, 7 Oct 2019 21:50:24 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2421B5C223; Mon, 7 Oct 2019 21:49:58 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:32 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 18/30] storagefile: Add externalDataStore member 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 07 Oct 2019 21:53:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add the plumbing to track a externalDataStoreRaw as a virStorageSource Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 9 +++++++++ src/util/virstoragefile.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 7ae6719dd6..ce669b6e0b 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2339,6 +2339,12 @@ virStorageSourceCopy(const virStorageSource *src, return NULL; } =20 + if (src->externalDataStore) { + if (!(def->externalDataStore =3D virStorageSourceCopy(src->externa= lDataStore, + true))) + return NULL; + } + VIR_STEAL_PTR(ret, def); return ret; } @@ -2560,6 +2566,9 @@ virStorageSourceClear(virStorageSourcePtr def) VIR_FREE(def->timestamps); VIR_FREE(def->externalDataStoreRaw); =20 + virObjectUnref(def->externalDataStore); + def->externalDataStore =3D NULL; + virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageAuthDefFree(def->auth); virObjectUnref(def->privateData); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index bbff511657..d84dad052d 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -292,6 +292,9 @@ struct _virStorageSource { /* backing chain of the storage source */ virStorageSourcePtr backingStore; =20 + /* external data store storage source */ + virStorageSourcePtr externalDataStore; + /* metadata for storage driver access to remote and local volumes */ virStorageDriverDataPtr drv; =20 --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485181; cv=none; d=zoho.com; s=zohoarc; b=Md+pe79VzwTs9tSij1eWw/01jKSGE2PmQ89cYvRo0E5/1VVCaaPAb2ld0kvRfQ8RnjX3HnPnzRyx/awdzOT+ldgPdqktDOt8eBm05PTYPuLLJVEFfCqU9Hovk3TU1KXI8e/M5cpcWVfbU7xtSzVcA95NlkUCorbVoRJDJumQ71A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485181; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ooQ8NQVpqcq589byhOREixiTAd44wmHd0EUdUSCviC0=; b=YDrNKi+Nws+Sn5qTv75lw+Zar4e8VKJnpEcCjMjwWXteE9KgvwKEhx2ckvMAm7Nk3HYBPuDHj3PnIGra6fYBcPt4S1feuyzxQlXS3tqVX967VXMGAJNt7iUuIjfUxyUia+iJup690RcerLLQjaRHGfGfDAPHpatEBUoKSpt0CRs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485181875834.132462679209; Mon, 7 Oct 2019 14:53:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57F8818C4277; Mon, 7 Oct 2019 21:52: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 2CC656012C; Mon, 7 Oct 2019 21:52: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 C6E9118037C9; Mon, 7 Oct 2019 21:52:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LoX9S015072 for ; Mon, 7 Oct 2019 17:50:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04CC15C290; Mon, 7 Oct 2019 21:50:33 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A31B5C224; Mon, 7 Oct 2019 21:50:24 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:33 -0400 Message-Id: <429e602ae44341aef3aaed8186ef032d80a1e6a9.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/30] storagefile: Fill in meta->externalDataStore 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Mon, 07 Oct 2019 21:53:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add virStorageSourceNewFromExternalData, similar to virStorageSourceNewFromBacking and use it to fill in a virStorageSource for externalDataStore Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index ce669b6e0b..4aa70d71b1 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3799,6 +3799,24 @@ virStorageSourceNewFromBacking(virStorageSourcePtr p= arent, } =20 =20 +static int +virStorageSourceNewFromExternalData(virStorageSourcePtr parent, + virStorageSourcePtr *externalDataStore) +{ + int rc; + + if ((rc =3D virStorageSourceNewFromChild(parent, + parent->externalDataStoreRaw, + externalDataStore)) < 0) + return rc; + + /* qcow2 data_file can only be raw */ + (*externalDataStore)->format =3D VIR_STORAGE_FILE_RAW; + (*externalDataStore)->readonly =3D parent->readonly; + return rc; +} + + /** * @src: disk source definition structure * @fd: file descriptor @@ -5007,6 +5025,23 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr= src, } =20 VIR_STEAL_PTR(src->backingStore, backingStore); + + if (src->externalDataStoreRaw) { + VIR_AUTOUNREF(virStorageSourcePtr) externalDataStore =3D NULL; + + if ((rv =3D virStorageSourceNewFromExternalData(src, + &externalDataStore))= < 0) + goto cleanup; + + if (rv =3D=3D 1) { + /* the file would not be usable for VM usage */ + ret =3D 0; + goto cleanup; + } + + VIR_STEAL_PTR(src->externalDataStore, externalDataStore); + } + ret =3D 0; =20 cleanup: --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485185; cv=none; d=zoho.com; s=zohoarc; b=ewyOkFKNp+sNAHZ7KhA9COLX9v3CMS+LkGYBnxIINLD1UOyW8ESf5w/iwRUOZxRU37sQxtiRA/Y+8mOUfq8edWDbZ/mqGyUvR6sHJyM7CjFW2YVPspxa5crwzUqQNXrLwR822Duz0Nn23JAxR1sD3ku7r92JHUVcVfJrarmcXH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485185; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2gXxKKhlWmJ43MeDExTA1chlDm6hIrwWOeG+FMZHA5o=; b=mb2ahG/UE+6l4fRgf+oyauZLlnCHXhIa1SmS4kgeXuAplCJiB4FQgOKUiLACg4xJJj4iodL3aF6XecOqaDdJnVjFvhoqS8L78suhqWqDNVQFYkUMOi9wyDqDnHqV3zfrubon7LSZBy4nAq//S9euVpRpv9CxzUKG57So6dQfsPo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485185503406.08500586248385; Mon, 7 Oct 2019 14:53:05 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id E194B308402D; Mon, 7 Oct 2019 21:53:02 +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 BA5625DA8C; Mon, 7 Oct 2019 21:53:02 +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 7F28C4EEB8; Mon, 7 Oct 2019 21:53:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LocIY015094 for ; Mon, 7 Oct 2019 17:50:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 44B885C231; Mon, 7 Oct 2019 21:50:38 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4451C5C224; Mon, 7 Oct 2019 21:50:33 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:34 -0400 Message-Id: <54d9c4ea4531ec10f219e92b6de133a496d24f1f.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 20/30] security: dac: Drop !parent handling in SetImageLabelInternal 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 07 Oct 2019 21:53:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The only caller always passes in a non-null parent Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_dac.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 4b4afef18a..bcc781213e 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -893,9 +893,8 @@ virSecurityDACSetImageLabelInternal(virSecurityManagerP= tr mgr, return 0; =20 disk_seclabel =3D virStorageSourceGetSecurityLabelDef(src, SECURITY_DA= C_NAME); - if (parent) - parent_seclabel =3D virStorageSourceGetSecurityLabelDef(parent, - SECURITY_DAC= _NAME); + parent_seclabel =3D virStorageSourceGetSecurityLabelDef(parent, + SECURITY_DAC_NAM= E); =20 if (disk_seclabel && (!disk_seclabel->relabel || disk_seclabel->label)= ) { if (!disk_seclabel->relabel) --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485234; cv=none; d=zoho.com; s=zohoarc; b=lWe4I4FWq04ItlWHoxw8fb+fPG79mIysB8hSarJ+b/3fibyYjuYeCcrIWa8/VYmvfAYsvuuETrfjOJqd+RTxc6+16zeTBW5PwqAmXaYH7JbpX554iOCiAsBT3+plvsqmkoNr1m3aR8ztWZJUv+C36wMHOb18fpf5qDXmiR4c7/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485234; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=AJD2k1C574v5oHdqviVGnvYiOetDZgIBOROcdC390Do=; b=C7OtOEDE+6okuMATVw+EAbYM2zAHwZT9FEPLhTYHS+G7ECQupwV0IvBVcO2vkdejo0ejOQWX48aKRd8273hxWYPHDXPgJ30Pf9eaR1QNDEhMeh7FZUuyyibdEagTUMVOZfvJ7N0EaJsoUuHcGVVf0PBUEl8EpuKccAqjJeLF5OY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485234492342.12371150388776; Mon, 7 Oct 2019 14:53:54 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 14739C054C52; Mon, 7 Oct 2019 21:53:53 +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 E3BD55C22F; Mon, 7 Oct 2019 21:53:52 +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 A8461180BA99; Mon, 7 Oct 2019 21:53:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97Loi9R015106 for ; Mon, 7 Oct 2019 17:50:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 176075C231; Mon, 7 Oct 2019 21:50:44 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id D500F5C290; Mon, 7 Oct 2019 21:50:38 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:35 -0400 Message-Id: <253129220c00b19e0ae28d9d0e84aea7c7645834.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 21/30] security: dac: Add is_toplevel to SetImageLabelInternal 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 07 Oct 2019 21:53:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This will simplify future patches and make the logic easier to follow Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_dac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index bcc781213e..6d0c8a9b1c 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -882,6 +882,7 @@ virSecurityDACSetImageLabelInternal(virSecurityManagerP= tr mgr, virSecurityDeviceLabelDefPtr parent_seclabel =3D NULL; virSecurityDACDataPtr priv =3D virSecurityManagerGetPrivateData(mgr); bool remember; + bool is_toplevel =3D parent =3D=3D src; uid_t user; gid_t group; =20 @@ -926,7 +927,7 @@ virSecurityDACSetImageLabelInternal(virSecurityManagerP= tr mgr, * but the top layer, or read only image, or disk explicitly * marked as shared. */ - remember =3D src =3D=3D parent && !src->readonly && !src->shared; + remember =3D is_toplevel && !src->readonly && !src->shared; =20 return virSecurityDACSetOwnership(mgr, src, NULL, user, group, remembe= r); } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485188; cv=none; d=zoho.com; s=zohoarc; b=DhA2QO7JAxEJS/KLtMwu5DqEAIAItrYb0gx52pZLQ5yY0h0c60kvFC7ABJu/v9ZXXvKAJD4/54PUirnEoSZxbkgGFDyblLM8RXg/7afIeoZX5/qNOPcQyD/ijx4QNvjNbIj3F+OTuHvlb/oqGy/a8+dFec7/TotivFMPyU5TNdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485188; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6IntyRMLy/22DPoU/4VY0uaXSnyOXx1DJdGmlRgbAh4=; b=MWAYBPcM0DSXlQcFTxU/FKbCKyU83+0zKRkEvMx+P4Mxiio9DMSLUJO9OOUYHkgUSWQpRttNluOWFNn6rTBhp033b9qh1Q24y0/XdH5mErfYczKTIa5XHcxxaWuV925lZs0HlEnjMfcWeco2weRg9ML/rUMA4sQAf37TiTbbOQ8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485188054103.72563281122927; Mon, 7 Oct 2019 14:53:08 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 7E56589C6AE; Mon, 7 Oct 2019 21:53:06 +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 522CD10027C3; Mon, 7 Oct 2019 21:53:06 +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 14D8E180B536; Mon, 7 Oct 2019 21:53:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LopAo015138 for ; Mon, 7 Oct 2019 17:50:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id D03755C231; Mon, 7 Oct 2019 21:50:51 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id C345B5C219; Mon, 7 Oct 2019 21:50:44 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:36 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 22/30] security: dac: Restore image label for externalDataStore 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Mon, 07 Oct 2019 21:53:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rename the existing virSecurityDACRestoreImageLabelInt to virSecurityDACRestoreImageLabelSingle, and extend the new ImageLabelInt handle externalDataStore Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_dac.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 6d0c8a9b1c..befa388791 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -954,10 +954,10 @@ virSecurityDACSetImageLabel(virSecurityManagerPtr mgr, =20 =20 static int -virSecurityDACRestoreImageLabelInt(virSecurityManagerPtr mgr, - virDomainDefPtr def, - virStorageSourcePtr src, - bool migrated) +virSecurityDACRestoreImageLabelSingle(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + bool migrated) { virSecurityDACDataPtr priv =3D virSecurityManagerGetPrivateData(mgr); virSecurityLabelDefPtr secdef; @@ -1008,6 +1008,26 @@ virSecurityDACRestoreImageLabelInt(virSecurityManage= rPtr mgr, } =20 =20 +static int +virSecurityDACRestoreImageLabelInt(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + bool migrated) +{ + if (virSecurityDACRestoreImageLabelSingle(mgr, def, src, migrated) < 0) + return -1; + + if (src->externalDataStore && + virSecurityDACRestoreImageLabelSingle(mgr, + def, + src->externalDataStore, + migrated) < 0) + return -1; + + return 0; +} + + static int virSecurityDACRestoreImageLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485238; cv=none; d=zoho.com; s=zohoarc; b=JOtZyfZhmVv1ZZfPiruaX9lIyNf0opPLwxwZR/JL7zSzBKjpVOt5q/lTBNQi1ge/KzMdYKm15bTKwRHcizCaknnMnCVGamN/arl8g0NunKlsGFB5KtHl6twHZRemtmTVsNl6Let+bdTJEnBOmktHuJnKUpdRdVx2UW09Oyv05ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485238; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lS0D2VW3Ix9j54Taj/gTpo7aYNoPvJtAI32XgvlNPA4=; b=TbXNCT7Ns9bDYmDBBHeQTsPECP8tNN8n03suj1mvJYEcBZgpGUot+xX6JnHFFLqLkzIksKzbHXaKrtLzdfviqdHqOs2XwuECrt/xL2Y5MMugqHSsL6TMVsApuB0ZCgHyVgPNr6Vsd51tIq1OaH1k7X0E816Ku42220JU9PNvkBY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 157048523867369.15398255028833; Mon, 7 Oct 2019 14:53:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1123309DEE2; Mon, 7 Oct 2019 21:53: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 B6E226012C; Mon, 7 Oct 2019 21:53: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 7B4C74EEB8; Mon, 7 Oct 2019 21:53:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97Loshu015149 for ; Mon, 7 Oct 2019 17:50:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 64C9D5C231; Mon, 7 Oct 2019 21:50:54 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id E77505C224; Mon, 7 Oct 2019 21:50:51 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:37 -0400 Message-Id: <06d363e9487fc7e7417d1305917c9b20989c4237.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/30] security: dac: break out SetImageLabelRelative 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 07 Oct 2019 21:53:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This will be used for recursing into externalDataStore Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_dac.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index befa388791..326b9b1a3c 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -934,15 +934,16 @@ virSecurityDACSetImageLabelInternal(virSecurityManage= rPtr mgr, =20 =20 static int -virSecurityDACSetImageLabel(virSecurityManagerPtr mgr, - virDomainDefPtr def, - virStorageSourcePtr src, - virSecurityDomainImageLabelFlags flags) +virSecurityDACSetImageLabelRelative(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virStorageSourcePtr parent, + virSecurityDomainImageLabelFlags flags) { virStorageSourcePtr n; =20 for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStore) { - if (virSecurityDACSetImageLabelInternal(mgr, def, n, src) < 0) + if (virSecurityDACSetImageLabelInternal(mgr, def, n, parent) < 0) return -1; =20 if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) @@ -952,6 +953,14 @@ virSecurityDACSetImageLabel(virSecurityManagerPtr mgr, return 0; } =20 +static int +virSecurityDACSetImageLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virSecurityDomainImageLabelFlags flags) +{ + return virSecurityDACSetImageLabelRelative(mgr, def, src, src, flags); +} =20 static int virSecurityDACRestoreImageLabelSingle(virSecurityManagerPtr mgr, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485515; cv=none; d=zoho.com; s=zohoarc; b=LElJg7JBd1uLxViZKbUBPm0e27vmOxlHGtk+u1UQ3c9sFjvB5BFmKPkRu6ugXjPKF+SLE8vKEuqV0QhM0GOhAdMpWHvANQ8fISKKeDl7NWcuSODEV//nMfmUYCLmMshtQ1Qlrds1uf+FOqW3n2GM342Q7LJ0MBZtaRUPXn1KlkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485515; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=0X48Fst6Y+m7zz9JriavALw3y9RJkGk65jT/gidieoA=; b=QCZQU1S16WDPlKdG+Zr5g8khzqFOQ0odsfL6cy+pFAeL3AbuMl+s1uGsAcolDQmHtZH33ywEqs53qwr3PU2zU6D3f+sdA9AdZ4El6ACPOCnsAm6/84XtLpM5UNCUHJGVFy1vngwLiYWF3zEptplOwU7UyEti5esf5HC8TntCYFw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485515831520.9491753790431; Mon, 7 Oct 2019 14:58:35 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F0F2964457; Mon, 7 Oct 2019 21:58:33 +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 95FC360A35; Mon, 7 Oct 2019 21:58:33 +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 032284EE97; Mon, 7 Oct 2019 21:58:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LosuW015155 for ; Mon, 7 Oct 2019 17:50:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id F03125C224; Mon, 7 Oct 2019 21:50:54 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 933CB5C1D4; Mon, 7 Oct 2019 21:50:54 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:38 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 24/30] security: dac: Label externalDataStore 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 07 Oct 2019 21:58:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We mirror the labeling strategy that was used for its sibling image Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_dac.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 326b9b1a3c..2bbf773dd3 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -882,7 +882,7 @@ virSecurityDACSetImageLabelInternal(virSecurityManagerP= tr mgr, virSecurityDeviceLabelDefPtr parent_seclabel =3D NULL; virSecurityDACDataPtr priv =3D virSecurityManagerGetPrivateData(mgr); bool remember; - bool is_toplevel =3D parent =3D=3D src; + bool is_toplevel =3D parent =3D=3D src || parent->externalDataStore = =3D=3D src; uid_t user; gid_t group; =20 @@ -946,6 +946,14 @@ virSecurityDACSetImageLabelRelative(virSecurityManager= Ptr mgr, if (virSecurityDACSetImageLabelInternal(mgr, def, n, parent) < 0) return -1; =20 + if (n->externalDataStore && + virSecurityDACSetImageLabelRelative(mgr, + def, + n->externalDataStore, + parent, + flags) < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485524; cv=none; d=zoho.com; s=zohoarc; b=KxQfWNZaQKZhGgbgQPfqUmgY9DeHgfMpFDq21pXVKgPsRYplH/ukPZ/cHW93uMRbUFrWJ2wV8QKBy7QfJsVjdYY47aPhoO+c1iZEq0Z9NMPUg4v7ttfUXHKsbUVitr8ghSDVACNI0fa3/eGq1kdHgJt9C0dIfEgd3K5akIqxHEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485524; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=loO52K808zflaD8P7fdR5q5/eHC3XV6ktq3KksMrgMU=; b=jT6ZCUGpT9UZbbNq9i5+XGcY+oLl2dlgAaNO1JuAuoDHrZlEPp5n/73VNA3VapQprEcydpE3NA1T/u6OKVzuX1tQyWYq07Dlp6/KU4v0MPszO1RhdHdaI8ktWc2iS7lukdfDQI9rR6IpJpN3eBD6KkHHGePyEE0ehmW2ssQNzY8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485524487604.4249738241135; Mon, 7 Oct 2019 14:58:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC45E18C8922; Mon, 7 Oct 2019 21:58:42 +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 57F7460BF4; Mon, 7 Oct 2019 21:58:42 +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 180E24EEB8; Mon, 7 Oct 2019 21:58:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97Loto2015161 for ; Mon, 7 Oct 2019 17:50:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 858E15C224; Mon, 7 Oct 2019 21:50:55 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29ADF5C1D4; Mon, 7 Oct 2019 21:50:55 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:39 -0400 Message-Id: <0223a7618af9936a4db511d4ede7492a2313f905.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 25/30] security: selinux: Simplify SetImageLabelInternal 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Mon, 07 Oct 2019 21:58:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" All the SetFileCon calls only differ by the label they pass in. Rework the conditionals to track what label we need, and use a single SetFileCon call Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_selinux.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index e879fa39ab..9d28bc5773 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1822,6 +1822,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityMa= nagerPtr mgr, virSecurityLabelDefPtr secdef; virSecurityDeviceLabelDefPtr disk_seclabel; virSecurityDeviceLabelDefPtr parent_seclabel =3D NULL; + char *use_label =3D NULL; bool remember; int ret; =20 @@ -1856,40 +1857,28 @@ virSecuritySELinuxSetImageLabelInternal(virSecurity= ManagerPtr mgr, if (!disk_seclabel->relabel) return 0; =20 - ret =3D virSecuritySELinuxSetFilecon(mgr, src->path, - disk_seclabel->label, remember); + use_label =3D disk_seclabel->label; } else if (parent_seclabel && (!parent_seclabel->relabel || parent_sec= label->label)) { if (!parent_seclabel->relabel) return 0; =20 - ret =3D virSecuritySELinuxSetFilecon(mgr, src->path, - parent_seclabel->label, remembe= r); + use_label =3D parent_seclabel->label; } else if (!parent || parent =3D=3D src) { if (src->shared) { - ret =3D virSecuritySELinuxSetFilecon(mgr, - src->path, - data->file_context, - remember); + use_label =3D data->file_context; } else if (src->readonly) { - ret =3D virSecuritySELinuxSetFilecon(mgr, - src->path, - data->content_context, - remember); + use_label =3D data->content_context; } else if (secdef->imagelabel) { - ret =3D virSecuritySELinuxSetFilecon(mgr, - src->path, - secdef->imagelabel, - remember); + use_label =3D secdef->imagelabel; } else { - ret =3D 0; + return 0; } } else { - ret =3D virSecuritySELinuxSetFilecon(mgr, - src->path, - data->content_context, - remember); + use_label =3D data->content_context; } =20 + ret =3D virSecuritySELinuxSetFilecon(mgr, src->path, use_label, rememb= er); + if (ret =3D=3D 1 && !disk_seclabel) { /* If we failed to set a label, but virt_use_nfs let us * proceed anyway, then we don't need to relabel later. */ --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485241; cv=none; d=zoho.com; s=zohoarc; b=EN4E3vjDptFhMDUf2z4oMj7y8biv2MMxORj2ly4VBtPkk1RQnl4qKNf23U95acfuv4eVKWoH9JDmwBbJWxlH7u1+j1vcLsvYCiKwmfUnB+IW3dIsSblajTN5kRE3g9l/85rUoxoyISBpFqOO2DVuG3nFd0VCMWgMC1GsyRcH69I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485241; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yrAsWrbf1XxuKHcdnldGVb/y5JxxZiUoTFBeKbAzqcA=; b=jwDCYZ3si8esAMUt7yEZDywq+LVKMK0uUbE+MzWlwkhrXmkYFfUXIsQqAO5AZYCqtpA5cFZN+/IrSkntZm1AoagKwppb/DThwBgm/c0uKczT0L4uyr4ABxEjNdU83yu5oGJD2J3bGJOJDjzg+vhVEYP0f4X3HdoiLf/c6S/HsOQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485241733766.2380014042963; Mon, 7 Oct 2019 14:54:01 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 31D24811DE; Mon, 7 Oct 2019 21:54: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 07A265B681; Mon, 7 Oct 2019 21:54: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 C2EEB1803518; Mon, 7 Oct 2019 21:53:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LouIR015169 for ; Mon, 7 Oct 2019 17:50:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CE3A5C231; Mon, 7 Oct 2019 21:50:56 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2A2D5C1D4; Mon, 7 Oct 2019 21:50:55 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:40 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 26/30] security: selinux: Drop !parent handling in SetImageLabelInternal 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Oct 2019 21:54:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The only caller always passes in a non-null parent Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_selinux.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 9d28bc5773..e384542c49 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1849,9 +1849,8 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityMa= nagerPtr mgr, =20 disk_seclabel =3D virStorageSourceGetSecurityLabelDef(src, SECURITY_SELINUX_N= AME); - if (parent) - parent_seclabel =3D virStorageSourceGetSecurityLabelDef(parent, - SECURITY_SEL= INUX_NAME); + parent_seclabel =3D virStorageSourceGetSecurityLabelDef(parent, + SECURITY_SELINUX= _NAME); =20 if (disk_seclabel && (!disk_seclabel->relabel || disk_seclabel->label)= ) { if (!disk_seclabel->relabel) @@ -1863,7 +1862,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityMa= nagerPtr mgr, return 0; =20 use_label =3D parent_seclabel->label; - } else if (!parent || parent =3D=3D src) { + } else if (parent =3D=3D src) { if (src->shared) { use_label =3D data->file_context; } else if (src->readonly) { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485527; cv=none; d=zoho.com; s=zohoarc; b=RLw9dnjBqRZ/neDN88K999+uSxyZDmEjr7K35P7Hrq/ChnBSaSu0a7oGH79jhYl+yNbJ1pwRj1h+DyNDurrxd4cmRPElfmvr5a1c2kftoYGi1SfG8eMELkW3xWeoKhybqx05pVfvmn+3/sf/5tRUvlD1kejmMejBgIFtXBcl/KE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485527; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=i46mNjIrBFYKACNkG2hSW0WezITiHDY/noOqStY/qQg=; b=C1pcKjS9IWwzdbw4F+tAkkdCTRQ9Eob2VKEdSOeQh9sk8WFeVqLNaJNi9aLKHJqTj8ZPq8kNA1qDNmdmZ9o4As2QlhkZ589zv3+tbicsxO6FDEf8U2R4CbtzuT3NREd36Uqgag8hXjo3pPamOI8L9Msa5VI5XHrdGp/uVIlsqlc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485527789478.72781161012585; Mon, 7 Oct 2019 14:58:47 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 184C03B58C; Mon, 7 Oct 2019 21:58:46 +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 C75535DC1E; Mon, 7 Oct 2019 21:58:45 +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 874D41803518; Mon, 7 Oct 2019 21:58:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97Lou8B015181 for ; Mon, 7 Oct 2019 17:50:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id A56325C231; Mon, 7 Oct 2019 21:50:56 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 489F15C1D4; Mon, 7 Oct 2019 21:50:56 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:41 -0400 Message-Id: <726ba82b9504505face29a83451f27a046635bcd.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 27/30] security: selinux: Add is_toplevel to SetImageLabelInternal 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 07 Oct 2019 21:58:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This will simplify future patches and make the logic easier to follow Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_selinux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index e384542c49..fd7dd080c1 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1824,6 +1824,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityMa= nagerPtr mgr, virSecurityDeviceLabelDefPtr parent_seclabel =3D NULL; char *use_label =3D NULL; bool remember; + bool is_toplevel =3D parent =3D=3D src; int ret; =20 if (!src->path || !virStorageSourceIsLocalStorage(src)) @@ -1845,7 +1846,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityMa= nagerPtr mgr, * but the top layer, or read only image, or disk explicitly * marked as shared. */ - remember =3D src =3D=3D parent && !src->readonly && !src->shared; + remember =3D is_toplevel && !src->readonly && !src->shared; =20 disk_seclabel =3D virStorageSourceGetSecurityLabelDef(src, SECURITY_SELINUX_N= AME); @@ -1862,7 +1863,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityMa= nagerPtr mgr, return 0; =20 use_label =3D parent_seclabel->label; - } else if (parent =3D=3D src) { + } else if (is_toplevel) { if (src->shared) { use_label =3D data->file_context; } else if (src->readonly) { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485530; cv=none; d=zoho.com; s=zohoarc; b=TkMP0/JDRhFayLAhvZuLc4WTKnmh/3BmzjGdHhF4i9u8nt2QYnif/Eva2ZF2FgyyucOqJXBD8uzypmSdyG7Jo0NIs+18n2PGPeLh/4oMs1Jt2lYqhUhWIxx6Ar4AppC2ff0KR8VO3iPmIp5+dhxLmDPv9yN9CxwYCT8648dogls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485530; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jJK2skjo1YdlDYOa3A8T4jZD8Cm5XBBLnG7sOyUfMp4=; b=ilc3L6DniUdDFBPSp3MBF0z6PfKifxzhyPZ4GReLk9TJIHJ8TuBFPaakNNEH9Dj4DxqEqfUYX+IIQJtE5QJRSJ67yISxgh0/F1bMEK7GxQR5hnr30CNqhENcQ3p+PoxBF30XiZ0nJHJjmr+SjAPH0o7Mi9wK/IGZ8hCRnBMiYCI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485530784543.70973010175; Mon, 7 Oct 2019 14:58:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 268BD81F2F; Mon, 7 Oct 2019 21:58:49 +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 F065F60C05; Mon, 7 Oct 2019 21:58:48 +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 A5F464EE97; Mon, 7 Oct 2019 21:58:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97LovUb015186 for ; Mon, 7 Oct 2019 17:50:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3C67E5C231; Mon, 7 Oct 2019 21:50:57 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id D32545C1D4; Mon, 7 Oct 2019 21:50:56 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:42 -0400 Message-Id: <5e3bee35fbc3bd400f062f0ec6179dd02309db65.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 28/30] security: selinux: Restore image label for externalDataStore 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Oct 2019 21:58:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Rename the existing virSecuritySELinuxRestoreImageLabelInt to virSecuritySELinuxRestoreImageLabelSingle, and extend the new ImageLabelInt handle externalDataStore Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_selinux.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index fd7dd080c1..c0bfb581e3 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1747,10 +1747,10 @@ virSecuritySELinuxRestoreTPMFileLabelInt(virSecurit= yManagerPtr mgr, =20 =20 static int -virSecuritySELinuxRestoreImageLabelInt(virSecurityManagerPtr mgr, - virDomainDefPtr def, - virStorageSourcePtr src, - bool migrated) +virSecuritySELinuxRestoreImageLabelSingle(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + bool migrated) { virSecurityLabelDefPtr seclabel; virSecurityDeviceLabelDefPtr disk_seclabel; @@ -1802,6 +1802,26 @@ virSecuritySELinuxRestoreImageLabelInt(virSecurityMa= nagerPtr mgr, } =20 =20 +static int +virSecuritySELinuxRestoreImageLabelInt(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + bool migrated) +{ + if (virSecuritySELinuxRestoreImageLabelSingle(mgr, def, src, migrated)= < 0) + return -1; + + if (src->externalDataStore && + virSecuritySELinuxRestoreImageLabelSingle(mgr, + def, + src->externalDataStore, + migrated) < 0) + return -1; + + return 0; +} + + static int virSecuritySELinuxRestoreImageLabel(virSecurityManagerPtr mgr, virDomainDefPtr def, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485534; cv=none; d=zoho.com; s=zohoarc; b=MUQPNoWRIUOPkIIqSBaA5C6G1peAnorM9jcIk+u88LKH+CLFE6eVygicyC5jCoKK74CM1O2cMFwIxEKLxM3qLDB2K500ailbKLUS7t8maZW60yOQtNfSWUKKDs6wWTv8efJkkfamDXZwcfAgk5399JKAz7v7APw0RKgQEY7nG2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485534; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ldf0gZ9i5zBrJXYGqKNWCRh3osG8wq5WOqaLBq5oCjs=; b=GwSfa3IFRl4EQ13ZLE/QSZll+wq7D+4+QaHE1TS17N7rU1h0gUSjA8cCcJbFxyU9YL6N36jC1PmQU6D0N8VugS0WljdCUtk24aIOo3dR3UsH2XunxMF9qDykSSIG/oCsNhodZNw03SQKh8gkCatSt/cBn/mAzSbypgVJ/KZPquQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 157048553412881.77768265932195; Mon, 7 Oct 2019 14:58:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F24210CC1EE; Mon, 7 Oct 2019 21:58:52 +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 696336012D; Mon, 7 Oct 2019 21:58:52 +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 2D3FF1803518; Mon, 7 Oct 2019 21:58:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97Lovbo015192 for ; Mon, 7 Oct 2019 17:50:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id C626E5C224; Mon, 7 Oct 2019 21:50:57 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 690005C1D4; Mon, 7 Oct 2019 21:50:57 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:43 -0400 Message-Id: <576bd3d5f50ab3cfec37d21e1e9729258838ec7d.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 29/30] security: selinux: break out SetImageLabelRelative 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Mon, 07 Oct 2019 21:58:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This will be used for recursing into externalDataStore Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_selinux.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index c0bfb581e3..feb703d325 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1919,15 +1919,16 @@ virSecuritySELinuxSetImageLabelInternal(virSecurity= ManagerPtr mgr, =20 =20 static int -virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr, - virDomainDefPtr def, - virStorageSourcePtr src, - virSecurityDomainImageLabelFlags flags) +virSecuritySELinuxSetImageLabelRelative(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virStorageSourcePtr parent, + virSecurityDomainImageLabelFlags f= lags) { virStorageSourcePtr n; =20 for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStore) { - if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, src) < 0) + if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, parent) <= 0) return -1; =20 if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) @@ -1938,6 +1939,15 @@ virSecuritySELinuxSetImageLabel(virSecurityManagerPt= r mgr, } =20 =20 +static int +virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virSecurityDomainImageLabelFlags flags) +{ + return virSecuritySELinuxSetImageLabelRelative(mgr, def, src, src, fla= gs); +} + struct virSecuritySELinuxMoveImageMetadataData { virSecurityManagerPtr mgr; const char *src; --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 11:58:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570485245; cv=none; d=zoho.com; s=zohoarc; b=DAsFRADuAJ8A1vKwTvosFRbJIBfCA5KF7oNjVzil8KcBav2Va7cH4n1gZPvrza3r51xLo4Eo8Psocf4xKTjd1Dytdr3lkgYhe1PhxpiGQep3exN6pv8jAx6R+KKpVXhmV5CsTI06qV/ob+MoZNlEWBkpzuAwydLqCtJGCO3UWNg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570485245; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XWa8XCwRus3mwFZX4aCMB+TG0mALjkaMthCPqznMddo=; b=hl7bOjjF8Lt16vR5Nb2O9TZHt4FFSook4287wPbmvpRh+N348pFQSk8TOJ7N+q+VeXmRUW8uMEorshAS7/N5+O9TW0lmVxSCIa0Ce71uumgluqs0IfW8SAn6uWYTY9AJ908ZdowG0cPw7tRAKiHc9cxGm42uFn3cN7EuLFmbHfs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570485245394500.2266533642389; Mon, 7 Oct 2019 14:54:05 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id AFB136696C; Mon, 7 Oct 2019 21:54:03 +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 83B6D1001DD8; Mon, 7 Oct 2019 21:54:03 +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 3B1FB1803B4D; Mon, 7 Oct 2019 21:54:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x97Low5m015197 for ; Mon, 7 Oct 2019 17:50:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 621265C231; Mon, 7 Oct 2019 21:50:58 +0000 (UTC) Received: from worklaptop.redhat.com (ovpn-123-156.rdu2.redhat.com [10.10.123.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id 019C25C1D4; Mon, 7 Oct 2019 21:50:57 +0000 (UTC) From: Cole Robinson To: libvir-list@redhat.com Date: Mon, 7 Oct 2019 17:49:44 -0400 Message-Id: <94b8d03253117e2155925f69743cafca7e00d321.1570482718.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 30/30] security: selinux: Label externalDataStore 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: , Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 07 Oct 2019 21:54:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We mirror the labeling strategy that was used for its top image Signed-off-by: Cole Robinson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/security/security_selinux.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index feb703d325..2a3b7fc10d 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1844,7 +1844,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityMa= nagerPtr mgr, virSecurityDeviceLabelDefPtr parent_seclabel =3D NULL; char *use_label =3D NULL; bool remember; - bool is_toplevel =3D parent =3D=3D src; + bool is_toplevel =3D parent =3D=3D src || parent->externalDataStore = =3D=3D src; int ret; =20 if (!src->path || !virStorageSourceIsLocalStorage(src)) @@ -1931,6 +1931,14 @@ virSecuritySELinuxSetImageLabelRelative(virSecurityM= anagerPtr mgr, if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, parent) <= 0) return -1; =20 + if (n->externalDataStore && + virSecuritySELinuxSetImageLabelRelative(mgr, + def, + n->externalDataStore, + parent, + flags) < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list