From 5f706cf9ca50573f42c44d154d18e6c813712610 Mon Sep 17 00:00:00 2001 Message-Id: <5f706cf9ca50573f42c44d154d18e6c813712610@dist-git> From: Martin Kletzander Date: Tue, 2 Aug 2016 13:32:35 +0200 Subject: [PATCH] qemu: Fix support for startupPolicy with volume/pool disks Until now we simply errored out when the translation from pool+volume failed. However, we should instead check whether that disk is needed or not since there is an option for that. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1168453 Signed-off-by: Martin Kletzander (cherry picked from commit a2b97a8d912a37ba1935bf98be4c332f42332236) Signed-off-by: Martin Kletzander --- src/qemu/qemu_domain.c | 18 ++++++++++++++++-- src/qemu/qemu_domain.h | 5 +++-- src/qemu/qemu_process.c | 20 +++++--------------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c74033b..8ab09c7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -27,6 +27,7 @@ #include "qemu_alias.h" #include "qemu_cgroup.h" #include "qemu_command.h" +#include "qemu_process.h" #include "qemu_parse_command.h" #include "qemu_capabilities.h" #include "qemu_migration.h" @@ -4110,11 +4111,14 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver, int -qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, +qemuDomainCheckDiskPresence(virConnectPtr conn, + virQEMUDriverPtr driver, virDomainObjPtr vm, - bool cold_boot) + unsigned int flags) { size_t i; + bool pretend = flags & VIR_QEMU_PROCESS_START_PRETEND; + bool cold_boot = flags & VIR_QEMU_PROCESS_START_COLD; VIR_DEBUG("Checking for disk presence"); for (i = vm->def->ndisks; i > 0; i--) { @@ -4122,6 +4126,16 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, virDomainDiskDefPtr disk = vm->def->disks[idx]; virStorageFileFormat format = virDomainDiskGetFormat(disk); + if (virStorageTranslateDiskSourcePool(conn, vm->def->disks[idx]) < 0) { + if (pretend || + qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) < 0) + return -1; + continue; + } + + if (pretend) + continue; + if (virStorageSourceIsEmpty(disk->src)) continue; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index bbec0d4..888732a 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -537,9 +537,10 @@ void qemuDomainSetFakeReboot(virQEMUDriverPtr driver, bool qemuDomainJobAllowed(qemuDomainObjPrivatePtr priv, qemuDomainJob job); -int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, +int qemuDomainCheckDiskPresence(virConnectPtr conn, + virQEMUDriverPtr driver, virDomainObjPtr vm, - bool start_with_state); + unsigned int flags); int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 129c070..2f0ef2b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4893,21 +4893,11 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuProcessSetupGraphics(driver, vm, flags) < 0) goto cleanup; - /* "volume" type disk's source must be translated before - * cgroup and security setting. - */ - for (i = 0; i < vm->def->ndisks; i++) { - if (virStorageTranslateDiskSourcePool(conn, vm->def->disks[i]) < 0) - goto cleanup; - } - - /* drop possibly missing disks from the definition. This needs to happen - * after the def is copied, aliases are set and disk sources are translated */ - if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) { - if (qemuDomainCheckDiskPresence(driver, vm, - flags & VIR_QEMU_PROCESS_START_COLD) < 0) - goto cleanup; - } + /* Drop possibly missing disks from the definition. This function + * also resolves source pool/volume into a path and it needs to + * happen after the def is copied and aliases are set. */ + if (qemuDomainCheckDiskPresence(conn, driver, vm, flags) < 0) + goto cleanup; VIR_DEBUG("Create domain masterKey"); if (qemuDomainMasterKeyCreate(vm) < 0) -- 2.9.2