From nobody Mon Feb 9 00:56:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1653311411; cv=none; d=zohomail.com; s=zohoarc; b=MMrX+lwMldTes9lloiU+k2jseqzCPvG4ypn0r1kTOe9bFpeKj/+rF7HRxj43TdPAdThE2B0l5Y/oK1hmXBITbAeIQ0nrwHAUryi+zfcJyfv2epXRZobtwnrJFUQ50ymhsUea2iTBGSbBM/gVuTJYdN5xwBDn9cWvjGzcAERDHNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653311411; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r59vj1lY19GSF0k8xXZsnKNxM3ZueyNlQfVA5rRw+Ls=; b=ZBwsL98JiXPyKnnkAP9rj3hbMRkJ4HkTy19tcgI2LX3wkUiHXeTmzGo7a6zTc2uBhLJR3CSzu6VZUDPizef+SgHsXCIP/fMDh782AWFpGaNKTl6ZMVzYA2dWkd2Rwm/hkTTy8X98vWEf0HqqAlQvBZ598gZOsw/98MRU0loIsmM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1653311411681420.454688219677; Mon, 23 May 2022 06:10:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-629-kqenD-cdOuODlq8_0DEVGw-1; Mon, 23 May 2022 09:09:12 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B7CB100BAC9; Mon, 23 May 2022 13:09:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83BCA401E9D; Mon, 23 May 2022 13:09:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 247D4194705A; Mon, 23 May 2022 13:09:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 00D9D1947059 for ; Mon, 23 May 2022 13:08:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C8527400E13A; Mon, 23 May 2022 13:08:56 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5278C400E115 for ; Mon, 23 May 2022 13:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653311408; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=r59vj1lY19GSF0k8xXZsnKNxM3ZueyNlQfVA5rRw+Ls=; b=f9jgx9vFErXj1wMsH/cWC5S6wbwU+urIUrj0fb+8CfHVQLguLt4bu0wLbPQdA5XgTfq5g3 f40PR3KjxfwGe0SyRzna1pqAgqqQDqRsOnUpX4WIodJT84m3+wdOuvoA7nRHsoTiQtg/z+ /Myc6YsE0tfJztxBzLQ8hwaQO0UHaQs= X-MC-Unique: kqenD-cdOuODlq8_0DEVGw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/17] virStorageSourceGetActualType: Change type of retval Date: Mon, 23 May 2022 15:08:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1653311412919100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virStorageSourceGetActualType() function returns either virStorageSource->type (which is of type virStorageType), or virStorageSourcePoolDef->type, which really stores a value of the same enum. Thus, the latter struct can be changed so that the virStorageSourceGetActualType() function can return correct type instead of generic int. Signed-off-by: Michal Privoznik Reviewed-by: Boris Fiuczynski --- src/conf/storage_source_conf.c | 2 +- src/conf/storage_source_conf.h | 4 ++-- src/libxl/libxl_conf.c | 2 +- src/libxl/libxl_domain.c | 2 +- src/libxl/xen_xl.c | 4 ++-- src/locking/domain_lock.c | 2 +- src/qemu/qemu_block.c | 12 ++++++------ src/qemu/qemu_command.c | 8 ++++---- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_migration.c | 4 ++-- src/qemu/qemu_snapshot.c | 16 ++++++++-------- src/storage_file/storage_source.c | 4 ++-- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 1a7284ec12..2b4cf5e241 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -1004,7 +1004,7 @@ virStorageSourcePoolDefFree(virStorageSourcePoolDef *= def) * and virDomainDiskTranslateSourcePool was called on @def the actual type * of the storage volume is returned rather than VIR_STORAGE_TYPE_VOLUME. */ -int +virStorageType virStorageSourceGetActualType(const virStorageSource *def) { if (def->type =3D=3D VIR_STORAGE_TYPE_VOLUME && diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index 035ea7016d..f2440cec6a 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -199,7 +199,7 @@ struct _virStorageSourcePoolDef { char *volume; /* volume name */ int voltype; /* virStorageVolType, internal only */ int pooltype; /* virStoragePoolType from storage_conf.h, internal only= */ - int actualtype; /* virStorageType, internal only */ + virStorageType actualtype; /* internal only */ int mode; /* virStorageSourcePoolMode, currently makes sense only for = iscsi pool */ }; =20 @@ -469,7 +469,7 @@ virStorageSourcePoolDefFree(virStorageSourcePoolDef *de= f); void virStorageSourceClear(virStorageSource *def); =20 -int +virStorageType virStorageSourceGetActualType(const virStorageSource *def); =20 bool diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 726ecdc945..401e47344e 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1067,7 +1067,7 @@ libxlMakeDisk(virDomainDiskDef *l_disk, libxl_device_= disk *x_disk) { const char *driver =3D virDomainDiskGetDriver(l_disk); int format =3D virDomainDiskGetFormat(l_disk); - int actual_type =3D virStorageSourceGetActualType(l_disk->src); + virStorageType actual_type =3D virStorageSourceGetActualType(l_disk->s= rc); =20 if (actual_type =3D=3D VIR_STORAGE_TYPE_NETWORK) { if (STRNEQ_NULLABLE(driver, "qemu")) { diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index af938192a9..49ac09d8a4 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -330,7 +330,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDef *dev, =20 if (dev->type =3D=3D VIR_DOMAIN_DEVICE_DISK) { virDomainDiskDef *disk =3D dev->data.disk; - int actual_type =3D virStorageSourceGetActualType(disk->src); + virStorageType actual_type =3D virStorageSourceGetActualType(disk-= >src); int format =3D virDomainDiskGetFormat(disk); =20 /* for network-based disks, set 'qemu' as the default driver */ diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 6b7f638783..eb3b0b3718 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1489,14 +1489,14 @@ xenFormatXLDiskSrcNet(virStorageSource *src) static int xenFormatXLDiskSrc(virStorageSource *src, char **srcstr) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); =20 *srcstr =3D NULL; =20 if (virStorageSourceIsEmpty(src)) return 0; =20 - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c index 9934e91aa9..8966980532 100644 --- a/src/locking/domain_lock.c +++ b/src/locking/domain_lock.c @@ -72,7 +72,7 @@ static int virDomainLockManagerAddImage(virLockManager *l= ock, virStorageSource *src) { unsigned int diskFlags =3D 0; - int type =3D virStorageSourceGetActualType(src); + virStorageType type =3D virStorageSourceGetActualType(src); =20 if (!src->path) return 0; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 60e03d418e..877c66d62b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1128,7 +1128,7 @@ virJSONValue * qemuBlockStorageSourceGetBackendProps(virStorageSource *src, unsigned int flags) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); g_autoptr(virJSONValue) fileprops =3D NULL; const char *driver =3D NULL; virTristateBool aro =3D VIR_TRISTATE_BOOL_ABSENT; @@ -1145,7 +1145,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourc= e *src, ro =3D VIR_TRISTATE_BOOL_NO; } =20 - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: if (virStorageSourceIsBlockLocal(src)) { @@ -2200,7 +2200,7 @@ char * qemuBlockGetBackingStoreString(virStorageSource *src, bool pretty) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); g_autoptr(virJSONValue) backingProps =3D NULL; g_autoptr(virJSONValue) sliceProps =3D NULL; virJSONValue *props =3D NULL; @@ -2599,12 +2599,12 @@ int qemuBlockStorageSourceCreateGetStorageProps(virStorageSource *src, virJSONValue **props) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); g_autoptr(virJSONValue) location =3D NULL; const char *driver =3D NULL; const char *filename =3D NULL; =20 - switch ((virStorageType) actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_FILE: driver =3D "file"; filename =3D src->path; @@ -2745,7 +2745,7 @@ qemuBlockStorageSourceCreateStorage(virDomainObj *vm, virStorageSource *chain, virDomainAsyncJob asyncJob) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); g_autoptr(virJSONValue) createstorageprops =3D NULL; int ret; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 34dffb0615..33069ea131 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1736,7 +1736,7 @@ qemuGetDriveSourceString(virStorageSource *src, qemuDomainSecretInfo *secinfo, char **source) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); =20 *source =3D NULL; =20 @@ -1744,7 +1744,7 @@ qemuGetDriveSourceString(virStorageSource *src, if (virStorageSourceIsEmpty(src)) return 1; =20 - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_DIR: @@ -1803,7 +1803,7 @@ qemuDiskBusIsSD(int bus) static bool qemuDiskSourceNeedsProps(virStorageSource *src) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); =20 if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_GLUSTER && @@ -1879,7 +1879,7 @@ static int qemuBuildDriveSourceStr(virDomainDiskDef *disk, virBuffer *buf) { - int actualType =3D virStorageSourceGetActualType(disk->src); + virStorageType actualType =3D virStorageSourceGetActualType(disk->src); qemuDomainStorageSourcePrivate *srcpriv =3D QEMU_DOMAIN_STORAGE_SOURCE= _PRIVATE(disk->src); qemuDomainSecretInfo *secinfo =3D NULL; qemuDomainSecretInfo *encinfo =3D NULL; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 31e60c7359..948ab76304 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4809,7 +4809,7 @@ qemuDomainValidateStorageSource(virStorageSource *src, virQEMUCaps *qemuCaps, bool maskBlockdev) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); bool blockdev =3D virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV); =20 if (maskBlockdev) @@ -10932,7 +10932,7 @@ qemuDomainPrepareDiskSource(virDomainDiskDef *disk, /* set default format for storage pool based disks */ if (disk->src->type =3D=3D VIR_STORAGE_TYPE_VOLUME && disk->src->format <=3D VIR_STORAGE_FILE_NONE) { - int actualType =3D virStorageSourceGetActualType(disk->src); + virStorageType actualType =3D virStorageSourceGetActualType(disk->= src); =20 if (actualType =3D=3D VIR_STORAGE_TYPE_DIR) disk->src->format =3D VIR_STORAGE_FILE_FAT; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6631edb9d6..1d50aa5271 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14790,7 +14790,7 @@ qemuDomainBlockCopyValidateMirror(virStorageSource = *mirror, const char *dst, bool *reuse) { - int desttype =3D virStorageSourceGetActualType(mirror); + virStorageType desttype =3D virStorageSourceGetActualType(mirror); struct stat st; =20 if (!virStorageSourceIsLocalStorage(mirror)) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 176c25cd11..97ce9ac27e 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1504,7 +1504,7 @@ qemuMigrationSrcIsSafe(virDomainDef *def, for (i =3D 0; i < def->ndisks; i++) { virDomainDiskDef *disk =3D def->disks[i]; const char *src =3D virDomainDiskGetSource(disk); - int actualType =3D virStorageSourceGetActualType(disk->src); + virStorageType actualType =3D virStorageSourceGetActualType(disk->= src); bool unsafe =3D false; =20 /* Disks without any source (i.e. floppies and CD-ROMs) @@ -1519,7 +1519,7 @@ qemuMigrationSrcIsSafe(virDomainDef *def, continue; =20 /* However, disks on local FS (e.g. ext4) are not safe. */ - switch ((virStorageType) actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_FILE: if ((rc =3D virFileIsSharedFS(src)) < 0) { return false; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index b62fab7bb3..c6beeda1d0 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -380,10 +380,10 @@ static int qemuSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDef *snapdisk, virDomainDiskDef *domdisk) { - int domDiskType =3D virStorageSourceGetActualType(domdisk->src); - int snapDiskType =3D virStorageSourceGetActualType(snapdisk->src); + virStorageType domDiskType =3D virStorageSourceGetActualType(domdisk->= src); + virStorageType snapDiskType =3D virStorageSourceGetActualType(snapdisk= ->src); =20 - switch ((virStorageType)domDiskType) { + switch (domDiskType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: break; @@ -425,7 +425,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapsh= otDiskDef *snapdisk, return -1; } =20 - switch ((virStorageType)snapDiskType) { + switch (snapDiskType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: break; @@ -456,7 +456,7 @@ qemuSnapshotPrepareDiskExternalActive(virDomainObj *vm, virDomainDiskDef *domdisk, bool blockdev) { - int actualType =3D virStorageSourceGetActualType(snapdisk->src); + virStorageType actualType =3D virStorageSourceGetActualType(snapdisk->= src); =20 if (snapdisk->snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_MANUAL) return 0; @@ -471,7 +471,7 @@ qemuSnapshotPrepareDiskExternalActive(virDomainObj *vm, if (!qemuDomainDiskBlockJobIsSupported(vm, domdisk)) return -1; =20 - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: break; @@ -620,7 +620,7 @@ static int qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, bool active) { - int actualType; + virStorageType actualType; =20 /* active disks are handled by qemu itself so no need to worry about t= hose */ if (active) @@ -631,7 +631,7 @@ qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, =20 actualType =3D virStorageSourceGetActualType(disk->src); =20 - switch ((virStorageType)actualType) { + switch (actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: return 0; diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index 698b9eb79d..dd2bb2641d 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -807,7 +807,7 @@ static int virStorageSourceGetBackendForSupportCheck(const virStorageSource *src, virStorageFileBackend **backend) { - int actualType; + virStorageType actualType; =20 =20 if (!src) { @@ -944,7 +944,7 @@ int virStorageSourceInitAs(virStorageSource *src, uid_t uid, gid_t gid) { - int actualType =3D virStorageSourceGetActualType(src); + virStorageType actualType =3D virStorageSourceGetActualType(src); virStorageDriverData *drv =3D g_new0(virStorageDriverData, 1); =20 src->drv =3D drv; --=20 2.35.1