mirror of https://gitee.com/openkylin/libvirt.git
qemu: hotplug: Don't try to infer secret object alias/presence
Now that we remember the alias we've used to attach the secret objects we should reuse them rather than trying to infer them from the disk configuration. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7c6b00b8fe
commit
dbb4ff0919
|
@ -3900,16 +3900,17 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virDomainDiskDefPtr disk)
|
virDomainDiskDefPtr disk)
|
||||||
{
|
{
|
||||||
|
qemuDomainStorageSourcePrivatePtr diskPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
|
||||||
virDomainDeviceDef dev;
|
virDomainDeviceDef dev;
|
||||||
virObjectEventPtr event;
|
virObjectEventPtr event;
|
||||||
size_t i;
|
size_t i;
|
||||||
const char *src = virDomainDiskGetSource(disk);
|
const char *src = virDomainDiskGetSource(disk);
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *drivestr;
|
char *drivestr;
|
||||||
char *objAlias = NULL;
|
|
||||||
char *encAlias = NULL;
|
|
||||||
bool prManaged = priv->prDaemonRunning;
|
bool prManaged = priv->prDaemonRunning;
|
||||||
bool prUsed = false;
|
bool prUsed = false;
|
||||||
|
const char *authAlias = NULL;
|
||||||
|
const char *encAlias = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("Removing disk %s from domain %p %s",
|
VIR_DEBUG("Removing disk %s from domain %p %s",
|
||||||
disk->info.alias, vm, vm->def->name);
|
disk->info.alias, vm, vm->def->name);
|
||||||
|
@ -3919,32 +3920,14 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
||||||
if (!(drivestr = qemuAliasFromDisk(disk)))
|
if (!(drivestr = qemuAliasFromDisk(disk)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Let's look for some markers for a secret object and create an alias
|
if (diskPriv) {
|
||||||
* object to be used to attempt to delete the object that was created.
|
if (diskPriv->secinfo &&
|
||||||
* We cannot just use the disk private secret info since it would have
|
diskPriv->secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
|
||||||
* been removed during cleanup of qemuProcessLaunch. Likewise, libvirtd
|
authAlias = diskPriv->secinfo->s.aes.alias;
|
||||||
* restart wouldn't have them, so no assumption can be made. */
|
|
||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) &&
|
|
||||||
qemuDomainStorageSourceHasAuth(disk->src)) {
|
|
||||||
|
|
||||||
if (!(objAlias =
|
if (diskPriv->encinfo &&
|
||||||
qemuDomainGetSecretAESAlias(disk->info.alias, false))) {
|
diskPriv->encinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
|
||||||
VIR_FREE(drivestr);
|
encAlias = diskPriv->encinfo->s.aes.alias;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Similarly, if this is possible a device using LUKS encryption, we
|
|
||||||
* can remove the luks object password too
|
|
||||||
*/
|
|
||||||
if (qemuDomainDiskHasEncryptionSecret(disk->src)) {
|
|
||||||
|
|
||||||
if (!(encAlias =
|
|
||||||
qemuDomainGetSecretAESAlias(disk->info.alias, true))) {
|
|
||||||
VIR_FREE(objAlias);
|
|
||||||
VIR_FREE(drivestr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
|
@ -3963,14 +3946,12 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
||||||
VIR_FREE(drivestr);
|
VIR_FREE(drivestr);
|
||||||
|
|
||||||
/* If it fails, then so be it - it was a best shot */
|
/* If it fails, then so be it - it was a best shot */
|
||||||
if (objAlias)
|
if (authAlias)
|
||||||
ignore_value(qemuMonitorDelObject(priv->mon, objAlias));
|
ignore_value(qemuMonitorDelObject(priv->mon, authAlias));
|
||||||
VIR_FREE(objAlias);
|
|
||||||
|
|
||||||
/* If it fails, then so be it - it was a best shot */
|
/* If it fails, then so be it - it was a best shot */
|
||||||
if (encAlias)
|
if (encAlias)
|
||||||
ignore_value(qemuMonitorDelObject(priv->mon, encAlias));
|
ignore_value(qemuMonitorDelObject(priv->mon, encAlias));
|
||||||
VIR_FREE(encAlias);
|
|
||||||
|
|
||||||
/* If it fails, then so be it - it was a best shot */
|
/* If it fails, then so be it - it was a best shot */
|
||||||
if (disk->src->pr &&
|
if (disk->src->pr &&
|
||||||
|
|
Loading…
Reference in New Issue