From 4c4c07b94169ad52f6fc3378f397528a698cf5cf Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 7 Dec 2020 13:04:29 +0100 Subject: [PATCH] qemuDomainGetStorageSourceByDevstr: Use virDomainDiskByTarget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function replaces the open-coded block. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_domain.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e4322aa2f6..fc24b551e5 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9953,7 +9953,6 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, virStorageSourcePtr src = NULL; g_autofree char *target = NULL; unsigned int idx; - size_t i; if (virStorageFileParseBackingStoreStr(devstr, &target, &idx) < 0) { virReportError(VIR_ERR_INVALID_ARG, @@ -9961,14 +9960,7 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, return NULL; } - for (i = 0; i < def->ndisks; i++) { - if (STREQ(target, def->disks[i]->dst)) { - disk = def->disks[i]; - break; - } - } - - if (!disk) { + if (!(disk = virDomainDiskByTarget(def, target))) { virReportError(VIR_ERR_INVALID_ARG, _("failed to find disk '%s'"), target); return NULL;