diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 48201c1..35ce32e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -603,6 +603,11 @@ qemuDomainFindMaxID(void *payload, *driver_maxid = vm->def->id + 1; } +static void +qemuSharedDiskFree(void *entry, const void *name ATTRIBUTE_UNUSED) +{ + VIR_FREE(entry); +} /** * qemuStartup: @@ -810,7 +815,7 @@ qemuStartup(bool privileged, if ((qemu_driver->inactivePciHostdevs = pciDeviceListNew()) == NULL) goto error; - if (!(qemu_driver->sharedDisks = virHashCreate(30, NULL))) + if (!(qemu_driver->sharedDisks = virHashCreate(30, qemuSharedDiskFree))) goto error; if (privileged) { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ba777e2..1e09cab 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3405,9 +3405,9 @@ qemuCheckSharedDisk(virHashTablePtr sharedDisks, return -1; if ((val == 0 && - disk->orig_cdbfilter == VIR_DOMAIN_DISK_CDB_FILTER_YES) || + disk->cdbfilter == VIR_DOMAIN_DISK_CDB_FILTER_YES) || (val == 1 && - disk->orig_cdbfilter == VIR_DOMAIN_DISK_CDB_FILTER_NO)) + disk->cdbfilter == VIR_DOMAIN_DISK_CDB_FILTER_NO)) return 0; virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3748,7 +3748,6 @@ int qemuProcessStart(virConnectPtr conn, if (disk->rawio == 1) virCommandAllowCap(cmd, CAP_SYS_RAWIO); - /* Set sysfs unpriv_sgio if cdbfilter is specified */ if (disk->cdbfilter) { if (virGetDeviceUnprivSGIO(disk->src, &val) < 0) goto cleanup; @@ -3757,12 +3756,6 @@ int qemuProcessStart(virConnectPtr conn, disk->orig_cdbfilter = VIR_DOMAIN_DISK_CDB_FILTER_YES; else disk->orig_cdbfilter = VIR_DOMAIN_DISK_CDB_FILTER_NO; - - if (virSetDeviceUnprivSGIO(disk->src, - (disk->cdbfilter == - VIR_DOMAIN_DISK_CDB_FILTER_NO) - ? 1 : 0) < 0) - goto cleanup; } if (disk->shared) { @@ -3778,6 +3771,15 @@ int qemuProcessStart(virConnectPtr conn, if (qemuCheckSharedDisk(driver->sharedDisks, disk) < 0) goto cleanup; } + + /* Set sysfs unpriv_sgio if cdbfilter is specified */ + if (disk->cdbfilter) { + if (virSetDeviceUnprivSGIO(disk->src, + (disk->cdbfilter == + VIR_DOMAIN_DISK_CDB_FILTER_NO) + ? 1 : 0) < 0) + goto cleanup; + } } virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData);