mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemuBlockReopenAccess: Fix update of 'readonly' state
Refactors done in24b667eeed
(and also9ec0e28e87
) broke the expected handling of the update of 'readonly' flag of a virStorage. The source is actually set to the proper state but rolled back to the previous state as the 'cleanup' label should have been 'error' and thus not reached on success. Additionally some of the code paths violate the statement in the comment after updating 'readonly' that only 'goto error' must be used. Fixes:24b667eeed
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
b510f8ca8a
commit
b83e87ca78
@ -3172,7 +3172,6 @@ qemuBlockReopenAccess(virDomainObj *vm,
|
||||
g_autoptr(virJSONValue) reopenoptions = virJSONValueNewArray();
|
||||
g_autoptr(virJSONValue) srcprops = NULL;
|
||||
int rc;
|
||||
int ret = -1;
|
||||
|
||||
VIR_DEBUG("nodename:'%s' current-ro:'%d requested-ro='%d'",
|
||||
qemuBlockStorageSourceGetEffectiveNodename(src),
|
||||
@ -3190,39 +3189,39 @@ qemuBlockReopenAccess(virDomainObj *vm,
|
||||
}
|
||||
|
||||
src->readonly = readonly;
|
||||
/* from now on all error paths must use 'goto cleanup' */
|
||||
/* from now on all error paths must use 'goto error' which restores the original state */
|
||||
|
||||
/* based on which is the current 'effecitve' layer we must reopen the
|
||||
* appropriate blockdev */
|
||||
if (qemuBlockStorageSourceGetFormatNodename(src)) {
|
||||
if (!(srcprops = qemuBlockStorageSourceGetFormatProps(src, src->backingStore)))
|
||||
return -1;
|
||||
goto error;
|
||||
} else if (qemuBlockStorageSourceGetSliceNodename(src)) {
|
||||
if (!(srcprops = qemuBlockStorageSourceGetBlockdevStorageSliceProps(src, true, false)))
|
||||
return -1;
|
||||
goto error;
|
||||
} else {
|
||||
if (!(srcprops = qemuBlockStorageSourceGetBackendProps(src,
|
||||
QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE)))
|
||||
return -1;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0)
|
||||
goto cleanup;
|
||||
goto error;
|
||||
|
||||
rc = qemuMonitorBlockdevReopen(qemuDomainGetMonitor(vm), &reopenoptions);
|
||||
|
||||
qemuDomainObjExitMonitor(vm);
|
||||
if (rc < 0)
|
||||
goto cleanup;
|
||||
goto error;
|
||||
|
||||
ret = 0;
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
error:
|
||||
src->readonly = !readonly;
|
||||
return ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user