Introduce a new function to prepare domain disks which will also do the volume source to actual disk source translation. --- src/qemu/qemu_domain.c | 10 +--------- src/qemu/qemu_domain.h | 3 +-- src/qemu/qemu_process.c | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 8aa082618..bf2ce29bf 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5682,8 +5682,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver, int -qemuDomainCheckDiskPresence(virConnectPtr conn, - virQEMUDriverPtr driver, +qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int flags) { @@ -5697,13 +5696,6 @@ qemuDomainCheckDiskPresence(virConnectPtr conn, 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; diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index b3db50c2f..914f2bec9 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -644,8 +644,7 @@ int qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver, size_t diskIndex, bool cold_boot); -int qemuDomainCheckDiskPresence(virConnectPtr conn, - virQEMUDriverPtr driver, +int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int flags); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index dfaacbcb9..ad7c7ee81 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5275,6 +5275,32 @@ qemuProcessPrepareDomainNUMAPlacement(virDomainObjPtr vm, } +static int +qemuProcessPrepareDomainStorage(virConnectPtr conn, + virQEMUDriverPtr driver, + virDomainObjPtr vm, + unsigned int flags) +{ + size_t i; + bool cold_boot = flags & VIR_QEMU_PROCESS_START_COLD; + + for (i = vm->def->ndisks; i > 0; i--) { + size_t idx = i - 1; + virDomainDiskDefPtr disk = vm->def->disks[idx]; + + if (virStorageTranslateDiskSourcePool(conn, disk) < 0) { + if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) < 0) + return -1; + + /* disk source was dropped */ + continue; + } + } + + return 0; +} + + /** * qemuProcessPrepareDomain: * @conn: connection object (for looking up storage volumes) @@ -5351,10 +5377,12 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuProcessSetupGraphics(driver, vm, flags) < 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) + VIR_DEBUG("Setting up storage"); + if (qemuProcessPrepareDomainStorage(conn, driver, vm, flags) < 0) + goto cleanup; + + /* Drop possibly missing disks from the definition. */ + if (qemuDomainCheckDiskPresence(driver, vm, flags) < 0) goto cleanup; VIR_DEBUG("Create domain masterKey"); -- 2.14.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list