mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
snapshot: fix double free of qemuImgBinary
Regression introduced in commit3881a470
, due to an improper rebase of a cleanup written beforehand but only applied after a rebased of a refactoring that created a new function in commit25fb3ef
. Also avoids passing NULL to printf %s. * src/qemu/qemu_driver.c: In qemuDomainSnapshotForEachQcow2() it free up the memory of qemu_driver->qemuImgBinary in the cleanup tag which leads to the garbage value of qemuImgBinary in qemu_driver struct and libvirtd crash when running "virsh snapshot-create" command a second time. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
7f2498efe4
commit
011eeb4130
@ -1681,14 +1681,13 @@ qemuDomainSnapshotForEachQcow2(struct qemud_driver *driver,
|
|||||||
bool try_all)
|
bool try_all)
|
||||||
{
|
{
|
||||||
const char *qemuimgarg[] = { NULL, "snapshot", NULL, NULL, NULL, NULL };
|
const char *qemuimgarg[] = { NULL, "snapshot", NULL, NULL, NULL, NULL };
|
||||||
int ret = -1;
|
|
||||||
int i;
|
int i;
|
||||||
bool skipped = false;
|
bool skipped = false;
|
||||||
|
|
||||||
qemuimgarg[0] = qemuFindQemuImgBinary(driver);
|
qemuimgarg[0] = qemuFindQemuImgBinary(driver);
|
||||||
if (qemuimgarg[0] == NULL) {
|
if (qemuimgarg[0] == NULL) {
|
||||||
/* qemuFindQemuImgBinary set the error */
|
/* qemuFindQemuImgBinary set the error */
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuimgarg[2] = op;
|
qemuimgarg[2] = op;
|
||||||
@ -1707,15 +1706,15 @@ qemuDomainSnapshotForEachQcow2(struct qemud_driver *driver,
|
|||||||
* disks in this VM may have the same snapshot name.
|
* disks in this VM may have the same snapshot name.
|
||||||
*/
|
*/
|
||||||
VIR_WARN("skipping snapshot action on %s",
|
VIR_WARN("skipping snapshot action on %s",
|
||||||
vm->def->disks[i]->info.alias);
|
vm->def->disks[i]->dst);
|
||||||
skipped = true;
|
skipped = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
_("Disk device '%s' does not support"
|
_("Disk device '%s' does not support"
|
||||||
" snapshotting"),
|
" snapshotting"),
|
||||||
vm->def->disks[i]->info.alias);
|
vm->def->disks[i]->dst);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuimgarg[4] = vm->def->disks[i]->src;
|
qemuimgarg[4] = vm->def->disks[i]->src;
|
||||||
@ -1727,16 +1726,12 @@ qemuDomainSnapshotForEachQcow2(struct qemud_driver *driver,
|
|||||||
skipped = true;
|
skipped = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = skipped ? 1 : 0;
|
return skipped ? 1 : 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(qemuimgarg[0]);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Discard one snapshot (or its metadata), without reparenting any children. */
|
/* Discard one snapshot (or its metadata), without reparenting any children. */
|
||||||
|
Loading…
Reference in New Issue
Block a user