From patchwork Mon Oct 7 21:49:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175418 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845796ill; Mon, 7 Oct 2019 14:49:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjI01D9yXH06oIscI6iJJ4/uBBUxEsLkdjWnUPE/MkigjqqsYTu+fghSuYIplKpTfC2vwA X-Received: by 2002:a92:b684:: with SMTP id m4mr30925477ill.181.1570484978146; Mon, 07 Oct 2019 14:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484978; cv=none; d=google.com; s=arc-20160816; b=vUl9n2f09p+RlZWiHFAjMqEc2+PuDm7alHQkBcLDMTXKpyNeeYlta2IpDoth3Dcn21 B1KUMdlj0u5uLJCuWiwveqoGw8Ug/7VcKixLRIeSe82xraRIxLMyKjKF+k/bilqmQgWS aZ/ad/en55LWxskZ0g3IYuGLSmdCXSjte4wVlG+t1HaI31ctth7WnFYiQyqyMMH/Pydr E9TBkUEOSiNZnN+JWofH1JrnvZhyYCjz41T8Y5SDWTI8NW3y1EuzxGmTrcUqPTozDeBz 09f0cynvK/WPte+Efkvn9X+xkjmzBpefOhtzGpujhbOn1H/csJM+R+rwVPQSdZGrqJe6 IDQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=7ts8cqzcvDPehDS++7zhERPB43EKIsUt7lYTiYUZ6nQ=; b=v3v2ShZvod30s41mAFTXh4abHOvbdhWynl2RVhZoApLhwKHuSEP6KZbc3aZhnUq3tn zdxeyGIvfcANGD49xLMW6JbFaAOoPDlTYXQ8ZCEVlVbbi7RgUjAoIf0VR08pWaT5JK/F mc/j+dKWiBTW4qpfzsTGZ1KoNUCLtywh+li1Z8Jj6HK/SzCR8CaiCRk1E+fDHoJs9O8J 82yehuQPjgvyzUdY5OyZJ6NFmRE2jKglCQI/3MR4rPbvV3bkaE5xeYqKQPiYTbvkqtEl Vo/VxZ9YNRX/+E5VVntiBu0YWtR+vv5BuPUo4b2Wv8BKN37pGv/frnVSk2RrVARwEjXe Zs+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id q7si17955126ioi.39.2019.10.07.14.49.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:38 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) It is only used in virstoragefile.c Signed-off-by: Cole Robinson --- src/libvirt_private.syms | 1 - src/util/virstoragefile.c | 2 +- src/util/virstoragefile.h | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 FileEncryptionInfo *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 { int virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid); -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, From patchwork Mon Oct 7 21:49:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175413 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845656ill; Mon, 7 Oct 2019 14:49:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVc5cpn7mjc0AntYzDRy6V6ptmRZ5/Ufj7Wl05Lxi3g6r3WU3ZByGeVXSccF26GQ6qG8vD X-Received: by 2002:a02:7113:: with SMTP id n19mr28419865jac.82.1570484968236; Mon, 07 Oct 2019 14:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484968; cv=none; d=google.com; s=arc-20160816; b=UNQ6LivxwPup+tFnbqUWLUQXmY+kuF3B9WLW1TozTvZ6a8ynYfFyNxFGEjjdBwpnzH 2f2mZUJpf3IpOHHQHv7pOkcV1TFv/iPhgGcVCYLsnQXbFUc+9HHy0aUPuJJRWHohhnvY qWVV/rq1HNVCpHGB/vapOAEmPFMiGF5qzC1IExdpuo2rOM4BnWuhUhPK6zT1d1FmZzX0 VUwod8oqi60i2UEvm+lq6d9jtjD1uCwyN62W7ebfVE3MADH8xKqWqgu7OKvAF3bb8zce U6A1EdNBtoo8zt54l4BK0w/AtRdVuAdxthIasv/yL3acn2ywK3JQPgDPEVtfl5w0Y/V4 Z4yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=cL130Jc0gPyOA1itsk7pXvvLN8eIyhVL1Gx6MfHFImo=; b=BHYEoELbCmcpQSBsTuWLx4FGihc4h5kWXQV0miPzFNQAnh6GBUIgr1qqqHBvkdUUdS BYWDikw72Bu9UTz49wu/+02OjrZ0aRslNU4e87EJ6eSP1FwkTkoSMNdG/FyGcTmQ1Tbe zy7tYdKXnQihEviKJln7Z7OBipPluMj7nGcEyqcMWxQod+em7H7CiPmb6JDKNXSKeJUD w+0tfONqS+2BT7HcbxNRsZGrqr9CMz0fKrBW+F7WfGuQj8cMyMZ0WrDE49VCBB2YXEEY bDJ3RndajN6qbbEOoyIbpT0X288CbSTX1Ir6Q8aN9DiPe80MRLZt0XMQkIVmoOpHOGjh WJ4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id o73si22284914jao.101.2019.10.07.14.49.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Check explicitly for BACKING_STORE_OK and not its 0 value Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 = VIR_STORAGE_FILE_AUTO; ret = qcowXGetBackingStore(res, NULL, buf, buf_size, false); - if (ret == 0 && *buf == '\0') + if (ret == BACKING_STORE_OK && *buf == '\0') *format = VIR_STORAGE_FILE_NONE; return ret; } From patchwork Mon Oct 7 21:49:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175416 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845785ill; Mon, 7 Oct 2019 14:49:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkvNuJByrGp3joxnbOSix0FtjhEY4iWh1w6a5bmY+DqJoKPFfI3et0fM/UU0d9f0Lwv8Uw X-Received: by 2002:a6b:8e92:: with SMTP id q140mr26548251iod.205.1570484977099; Mon, 07 Oct 2019 14:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484977; cv=none; d=google.com; s=arc-20160816; b=ZPZvEecf/tysS+BmSxNUfEw+hInsPk8Tg/o0ZoNAdXuevMuwQAR5/dOQYneLzfIE2o 5jMPoj3iBKg+S3ukncB3W2Q2oc6Fv1pk0Kk/pDCAkqyHF2Ez9/SMZWook07K9SnOsQeA OM/RuS9NNfrDk2Fpt0PdkZxhswWgdZP50oGD/ixxCKnQ0TYJHfAgjR0SrKcrVVpT2rTN bZE6dt1dpWWDf7LaLPE0nDHP9mSGtYUfYp/KaiMnuBMLREJbVyEDkols+2BkbmUthf12 O/kQlUPjaCbOENtfBfOHf79ikUJOMsYyNZVP5DBjLomxdd/MM8D0ZZek+DdUj4sYg+Ej AO2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=wSFofZ0ACqVXSiFp8wCl2F/P87ioVhl58AmY0kmYSbA=; b=SQJaedl3gPEhBhKlzEnOyG0QE5ujiCt21urQ41JEsc/jKtFBJsIPt1OHdr3DmSILNT 4U5MXi1flqvFXJHztfK0Q+eTVPGmUJlMIZmsrpNy/opGvppqjftB7IHdMinavE5QUVu6 QqjhmS2RHDi3SVWQgLddHNOmR/x9oQkMeMzSONNYTLcnDnLwnG0La484MESw4EKXBqaW 95JBiHUIDY4+RUK4vY9FklHQ0rOvDGJu/gmp30NxhgiIs1BkO3SNIqee/2P/VgLiLcfx 9rHJNt6JYuiRQBUjMdSDFKCeyq3PiFGG9vfl3OF+t9NbF9sS9FWFJsV2ur8nLDuNB0BC 7Big== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l1si18047631ilo.147.2019.10.07.14.49.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:37 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) >From f772b3d91fd the intention of this code seems to be to set format=NONE 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 --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 = VIR_STORAGE_FILE_AUTO; ret = qcowXGetBackingStore(res, NULL, buf, buf_size, false); - if (ret == BACKING_STORE_OK && *buf == '\0') + if (ret == BACKING_STORE_OK && !*res) *format = VIR_STORAGE_FILE_NONE; return ret; } From patchwork Mon Oct 7 21:49:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175420 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845837ill; Mon, 7 Oct 2019 14:49:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZEXBB+ANIxFDQqqMS0mmGLoKYFg95lgosyfkP03e2S193I8dsZIVArw+Da5VEZq68ZsPv X-Received: by 2002:a92:3314:: with SMTP id a20mr30700048ilf.276.1570484981542; Mon, 07 Oct 2019 14:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484981; cv=none; d=google.com; s=arc-20160816; b=kMiZAzcc7rywvOD6A6qDnwUIGPqBFMFVMBx/Av5b44TqFt1vDSB+wVwJR2yFA4caXa oy2AOJL6FO52Vn/TtXqpNARYj62kuRkg9IC9yKzip/MEFv+CzrJ0hR+SraA8Othhansj erxuYEE/PvOIEc54kcYor6bfPcylPd43Fm5F3xWD1lko2gtI1+tCKg83zY5Jm4OyWR0r LiOFHT6QyOXDPAdovWd2+5Mq3V2P8zH+FJzH6NauGJaC8bm172DjE0hYJopn4uBekUXz JwBcFOqDVrkH/RZLUQJEyWX5ZH0tdy8cwPUpsenELrlLkH8x1dM3W/txnjTh4MRzErvf uoQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=HRCVMCZIT1Bc69Lneq5240E70lCr2QFF9swB2o7p9GM=; b=foNVxVoGCvJX0NwvMbep8PluwZShGHkwlFVehkIo3F6cdxxAgBL3r/1StYCoPKmKgN EzxhqUY7e1kUTpQ2uOd+pPAMTuMU+XnYevt/m7ZMskmBNJkMwFJ1zqacyS1tfqeJgGaR qTmoDRYVLQBbDCdi7YuhmPhVqhr5VxCmugFJzTSyGEFxXvjG0ZQM1HLsObIbjdl5fFdp I3Ts00LnHsW1h9PmUgVSuWQJbD/5qNNm4Sce8K0Sfyx6+ZRbenj1ya1VnogmMwB77M5L c7zKfA6rqghjcKLs7AN7y643XwJ9bhwg6CZY+f8NJjmSm9PSO5bgm6/H4JcP9RK6GAAV A6GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id z95si20300382jah.67.2019.10.07.14.49.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:41 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Letting qcowXGetBackingStore fill in format gives the same behavior we were opencoding in qcow1GetBackingStore Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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; *res = NULL; - if (format) - *format = VIR_STORAGE_FILE_AUTO; + *format = VIR_STORAGE_FILE_AUTO; 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; if (offset == 0) { - if (format) - *format = VIR_STORAGE_FILE_NONE; + *format = VIR_STORAGE_FILE_NONE; return BACKING_STORE_OK; } size = virReadBufInt32BE(buf + QCOWX_HDR_BACKING_FILE_SIZE); if (size == 0) { - if (format) - *format = VIR_STORAGE_FILE_NONE; + *format = 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 = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); if (version == 2) start = 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 = VIR_STORAGE_FILE_AUTO; - ret = qcowXGetBackingStore(res, NULL, buf, buf_size, false); - if (ret == BACKING_STORE_OK && !*res) - *format = VIR_STORAGE_FILE_NONE; - return ret; + return qcowXGetBackingStore(res, format, buf, buf_size, false); } static int From patchwork Mon Oct 7 21:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175414 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845664ill; Mon, 7 Oct 2019 14:49:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH3f2nV5XBJygl7fZpxtoiQvYa8aDdhkoV4seOIZI+4hImC0XBmAT86q7SqDqESlMVFlf4 X-Received: by 2002:a6b:b2d0:: with SMTP id b199mr1579540iof.159.1570484968416; Mon, 07 Oct 2019 14:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484968; cv=none; d=google.com; s=arc-20160816; b=LSWJXR0AOPYfqoGk5w+Tmw8Jf3XQKbmc8IEaBHlcN4w+oAgRYzkZO64e5yzx4/HpIN l7G50oeKfkzOdLwF0R/Fjvbnnts7tDm2J7anyQYV/z9HVlM4vazq2HdC/Y4afvkiBpLU ulXn13e/EblWfH1W+TLUB+/LeJKy/C99zo94bDEHsiuOKyEo9BDIavKpFEK8rO3i3QrR lCQizFKIdO06wzg65K2B7ITEWiFIxHsOnfsn1dM4cHinAtQBAlG3XuTyAmF+JoQSIPJP /BCeOhgoOMBBy4XAufItECecFoNSFpYtJn8qnuf7DvLyKzCa9TRpYuxyAiJ/QmMiXG2y S6mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=Er7dLCQZnHUE3ARe80J8CoLvCLvKRgQaPRwdOUpajZw=; b=vHR+c72osWPrLLbEagJMZ++MR/EpJUlMDWaFC24aj2+EUaVik0AI+amR+EiBMzL1PG 09YimIbYV5yeZDCyDQxjHvIIFHynY0NHdSWk/b0UNpWc9NHyp8p8eXNF6eHCzLh9EaDT U7rpFI+n9sCJ2OOhlDoNZv/JydNMQTeMcKsiVnpOF38ZiDAwlk0xD2eDFjRRsy6T1pq4 2XAMkqN6p+sKyzonTN6ykqoYGfnbo+E6qijwcphFpQiZkipbQcjKiuPMrTvUEVmC4q03 qngGaVW0gHarxDJPuNPzSML35GaRoq4ltajDPwr7S6rp5XwtCWkBaaQYe/Q4YbjZVSDP 8QcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id t4si17471568ilg.101.2019.10.07.14.49.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Rather than require a boolean to be passed in Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); + + version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); + if (version >= 2) { + /* QCow1 doesn't have the extensions capability + * used to store backing format */ if (version == 2) start = 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); } From patchwork Mon Oct 7 21:49:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175423 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845883ill; Mon, 7 Oct 2019 14:49:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpMG97kFa0Fve/BNj59GeG3PsGvI4ri6C41I7JM2SCbZAn4DMqyWkKDoRXK0rEi+Rp8Mt4 X-Received: by 2002:a6b:3a43:: with SMTP id h64mr24105879ioa.89.1570484985046; Mon, 07 Oct 2019 14:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484985; cv=none; d=google.com; s=arc-20160816; b=Ux5h9hdlid6hnQPaj3JApvBIRQTkVSYjP2RAPIvk+jvadr4Wc20XM4tqqQCJo5nDMK /Rm89g+jkHGtrZ/QfYSwWVd8r6rQe+YsVCWR/ATcVUyz659fMgiG/GduEe2Fi2mVwH9A /1H27EEQig2iq47u/L4/chB34NRT7qzqCsSE4x17jmUZLf2dNkCph7lcu83OWY7rgqSd +ueHiPgbaupJTWCMJnu3Hkt8tHB5iGqtShNK0meSNa+JaXkFzKtXgQD4KCKZRylexLyX 0Vo9W5KZXB7NluEO6kBook1/BNyIWhe5WPs/nzIu4hIb8K3njKJHb3KY2/f0qv3BMdee 6Yvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=ayS8Vwl+OPKTFfvVQYsBcpOmyBIl2+IE1swBiDhgXvM=; b=kjgHnBfJnVGGW9TO4izWSaov6a8pv/de/78i9QtPAHOPNrhHjOXOnKtZYAdBgj6zJI PNxQEfs9M97SDt3O3WO00ugfXcHz1Z2aXZ9SQHk3p1+S+fOP9Lz6WGEd2hqSFWO6I7p9 hHhwkiMo2z5QQM3sYFuJYb4cIjzTJxOdlxfo3mmgizYB8xlU5I/ckCc1mlIAY6lVTHGX 1mS/uzGFGAShVxuUQK3ojWhQOp76QD6xBT8pOpBmBTYcY0XE0xfZCEZjI3ocupPaXFmn EQyQuhiSJf1DyE1D2XVsnFr//lNDAF2ZHhljdvA6/MwMG+YOxZUBIhTrZl70R8cKyCky JWhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id m36si19549185jac.94.2019.10.07.14.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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); } 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); } From patchwork Mon Oct 7 21:49:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175424 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845941ill; Mon, 7 Oct 2019 14:49:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1AXNoodrgywmUJ17bQ1OAQEW7guANNlIdgQjeFempx1M9fN/93rQhGN316vHzKNM3iW/f X-Received: by 2002:a92:d20e:: with SMTP id y14mr32528970ily.230.1570484989792; Mon, 07 Oct 2019 14:49:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484989; cv=none; d=google.com; s=arc-20160816; b=Qf4UqhIpfMa0jFwEUyJq6zCaq0HsWvgZpSIkZLNKgVJzO0mVvEF07Uf/60VRsWBBYx rAGgs83vQS7GazjhCbge4VfmWtpqp2mOwOcMv8oXgKKQSNUZT+VmgMW1kqYSbQCQCetk HijFEwSGkwAEQw5wSw6aJB0+3jw9rmXZRm/ZJnann1UCf60VWDNzO14sd5+9H3LuqndD X75Bk08EBVnJnkMvnQd5nZE56qWTd51bVUAfU5JuSuhvBhA2KscEAX1ElwQIqwI7QjQS /UP50JVrcoywISE4eD5BdKsjULElkODv37NbZ1uiywTrzNyyRP21j67U9Sva6Z5r9bTS 7n4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=2s2KKWOOpoje/szkXhm5hdVYxfRXFp7WhPj4pWxV6Fc=; b=fAI2DV8MJZPf3PuTzUGE/OM+/T+ZKPcwP4vshKjhDGPDAy4LiewTbuTWAZhcYZuQZq ylNN260SsklYLKcz/xNn/nPUMlwlyOpqcBNdRtNbdG6jg1X2BADZESrwHb37LdkTlzNF I13a8yoLL3BEmrJ3bWwJyJe4HvjD4vNtFfd2Gp44+Gvn/Dp9j3UzSJBPv4etIZCtlDdk tOg86YeSrGs2Mtd/3xtBn1h6LXNS+9SUpQlHjYyr6gAIiNc3Za/VO42LMc0WVe0LDBKx SOcYbZrA/S8WV7WaHp0YfQqzPIKE2z6hKmmjn/vdn1Mmk84HlimHhFdnL19paEfhFnvu d38g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id x21si18208160ill.127.2019.10.07.14.49.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:49 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) The qcow1 and qcow2 variants are identical, so remove the wrappers Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 { 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[] = { LV_BIG_ENDIAN, 4, 4, {1}, QCOWX_HDR_IMAGE_SIZE, 8, 1, qcow1EncryptionInfo, - qcow1GetBackingStore, NULL + qcowXGetBackingStore, NULL }, [VIR_STORAGE_FILE_QCOW2] = { 0, "QFI", NULL, LV_BIG_ENDIAN, 4, 4, {2, 3}, QCOWX_HDR_IMAGE_SIZE, 8, 1, qcow2EncryptionInfo, - qcow2GetBackingStore, + qcowXGetBackingStore, qcow2GetFeatures }, [VIR_STORAGE_FILE_QED] = { @@ -565,25 +563,6 @@ qcowXGetBackingStore(char **res, } -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, From patchwork Mon Oct 7 21:49:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175419 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845827ill; Mon, 7 Oct 2019 14:49:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxjb/ZSqFZxEG/hQjq8UNsEtfGhhuKLbZvty8utMrB8+EbaergbkcG3bWVKNTvpo+iy6kM X-Received: by 2002:a92:39d4:: with SMTP id h81mr31882955ilf.250.1570484980170; Mon, 07 Oct 2019 14:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484980; cv=none; d=google.com; s=arc-20160816; b=Ols8/C645FRD9gKvHPhJlWGVu4WBFpjLQbrH+k4k98pjyH/AKiIITe43Iy0yI2Na8l XnelMEuGrkfKmwimzaYhMdrWVEDa789cE8aa5zXXsudkVMCL0gqH8zB3ScDaQsaWllua GbDrxsCA4RXfsPqWMlnnrXXodz146px63XL0kaxyFuFcgvabM3JLxIPtC61UIlJqALab qeb5ykSvzkNj34Sn2qvxneavLw7c1tdBD5KtAVqbudMEc1YuNi1JP8EyMFfGLd6I9FmG /HP6jpb48q0tlzaMY/Vr+ztna1K/1XrxiJrPaX6ENpIVymlj9Se7QuWIgWl/Mf95wyF6 wAzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=l1XIbidfq4Hv0ypGR9hk6RgE9rMDC9wTu608dd9IQrM=; b=SE2ohKx6RFLlkn4IfljSaD7P9Gh+MSOVoDD1xNlrHAnhLp8wUluLBN50zoVZEjVT0j IEOyj/m/it225NdJH0aHNRmGwHR2cE53EH0S9pRpsnbGlidOV3s/VE46WF837MffPEpL cljivSZn45RVVko4ioBxz+Y+zs7Wo8Lpxv0HNbelwezriGnuZD8yT5QX6QNKi/Cs1Z7l ipbYNNM5b3A3rpUmAZUBlKNT9pYmFwzeC2pG4zQLwSGftdx9T23fVkdi+srZ4ZS49/+Q CiuhujP5W28Fh112rl1RCvJX7MEd5bCqOfRLcCHCqzG1WVw6td+QMdlwfC1foOoqlImJ iJWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id t20si19276684jap.69.2019.10.07.14.49.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:40 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) This is a step towards making this qcow2GetBackingStoreFormat into a generic qcow2 extensions parser Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 = extension_start; + size_t offset; + size_t extension_start; + int version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); + + if (version < 2) { + /* QCow1 doesn't have the extensions capability + * used to store backing format */ + return 0; + } + + if (version == 2) + extension_start = QCOW2_HDR_TOTAL_SIZE; + else + extension_start = virReadBufInt32BE(buf + QCOW2v3_HDR_SIZE); /* * 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 = extension_start; while (offset < (buf_size-8) && offset < (extension_end-8)) { unsigned int magic = virReadBufInt32BE(buf + offset); @@ -487,8 +500,6 @@ qcowXGetBackingStore(char **res, { unsigned long long offset; unsigned int size; - unsigned long long start; - int version; *res = NULL; *format = VIR_STORAGE_FILE_AUTO; @@ -546,18 +557,8 @@ qcowXGetBackingStore(char **res, * is stored at QCOW2v3_HDR_SIZE */ - version = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); - if (version >= 2) { - /* QCow1 doesn't have the extensions capability - * used to store backing format */ - if (version == 2) - start = QCOW2_HDR_TOTAL_SIZE; - else - start = 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; return BACKING_STORE_OK; } From patchwork Mon Oct 7 21:49:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175422 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845870ill; Mon, 7 Oct 2019 14:49:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIgkIYVpE79BgpDycCG1QE5DUJKKJf8UYYRrWHFsdk45EHT9VLM1s2aW0InV3fvegSr1Ta X-Received: by 2002:a92:45c2:: with SMTP id z63mr32744364ilj.241.1570484983579; Mon, 07 Oct 2019 14:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484983; cv=none; d=google.com; s=arc-20160816; b=nOUkCIRUY/c56shE6I/1iAF4+DxoMW+t9TuIwYgzmJgiW2Y02A9TeFtdUVQa+WwW+Y eMF7H0DEDof/qDQoFRARNKW7GzZe81cU3FwOypnzi1+GALwasb7vontRD9bd02yHA7ov XgD3Y0LSN3tvL56JQyuJgfVTNky9jBiOvWUv13x8YxOfH2RSNvrKAiVeFxpyFMbOk7dP 6V/nLcPfMfN9YRiuqIv4J5UbtvAYEUVQyGQpe6Dy2e36+Vc6c3X6Brar/ZFd7kYVAU+T g3B5fn/K1o3+Aw2cDUD2nnyyqLJrblhXpsUx8W1wyAsFnAf6GKmjhFcP74S7Ir+TjoVN 8IPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=U1z+J10VwAc3k7vr8zcf4inHijU4Koauhlw/iQST78Y=; b=Yv6PgdtmWMaxBY3FwY3+K1pOHa5I5/YpwYmUAUHT0LbOMg7tpBm1j3Z8nzDkxqQXbF 7VkK+u2JpP+McARQmyKxcY494lAnWkU15QH01qs/Ij2Z9hj+8uE+Is+vDw+mFJ/kSwHI b6KVdp03RrhcdfN1uhNwcpobbxMoX7dC8beoDlWqfl+33mg/ZMZkKhCoELC9RihOkFjs gyQHPZnXxiuebgYTiQzWKtEYyb9gFmF54O/RCAw6hems8CVfQE7vLLoAPG4AR0RFmj46 eSkorbgzvX/PItlEnhWrzFSzunbm85QLxVWfbH3qhFw+F6KYGtDyEF1J55kjvvPs4kFb nOJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id h13si19175602ild.29.2019.10.07.14.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) This is a step towards making this qcow2GetBackingStoreFormat into a generic qcow2 extensions parser Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 66 +++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 31 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 = virReadBufInt32BE(buf + QCOWX_HDR_VERSION); if (version < 2) { @@ -447,6 +447,37 @@ qcow2GetBackingStoreFormat(int *format, else extension_start = virReadBufInt32BE(buf + QCOW2v3_HDR_SIZE); + /* + * 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 = virReadBufInt64BE(buf + QCOWX_HDR_BACKING_FILE_OFFSET); + if (extension_end > buf_size) + return -1; + /* * The extensions take format of * @@ -506,6 +537,7 @@ qcowXGetBackingStore(char **res, if (buf_size < QCOWX_HDR_BACKING_FILE_OFFSET+8+4) return BACKING_STORE_INVALID; + offset = 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] = '\0'; - /* - * 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; return BACKING_STORE_OK; From patchwork Mon Oct 7 21:49:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175425 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845995ill; Mon, 7 Oct 2019 14:49:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBkqZLVn69poIxryb/xZkyWCq1OBoSrJYkx48qHuS1zemKl6BA0NT0yJm2nOjrTIAK/2Pe X-Received: by 2002:a92:91da:: with SMTP id e87mr31918528ill.53.1570484993272; Mon, 07 Oct 2019 14:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484993; cv=none; d=google.com; s=arc-20160816; b=jwExPVJ/WFzK7gVr/iwzBAfocwbSrkur3GxH6xG6XiC4pYScf9cuS09GVSfbuBz6+p +Pl7j/Y3CQEGDqxPPZS2ha6jkHLU2GJv7TuUa1SiSv+Kra2yNKnSB+1S9UMR9EhEb5+T sfGERT/kWiH2R6jHZKEjk+uhZH6kVCPlsNufQ+LwbhOzSkfafsZYDeMGEVTMoYJ7X2sX wjptsfApd+aXOijqCIKP6Q747Sfjw1ELEww7Te2PgKVIT7ECLMdP7bRB9ncSCcYWBl51 Dni4zXdtkBA0jWgtDI0qiFASKDf6THPLaDMfOb0Kkm9EapTyU525Nq3z75twEvfn+l0K 1cxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=qdC76TJnDtWZ/BSqrUYA6+WME5fqhvv1KP5J/G7TEYo=; b=uP28ERXA3R6mLk3QAlcT8YcQKczhXoxFScU1u1ARGeAiJj5e94xVGeGW8KS+aXEs0L HuBYPJfboTLtx+xHorhU/sRVbw0hB4XDFTT+UvF4rXLGw2xGofDHjFCKuxqfct7k1L7V DqS/MxZVhTO9qqaSWVzlANG/JxEQiEnAx/gaAP2QAkIw+J9u5K8jksept6HgpLoZ75Yf SXN4PUJEwpGvQD9NQzfV4PRN0qw20VQCFvpAY6u9Yc7RTStMRAmgsrg9PFqAAiMDlxVU 0oucv4DKOmdGrsSNj6o0zrSl9vnE1jo6hF3xWkv1kQMUfjDqjRhGVFNAH8pgJpHTjpDn A+iQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id u138si19035222jab.122.2019.10.07.14.49.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:53 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) ...to qcow2GetExtensions. We will extend it for more extension parsing in future patches Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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, 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] = '\0'; - if (qcow2GetBackingStoreFormat(format, buf, buf_size) < 0) + if (qcow2GetExtensions(format, buf, buf_size) < 0) return BACKING_STORE_INVALID; return BACKING_STORE_OK; From patchwork Mon Oct 7 21:49:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175417 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845786ill; Mon, 7 Oct 2019 14:49:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQW3vxJrx+IxSKxdQfSFy6TL4GTJxT0yJK+u150x6VwKZcea5rSIgH1W2kKlpIqYzE94up X-Received: by 2002:a5d:87d0:: with SMTP id q16mr572573ios.157.1570484977145; Mon, 07 Oct 2019 14:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484977; cv=none; d=google.com; s=arc-20160816; b=v/amrB2XI/10QofGqQ/iL6xNCLoorve8CFA6RBvNI5lq3dMxh3Ty5LG7qZjYq8KWmx 86e5OsMXBP0UEFh+LfdvVH6mA6zfZaPrGkXhwsbo7NfZ9BqY74ZEPP5GBsG2hNrDX7CE 5qUt1aCAOxsw3lc326+LTezvLexDHjzSVdalurKgAKMEtvw5mZXavnsLui/kdowulSpm stXCCTv0sJyVo5BCxtAx2HRP+U+f0NwNgIeDPGcSp7ldNd9Pr7wkfh3qiKiwwbpMMdn7 Y6I3c3srV3nR3lBoeR0IRmTqeLKvLI5pJulf+jFNopwv6G6z6U21CyoSRnI2/CCI5ePO OUGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=678rrsui4JWFZ/rdaq3meOUymjbbvzhP0mk2rQNwUMo=; b=Smp6fmpb4U2uM9By3Qoa1jIb4rW0w/BGd/lIDYmaaIeIBJQqZZq2XW2746ACcJvbWV LiF57VzUPHtzzTPCe13Fh954bp6+WtrVn/Csw6L/Pm3uW+nc+bM6pzrajNwTy3qb/geq zLm4yJRJtfXWR4KO8VEQUVtRI69/bTfWeJ3q/fqzbBq37cuwLeLJaLc2Jvz4UnyFfGv6 eQe+MPGsIwdHdAwmK/LjfuCySokYLbmy6i8IRe4jWbgqBt2knQp5GIZ2jcFqrZDv3KCA utsV+VyZlkbn3wzlab1C5RQCJNJFcm/bShd2Qme7OP0hxCwtt73slAf+Vl1LjyESYTtS K6qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id d6si19806312jad.105.2019.10.07.14.49.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:37 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) 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 --- src/util/virstoragefile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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, 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] != '\0') break; - *format = virStorageFileFormatTypeFromString(buf+offset); - if (*format <= VIR_STORAGE_FILE_NONE) + *backingFormat = virStorageFileFormatTypeFromString(buf+offset); + if (*backingFormat <= VIR_STORAGE_FILE_NONE) return -1; } @@ -561,7 +561,7 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] = '\0'; - if (qcow2GetExtensions(format, buf, buf_size) < 0) + if (qcow2GetExtensions(buf, buf_size, format) < 0) return BACKING_STORE_INVALID; return BACKING_STORE_OK; From patchwork Mon Oct 7 21:49:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175426 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4846037ill; Mon, 7 Oct 2019 14:49:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPHVdpFnRfvXywP4wp4lYBWBLT+sIW1Aop+48q/iosCjhv5IoPP6KzfPpANQIT7cs1J2MB X-Received: by 2002:a92:d0c6:: with SMTP id y6mr30322830ila.307.1570484996480; Mon, 07 Oct 2019 14:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484996; cv=none; d=google.com; s=arc-20160816; b=oNnEzJQqZPHR3tAI/71RTdyDhm8ddSFCWIGZWB+2H6ZKTOFdOgHeW2QDOQb98Ey2qB zbXPDNt5D6/UUWwCvi6CGygcVR6IAEnj9jf8zHVYkmWcyDBht2ZKCvJohAjzzE/2/3oh 9wpJCtGG7j1zdJW1UUYzovF4x7hicgpkdX8rfB38Xr4R/YkthaFwoSSbjL0/xAdyV5yN SM56c+SxmInAHYI6ZxRMwLRy1UzTDZw9yLtI/7rnJJYSVn8juE04NZhI21LhDyZOADLC qQmoXXE9xhBpwP4u/dWXjbRZaG+8jKMiZPSqLL6ZegOZE2ozXvC3H/Zu60fmq+ADbPXY 2tSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=WElK69WwTq5tW09hwRCCPa6mz5lhrDBfTZ5pUXY1PIQ=; b=ruj2OVdLi66JEru451J3nQtNiZ+tP+bdrfoC2+QBi4Wddyr+OxuQcZej5l8EjPjNSU Qjqr4WfIgcC/qgAkOIMZk8WmtR3DsFPaBim0m/7JZmPzq4SV7XqQkwgTyiZWGSIFODO0 wemDI5s/JNZtcSwi/d3HATUGblEK+6GvvKL5x2K2wfEzFxRyP9zne7Djyjuxjj0W/atz tsgArPzzux7r2EPiM8H8FSxuvX79NA6kkmoxYt2f5J8vsgi70o7/C37Va967s2l/V/2g irykcv5dvMYTGF83llUOJx4TaZYsRm8wH6mPV5U/WjMb0bpRrxtHb5S4WJsaGRUuNGTm 81uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id j15si17936508jad.5.2019.10.07.14.49.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) >From qemu.git docs/interop/qcow2.txt == String header extensions == 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 --- src/util/virstoragefile.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list 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; - case QCOW2_HDR_EXTENSION_BACKING_FORMAT: - if (buf[offset+len] != '\0') - break; - *backingFormat = virStorageFileFormatTypeFromString(buf+offset); + case QCOW2_HDR_EXTENSION_BACKING_FORMAT: { + VIR_AUTOFREE(char *) tmp = NULL; + if (VIR_ALLOC_N(tmp, len + 1) < 0) + return -1; + memcpy(tmp, buf + offset, len); + tmp[len] = '\0'; + + *backingFormat = virStorageFileFormatTypeFromString(tmp); if (*backingFormat <= VIR_STORAGE_FILE_NONE) return -1; } + } offset += len; } From patchwork Mon Oct 7 21:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175421 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4845830ill; Mon, 7 Oct 2019 14:49:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxze/uA18HKAGR5OvNSrnBQclXn9HrL1e8J85H/bnhK4jm0ZIf2gER67DeVaT4tQc9WJoU X-Received: by 2002:a02:9f02:: with SMTP id z2mr28147066jal.78.1570484980419; Mon, 07 Oct 2019 14:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570484980; cv=none; d=google.com; s=arc-20160816; b=GlzA0BOCWgWpfeA+b8qty6eJsEvVIp/qDwzydPKD6sSMd9w+vyycn9wLbbYiSkKYEf s1uko3WLOwXqmar9z5WW3EAd0wAPe62/T3Ykab7+TPvKYRlwxtlqHYighQyLJzFjMKFM zJNuddj1UszXb4T7oL6ba0+HONe+4JL6g/2YpB6wTSvhwxpsb7vP+Rr8J7XPfevFSEYd yr1AN7BfMjrbHtpB0mLnnBkNjMvnzCWwE6BKIB4gQ5W6dZP6aGTsZrCrhHgdJarvJf/T kRn7K/BLopFuzh/nbgCqVr/8YfGm6mh5WhpI5Ax4I7R660NFdn2g8SLhbSiS+HPwMv/B CA+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=Mubs0GLh1rcpHXBMvKaTntU6dv9FxY8xGdAaUcK3pDI=; b=kLfWLOtxXD8t2vUqbmoyKupzyFdAdxIoJj9IrRyz3wba9Gnc+1HtB6eDRi0HX+qNi7 3Ox9FYqI5PoWNDaVToR/IbFTsXlB7zRY82ojgplwIjYH5VLcdP3aH/2raXJxPELrNbMO YlwvwaEZ4QiQAg0zD6b5UVNvr2InrKgPCINlRmpzS+/j7L415HSuI/CVg2QBr/hzk5cm NwGDM1/x1hSnEueaoI5bTxwE5RqkDzxuvUmWRFGteYFCb4A/t1KU+FtL8QggRSZq2CBF ptQcW5n6CigbaSbvcvBwrEni7WP2QCnJjYR1tA23MQ9OGHJ0qDTU+SbMxiWfQHRErJuo BoLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id p10si20717733ilh.83.2019.10.07.14.49.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:49:40 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Add the plumbing to track a qcow2 external data file path in virStorageSource Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 2 ++ src/util/virstoragefile.h | 2 ++ 2 files changed, 4 insertions(+) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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); 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 file. */ + char *externalDataStoreRaw; /* metadata that allows identifying given storage source */ char *nodeformat; /* name of the format handler object */ From patchwork Mon Oct 7 21:49:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175432 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849281ill; Mon, 7 Oct 2019 14:53:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCyydQfiHdg8VMTwler9+ORAYJ1udSCaYXfdhJg7TK7lk4GXe4bDxhkKiWNsxC5I5ItApf X-Received: by 2002:aca:1b14:: with SMTP id b20mr1157776oib.48.1570485224304; Mon, 07 Oct 2019 14:53:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485224; cv=none; d=google.com; s=arc-20160816; b=cCSr1JSwwzY4Ype4gHIjvBqdCmGzYfmFJV/KXpUzVOo1h6M6l5wXJhPE0ElfNBblpG f5udJClOK4t30dDmdJ1kSQofYKAB0UvWa+6ZZhzOUhQVVVFsHKihy5xnn2vuz4yq6am8 dXMGSSrm2QV2nvOP6OayxMlsjnycycs+SZuQVAJy3xB+MbFfzJUQoz/iywD4o5b/6CTb 9XpqMWLfx8dqEUTGPRyQnJ1oc0WclL48NDDSMhs21acFfm9fN3rXDtVdWzmVF659sx+r Ac88085RUUflohZp58GMGPSno68+4yB3S5++QijRm5eKx+fMauYsbQOCZtFKMJ6g/TDx 09+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=iJlpkK6IRSaU2ztojwhT0w5FVG4m/kZXidOfDpIiETM=; b=IAPS9LdHusC1UbHsOgeK5bz6JB/dojZINq38CUSpxPc8FelG6eGvWwt/yd9DOU0UQg koiCc3WjuvXqK41xKb4eeL098qsRjyZMhFf7F39YPIHG1E1H9keNBEj1nH5if9NrhU/l xCyoQihEwSDYGm7AdRqhVwQgcNBx7g1qSiuIJvGrZJbRE4wx2fBQvlflym67ybPsWuZ7 +9LGoCjv1Wv1CYaNxqWPqDrML1oZ1CJOqbr7QpGRYHSVpAtatFLEV6rvfV6hXmNl7L0p w9l33CM8+UVu8YzOncwk/e1TOqPS7Lx0T7DRvkXgUjxsZnwAGzN/4Tw27KhoVwJcMqrY w+Ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id z2si8854290oti.64.2019.10.07.14.53.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:44 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) This is tracked as a qcow2 extension, like backing store format Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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); #define QCOW2_HDR_EXTENSION_END 0 #define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA +#define QCOW2_HDR_EXTENSION_DATA_FILE 0x44415441 #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, case QCOW2_HDR_EXTENSION_BACKING_FORMAT: { VIR_AUTOFREE(char *) tmp = 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 = virStorageFileFormatTypeFromString(tmp); if (*backingFormat <= 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] = '\0'; + VIR_DEBUG("parsed externalDataStoreRaw='%s'", *externalDataStoreRaw); + break; } } @@ -566,7 +584,7 @@ qcowXGetBackingStore(char **res, memcpy(*res, buf + offset, size); (*res)[size] = '\0'; - if (qcow2GetExtensions(buf, buf_size, format) < 0) + if (qcow2GetExtensions(buf, buf_size, format, NULL) < 0) return BACKING_STORE_INVALID; return BACKING_STORE_OK; From patchwork Mon Oct 7 21:49:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175427 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4848479ill; Mon, 7 Oct 2019 14:52:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzg08j7y64fd08ZgrdCKdCj/nwcBkBR2syLX8VZnNM1J8J92Mus4nDNB4FA5PkVSymQ6vTR X-Received: by 2002:a92:1951:: with SMTP id e17mr32293718ilm.288.1570485172865; Mon, 07 Oct 2019 14:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485172; cv=none; d=google.com; s=arc-20160816; b=xZyDuTWfhv3VfxZhD+TXdxSVBKP97BDQHKW8a1gjh9uOQYRvkNAe69HBIzpguFReL9 zWclBlW73dPMAuEZfIwjGnRtqIuE/aEmvwA2hMMWxqDUBy7QCwtizuLIrYcxv76XMOsS Ge3RtoP2oaHn0YUJBU9qVDXMjyQcwj2kBoVurJQ554tlqkCzWl9K9vVbITjekgTPbKS6 k2vP1ggFqxCUawbrPyjJLkHS30G6aJ9FR+JEG+FNWvwlAYmsfDSdOIaPH+weIGZ1Jma+ tEUz6ctZs6gGggsHyYVsWcDxJFoLjX38898PDAHJ629yydMC/44sewF/YqEbOxkdJIwe Dwkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=Vwu9moFWTtO+soP8ymvgEbaCTf028eYT0ZfaF5Kr5+I=; b=hRAIGV2x/Z5zG3BLRTK9O9Msyk0ckHc1be6hF3R+tIFp/454EOmt9ZMdeRIN9TSJyS 1Wh/DpKc3fYB6UfLtSopSm6V3E47NRk9S/gDRcVVE4085HVLsmnvnJJrMMUi+3oLR3Ez Id2pgsb8L81yiO4x9QlvL9GQte5BPgaGigisOA18HLRgHDL85WPtxI9oVjyOEgYqr2Eh o97XfCPmaVRaZw+0p07TyqjANPFHkBhYgAb1Fu54mIZXtF6Q5mO89WhPm/4HQFSHlQjQ MboPfHI0em/bO0b22oYa7qDWHFeiGxR+RnWG0IJkxR8iosgaLwXAt9lZ8zP1iNp4h3Nl muGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id s129si18985818jas.108.2019.10.07.14.52.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:52:52 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Call qcow2GetExtensions to actually fill in the virStorageSource externalDataStoreRaw member Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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(virStorageSourcePtr meta, fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0) return -1; + VIR_FREE(meta->externalDataStoreRaw); + if (meta->format == VIR_STORAGE_FILE_QCOW2 && + qcow2GetExtensions(buf, len, NULL, &meta->externalDataStoreRaw) < 0) { + return -1; + } + VIR_FREE(meta->compat); if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features && VIR_STRDUP(meta->compat, "1.1") < 0) From patchwork Mon Oct 7 21:49:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175433 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849339ill; Mon, 7 Oct 2019 14:53:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxx97ru3ekb9Bs1J/PwcFHbDsy5l/INEmNZ5cws1IqlhuJmhBQnePPe6o5c/J/aH48S1Wjx X-Received: by 2002:a05:6808:689:: with SMTP id k9mr1214442oig.58.1570485227515; Mon, 07 Oct 2019 14:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485227; cv=none; d=google.com; s=arc-20160816; b=dggwHRRRGCPOaWW0imP+h0vpAgvT39lTkDfU0fRiJ8NXPo2sLUONAC0sYA+YX9qXEk NAtoRJRY7BUcmpzGIpJQS8SAZ7VxNKU6+hAgExDDU+BcEq9TSqO1E7bnBiX9uFhbVwFG ECD6pw9CyXmWFr4Lpn6H6JMv74p4LYCQSR8HZwV8P8xvFPd44gMczL7KwW4UUvS0X7rh 1/1dXobSDRuwNeP4Vw8ocQ2E5Z596iMZHFue53UVXI1nONTPzXwuxbf5/nQK5el6lOQd oUlSnchFAOgDF8nnVR0CBZeFA9zOo8lcaHUn1N+FzvINABhBSlaS2WI8a8MTRMbJAS6Z 7GNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=k33Ixq2WgBBYpYV8nwIKQFQkdNXjO215KEDqFVc2DoQ=; b=B+/Fr7o9GoUvK9lFII0uDKIpRHERq23b2qT/Yx1mpnzB6GkuE8kAQiB/gb4CGBxNU1 azgN/KmpY9WANyuzusZoLUop/8eEatggAclBTA03ULWlXJqXj9tM+itw5Fsvu7aNiDr7 xPfa3vwwmRm3rW8eCGx4Lo5+brhy/aQpY2gf7IcE4j56B6aAbo6lvBGVnWOlZ8xknMfp rIWgac0Lem5xwa6Nn8gecAitM6IBPJWRzkaqo0N2i1srLGCY59w7GVLBFetotaMJFXbs RK6tGXvcsJYkNkvZ4X1JsKtd4gHPmMCkX/97hzaeGos1ZRUmjo30p/JwI5ZQXHxmFo/c 9+eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id a144si9937099oii.221.2019.10.07.14.53.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:47 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) For the only usage, the rel == parent->backingStoreRaw, so drop the direct access Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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(virStorageSourcePtr parent, return NULL; /* store relative name */ - if (VIR_STRDUP(def->relPath, parent->backingStoreRaw) < 0) + if (VIR_STRDUP(def->relPath, rel) < 0) return NULL; if (!(dirname = mdir_name(parent->path))) { From patchwork Mon Oct 7 21:49:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175428 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4848551ill; Mon, 7 Oct 2019 14:52:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgR57hi45is2rnxtaPyzRBL5EXDDalc7fMa1RG5NW2GYW4hIv+JTKm8PrMP0dlVGCxR/XW X-Received: by 2002:a02:683:: with SMTP id 125mr29315582jav.132.1570485176967; Mon, 07 Oct 2019 14:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485176; cv=none; d=google.com; s=arc-20160816; b=yfKDBO9cnQl7H5+S1Op5jUXtX68elM3Caidx/BQxO7hQTmx3LndJb4SO7xXXvogbUC XRqx1CmrZMJJfufmAT7N4Ru706liREYnN5Z0aMdTsuqYl/kp2wWSBtGaNVndtu//Mty0 p0i6MtBhVQLv+8ua+kUH5efTlSs47JaUbbewkDy9kCevAdKWLzIYMZfA3+qjgDiYydhv kA7IZNklHEm7yM4qRr5mGnasITE+AyJqgKXL3rTLIG+BoJklNO++5vmMt8/ivyVgMU7l h2McF3r+QU9PtpMDc7djG5PScJ/H+eRLaIckjAbsyULXHjfAO6dqf2zjfLiznwhLywk/ SjaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=/SDGbiUQRTjd7zaxMk87iIwTMBUvqVmNG7EFO/uTLWA=; b=HIYziA21YHISN+0gKN1Cd0F8AgpJ3LGgs7/ZoREtgSOEmr7qhM8xqU1eOB1DZ4990B KvVGg3VuKcRL3+BeNALKIT/4U+a2sBiMGqqRe1buPVe13KfbcaZqR+wP/92PuQgNzADA ADAppR74tGDAWKXbP6m/pSgB6nvX+0uBiV3dqm0nqtgAIaG4Hz9C+Hxgz/O5+99fuC2e mSYvdcy4bLlhQyPIaTjqaBXEqZtymv/FcP53E3w3zt35j+5/kKOcpOt/23OSp+fKDFTX cXiB2iAmjv+9nNHp/bOTKQRwYEOoX5eTW5EYNTJmRj68bonvSH402K8UyShgX91eUUbR NFqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l12si18393397jaa.6.2019.10.07.14.52.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Future patches will use this for external data file handling Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 47 ++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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, /** - * 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 and - * fills it into @backing depending on the 'backingStoreRaw' property of @parent + * fills it into @backing depending on the passed parentRaw (backingStoreRaw) * 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 backinig + * Returns 0 on success, 1 if we could parse all location data but the child * 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 = NULL; int rc = 0; - *backing = NULL; + *child = NULL; - if (virStorageIsRelative(parent->backingStoreRaw)) { - if (!(def = virStorageSourceNewFromBackingRelative(parent, - parent->backingStoreRaw))) + if (virStorageIsRelative(parentRaw)) { + if (!(def = virStorageSourceNewFromBackingRelative(parent, parentRaw))) return -1; } else { - if ((rc = virStorageSourceNewFromBackingAbsolute(parent->backingStoreRaw, - &def)) < 0) + if ((rc = virStorageSourceNewFromBackingAbsolute(parentRaw, &def)) < 0) return -1; } @@ -3767,10 +3767,25 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent, if (virStorageSourceInitChainElement(def, parent, true) < 0) return -1; - def->readonly = true; def->detected = true; - VIR_STEAL_PTR(*backing, def); + VIR_STEAL_PTR(*child, def); + return rc; +} + + +int +virStorageSourceNewFromBacking(virStorageSourcePtr parent, + virStorageSourcePtr *backing) +{ + int rc; + + if ((rc = virStorageSourceNewFromChild(parent, + parent->backingStoreRaw, + backing)) < 0) + return rc; + + (*backing)->readonly = true; return rc; } From patchwork Mon Oct 7 21:49:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175434 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849409ill; Mon, 7 Oct 2019 14:53:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCtBa/Z8kLs43FT5PzyLQfrtySe3fkcxxpG3p6gT+0lVdi51nOTSR6zWhRfFxqT2Y7nkaF X-Received: by 2002:a54:4f1b:: with SMTP id e27mr1198509oiy.85.1570485232007; Mon, 07 Oct 2019 14:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485232; cv=none; d=google.com; s=arc-20160816; b=nnE2Z+4OAkGOWu2WjwgYxq48GsZIbgf3Qsyc42LWsZU7L3PkkchHS1jXkt911ZpYuM mashDbY/YdAGtxwJzFgKlUfP51BUoe4zfPUVWVayMuVaocWo/bAuAAHLK+SK+QSz47SP HnMGDvzsLztMKloJa6kWiPD8F9yyv6Lmcqus4bNnyXTR90AOwEAYRyvUIwz7yelqGE7P ZjO1+B3vIVnEB0lSnVBqj+plWKbW5jEtlL6nC/uwZVuiZkI27EypqI4bQRnmln5ruqmL Z+mKOFOmwdddX3TZyEwDLB5K6znaewsoseG0UdE6e3F8gUaLkwuqD0nVAw95w4ahxIwz 697w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=xej1xLcS4uGqhQQois+fdJyo3DobfbQL5u4d3PVMb+w=; b=XnLdkYhQYfkAom8uSujk4lZApN9gKkEY5XOhFsY9mkx4gf361eLpwFOqLCHZsKe0kp zFRuWSNzzdd59ionVywCInT7XppM2ynoE5Jkhpd7BbnM8NgQvLpv3vnJVRq2dm+bTrQI 9hSAYf+tc4WbDjT6Oc6MN31f+m1y7umrObPIK8L2mOAVEGfdXq8j7RE+mXHn2jqHxCUB jj9rsi7BULQ3AaEKjxIpt2bKQo4BstfLw8PGSvl1ntK5o8JuG2NR5n894w21MSmyMs/r emHH0Donph5LeuY/Hk1JNVn1FRigUyEBZYjXybZuxocmuC3fL0ldykYuQmpaJ5fktbyd c62Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id e18si8628269otp.71.2019.10.07.14.53.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:51 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Add the plumbing to track a externalDataStoreRaw as a virStorageSource Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 9 +++++++++ src/util/virstoragefile.h | 3 +++ 2 files changed, 12 insertions(+) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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; } + if (src->externalDataStore) { + if (!(def->externalDataStore = virStorageSourceCopy(src->externalDataStore, + 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); + virObjectUnref(def->externalDataStore); + def->externalDataStore = 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; + /* external data store storage source */ + virStorageSourcePtr externalDataStore; + /* metadata for storage driver access to remote and local volumes */ virStorageDriverDataPtr drv; From patchwork Mon Oct 7 21:49:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175429 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4848632ill; Mon, 7 Oct 2019 14:53:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPSLyzAIeQ/9hVBjDOjE8DoF/DmCddJdSOgR/FhugqWXKyg6wyNeSaX6zHWz8Raw/wLjD8 X-Received: by 2002:aca:1c06:: with SMTP id c6mr1187367oic.27.1570485181554; Mon, 07 Oct 2019 14:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485181; cv=none; d=google.com; s=arc-20160816; b=hpRmYugw+dBbZiZof+fsy/UZKftRx2XBtL8nT/+Dac4k0BNQWe+njB2Rx+gVq9iv3i 2vsClmCmCg3tEdUCkzbedn5QkXQdS21VDzAfUMrFeUUJCcgGTN3XuQx1gyu1FBjAD1v+ sDmDaDcVQRHgNPmt6GVgtRtmN98u8Yva2eo5UKE/vEhOPoCZcLjJTTOB+PQZ4vKncTKw Gd+7XbaBqyRSp/bny43mlTjaw9tViXoFrVgUypdrxAKRtBpEDFmfTHgvn0HASYMudcOa KaDXf12rAcFDR8rg+pYqAqrRphNVe7ZXxtjCL5yWLJU29+l/j87V92gnYXZbVe3nKT3F upoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=ooQ8NQVpqcq589byhOREixiTAd44wmHd0EUdUSCviC0=; b=Rea82fqoMpl8xGRk266n5Hw1gQG2hx4OMwSFfuu/gcgLhawxVpxQwdwk1weeGfCMMm txtGAhrzW4noWbNcHK0O2qPr5ntWqADTJlS/MikpQkQ19sWmWrXzoAZyc0FfSNqQtX2Q DmMiWkRDie/OUIbnrNn+WWcikFT4oa3bfBFohMMHuiuSN0e0TacawiquDKucWTAwgSxw zpHi0/Mrdu+dfFccNUIhX4WNaKz95AU0mXdRjCtUgtW0mzCQNKzsf6RRTPG/34/84tzA hGMD94jwhQpCjWg8X5LXUEWzq8UkqcIioGZ0+buz6zHSnjtTyPVuoZcP8E9xK17wKrTQ AjKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 2si10310338oih.277.2019.10.07.14.53.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Add virStorageSourceNewFromExternalData, similar to virStorageSourceNewFromBacking and use it to fill in a virStorageSource for externalDataStore Signed-off-by: Cole Robinson --- src/util/virstoragefile.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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 parent, } +static int +virStorageSourceNewFromExternalData(virStorageSourcePtr parent, + virStorageSourcePtr *externalDataStore) +{ + int rc; + + if ((rc = virStorageSourceNewFromChild(parent, + parent->externalDataStoreRaw, + externalDataStore)) < 0) + return rc; + + /* qcow2 data_file can only be raw */ + (*externalDataStore)->format = VIR_STORAGE_FILE_RAW; + (*externalDataStore)->readonly = parent->readonly; + return rc; +} + + /** * @src: disk source definition structure * @fd: file descriptor @@ -5007,6 +5025,23 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, } VIR_STEAL_PTR(src->backingStore, backingStore); + + if (src->externalDataStoreRaw) { + VIR_AUTOUNREF(virStorageSourcePtr) externalDataStore = NULL; + + if ((rv = virStorageSourceNewFromExternalData(src, + &externalDataStore)) < 0) + goto cleanup; + + if (rv == 1) { + /* the file would not be usable for VM usage */ + ret = 0; + goto cleanup; + } + + VIR_STEAL_PTR(src->externalDataStore, externalDataStore); + } + ret = 0; cleanup: From patchwork Mon Oct 7 21:49:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175430 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4848665ill; Mon, 7 Oct 2019 14:53:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKMPvlxUZG21FIswPYCoUXpvmipzOp4rv7dmFfzZTi6CZYs1Zy469st2KordKwC3x0u0Mu X-Received: by 2002:a05:6e02:c27:: with SMTP id q7mr31385980ilg.148.1570485184114; Mon, 07 Oct 2019 14:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485184; cv=none; d=google.com; s=arc-20160816; b=wNgzpase1vihXOElu2DGL/KvPergka2Dk6cLsWWQSUzNntH4HFTeQFFzCzXBngFxQB p+OWAlP1Jzh8z2Jyqv7uZSbnzUw3iNyrp+/GWbbVsAEQ8CeP1i+9FP4SBj22M2quWop6 VBAguJ66R1aOkTOzWqhbUEgs7FHqdtSaPVeudAoAOgYxXiTzWC7rK1XsouqtbKtZkgJ5 lf9M6I/48f8kwjDPkgdb7XV3Ksux8mA2VKY52IddPKmdEDyyO+vzzT/6hxMkTwlbVT+T evSSJwbw2OLtYzOGTMOAFZmuHVaB4Ib1Xt4ETV9GF0eQp3Kzm0p8N8oPl4D1m33YLX18 Mxsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=2gXxKKhlWmJ43MeDExTA1chlDm6hIrwWOeG+FMZHA5o=; b=ww+b3BxdGgQCSlzq3Wm09WJ+u2egTxtBqcQh27WCMFhjzO2N5rqrJEmdKWaXnEt4F2 VlGB24lINaTX1cHQqrSx6HjS30CLiW/Um6Bp4sv2uAgX8Oe0HI+4+C02fwpw/PTuZnkB FK43PmKvBXzzcM24DhfHI7JSbflfs0wNPhhDRq6TVW7vPcwbxO5K6GCvbni85mqqAyn0 A32HPFbaLwXXWRa4zXPg5ljtiHddrLYztix9sVLiclIPbbGM7wfsEBWlvOugTVOkOvyt 7GqPEIcjOsxWwng4uTLIqQdy5QikriOa5zHYmwShUerD3YzjaZjLoZzjOrX1S01ww+fc Z/Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l7si18022409ilg.18.2019.10.07.14.53.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:04 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) The only caller always passes in a non-null parent Signed-off-by: Cole Robinson --- src/security/security_dac.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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(virSecurityManagerPtr mgr, return 0; disk_seclabel = virStorageSourceGetSecurityLabelDef(src, SECURITY_DAC_NAME); - if (parent) - parent_seclabel = virStorageSourceGetSecurityLabelDef(parent, - SECURITY_DAC_NAME); + parent_seclabel = virStorageSourceGetSecurityLabelDef(parent, + SECURITY_DAC_NAME); if (disk_seclabel && (!disk_seclabel->relabel || disk_seclabel->label)) { if (!disk_seclabel->relabel) From patchwork Mon Oct 7 21:49:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175435 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849440ill; Mon, 7 Oct 2019 14:53:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV5lOvtCrw9jzHry2AN5dVcV8FfXlnzOr+QW6Z94FksuFUyt6aw/8+Qs4w5rwuVydvXcxR X-Received: by 2002:a9d:4803:: with SMTP id c3mr23601266otf.155.1570485234172; Mon, 07 Oct 2019 14:53:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485234; cv=none; d=google.com; s=arc-20160816; b=Id8YyKCyczEbiNfLd1Vc62/KYHSn1/kAkOZQVpv5VCmh5gqka/8Q/fWydU2TB27tij Rg+sm5zeUDuwK1zkrsbWVjy3ryw/X4wkIlsZ7Eyi/lzY4F+zThZwVy/cMwOMAWYnBnjQ +vvgDpnfFZSbuCiHzMIUMftLge6AICShWsXpsCjNLAzG0fTRuXAnIEpIacYJ8B1oieh6 vPR8Ladsdksh5dcHUmd+i+XTBQSGQ+urWHC1+ddNPN9dXQTHLufwFKwmLbctloB6ZqZW ercFqRaRxFAGEZMBcC6jHNMCilnL/XPJVotUhEsLc3N1RjoCrLZvXkibgNS2k06HFAv4 y1sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=AJD2k1C574v5oHdqviVGnvYiOetDZgIBOROcdC390Do=; b=TvSm042GpIv5GUfDAQpnBTVZhXm01YGOwlPQ2ELuZDjYkHh+1jCKRxrY27Pfq4kR2y vSBor0RP8JqGlq0odxKbAdY3ev2jqkHKcSJQUaFA4vHQG6DqRVpz0NO8omCKsq2XINf1 3G14OKc/+3D27hbD72UIvigM5N8mx/wrzXYLw5gYMI8vLe4Eu2wJzmz6Kk/RMFr6FrOf HTIx4xiOxgBXU7XRSGr3VxRDTHE5ud4TB0hni/4fND9/97m+K7B613PevRWyTSWdc9b8 KI6J5C2qsODKSCenAXjy7/Dr0kFGi7CvlEo190ZI8Y8RrM+AYyeq9pNaL4eYYfQgag/4 Kbdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id v137si9626884oia.104.2019.10.07.14.53.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:54 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) This will simplify future patches and make the logic easier to follow Signed-off-by: Cole Robinson --- src/security/security_dac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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(virSecurityManagerPtr mgr, virSecurityDeviceLabelDefPtr parent_seclabel = NULL; virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr); bool remember; + bool is_toplevel = parent == src; uid_t user; gid_t group; @@ -926,7 +927,7 @@ virSecurityDACSetImageLabelInternal(virSecurityManagerPtr mgr, * but the top layer, or read only image, or disk explicitly * marked as shared. */ - remember = src == parent && !src->readonly && !src->shared; + remember = is_toplevel && !src->readonly && !src->shared; return virSecurityDACSetOwnership(mgr, src, NULL, user, group, remember); } From patchwork Mon Oct 7 21:49:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175431 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4848701ill; Mon, 7 Oct 2019 14:53:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwioJekFOWnA42Eddksq8FxwHGXUXvZG0BTD6KUgp8KgYkeLufTGsqx+JGz71dlxLcCW8Uw X-Received: by 2002:a92:cd45:: with SMTP id v5mr33282213ilq.197.1570485187599; Mon, 07 Oct 2019 14:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485187; cv=none; d=google.com; s=arc-20160816; b=yANvVF14BbRXRaZd8lAm97HgmcQs/sKiE3iRMSnMoXSWmAwOtgwDEOhWPCsBV6HcJv JjSgo54p8SveKTM/cCPF1BWKwOIZbNuWsPbF9XOdf02SS7T90V0j9oKYUzWOAT8BTjf8 przPS/4bdhMPtkop6GKu5lxM5bnYRuxtX3cR0YFBZeEVEKcNzxr6EeZ2lckAyDIm4wcH 0wxSchs2qofxYqEZvHAs6g55MTmKTkieU2NifJvKfDfjEaUpK3yPozzG1LpYtTwlIukV TiBDGwmIkVRYOMXs4/QXp7DFsPEfP9eOiDGDfJOmv0H6jWaoa5kBKwrqZlU1Kxhet3YL L9Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=6IntyRMLy/22DPoU/4VY0uaXSnyOXx1DJdGmlRgbAh4=; b=go3hjO6f5djARxlyccBxH3WIyuk8zuLgGZouCcPZ/mYmOaA5GYdQpWmvBQ71ngmYTc vhj66Od+KmBZ5RkqYD/zT7qBfr8Tp1l7KcOwYkrMIHVhtlhocgb8EtVIIwtbV7IAEQ1m u18RGbJGhY22nXt8Gw/dItS/zRx/ETahthnrIh+szVRet4mxmmay4pn6kguUOrSTT7CH MtdCVDPJ+IFMd3bA2SAfMiThq3yEAd0PXBFyFwUyFdezoobd/eEWwOYA8K65Xd9ZrFB4 NXyfFTgN8TJ/HAv8S2vrxN34StQcKSXcIrOcbbjG6MI8ueHJYPpg/1uPQFUURnqoZ1Jn RYtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id c22si18783182ioa.24.2019.10.07.14.53.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Rename the existing virSecurityDACRestoreImageLabelInt to virSecurityDACRestoreImageLabelSingle, and extend the new ImageLabelInt handle externalDataStore Signed-off-by: Cole Robinson --- src/security/security_dac.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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, static int -virSecurityDACRestoreImageLabelInt(virSecurityManagerPtr mgr, - virDomainDefPtr def, - virStorageSourcePtr src, - bool migrated) +virSecurityDACRestoreImageLabelSingle(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + bool migrated) { virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr); virSecurityLabelDefPtr secdef; @@ -1008,6 +1008,26 @@ virSecurityDACRestoreImageLabelInt(virSecurityManagerPtr mgr, } +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, From patchwork Mon Oct 7 21:49:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175436 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849499ill; Mon, 7 Oct 2019 14:53:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdIKKtmXUttqbuLXnO/vgvKRppN/kafqL1s5BfNJ5uW6ducG2beHweBYoP/59Wp+8RQnv9 X-Received: by 2002:a92:d44e:: with SMTP id r14mr3905297ilm.8.1570485238060; Mon, 07 Oct 2019 14:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485238; cv=none; d=google.com; s=arc-20160816; b=BExLER3f2ZsMrgDIB4s5+0jqIxdNaXjMuLqXIk6Os7um2Jx777e8T9vpSlHgrTvXkd /PXyB9/I4LMY3bhx6f+XTwD2NSe30ve51lj5M2uuBDARcboQVZTwsyLBaKRmrEZ8N/JR lhowNCDGkFJIen+vbOEgl0mDNbkDIppsJvahfj/MHKnYWHYPFP4G4JI2jjcgq34nuWON dCKma9phIXkv3HlqMSiOUKDj2/oBBUxVcIBBzbbJPVtcCml1aNj2Fbd5KWXwfpCqwKyx RKMuKOUbSml4Jxf3fMk/AnL/4oDSDhzQprDv55Mfvkr/pVoC5SlPv2c3RrMQVGxFYqbK 8YYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=lS0D2VW3Ix9j54Taj/gTpo7aYNoPvJtAI32XgvlNPA4=; b=MBQx62Q+LSDdbWYi90HE4kvZC4+cxMHJB7AeUH45mI/8onqqKTXnY+9pU2Bk4gUXkD RCxh2LfjMvNJp4mA9zvBSVqZam07LT9KbU2tua+K11HQ8KhrKX2v1OrcQcQ3uC0cBVO9 MQYyAW7ospmdr4/+X6Pqz+S7AdqIzNMEtNR1lPApJ9JuHUyyhJpgJHIw9BAKsXUx98WJ 1dj4zXbMCPYf0Smu+5788it6gDkkjGA78bSrOnY7uGuzY8AXxChs21opWOcZWEIvCp3K VUANDZUHXfo8BiYrY/AqxSv120PkyJdMcIUkdOARxXEoYQNapnHDkZJleHLmlkOxdgnJ Vhcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id n5si17876481ili.141.2019.10.07.14.53.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:53:58 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) This will be used for recursing into externalDataStore Signed-off-by: Cole Robinson --- src/security/security_dac.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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(virSecurityManagerPtr mgr, static int -virSecurityDACSetImageLabel(virSecurityManagerPtr mgr, - virDomainDefPtr def, - virStorageSourcePtr src, - virSecurityDomainImageLabelFlags flags) +virSecurityDACSetImageLabelRelative(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virStorageSourcePtr parent, + virSecurityDomainImageLabelFlags flags) { virStorageSourcePtr n; for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) { - if (virSecurityDACSetImageLabelInternal(mgr, def, n, src) < 0) + if (virSecurityDACSetImageLabelInternal(mgr, def, n, parent) < 0) return -1; if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) @@ -952,6 +953,14 @@ virSecurityDACSetImageLabel(virSecurityManagerPtr mgr, return 0; } +static int +virSecurityDACSetImageLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virSecurityDomainImageLabelFlags flags) +{ + return virSecurityDACSetImageLabelRelative(mgr, def, src, src, flags); +} static int virSecurityDACRestoreImageLabelSingle(virSecurityManagerPtr mgr, From patchwork Mon Oct 7 21:49:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175439 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4853566ill; Mon, 7 Oct 2019 14:58:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuH5k3Pl9LIQtr8cwiZkAdB4wADuFokFyVpo8K4k92iO31JvcejXO5YYb9RXNlh4jpsxt3 X-Received: by 2002:a6b:9109:: with SMTP id t9mr24653346iod.16.1570485515288; Mon, 07 Oct 2019 14:58:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485515; cv=none; d=google.com; s=arc-20160816; b=aGPTIZ62qANcdaBJcxKSNRfxooZNfhe01xOGF59QMEX90O+ZIJJ9IJhsDdBqMVq/of kzRSybgnhORHwXLKODTwREtswTiJfj3hKWsV6ZTYJeCxhvXQXxXWQsm+TQtyvgKUOv9T xagExHTl1OKKxLHDodlIabEp7uUgmBaIC+Jn0Wz8u2mST4VsKoPKMmiTQMtVi8sm77zk C7770QrV18yQj/welQSuOMHfetGGhUY8caRe52qvx+ekblRVWGcY26ui9T0FBU+oC6iN uXzSzGyxJ8MDR/rqV2dT0wtunOdD9+2eOuSYcvf7ZiTc+y1nNp6h6dYxnjy54+0PLaXt ZnIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=0X48Fst6Y+m7zz9JriavALw3y9RJkGk65jT/gidieoA=; b=E8KKMtcqrkckRiyxmRJVDzuYCNRz/JOBHMDeGgVVLTGVlqLl1RnTBURo9K5ow2EQUP N3jiJKvvQ5e6bwEymNcDfPQWrtVbppzAf0r87ElgLM8jxOv460qqsBXNAnOs2AKcFEGA 8DjeQLPjBkZ/4HrT1tL9KTc7klkggQ2XJSSw/w/zslA47mP/LXbrUB589y0xv9j1wBl9 qY8xssWr9RehDEZl1PgvWqCTh63MSgnHWlz2Ub9XroTDUIod6bD8JqRAQYBpPybPblf8 OXtEJPl1wfczPOrYyrKQQTnZqx46VXQUgmSAPk7yNZVRF2yOzY1JR5CtwRueLJoxNZx/ 29vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id u11si16335894iom.109.2019.10.07.14.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:58:35 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) We mirror the labeling strategy that was used for its sibling image Signed-off-by: Cole Robinson --- src/security/security_dac.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza 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(virSecurityManagerPtr mgr, virSecurityDeviceLabelDefPtr parent_seclabel = NULL; virSecurityDACDataPtr priv = virSecurityManagerGetPrivateData(mgr); bool remember; - bool is_toplevel = parent == src; + bool is_toplevel = parent == src || parent->externalDataStore == src; uid_t user; gid_t group; @@ -946,6 +946,14 @@ virSecurityDACSetImageLabelRelative(virSecurityManagerPtr mgr, if (virSecurityDACSetImageLabelInternal(mgr, def, n, parent) < 0) return -1; + if (n->externalDataStore && + virSecurityDACSetImageLabelRelative(mgr, + def, + n->externalDataStore, + parent, + flags) < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; } From patchwork Mon Oct 7 21:49:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175440 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4853723ill; Mon, 7 Oct 2019 14:58:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMmM5vqFEBRhasXkhd/G2Fv8BoV0/XvIqFl8b/eZJ+iyAH65V7Wec0RTEMD0kgjNhfHe9+ X-Received: by 2002:a6b:1456:: with SMTP id 83mr8334812iou.152.1570485523919; Mon, 07 Oct 2019 14:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485523; cv=none; d=google.com; s=arc-20160816; b=CC9uj2ylVwtWUqpP6Kxp/yjYK5m+8ct3AWve6hC5cWEZ6p9OMMgUT7S9RkHQ5VH1CB XeRQzFvr5TBByEsFKf/K7FtlgGF7HixSXD4v+zMnbp1s74VplssmO2XlVajbrePTF6H/ ZraskJtLl9q1iBKUEvCSwIsgb2fk8W5SDxwoJRQj07Ljc7riDeg/9IWdXRncIk5lG9x1 S/7XPcxs/m++5g80fGis9LM6I7sXWzxh1esQZ2Ye896pSKG6WuYQES/nmViXWmrJSNtq y6ziUznmOOpIWnA0QDIuEFu6xpygJapYzuRpcKD1HYpiNjwaI03GWwDdw1OTA3y1VtJn 72Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=loO52K808zflaD8P7fdR5q5/eHC3XV6ktq3KksMrgMU=; b=RYLGYOKfqXeLBk/k5+HbSTW41pIf/wUOqsXErSyR0EQX63AuWYo+I4o1HjtNn5uEm+ ssOh9Zxzx906lnzcmh4q/eBGudeS3Ntg698PVudBIIBiO3vSwMfk+DkRMOKfshEodZkU VH52A6sIkDdG1A0kUVbxgnenSdxBVZKQ3OupkWoz7wUym6ZqOd/37PVwVqxy411PRLYw bWl4TZoMT+TXuDVlW/tNqLT/jnAp5YfvZAKQF85cFUn+T7xoyLcpS7qS77XtcwHSVZEm khlt5JWDe4msORjr1rlel8Go9ljDTKmGYbskXsG3oCISfIHQO+ZuH7/9pCpiZ630WlDY 9MXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id e9si18783562jam.73.2019.10.07.14.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:58:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) 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 --- src/security/security_selinux.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index e879fa39ab..9d28bc5773 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1822,6 +1822,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, virSecurityLabelDefPtr secdef; virSecurityDeviceLabelDefPtr disk_seclabel; virSecurityDeviceLabelDefPtr parent_seclabel = NULL; + char *use_label = NULL; bool remember; int ret; @@ -1856,40 +1857,28 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, if (!disk_seclabel->relabel) return 0; - ret = virSecuritySELinuxSetFilecon(mgr, src->path, - disk_seclabel->label, remember); + use_label = disk_seclabel->label; } else if (parent_seclabel && (!parent_seclabel->relabel || parent_seclabel->label)) { if (!parent_seclabel->relabel) return 0; - ret = virSecuritySELinuxSetFilecon(mgr, src->path, - parent_seclabel->label, remember); + use_label = parent_seclabel->label; } else if (!parent || parent == src) { if (src->shared) { - ret = virSecuritySELinuxSetFilecon(mgr, - src->path, - data->file_context, - remember); + use_label = data->file_context; } else if (src->readonly) { - ret = virSecuritySELinuxSetFilecon(mgr, - src->path, - data->content_context, - remember); + use_label = data->content_context; } else if (secdef->imagelabel) { - ret = virSecuritySELinuxSetFilecon(mgr, - src->path, - secdef->imagelabel, - remember); + use_label = secdef->imagelabel; } else { - ret = 0; + return 0; } } else { - ret = virSecuritySELinuxSetFilecon(mgr, - src->path, - data->content_context, - remember); + use_label = data->content_context; } + ret = virSecuritySELinuxSetFilecon(mgr, src->path, use_label, remember); + if (ret == 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. */ From patchwork Mon Oct 7 21:49:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175437 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849554ill; Mon, 7 Oct 2019 14:54:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyfYFHTgANTPJ3rH01bazNv6VswK1Qe7yU0jfYiIVehFTNbwFdXbmbvY7FOdUeCSZgLoDw X-Received: by 2002:aca:cc96:: with SMTP id c144mr1243767oig.72.1570485241745; Mon, 07 Oct 2019 14:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485241; cv=none; d=google.com; s=arc-20160816; b=hPs7PiJ+cfdLcVdCE0ZPCEvpJJRCh4LS7iHB705is7575BgTcP+walgy23yX+p+3hA /wx6HdCO12TlZRCgYRZJOf58waLjgC36ONE+bl8Mlx+bmiEV5YmYBH5N+1T7FO+b+7vb H9vRWlBXIe1MCxro63fP0lbq7Mec2Lb/jw1x/xXmEpVmMudkoqHwzpNVfojN3UZBK4y1 f8HnuVasKjILgK1AJUBPLW0r2GPQhGVOfTDwVQExMVwqpyCoLL0cYPmiMRpNLBaSQUTe l2HFNSeVI8+mDyQ63Osvy1FBGJITGsTAeZorwP1I/nKdTysVDKkiHb0eocKdgcr+JFX1 xfGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=yrAsWrbf1XxuKHcdnldGVb/y5JxxZiUoTFBeKbAzqcA=; b=dvj33dAWSt0ktXuDgVxWFu8wkXZDzAE5tDDex/0YtNDDv27xc2Fn6RU5jR01/scq5Z xUj2s+XBziJFHMyp0MJd2oILD1N1Ww2JdF4IVfiV29tWCTFkD3ti/WbRjh8TZdQoRd4f bWolqnruxTrhhv/3Y3O/4VtAXTEMVssFoclyIVgbsay6XVt1wbuGb/Kik6rLuCQ2vc0x 4wryKh6oP7uvhZEhJnY3XZpTHAqw47ngUlAmsMFTpKt4LeBbyMnLHmBEkfwmbKvvJju6 UrVkQXK5OhIv7t8vXqGKxilPSJa4g8MC1MLsBzGBZ4O7vNXax7AZbjtHduYg9CmwAse2 KGLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id a61si8441526otc.193.2019.10.07.14.54.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) The only caller always passes in a non-null parent Signed-off-by: Cole Robinson --- src/security/security_selinux.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 9d28bc5773..e384542c49 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1849,9 +1849,8 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, disk_seclabel = virStorageSourceGetSecurityLabelDef(src, SECURITY_SELINUX_NAME); - if (parent) - parent_seclabel = virStorageSourceGetSecurityLabelDef(parent, - SECURITY_SELINUX_NAME); + parent_seclabel = virStorageSourceGetSecurityLabelDef(parent, + SECURITY_SELINUX_NAME); if (disk_seclabel && (!disk_seclabel->relabel || disk_seclabel->label)) { if (!disk_seclabel->relabel) @@ -1863,7 +1862,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, return 0; use_label = parent_seclabel->label; - } else if (!parent || parent == src) { + } else if (parent == src) { if (src->shared) { use_label = data->file_context; } else if (src->readonly) { From patchwork Mon Oct 7 21:49:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175441 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4853769ill; Mon, 7 Oct 2019 14:58:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjEdRlMcvuyB1V1+8teVOXJ+2GIZf22WpipiYH1pUuYrqX0TfU4uwpyMggXCN+Py9NaP6K X-Received: by 2002:a6b:6d07:: with SMTP id a7mr21669666iod.261.1570485527220; Mon, 07 Oct 2019 14:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485527; cv=none; d=google.com; s=arc-20160816; b=RAEeAEZYYBhH/vHDR7lWxmgr476VFLGxd1tOct8IKocioqn4DIO0M5WYsuDKYl4G9J q/gUDyocicfPPlrK5H+F8QMIik0535RSNVsPuWokVvKVywPtKTyX8dj7aYBEmn9iMTaz Hdn9wux2iJlXsX/H+IzUyWhdxdNOfUflep7Eo8mI1d2VHBRAA/vGfyPUfXi+HKXBUPe/ yzhEQrlQnGTYoFYzY9d1H/e7f89zouRIaQ1kh9svAqoXbQOm2jXKtaq1cgqknUtUI4OH 4g05uYVbQwMCtvuZVfgRupZEuxGbyb2NI0dgQQeje7YK/vVqta9ZBqBOVAdzyK/7D59D Qx4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=i46mNjIrBFYKACNkG2hSW0WezITiHDY/noOqStY/qQg=; b=GY35qzF3YcOZoLz/EQBBPNEX36EzBjKlIsrnz7yF7FbVrD65k9OSzoKFYmWQmeoXB/ yEJpAmsmE4u2V7kII+zn9SgthgIBLkn4JBdTVeZSuNivOnSibyjPMmaXU8vqYsmsXnKN sODsXO94QXkvYIncouU661mz2a+01jiWBJEYr30M2sGZmrxhhpCMMCXPxRhD99E3k4RR cby+vxr4gubvskVrSfXs0AQCVm0SmIDhHoHar9lEUE3nerSNI2dVgw8+3AT8zs5shtBS sL6QGolkN6gJ4i2eNB9Rsw+Ata0tRv5oDk55UFsu7A2iwuEHsGzxFOjx3srjvaUMZlRq w20w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id h83si17558480ioa.60.2019.10.07.14.58.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:58:47 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) This will simplify future patches and make the logic easier to follow Signed-off-by: Cole Robinson --- src/security/security_selinux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index e384542c49..fd7dd080c1 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1824,6 +1824,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, virSecurityDeviceLabelDefPtr parent_seclabel = NULL; char *use_label = NULL; bool remember; + bool is_toplevel = parent == src; int ret; if (!src->path || !virStorageSourceIsLocalStorage(src)) @@ -1845,7 +1846,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, * but the top layer, or read only image, or disk explicitly * marked as shared. */ - remember = src == parent && !src->readonly && !src->shared; + remember = is_toplevel && !src->readonly && !src->shared; disk_seclabel = virStorageSourceGetSecurityLabelDef(src, SECURITY_SELINUX_NAME); @@ -1862,7 +1863,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, return 0; use_label = parent_seclabel->label; - } else if (parent == src) { + } else if (is_toplevel) { if (src->shared) { use_label = data->file_context; } else if (src->readonly) { From patchwork Mon Oct 7 21:49:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175442 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4853830ill; Mon, 7 Oct 2019 14:58:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqymnO1S6xj9omiuRAiTLpcNujTAWY+dviwhr00wIXRqrANjDsTjK9sPN8hZWKXFGSgTKlXS X-Received: by 2002:a02:9443:: with SMTP id a61mr28297700jai.35.1570485530366; Mon, 07 Oct 2019 14:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485530; cv=none; d=google.com; s=arc-20160816; b=Edi+XG+U9AZKZQlguXvoJ+5kRqKy/OEHhxmdWDsvpVbXr2BJUmNH5zc1KqhlNJKf3O kolD0OBIatmlCsJBt1pk70LZscOG3YAwCOS7Fu4KriO4fUE7ns87skSFz6flc0GNFm2N LR+uFeD6qpXDuhrfLGqlcZrYHQZeGZEVcsBtq0E5WHCqISsuvWSjot8+9T+9psLE4KAX Z/w9ONWeOBcc+K8D/+PTWpkku6QHa9Vif+1vlnqbNFPG2qHGQS37LhsBr4jDRFEarVQR RkAMSteqd891M+9WVhu9HC/uiJrVitx/9gn/kjO3S2XM60ipJBowpekM74CIypyhlAeK lyAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=jJK2skjo1YdlDYOa3A8T4jZD8Cm5XBBLnG7sOyUfMp4=; b=RxqC4V3j/a/3Z8AtaeNwabp/ae/GEzY1uUtci9iHyWV8CIokXmHm6wQ+IV1vJ0YDjp 8zAj43JRUmoFAfYoMugsN6oVEamRuZ6SfR6eSj4Mj4lhy0PiyAFfMmBb43kYDgd32/im rRYnnW7PinvIRw7EpCu6lPQ1xtvU2OAD4QOM+b3TMADOVNlDqOIGxpoD34lV6/rhfvAo K3n85UQGBSEDrBNv8gycCk5alVqbj+/hZMwWZxgMiTescinxdaU+j+wSowFJnD7fRgJR 6WucGn3RIpjDRhr30pbofg4oSgOVdxxkdthUPTiIgX2zAL1crVUu+ebTZOT4DDjAmwLZ oLOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id d22si16909129ios.77.2019.10.07.14.58.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:58:50 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) Rename the existing virSecuritySELinuxRestoreImageLabelInt to virSecuritySELinuxRestoreImageLabelSingle, and extend the new ImageLabelInt handle externalDataStore Signed-off-by: Cole Robinson --- src/security/security_selinux.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index fd7dd080c1..c0bfb581e3 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1747,10 +1747,10 @@ virSecuritySELinuxRestoreTPMFileLabelInt(virSecurityManagerPtr mgr, 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(virSecurityManagerPtr mgr, } +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, From patchwork Mon Oct 7 21:49:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175443 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4853873ill; Mon, 7 Oct 2019 14:58:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxPh//qV7TWCmPIdqWQGUFrzYK/4mKRB2McDUJbViz74PiIrE6+dmVuuHFmfedGhm51jxI X-Received: by 2002:a92:6c10:: with SMTP id h16mr32313590ilc.299.1570485533722; Mon, 07 Oct 2019 14:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485533; cv=none; d=google.com; s=arc-20160816; b=opL79nUDaNoC5FkeyjVEdEJ9y4ypraigVcO9BXIza1Jlhzs2gu8HH/iv0ulh0CWVHq mrnm6aoJQwbQHeOxmw9Jrsv+L5VUMACGW/8c1Yr/cCoUpgMHr8FKgXUqn2TgWnNUyNAj 4nv8QRhPYGArVcUc/5269dxgHQycQPqDz6TykFl09L0PftRfitvdDNa7IpbOZxIh66rZ uqF9U+OAID9sApRiLcpxw7LCK/ewWu65JZoDhtzx2WDLSoQwCVQmKvulh38YSRgAkVf3 ydzllmCasg5CuYhsKnBqNUHeSCu1elTqRbFmzPJQ33TD1DZ93xifd1IosYxp13UEE6nM e7Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=ldf0gZ9i5zBrJXYGqKNWCRh3osG8wq5WOqaLBq5oCjs=; b=vTzwdCGN5Id9bl5+vAv0vEwbOz/B0oiA4O+CYCIar5JRCephQ4YGMeEFggriB/FzER My+AcC4cUbZI0z5RHv3fo23AHOVcD9wADLXOLnWdSigNn+5PaFaoLeSWlzYlWVr4kOyp 8dMLhg7ZcJNQz/ZwbqekQSg8inniytvf2IvA4akRvspwYoetM/1Kbtr02dLhmISKyLUV 3R+41qeAVEhtpkZZANEjRDa4ZF2ju6N/XWb60f7mNR5I6ohrqXQ7r13AwRGBDNfat6R+ 6Lov5q1CZVWQbHnabWWds6hjgsR/vWHVVdcVp/q6WP0iDopICWeFa6Vdj/fTJLnCw5Xt Bd3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id y19si19240445jad.52.2019.10.07.14.58.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:58:53 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) This will be used for recursing into externalDataStore Signed-off-by: Cole Robinson --- src/security/security_selinux.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index c0bfb581e3..feb703d325 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1919,15 +1919,16 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, static int -virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr, - virDomainDefPtr def, - virStorageSourcePtr src, - virSecurityDomainImageLabelFlags flags) +virSecuritySELinuxSetImageLabelRelative(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virStorageSourcePtr parent, + virSecurityDomainImageLabelFlags flags) { virStorageSourcePtr n; for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) { - if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, src) < 0) + if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, parent) < 0) return -1; if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) @@ -1938,6 +1939,15 @@ virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr, } +static int +virSecuritySELinuxSetImageLabel(virSecurityManagerPtr mgr, + virDomainDefPtr def, + virStorageSourcePtr src, + virSecurityDomainImageLabelFlags flags) +{ + return virSecuritySELinuxSetImageLabelRelative(mgr, def, src, src, flags); +} + struct virSecuritySELinuxMoveImageMetadataData { virSecurityManagerPtr mgr; const char *src; From patchwork Mon Oct 7 21:49:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 175438 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4849611ill; Mon, 7 Oct 2019 14:54:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrA//sHvyNYaFFf+KX9U46tRudHgAOi3dyPLGxxdWnOKMN61gSOf7xTwXGZorZOFb0zMNo X-Received: by 2002:a5e:9911:: with SMTP id t17mr13655955ioj.283.1570485245025; Mon, 07 Oct 2019 14:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570485245; cv=none; d=google.com; s=arc-20160816; b=nqD81yToI5yNw2gxmMpwSYEB/B/0tMSKn26AK1MVYyEmTATL+uKunhGm+8aPIRajLw e5Qdco/vaaL86a91UoYbhzEqCZGg+AusMv8ob4GwNiukackBzafrXOSSf4irEB2d7lRr ivIBL7xFM5EnyJjOehn27/eqQmDniLNGZo7hIhfXSO4PqxcP1Zs0nAzaSWUdja+3QEoz 8MrEaN85OpFfoIQyYnH0COeq1JXvzdnYNnFkuz1K/fm+kEH2Q6fG0x2rX2NxNH67/LVK QYmlINmIzBsssTbfX6a9UqrjDBKgO6vkpB0Fm4+GyXe5P7bLU8euRYvU/OSBXtXXnMq9 GQZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=XWa8XCwRus3mwFZX4aCMB+TG0mALjkaMthCPqznMddo=; b=QvsemhtJ/zpWjowRnr/hGwPNgnaZAVLTbNyjfkUTagCIJdxy5diceVVlpm680p+xRz LQn5FPnDkgtLRXFqHCkgHW+0JTsc8I3MxpcWUr4UlvX673Uk11FhyCnP+FiXyFaeAu2Z HkN6lnaQ6GY4iDVCCIGBqhhNAJ67ZCDB6AsFyqykQcpVShnOJEwISnCcg4GUjJMMIlWV hlKlsUdOwBmLjr+f9/WNriYMw9KFqnH7jndb41vkqGyo560/BWyH4B41kV4EHgS5pNZ1 jioq6hsF/zV5RQovvfVPYPyhEE+8hMaXwBQY2IhkWa/9QQm8Un0H62LzZcPsn7tX1WG1 taKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id e2si16828123ilc.4.2019.10.07.14.54.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2019 14:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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) Delivered-To: libvir-list@redhat.com 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: , 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) We mirror the labeling strategy that was used for its top image Signed-off-by: Cole Robinson --- src/security/security_selinux.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index feb703d325..2a3b7fc10d 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1844,7 +1844,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityManagerPtr mgr, virSecurityDeviceLabelDefPtr parent_seclabel = NULL; char *use_label = NULL; bool remember; - bool is_toplevel = parent == src; + bool is_toplevel = parent == src || parent->externalDataStore == src; int ret; if (!src->path || !virStorageSourceIsLocalStorage(src)) @@ -1931,6 +1931,14 @@ virSecuritySELinuxSetImageLabelRelative(virSecurityManagerPtr mgr, if (virSecuritySELinuxSetImageLabelInternal(mgr, def, n, parent) < 0) return -1; + if (n->externalDataStore && + virSecuritySELinuxSetImageLabelRelative(mgr, + def, + n->externalDataStore, + parent, + flags) < 0) + return -1; + if (!(flags & VIR_SECURITY_DOMAIN_IMAGE_LABEL_BACKING_CHAIN)) break; }