提交 2a702717 编写于 作者: P Peter Krempa 提交者: Eric Blake

qemu: Fix crash when updating media with shared device

Mimic the fix done in 02b90972 to fix crash by
accessing an already freed structure. Also copy the explaining comment why the
pointer can't be accessed any more.
(cherry picked from commit 43b6f304)
上级 5fdccc85
......@@ -6073,12 +6073,15 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm,
goto end;
ret = qemuDomainChangeEjectableMedia(driver, vm, disk, orig_disk, force);
if (ret == 0) {
dev->data.disk = NULL;
/* 'disk' must not be accessed now - it has been freed.
* 'orig_disk' now points to the new disk, while 'dev_copy'
* now points to the old disk */
/* Need to remove the shared disk entry for the original
* disk src if the operation is either ejecting or updating.
*/
if (orig_disk->src && STRNEQ_NULLABLE(orig_disk->src, disk->src))
if (ret == 0) {
dev->data.disk = NULL;
ignore_value(qemuRemoveSharedDisk(driver, dev_copy->data.disk,
vm->def->name));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册