From bd57977391d0ece023205526829f667772f2ef2d Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 22 Apr 2015 11:41:22 +0200 Subject: [PATCH] qemu: migration: Refactor hostdev validation in migration check The hostdev check can error out right away. --- src/qemu/qemu_migration.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 9344382286..1da687c0cf 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1951,7 +1951,6 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm, { int nsnapshots; int pauseReason; - bool forbid; size_t i; if (vm) { @@ -1995,22 +1994,16 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm, } /* Migration with USB host devices is allowed, all other devices are - * forbidden. - */ - forbid = false; + * forbidden. */ for (i = 0; i < def->nhostdevs; i++) { virDomainHostdevDefPtr hostdev = def->hostdevs[i]; if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { - forbid = true; - break; + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain has assigned non-USB host devices")); + return false; } } - if (forbid) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain has assigned non-USB host devices")); - return false; - } if (def->cpu && def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH) { for (i = 0; i < def->cpu->nfeatures; i++) { -- GitLab