From nobody Wed Feb 11 08:40:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491403544486959.4237085162206; Wed, 5 Apr 2017 07:45:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 534DA75EBE; Wed, 5 Apr 2017 14:45:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3692FAC6EB; Wed, 5 Apr 2017 14:45: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 48E215EC6F; Wed, 5 Apr 2017 14:45:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v35EjBQh008218 for ; Wed, 5 Apr 2017 10:45:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id D208785F6F; Wed, 5 Apr 2017 14:45:11 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-19.phx2.redhat.com [10.3.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FF6D85F66 for ; Wed, 5 Apr 2017 14:45:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 534DA75EBE Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 534DA75EBE From: John Ferlan To: libvir-list@redhat.com Date: Wed, 5 Apr 2017 10:45:04 -0400 Message-Id: <20170405144504.27594-5-jferlan@redhat.com> In-Reply-To: <20170405144504.27594-1-jferlan@redhat.com> References: <20170405144504.27594-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/4] conf: Check for storage conflicts across pool types 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 05 Apr 2017 14:45:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1233129 The virStoragePoolObjSourceFindDuplicate logic used by PoolCreateXML and PoolDefineXML avoids comparing the new definition against "other" pool types. This can cause unexpected corruption if two different pool source types used the same source device path. For example, a 'disk' pool using source type device=3D/dev/sdc could be unwittingly overwritten by using /dev/sdc for a 'logical' pool which also uses the source device path. So rather than blindly ignoring those checks when def->type !=3D pool->def->type - have the pool->def->type switch logic handle the check for which def->type's should be checked. Signed-off-by: John Ferlan --- src/conf/virstorageobj.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 1623162..ae327d9 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -794,6 +794,9 @@ virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolOb= jPtr pool, virStoragePoolObjPtr matchpool =3D NULL; =20 if (pool->def->type =3D=3D VIR_STORAGE_POOL_ISCSI) { + if (def->type !=3D VIR_STORAGE_POOL_ISCSI) + return NULL; + if ((matchpool =3D virStoragePoolSourceFindDuplicateDevices(pool, = def))) { if (!virStoragePoolSourceISCSIMatch(matchpool, def)) return NULL; @@ -801,6 +804,9 @@ virStoragePoolObjSourceMatchTypeDEVICE(virStoragePoolOb= jPtr pool, return matchpool; } =20 + if (def->type =3D=3D VIR_STORAGE_POOL_ISCSI) + return NULL; + /* VIR_STORAGE_POOL_FS * VIR_STORAGE_POOL_LOGICAL * VIR_STORAGE_POOL_DISK @@ -822,8 +828,6 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr conn, /* Check the pool list for duplicate underlying storage */ for (i =3D 0; i < pools->count; i++) { pool =3D pools->objs[i]; - if (def->type !=3D pool->def->type) - continue; =20 /* Don't match against ourself if re-defining existing pool ! */ if (STREQ(pool->def->name, def->name)) @@ -835,11 +839,14 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr co= nn, case VIR_STORAGE_POOL_DIR: case VIR_STORAGE_POOL_GLUSTER: case VIR_STORAGE_POOL_NETFS: - matchpool =3D virStoragePoolObjSourceMatchTypeDIR(pool, def); + if (def->type =3D=3D pool->def->type) + matchpool =3D virStoragePoolObjSourceMatchTypeDIR(pool, de= f); break; =20 case VIR_STORAGE_POOL_SCSI: - matchpool =3D virStoragePoolObjSourceMatchTypeISCSI(pool, def,= conn); + if (def->type =3D=3D pool->def->type) + matchpool =3D virStoragePoolObjSourceMatchTypeISCSI(pool, = def, + conn); break; =20 case VIR_STORAGE_POOL_ISCSI: @@ -847,22 +854,33 @@ virStoragePoolObjSourceFindDuplicate(virConnectPtr co= nn, case VIR_STORAGE_POOL_LOGICAL: case VIR_STORAGE_POOL_DISK: case VIR_STORAGE_POOL_ZFS: - matchpool =3D virStoragePoolObjSourceMatchTypeDEVICE(pool, def= ); + if (def->type =3D=3D VIR_STORAGE_POOL_ISCSI || + def->type =3D=3D VIR_STORAGE_POOL_FS || + def->type =3D=3D VIR_STORAGE_POOL_LOGICAL || + def->type =3D=3D VIR_STORAGE_POOL_DISK || + def->type =3D=3D VIR_STORAGE_POOL_ZFS) + matchpool =3D virStoragePoolObjSourceMatchTypeDEVICE(pool,= def); break; =20 case VIR_STORAGE_POOL_SHEEPDOG: - if (virStoragePoolSourceMatchSingleHost(&pool->def->source, + if (def->type =3D=3D pool->def->type && + virStoragePoolSourceMatchSingleHost(&pool->def->source, &def->source)) matchpool =3D pool; break; + case VIR_STORAGE_POOL_MPATH: /* Only one mpath pool is valid per host */ - matchpool =3D pool; + if (def->type =3D=3D pool->def->type) + matchpool =3D pool; break; + case VIR_STORAGE_POOL_VSTORAGE: - if (STREQ(pool->def->source.name, def->source.name)) + if (def->type =3D=3D pool->def->type && + STREQ(pool->def->source.name, def->source.name)) matchpool =3D pool; break; + case VIR_STORAGE_POOL_RBD: case VIR_STORAGE_POOL_LAST: break; --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list