qemuBlockJobProcessEventCompletedPull: Add backingStore terminators if base is NULL

When doing a blockpull with NULL base the full contents of the disk are
pulled into the topmost image which then becomes fully self-contained.

qemuBlockJobProcessEventCompletedPull doesn't install the backing chain
terminators though, although it's guaranteed that there will be no
backing chain behind disk->src.

Add the terminators for completness and for disabling backing chain
detection on further boots.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Peter Krempa 2021-04-12 17:42:23 +02:00
parent 46e748aa02
commit b4d0207906

View File

@ -992,6 +992,7 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPtr driver,
qemuBlockJobDataPtr job, qemuBlockJobDataPtr job,
qemuDomainAsyncJob asyncJob) qemuDomainAsyncJob asyncJob)
{ {
virStorageSource *base = NULL;
virStorageSourcePtr baseparent = NULL; virStorageSourcePtr baseparent = NULL;
virDomainDiskDefPtr cfgdisk = NULL; virDomainDiskDefPtr cfgdisk = NULL;
virStorageSourcePtr cfgbase = NULL; virStorageSourcePtr cfgbase = NULL;
@ -1015,8 +1016,11 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPtr driver,
return; return;
if (job->data.pull.base) { if (job->data.pull.base) {
base = job->data.pull.base;
if (cfgdisk) if (cfgdisk)
cfgbase = cfgdisk->src->backingStore; cfgbase = cfgdisk->src->backingStore;
for (n = job->disk->src->backingStore; n && n != job->data.pull.base; n = n->backingStore) { for (n = job->disk->src->backingStore; n && n != job->data.pull.base; n = n->backingStore) {
/* find the image on top of 'base' */ /* find the image on top of 'base' */
@ -1027,10 +1031,17 @@ qemuBlockJobProcessEventCompletedPull(virQEMUDriverPtr driver,
baseparent = n; baseparent = n;
} }
} else {
/* create terminators for the chain; since we are pulling everything
* into the top image the chain is automatically considered terminated */
base = virStorageSourceNew();
if (cfgdisk)
cfgbase = virStorageSourceNew();
} }
tmp = job->disk->src->backingStore; tmp = job->disk->src->backingStore;
job->disk->src->backingStore = job->data.pull.base; job->disk->src->backingStore = base;
if (baseparent) if (baseparent)
baseparent->backingStore = NULL; baseparent->backingStore = NULL;
qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, tmp); qemuBlockJobEventProcessConcludedRemoveChain(driver, vm, asyncJob, tmp);