mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
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 <mkletzan@redhat.com>
This commit is contained in:
parent
779a4ea906
commit
a2b97a8d91
@ -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"
|
||||
@ -4213,11 +4214,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--) {
|
||||
@ -4225,6 +4229,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;
|
||||
|
||||
|
@ -545,9 +545,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,
|
||||
|
@ -4792,21 +4792,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)
|
||||
|
Loading…
Reference in New Issue
Block a user