From: John Ferlan <jferlan(a)redhat.com>
Add the object definition and helpers to store security-related private
data for virStorageSources.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 43 +++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 17 +++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 41009331a..f44e1436d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -932,6 +932,49 @@ qemuDomainDiskPrivateDispose(void *obj)
}
+static virClassPtr qemuDomainStorageSourcePrivateClass;
+static void qemuDomainStorageSourcePrivateDispose(void *obj);
+
+static int
+qemuDomainStorageSourcePrivateOnceInit(void)
+{
+ qemuDomainStorageSourcePrivateClass = virClassNew(virClassForObject(),
+
"qemuDomainStorageSourcePrivate",
+
sizeof(qemuDomainStorageSourcePrivate),
+
qemuDomainStorageSourcePrivateDispose);
+ if (!qemuDomainStorageSourcePrivateClass)
+ return -1;
+ else
+ return 0;
+}
+
+VIR_ONCE_GLOBAL_INIT(qemuDomainStorageSourcePrivate)
+
+virObjectPtr
+qemuDomainStorageSourcePrivateNew(void)
+{
+ qemuDomainStorageSourcePrivatePtr priv;
+
+ if (qemuDomainStorageSourcePrivateInitialize() < 0)
+ return NULL;
+
+ if (!(priv = virObjectNew(qemuDomainStorageSourcePrivateClass)))
+ return NULL;
+
+ return (virObjectPtr) priv;
+}
+
+
+static void
+qemuDomainStorageSourcePrivateDispose(void *obj)
+{
+ qemuDomainStorageSourcePrivatePtr priv = obj;
+
+ qemuDomainSecretInfoFree(&priv->secinfo);
+ qemuDomainSecretInfoFree(&priv->encinfo);
+}
+
+
static virClassPtr qemuDomainHostdevPrivateClass;
static void qemuDomainHostdevPrivateDispose(void *obj);
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 7c9364f35..2e1515fa1 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -363,6 +363,23 @@ struct _qemuDomainDiskPrivate {
bool removable; /* device media can be removed/changed */
};
+# define QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src) \
+ ((qemuDomainStorageSourcePrivatePtr) (src)->privateData)
+
+typedef struct _qemuDomainStorageSourcePrivate qemuDomainStorageSourcePrivate;
+typedef qemuDomainStorageSourcePrivate *qemuDomainStorageSourcePrivatePtr;
+struct _qemuDomainStorageSourcePrivate {
+ virObject parent;
+
+ /* data required for authentication to the storage source */
+ qemuDomainSecretInfoPtr secinfo;
+
+ /* data required for decryption of encrypted storage source */
+ qemuDomainSecretInfoPtr encinfo;
+};
+
+virObjectPtr qemuDomainStorageSourcePrivateNew(void);
+
# define QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev) \
((qemuDomainHostdevPrivatePtr) (hostdev)->privateData)
--
2.14.1