From ad957d92a607731a00de8b946718d43cff8482a4 Mon Sep 17 00:00:00 2001 From: Peter Krempa <pkrempa@redhat.com> Date: Fri, 22 Apr 2022 17:15:33 +0200 Subject: [PATCH] qemu: domain: Inline qemuDomainStorageSourceHasAuth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The iSCSI hostdev code doesn't require the check for the empty drive and the check for the protocol because those are already guaranteed at that point. In qemuDomainSecretStorageSourcePrepare we don't need to check the network disk type either as it's now guaranteed by the definition validator. Thus both callers can simply check whether src->auth is present and the helper can be removed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 19 +++---------------- src/qemu/qemu_domain.h | 3 --- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1eb15c8989..7974cdb00b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1231,18 +1231,6 @@ qemuDomainSecretDiskDestroy(virDomainDiskDef *disk) } -bool -qemuDomainStorageSourceHasAuth(virStorageSource *src) -{ - if (!virStorageSourceIsEmpty(src) && - virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK && - src->auth) - return true; - - return false; -} - - static qemuDomainSecretInfo * qemuDomainSecretStorageSourcePrepareCookies(qemuDomainObjPrivate *priv, virStorageSource *src, @@ -1277,13 +1265,12 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivate *priv, const char *aliasformat) { qemuDomainStorageSourcePrivate *srcPriv; - bool hasAuth = qemuDomainStorageSourceHasAuth(src); bool hasEnc = src->encryption && src->encryption->nsecrets > 0; if (virStorageSourceIsEmpty(src)) return 0; - if (!hasAuth && !hasEnc && src->ncookies == 0) + if (!src->auth && !hasEnc && src->ncookies == 0) return 0; if (!(src->privateData = qemuDomainStorageSourcePrivateNew())) @@ -1291,7 +1278,7 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivate *priv, srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); - if (hasAuth) { + if (src->auth) { virSecretUsageType usageType = VIR_SECRET_USAGE_TYPE_ISCSI; if (src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) @@ -5663,7 +5650,7 @@ qemuDomainDeviceHostdevDefPostParseRestoreSecAlias(virDomainHostdevDef *hostdev, if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI || scsisrc->protocol != VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI || - !qemuDomainStorageSourceHasAuth(iscsisrc->src)) + !iscsisrc->src->auth) return 0; if (!(priv = qemuDomainStorageSourcePrivateFetch(iscsisrc->src))) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 0415a34908..c7125722e0 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -870,9 +870,6 @@ void qemuDomainSecretInfoDestroy(qemuDomainSecretInfo *secinfo); void qemuDomainSecretDiskDestroy(virDomainDiskDef *disk) ATTRIBUTE_NONNULL(1); -bool qemuDomainStorageSourceHasAuth(virStorageSource *src) - ATTRIBUTE_NONNULL(1); - qemuDomainSecretInfo * qemuDomainSecretInfoTLSNew(qemuDomainObjPrivate *priv, const char *srcAlias,