mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
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: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
3f968fda7b
commit
eba6467fed
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user