mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
conf: modify tracking of encrypted images
A future patch will merge virStorageFileMetadata and virStorageSource, but I found it easier to do if both structs use the same information for tracking whether a source file needs encryption keys. * src/util/virstoragefile.h (_virStorageFileMetadata): Prepare full encryption struct instead of just a bool. * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget): Use transfer semantics. * src/storage/storage_backend_gluster.c (virStorageBackendGlusterRefreshVol): Likewise. * src/util/virstoragefile.c (virStorageFileGetMetadataInternal): Populate struct. (virStorageFileFreeMetadata): Adjust clients. * tests/virstoragetest.c (testStorageChain): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
ac9a0963fa
commit
2279d5605c
@ -142,9 +142,9 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
|
|||||||
if (meta && meta->capacity)
|
if (meta && meta->capacity)
|
||||||
target->capacity = meta->capacity;
|
target->capacity = meta->capacity;
|
||||||
|
|
||||||
if (encryption && meta && meta->encrypted) {
|
if (encryption && meta && meta->encryption) {
|
||||||
if (VIR_ALLOC(*encryption) < 0)
|
*encryption = meta->encryption;
|
||||||
goto cleanup;
|
meta->encryption = NULL;
|
||||||
|
|
||||||
switch (target->format) {
|
switch (target->format) {
|
||||||
case VIR_STORAGE_FILE_QCOW:
|
case VIR_STORAGE_FILE_QCOW:
|
||||||
|
@ -310,9 +310,9 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||||||
}
|
}
|
||||||
if (meta->capacity)
|
if (meta->capacity)
|
||||||
vol->target.capacity = meta->capacity;
|
vol->target.capacity = meta->capacity;
|
||||||
if (meta->encrypted) {
|
if (meta->encryption) {
|
||||||
if (VIR_ALLOC(vol->target.encryption) < 0)
|
vol->target.encryption = meta->encryption;
|
||||||
goto cleanup;
|
meta->encryption = NULL;
|
||||||
if (vol->target.format == VIR_STORAGE_FILE_QCOW ||
|
if (vol->target.format == VIR_STORAGE_FILE_QCOW ||
|
||||||
vol->target.format == VIR_STORAGE_FILE_QCOW2)
|
vol->target.format == VIR_STORAGE_FILE_QCOW2)
|
||||||
vol->target.encryption->format = VIR_STORAGE_ENCRYPTION_FORMAT_QCOW;
|
vol->target.encryption->format = VIR_STORAGE_ENCRYPTION_FORMAT_QCOW;
|
||||||
|
@ -837,7 +837,8 @@ virStorageFileGetMetadataInternal(const char *path,
|
|||||||
|
|
||||||
crypt_format = virReadBufInt32BE(buf +
|
crypt_format = virReadBufInt32BE(buf +
|
||||||
fileTypeInfo[format].qcowCryptOffset);
|
fileTypeInfo[format].qcowCryptOffset);
|
||||||
meta->encrypted = crypt_format != 0;
|
if (crypt_format && VIR_ALLOC(meta->encryption) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileTypeInfo[format].getBackingStore != NULL) {
|
if (fileTypeInfo[format].getBackingStore != NULL) {
|
||||||
@ -1209,6 +1210,7 @@ virStorageFileFreeMetadata(virStorageFileMetadata *meta)
|
|||||||
VIR_FREE(meta->compat);
|
VIR_FREE(meta->compat);
|
||||||
VIR_FREE(meta->directory);
|
VIR_FREE(meta->directory);
|
||||||
virBitmapFree(meta->features);
|
virBitmapFree(meta->features);
|
||||||
|
virStorageEncryptionFree(meta->encryption);
|
||||||
VIR_FREE(meta);
|
VIR_FREE(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +114,9 @@ struct _virStorageFileMetadata {
|
|||||||
int backingStoreFormat; /* enum virStorageFileFormat */
|
int backingStoreFormat; /* enum virStorageFileFormat */
|
||||||
bool backingStoreIsFile;
|
bool backingStoreIsFile;
|
||||||
virStorageFileMetadataPtr backingMeta;
|
virStorageFileMetadataPtr backingMeta;
|
||||||
|
|
||||||
|
virStorageEncryptionPtr encryption;
|
||||||
unsigned long long capacity;
|
unsigned long long capacity;
|
||||||
bool encrypted;
|
|
||||||
virBitmapPtr features; /* bits described by enum virStorageFileFeature */
|
virBitmapPtr features; /* bits described by enum virStorageFileFeature */
|
||||||
char *compat;
|
char *compat;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Red Hat, Inc.
|
* Copyright (C) 2013-2014 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -284,7 +284,7 @@ testStorageChain(const void *args)
|
|||||||
NULLSTR(elt->backingStoreRaw),
|
NULLSTR(elt->backingStoreRaw),
|
||||||
NULLSTR(elt->directory),
|
NULLSTR(elt->directory),
|
||||||
elt->backingStoreFormat, elt->backingStoreIsFile,
|
elt->backingStoreFormat, elt->backingStoreIsFile,
|
||||||
elt->capacity, elt->encrypted) < 0) {
|
elt->capacity, !!elt->encryption) < 0) {
|
||||||
VIR_FREE(expect);
|
VIR_FREE(expect);
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user