mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Fill in secret UUID for qcow encryption
* src/storage_backend_fs.c: Lookup & fill in secret passphrase UUID for storage volumes using encryption
This commit is contained in:
parent
a2a30038cf
commit
756be09d23
@ -430,6 +430,11 @@ static int virStorageBackendProbeTarget(virConnectPtr conn,
|
||||
}
|
||||
enc->format = VIR_STORAGE_ENCRYPTION_FORMAT_QCOW;
|
||||
*encryption = enc;
|
||||
/* XXX ideally we'd fill in secret UUID here
|
||||
* but we cannot guarentee 'conn' is non-NULL
|
||||
* at this point in time :-( So we only fill
|
||||
* in secrets when someone first queries a vol
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1230,8 +1235,42 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
|
||||
virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
|
||||
virStorageVolDefPtr vol)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Refresh allocation / permissions info in case its changed */
|
||||
return virStorageBackendUpdateVolInfo(conn, vol, 0);
|
||||
ret = virStorageBackendUpdateVolInfo(conn, vol, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Load any secrets if posible */
|
||||
if (vol->target.encryption &&
|
||||
vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_QCOW &&
|
||||
vol->target.encryption->nsecrets == 0) {
|
||||
virSecretPtr sec;
|
||||
virStorageEncryptionSecretPtr encsec = NULL;
|
||||
|
||||
sec = virSecretLookupByUsage(conn,
|
||||
VIR_SECRET_USAGE_TYPE_VOLUME,
|
||||
vol->target.path);
|
||||
if (sec) {
|
||||
if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 ||
|
||||
VIR_ALLOC(encsec) < 0) {
|
||||
VIR_FREE(vol->target.encryption->secrets);
|
||||
virReportOOMError(conn);
|
||||
virSecretFree(sec);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vol->target.encryption->nsecrets = 1;
|
||||
vol->target.encryption->secrets[0] = encsec;
|
||||
|
||||
encsec->type = VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE;
|
||||
virSecretGetUUID(sec, encsec->uuid);
|
||||
virSecretFree(sec);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virStorageBackend virStorageBackendDirectory = {
|
||||
|
Loading…
Reference in New Issue
Block a user