mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-30 16:35:24 +00:00
util: Add 'luks' to the FileTypeInfo
Add the ability to detect a luks encrypted device. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
ea0ef33d05
commit
318ebb36f1
@ -63,7 +63,7 @@ VIR_ENUM_IMPL(virStorageFileFormat,
|
||||
"cloop", "dmg", "iso",
|
||||
"vpc", "vdi",
|
||||
/* Not direct file formats, but used for various drivers */
|
||||
"fat", "vhd", "ploop",
|
||||
"fat", "vhd", "ploop", "luks",
|
||||
/* Formats with backing file below here */
|
||||
"cow", "qcow", "qcow2", "qed", "vmdk")
|
||||
|
||||
@ -189,6 +189,13 @@ qedGetBackingStore(char **, int *, const char *, size_t);
|
||||
#define PLOOP_IMAGE_SIZE_OFFSET 36
|
||||
#define PLOOP_SIZE_MULTIPLIER 512
|
||||
|
||||
#define LUKS_HDR_MAGIC_LEN 6
|
||||
#define LUKS_HDR_VERSION_LEN 2
|
||||
|
||||
/* Format described by qemu commit id '3e308f20e' */
|
||||
#define LUKS_HDR_VERSION_OFFSET LUKS_HDR_MAGIC_LEN
|
||||
|
||||
|
||||
static struct FileTypeInfo const fileTypeInfo[] = {
|
||||
[VIR_STORAGE_FILE_NONE] = { 0, NULL, NULL, LV_LITTLE_ENDIAN,
|
||||
-1, 0, {0}, 0, 0, 0, 0, NULL, NULL },
|
||||
@ -244,6 +251,13 @@ static struct FileTypeInfo const fileTypeInfo[] = {
|
||||
-2, 0, {0}, PLOOP_IMAGE_SIZE_OFFSET, 0,
|
||||
PLOOP_SIZE_MULTIPLIER, -1, NULL, NULL },
|
||||
|
||||
/* Magic is 'L','U','K','S', 0xBA, 0xBE
|
||||
* Set sizeOffset = -1 and let hypervisor handle */
|
||||
[VIR_STORAGE_FILE_LUKS] = {
|
||||
0, "\x4c\x55\x4b\x53\xba\xbe", NULL,
|
||||
LV_BIG_ENDIAN, LUKS_HDR_VERSION_OFFSET, 2, {1},
|
||||
-1, 0, 0, -1, NULL, NULL
|
||||
},
|
||||
/* All formats with a backing store probe below here */
|
||||
[VIR_STORAGE_FILE_COW] = {
|
||||
0, "OOOM", NULL,
|
||||
@ -626,7 +640,7 @@ virStorageFileMatchesVersion(int format,
|
||||
char *buf,
|
||||
size_t buflen)
|
||||
{
|
||||
int version;
|
||||
int version = 0;
|
||||
size_t i;
|
||||
|
||||
/* Validate version number info */
|
||||
@ -843,6 +857,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (meta->format == VIR_STORAGE_FILE_LUKS) {
|
||||
/* By definition, this is encrypted */
|
||||
if (!meta->encryption && VIR_ALLOC(meta->encryption) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
VIR_FREE(meta->backingStoreRaw);
|
||||
if (fileTypeInfo[meta->format].getBackingStore != NULL) {
|
||||
int store = fileTypeInfo[meta->format].getBackingStore(&meta->backingStoreRaw,
|
||||
|
@ -74,6 +74,7 @@ typedef enum {
|
||||
VIR_STORAGE_FILE_FAT,
|
||||
VIR_STORAGE_FILE_VHD,
|
||||
VIR_STORAGE_FILE_PLOOP,
|
||||
VIR_STORAGE_FILE_LUKS,
|
||||
|
||||
/* Not a format, but a marker: all formats below this point have
|
||||
* libvirt support for following a backing chain */
|
||||
|
Loading…
x
Reference in New Issue
Block a user