qemu: driver: Remove pre-blockdev code paths from qemuDomainBlockCommit

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-07-20 12:12:41 +02:00
parent 8c67518256
commit b04482d67c

View File

@ -15412,24 +15412,16 @@ qemuDomainBlockCommit(virDomainPtr dom,
virQEMUDriver *driver = dom->conn->privateData; virQEMUDriver *driver = dom->conn->privateData;
qemuDomainObjPrivate *priv; qemuDomainObjPrivate *priv;
virDomainObj *vm = NULL; virDomainObj *vm = NULL;
const char *device = NULL;
const char *jobname = NULL;
int ret = -1; int ret = -1;
virDomainDiskDef *disk = NULL; virDomainDiskDef *disk = NULL;
virStorageSource *topSource; virStorageSource *topSource;
virStorageSource *baseSource = NULL; virStorageSource *baseSource = NULL;
virStorageSource *top_parent = NULL; virStorageSource *top_parent = NULL;
bool clean_access = false; bool clean_access = false;
g_autofree char *topPath = NULL;
g_autofree char *basePath = NULL;
g_autofree char *backingPath = NULL; g_autofree char *backingPath = NULL;
unsigned long long speed = bandwidth; unsigned long long speed = bandwidth;
qemuBlockJobData *job = NULL; qemuBlockJobData *job = NULL;
g_autoptr(virStorageSource) mirror = NULL; g_autoptr(virStorageSource) mirror = NULL;
const char *nodetop = NULL;
const char *nodebase = NULL;
bool persistjob = false;
bool blockdev = false;
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW | virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
VIR_DOMAIN_BLOCK_COMMIT_ACTIVE | VIR_DOMAIN_BLOCK_COMMIT_ACTIVE |
@ -15450,8 +15442,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (virDomainObjCheckActive(vm) < 0) if (virDomainObjCheckActive(vm) < 0)
goto endjob; goto endjob;
blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
/* Convert bandwidth MiB to bytes, if necessary */ /* Convert bandwidth MiB to bytes, if necessary */
if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) { if (!(flags & VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES)) {
if (speed > LLONG_MAX >> 20) { if (speed > LLONG_MAX >> 20) {
@ -15482,12 +15472,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0) if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
goto endjob; goto endjob;
if (!blockdev && (flags & VIR_DOMAIN_BLOCK_COMMIT_DELETE)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("deleting committed images is not supported by this VM"));
goto endjob;
}
if (!top || STREQ(top, disk->dst)) if (!top || STREQ(top, disk->dst))
topSource = disk->src; topSource = disk->src;
else if (!(topSource = virStorageSourceChainLookup(disk->src, NULL, top, else if (!(topSource = virStorageSourceChainLookup(disk->src, NULL, top,
@ -15543,7 +15527,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE && if (flags & VIR_DOMAIN_BLOCK_COMMIT_RELATIVE &&
topSource != disk->src) { topSource != disk->src) {
if (blockdev && top_parent && if (top_parent &&
qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0) qemuBlockUpdateRelativeBacking(vm, top_parent, disk->src) < 0)
goto endjob; goto endjob;
@ -15587,39 +15571,21 @@ qemuDomainBlockCommit(virDomainPtr dom,
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE; disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_NONE;
/* Start the commit operation. Pass the user's original spelling, if (!backingPath && top_parent &&
* if any, through to qemu, since qemu may behave differently !(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
* depending on whether the input was specified as relative or goto endjob;
* absolute (that is, our absolute top_canon may do the wrong
* thing if the user specified a relative name). */
if (blockdev) {
persistjob = true;
jobname = job->name;
nodetop = topSource->nodeformat;
nodebase = baseSource->nodeformat;
device = qemuDomainDiskGetTopNodename(disk);
if (!backingPath && top_parent &&
!(backingPath = qemuBlockGetBackingStoreString(baseSource, false)))
goto endjob;
} else {
device = job->name;
}
qemuDomainObjEnterMonitor(vm); qemuDomainObjEnterMonitor(vm);
if (!blockdev) { ret = qemuMonitorBlockCommit(priv->mon,
basePath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src, qemuDomainDiskGetTopNodename(disk),
baseSource); job->name,
topPath = qemuMonitorDiskNameLookup(priv->mon, device, disk->src, true,
topSource); NULL,
} topSource->nodeformat,
NULL,
if (blockdev || (basePath && topPath)) baseSource->nodeformat,
ret = qemuMonitorBlockCommit(priv->mon, device, jobname, persistjob, backingPath, speed);
topPath, nodetop, basePath, nodebase,
backingPath, speed);
qemuDomainObjExitMonitor(vm); qemuDomainObjExitMonitor(vm);