From patchwork Fri Mar 8 17:43: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: 159992 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp9000203jad; Fri, 8 Mar 2019 09:43:28 -0800 (PST) X-Google-Smtp-Source: APXvYqx/elckQiauUa5SuiOEe2vb8xjYrkzR5iptG9SEq44J2gMvNoVujFBeR4K/J3RgcsWN3Z+7 X-Received: by 2002:ae9:dec2:: with SMTP id s185mr14436575qkf.107.1552067007968; Fri, 08 Mar 2019 09:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552067007; cv=none; d=google.com; s=arc-20160816; b=QDXh3LIO3Uzt6GNOx12NIIXUBE3ZYBFoxee4M8Bcrw8+MxyizIXWtmx31fk1sTmLtv TMcYaO5HS5/9RHmsAlHhwpPnJXDxNW7WJFByW9h94QugfSTrGkIJC7WQWxQw/otR9diS poYPtA86PzYlYYbEeMNuosmyaeN7/S7JnrafnlmVwkKRSsqn8S5oGyW8MY1YrBPtCNy3 xPOjS+WkfAZ4cZA7PfKUuNamifG9X38HI5Ut5MKXvUSy0Md+DkCRuTMi7d9ug9QvZpdT 5nLLNEj/dCFEmPjgOb3YGVoqdWG+IyJEK2auXdluSAc1iJU/65eGlopCtQ9+HHFzyfJL K/XQ== 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:message-id:date:to:from:delivered-to; bh=MOCl9PYTjiFyaPQP7aISvlrT4Ie3OEWxZPeTMHnXpkA=; b=p4hymVZ/R/6tAaRa8trPnfoK3qowZBVMVQCs9Y+5KE62ahL1csqM2hWVy2/+ch27IG iAylMpUgvDtFSQ5cpWP9qTMO0YWy3wr4gmiFQioEyJA15TsvzHBJ/GWHvpma0ix4+d+F qlcAO4wGxyXgm5I12oy4AVypRYG3GnIU7iPHbKVO8Kr2Mr4+j6nG1VbX2v5DdJpIYru8 qKPw8vxJ5aMfFs+IkJ6TgTEiitccJV7A0zW0td17T2x4dFW9rezBDZt2FdoVDjW0BwPx Xgw95gfA4f/e6x7yz4m0j+uKuMP7WSXVRMTKOK2vq8P3ZbzBIpsaEGK5EFtbnwz4FaPL K4fw== 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 y38si983543qth.24.2019.03.08.09.43.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 09:43:27 -0800 (PST) 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 85A5E30718CB; Fri, 8 Mar 2019 17:43: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 D63F626365; Fri, 8 Mar 2019 17:43:25 +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 610343F5CC; Fri, 8 Mar 2019 17:43:24 +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 x28HhNLM005998 for ; Fri, 8 Mar 2019 12:43:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 260D317D94; Fri, 8 Mar 2019 17:43:23 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-126-65.rdu2.redhat.com [10.10.126.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE6104141; Fri, 8 Mar 2019 17:43:19 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 8 Mar 2019 12:43:17 -0500 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] test: storage: Fill in default vol types for every pool 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.40]); Fri, 08 Mar 2019 17:43:27 +0000 (UTC) Fill in a default volume type for every pool type, as reported by the VolGetInfo API. Now that we cover the whole enum, report an error for invalid values. Signed-off-by: Cole Robinson --- v2: Use virReportEnumRangeError and handle the error in the caller index ef754658f3..08970f8d6c 100644 -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5164,13 +5164,28 @@ testStorageVolDelete(virStorageVolPtr vol, static int testStorageVolumeTypeForPool(int pooltype) { - switch (pooltype) { - case VIR_STORAGE_POOL_DIR: - case VIR_STORAGE_POOL_FS: - case VIR_STORAGE_POOL_NETFS: - return VIR_STORAGE_VOL_FILE; - default: - return VIR_STORAGE_VOL_BLOCK; + switch ((virStoragePoolType) pooltype) { + case VIR_STORAGE_POOL_DIR: + case VIR_STORAGE_POOL_FS: + case VIR_STORAGE_POOL_NETFS: + case VIR_STORAGE_POOL_VSTORAGE: + return VIR_STORAGE_VOL_FILE; + case VIR_STORAGE_POOL_SHEEPDOG: + case VIR_STORAGE_POOL_ISCSI_DIRECT: + case VIR_STORAGE_POOL_GLUSTER: + case VIR_STORAGE_POOL_RBD: + return VIR_STORAGE_VOL_NETWORK; + case VIR_STORAGE_POOL_LOGICAL: + case VIR_STORAGE_POOL_DISK: + case VIR_STORAGE_POOL_MPATH: + case VIR_STORAGE_POOL_ISCSI: + case VIR_STORAGE_POOL_SCSI: + case VIR_STORAGE_POOL_ZFS: + return VIR_STORAGE_VOL_BLOCK; + case VIR_STORAGE_POOL_LAST: + default: + virReportEnumRangeError(virStoragePoolType, pooltype); + return -1; } } @@ -5193,7 +5208,8 @@ testStorageVolGetInfo(virStorageVolPtr vol, goto cleanup; memset(info, 0, sizeof(*info)); - info->type = testStorageVolumeTypeForPool(def->type); + if ((info->type = testStorageVolumeTypeForPool(def->type)) < 0) + goto cleanup; info->capacity = privvol->target.capacity; info->allocation = privvol->target.allocation; ret = 0;