提交 eba6467f 编写于 作者: M Michal Privoznik

qemu_hotplug: Hotunplug of reservations

If we are the last one to use pr-manager object we need to remove
it and also kill the qemu-pr-helper process.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 3f968fda
......@@ -3826,6 +3826,49 @@ static bool qemuIsMultiFunctionDevice(virDomainDefPtr def,
}
static int
qemuDomainDiskNeedRemovePR(virDomainObjPtr vm,
virDomainDiskDefPtr disk,
char **aliasret,
bool *stopDaemon)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
size_t i;
*aliasret = NULL;
*stopDaemon = false;
if (!virStoragePRDefIsEnabled(disk->src->pr))
return 0;
if (!virStoragePRDefIsManaged(disk->src->pr)) {
*aliasret = qemuDomainGetUnmanagedPRAlias(disk);
return *aliasret ? 0 : -1;
}
for (i = 0; i < vm->def->ndisks; i++) {
const virDomainDiskDef *domainDisk = vm->def->disks[i];
if (domainDisk == disk)
continue;
if (virStoragePRDefIsManaged(domainDisk->src->pr))
break;
}
if (i != vm->def->ndisks)
return 0;
if (VIR_STRDUP(*aliasret, qemuDomainGetManagedPRAlias()) < 0)
return -1;
if (priv->prDaemonRunning)
*stopDaemon = true;
return 0;
}
static int
qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
......@@ -3839,6 +3882,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
char *drivestr;
char *objAlias = NULL;
char *encAlias = NULL;
char *prmgrAlias = NULL;
bool stopPRDaemon = false;
VIR_DEBUG("Removing disk %s from domain %p %s",
disk->info.alias, vm, vm->def->name);
......@@ -3876,6 +3921,9 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
}
}
if (qemuDomainDiskNeedRemovePR(vm, disk, &prmgrAlias, &stopPRDaemon) < 0)
return -1;
qemuDomainObjEnterMonitor(driver, vm);
qemuMonitorDriveDel(priv->mon, drivestr);
......@@ -3891,6 +3939,11 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
ignore_value(qemuMonitorDelObject(priv->mon, encAlias));
VIR_FREE(encAlias);
/* If it fails, then so be it - it was a best shot */
if (prmgrAlias)
ignore_value(qemuMonitorDelObject(priv->mon, prmgrAlias));
VIR_FREE(prmgrAlias);
if (disk->src->haveTLS)
ignore_value(qemuMonitorDelObject(priv->mon, disk->src->tlsAlias));
......@@ -3909,6 +3962,9 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
}
}
if (stopPRDaemon)
qemuProcessKillPRDaemon(vm);
qemuDomainReleaseDeviceAddress(vm, &disk->info, src);
if (qemuSecurityRestoreDiskLabel(driver, vm, disk) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册