]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainAttachDiskGenericTransient: Add NULL check in case the overlay disk already...
authorMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Wed, 26 May 2021 20:19:22 +0000 (16:19 -0400)
committerJán Tomko <jtomko@redhat.com>
Thu, 27 May 2021 07:37:58 +0000 (09:37 +0200)
When <transient shareBacking='yes'> is set to a disk and the overlay
disk already exists because of something abnormal, libvirt is terminated
by Segmentation fault.

  # virsh start Test0
  error: Disconnected from qemu:///system due to end of file
  error: Failed to start domain 'Test0'
  error: End of file while reading data: Input/output error

Add NULL check for snapdiskdef so that the rollback can work correctly.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Fixes: 2e94002d2ace4e4a6dbfc13a84fdab28f22c5c4a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_hotplug.c

index 9ff6175dd3dffbe50c9b97d3039b8698e9d24ae0..0640cdd9f791a32cf14902dbda0e4079f42fa311 100644 (file)
@@ -695,7 +695,9 @@ qemuDomainAttachDiskGenericTransient(virDomainObj *vm,
     g_autoptr(qemuSnapshotDiskContext) snapctxt = NULL;
     g_autoptr(virDomainSnapshotDiskDef) snapdiskdef = NULL;
 
-    snapdiskdef = qemuSnapshotGetTransientDiskDef(disk, vm->def->name);
+    if (!(snapdiskdef = qemuSnapshotGetTransientDiskDef(disk, vm->def->name)))
+        return NULL;
+
     snapctxt = qemuSnapshotDiskContextNew(1, vm, asyncJob);
 
     if (qemuSnapshotDiskPrepareOne(snapctxt, disk, snapdiskdef,