2009-08-19 19:50:10 +00:00
|
|
|
/*
|
|
|
|
* storage_encryption_conf.h: volume encryption information
|
|
|
|
*
|
2010-05-07 20:34:15 +00:00
|
|
|
* Copyright (C) 2009-2010 Red Hat, Inc.
|
2009-08-19 19:50:10 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Red Hat Author: Miloslav Trmač <mitr@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_STORAGE_ENCRYPTION_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_STORAGE_ENCRYPTION_H__
|
2009-08-19 19:50:10 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
|
|
|
# include "buf.h"
|
|
|
|
# include "util.h"
|
2009-08-19 19:50:10 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <stdbool.h>
|
|
|
|
# include <libxml/tree.h>
|
2009-08-19 19:50:10 +00:00
|
|
|
|
|
|
|
enum virStorageEncryptionSecretType {
|
|
|
|
VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE = 0,
|
|
|
|
|
|
|
|
VIR_STORAGE_ENCRYPTION_SECRET_TYPE_LAST
|
|
|
|
};
|
|
|
|
VIR_ENUM_DECL(virStorageEncryptionSecretType)
|
|
|
|
|
|
|
|
typedef struct _virStorageEncryptionSecret virStorageEncryptionSecret;
|
|
|
|
typedef virStorageEncryptionSecret *virStorageEncryptionSecretPtr;
|
|
|
|
struct _virStorageEncryptionSecret {
|
|
|
|
int type; /* enum virStorageEncryptionSecretType */
|
Fix UUID handling in secrets/storage encryption APIs
Convert all the secret/storage encryption APIs / wire format to
handle UUIDs in raw format instead of non-canonical printable
format. Guarentees data format correctness.
* docs/schemas/storageencryption.rng: Make UUID mandatory for a secret
and validate fully
* docs/schemas/secret.rng: Fully validate UUID
* include/libvirt/libvirt.h, include/libvirt/libvirt.h.in, Add
virSecretLookupByUUID and virSecretGetUUID. Make
virSecretGetUUIDString follow normal API design pattern
* python/generator.py: Skip generation of virSecretGetUUID,
virSecretGetUUIDString and virSecretLookupByUUID
* python/libvir.c, python/libvirt-python-api.xml: Manual impl
of virSecretGetUUID,virSecretGetUUIDString and virSecretLookupByUUID
* qemud/remote.c: s/virSecretLookupByUUIDString/virSecretLookupByUUID/
Fix get_nonnull_secret/make_nonnull_secret to use unsigned char
* qemud/remote_protocol.x: Fix remote_nonnull_secret to use a
remote_uuid instead of remote_nonnull_string for UUID field.
Rename REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING to
REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING and make it take an
remote_uuid value
* qemud/remote_dispatch_args.h, qemud/remote_dispatch_prototypes.h,
qemud/remote_dispatch_ret.h, qemud/remote_dispatch_table.h,
qemud/remote_protocol.c, qemud/remote_protocol.h: Re-generate
* src/datatypes.h, src/datatypes.c: Store UUID in raw format instead
of printable. Change virGetSecret to use raw format UUID
* src/driver.h: Rename virDrvSecretLookupByUUIDString to
virDrvSecretLookupByUUID and use raw format UUID
* src/libvirt.c: Add virSecretLookupByUUID and virSecretGetUUID
and re-implement virSecretLookupByUUIDString and
virSecretGetUUIDString in terms of those
* src/libvirt_public.syms: Add virSecretLookupByUUID and
virSecretGetUUID
* src/remote_internal.c: Rename remoteSecretLookupByUUIDString
to remoteSecretLookupByUUID. Fix typo in args for
remoteSecretDefineXML impl. Use raw UUID format for
get_nonnull_secret and make_nonnull_secret
* src/storage_encryption_conf.c, src/storage_encryption_conf.h:
Storage UUID in raw format, and require it to be present in
XML. Use UUID parser to validate.
* secret_conf.h, secret_conf.c: Generate a UUID if none is provided.
Storage UUID in raw format.
* src/secret_driver.c: Adjust to deal with raw UUIDs. Save secrets
in a filed with printable UUID, instead of base64 UUID.
* src/virsh.c: Adjust for changed public API contract of
virSecretGetUUIDString.
* src/storage_Backend.c: DOn't undefine secret we just generated
upon successful volume creation. Fix to handle raw UUIDs. Generate
a non-clashing UUID
* src/qemu_driver.c: Change to use lookupByUUID instead of
lookupByUUIDString
2009-09-10 16:44:12 +00:00
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
2009-08-19 19:50:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum virStorageEncryptionFormat {
|
|
|
|
/* "default" is only valid for volume creation */
|
|
|
|
VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT = 0,
|
|
|
|
VIR_STORAGE_ENCRYPTION_FORMAT_QCOW, /* Both qcow and qcow2 */
|
|
|
|
|
|
|
|
VIR_STORAGE_ENCRYPTION_FORMAT_LAST,
|
|
|
|
};
|
|
|
|
VIR_ENUM_DECL(virStorageEncryptionFormat)
|
|
|
|
|
|
|
|
typedef struct _virStorageEncryption virStorageEncryption;
|
|
|
|
typedef virStorageEncryption *virStorageEncryptionPtr;
|
|
|
|
struct _virStorageEncryption {
|
|
|
|
int format; /* enum virStorageEncryptionFormat */
|
|
|
|
|
|
|
|
size_t nsecrets;
|
|
|
|
virStorageEncryptionSecretPtr *secrets;
|
|
|
|
};
|
|
|
|
|
|
|
|
void virStorageEncryptionFree(virStorageEncryptionPtr enc);
|
Fix UUID handling in secrets/storage encryption APIs
Convert all the secret/storage encryption APIs / wire format to
handle UUIDs in raw format instead of non-canonical printable
format. Guarentees data format correctness.
* docs/schemas/storageencryption.rng: Make UUID mandatory for a secret
and validate fully
* docs/schemas/secret.rng: Fully validate UUID
* include/libvirt/libvirt.h, include/libvirt/libvirt.h.in, Add
virSecretLookupByUUID and virSecretGetUUID. Make
virSecretGetUUIDString follow normal API design pattern
* python/generator.py: Skip generation of virSecretGetUUID,
virSecretGetUUIDString and virSecretLookupByUUID
* python/libvir.c, python/libvirt-python-api.xml: Manual impl
of virSecretGetUUID,virSecretGetUUIDString and virSecretLookupByUUID
* qemud/remote.c: s/virSecretLookupByUUIDString/virSecretLookupByUUID/
Fix get_nonnull_secret/make_nonnull_secret to use unsigned char
* qemud/remote_protocol.x: Fix remote_nonnull_secret to use a
remote_uuid instead of remote_nonnull_string for UUID field.
Rename REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING to
REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING and make it take an
remote_uuid value
* qemud/remote_dispatch_args.h, qemud/remote_dispatch_prototypes.h,
qemud/remote_dispatch_ret.h, qemud/remote_dispatch_table.h,
qemud/remote_protocol.c, qemud/remote_protocol.h: Re-generate
* src/datatypes.h, src/datatypes.c: Store UUID in raw format instead
of printable. Change virGetSecret to use raw format UUID
* src/driver.h: Rename virDrvSecretLookupByUUIDString to
virDrvSecretLookupByUUID and use raw format UUID
* src/libvirt.c: Add virSecretLookupByUUID and virSecretGetUUID
and re-implement virSecretLookupByUUIDString and
virSecretGetUUIDString in terms of those
* src/libvirt_public.syms: Add virSecretLookupByUUID and
virSecretGetUUID
* src/remote_internal.c: Rename remoteSecretLookupByUUIDString
to remoteSecretLookupByUUID. Fix typo in args for
remoteSecretDefineXML impl. Use raw UUID format for
get_nonnull_secret and make_nonnull_secret
* src/storage_encryption_conf.c, src/storage_encryption_conf.h:
Storage UUID in raw format, and require it to be present in
XML. Use UUID parser to validate.
* secret_conf.h, secret_conf.c: Generate a UUID if none is provided.
Storage UUID in raw format.
* src/secret_driver.c: Adjust to deal with raw UUIDs. Save secrets
in a filed with printable UUID, instead of base64 UUID.
* src/virsh.c: Adjust for changed public API contract of
virSecretGetUUIDString.
* src/storage_Backend.c: DOn't undefine secret we just generated
upon successful volume creation. Fix to handle raw UUIDs. Generate
a non-clashing UUID
* src/qemu_driver.c: Change to use lookupByUUID instead of
lookupByUUIDString
2009-09-10 16:44:12 +00:00
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
|
2009-08-19 19:50:10 +00:00
|
|
|
xmlNodePtr root);
|
2010-02-10 11:42:56 +00:00
|
|
|
int virStorageEncryptionFormat(virBufferPtr buf,
|
2010-04-27 10:01:32 +00:00
|
|
|
virStorageEncryptionPtr enc,
|
2010-05-07 20:34:15 +00:00
|
|
|
int indent);
|
2009-08-19 19:50:10 +00:00
|
|
|
|
2009-08-14 18:06:59 +00:00
|
|
|
/* A helper for VIR_STORAGE_ENCRYPTION_FORMAT_QCOW */
|
|
|
|
enum {
|
|
|
|
VIR_STORAGE_QCOW_PASSPHRASE_SIZE = 16
|
|
|
|
};
|
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
int virStorageGenerateQcowPassphrase(unsigned char *dest);
|
2009-08-14 18:06:59 +00:00
|
|
|
|
2009-08-19 19:50:10 +00:00
|
|
|
#endif /* __VIR_STORAGE_ENCRYPTION_H__ */
|