The crash could happen if the disk source is empty for cdrom or
floppy disk.
---
src/qemu/qemu_driver.c | 7 +++++--
src/qemu/qemu_process.c | 3 +++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 812bf95..906501b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5884,7 +5884,9 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
}
if (ret == 0) {
- if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK && disk->shared) {
+ if (disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK &&
+ disk->shared &&
+ disk->src) {
if (qemuAddSharedDisk(driver->sharedDisks, disk->src) < 0)
VIR_WARN("Failed to add disk '%s' to shared disk
table",
disk->src);
@@ -6011,7 +6013,8 @@ qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
if (ret == 0 &&
disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK &&
- disk->shared) {
+ disk->shared &&
+ disk->src) {
if (qemuRemoveSharedDisk(driver->sharedDisks, disk->src) < 0)
VIR_WARN("Failed to remove disk '%s' from shared disk
table",
disk->src);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d1872c0..98ed552 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3458,6 +3458,9 @@ qemuCheckSharedDisk(virHashTablePtr sharedDisks,
char *key = NULL;
int ret = 0;
+ if (!disk->src)
+ return 0;
+
if (!(key = qemuGetSharedDiskKey(disk->src)))
return -1;
--
1.7.7.6