qemu: process: Move 'volume' translation to domain prepare stage
Introduce a new function to prepare domain disks which will also do the volume source to actual disk source translation. The 'pretend' condition is not transferred to the new location since it does not help in writing tests and also no tests abuse it.
This commit is contained in:
parent
76039bba87
commit
f1cec8829e
@ -5682,8 +5682,7 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainCheckDiskPresence(virConnectPtr conn,
|
qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
|
||||||
virQEMUDriverPtr driver,
|
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
@ -5697,13 +5696,6 @@ qemuDomainCheckDiskPresence(virConnectPtr conn,
|
|||||||
virDomainDiskDefPtr disk = vm->def->disks[idx];
|
virDomainDiskDefPtr disk = vm->def->disks[idx];
|
||||||
virStorageFileFormat format = virDomainDiskGetFormat(disk);
|
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)
|
if (pretend)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -644,8 +644,7 @@ int qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
|
|||||||
size_t diskIndex,
|
size_t diskIndex,
|
||||||
bool cold_boot);
|
bool cold_boot);
|
||||||
|
|
||||||
int qemuDomainCheckDiskPresence(virConnectPtr conn,
|
int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
|
||||||
virQEMUDriverPtr driver,
|
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
@ -5284,6 +5284,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:
|
* qemuProcessPrepareDomain:
|
||||||
* @conn: connection object (for looking up storage volumes)
|
* @conn: connection object (for looking up storage volumes)
|
||||||
@ -5360,10 +5386,12 @@ qemuProcessPrepareDomain(virConnectPtr conn,
|
|||||||
if (qemuProcessSetupGraphics(driver, vm, flags) < 0)
|
if (qemuProcessSetupGraphics(driver, vm, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Drop possibly missing disks from the definition. This function
|
VIR_DEBUG("Setting up storage");
|
||||||
* also resolves source pool/volume into a path and it needs to
|
if (qemuProcessPrepareDomainStorage(conn, driver, vm, flags) < 0)
|
||||||
* happen after the def is copied and aliases are set. */
|
goto cleanup;
|
||||||
if (qemuDomainCheckDiskPresence(conn, driver, vm, flags) < 0)
|
|
||||||
|
/* Drop possibly missing disks from the definition. */
|
||||||
|
if (qemuDomainCheckDiskPresence(driver, vm, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
VIR_DEBUG("Create domain masterKey");
|
VIR_DEBUG("Create domain masterKey");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user