This patch implements a new save cookie object and callbacks for qemu
driver. The actual useful content will be added in the object later.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
Reviewed-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Notes:
Version 2:
- no change
src/qemu/qemu_conf.c | 2 +-
src/qemu/qemu_domain.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_domain.h | 9 ++++++
3 files changed, 86 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index d02e776b0..73c33d678 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -911,7 +911,7 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver)
&virQEMUDriverPrivateDataCallbacks,
&virQEMUDriverDomainXMLNamespace,
&virQEMUDriverDomainABIStability,
- NULL);
+ &virQEMUDriverDomainSaveCookie);
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 814232164..80e9fea98 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -122,11 +122,13 @@ struct _qemuDomainLogContext {
};
static virClassPtr qemuDomainLogContextClass;
+static virClassPtr qemuDomainSaveCookieClass;
static void qemuDomainLogContextDispose(void *obj);
+static void qemuDomainSaveCookieDispose(void *obj);
static int
-qemuDomainLogContextOnceInit(void)
+qemuDomainOnceInit(void)
{
if (!(qemuDomainLogContextClass = virClassNew(virClassForObject(),
"qemuDomainLogContext",
@@ -134,10 +136,16 @@ qemuDomainLogContextOnceInit(void)
qemuDomainLogContextDispose)))
return -1;
+ if (!(qemuDomainSaveCookieClass = virClassNew(virClassForObject(),
+ "qemuDomainSaveCookie",
+ sizeof(qemuDomainSaveCookie),
+ qemuDomainSaveCookieDispose)))
+ return -1;
+
return 0;
}
-VIR_ONCE_GLOBAL_INIT(qemuDomainLogContext)
+VIR_ONCE_GLOBAL_INIT(qemuDomain)
static void
qemuDomainLogContextDispose(void *obj)
@@ -4554,7 +4562,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr
driver,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
qemuDomainLogContextPtr ctxt = NULL;
- if (qemuDomainLogContextInitialize() < 0)
+ if (qemuDomainInitialize() < 0)
goto cleanup;
if (!(ctxt = virObjectNew(qemuDomainLogContextClass)))
@@ -9105,3 +9113,68 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
VIR_FREE(target);
return src;
}
+
+
+static void
+qemuDomainSaveCookieDispose(void *obj)
+{
+ qemuDomainSaveCookiePtr cookie = obj;
+
+ VIR_DEBUG("cookie=%p", cookie);
+}
+
+
+qemuDomainSaveCookiePtr
+qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED)
+{
+ qemuDomainSaveCookiePtr cookie = NULL;
+
+ if (qemuDomainInitialize() < 0)
+ goto error;
+
+ if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
+ goto error;
+
+ VIR_DEBUG("Save cookie %p", cookie);
+
+ return cookie;
+
+ error:
+ virObjectUnref(cookie);
+ return NULL;
+}
+
+
+static int
+qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
+ virObjectPtr *obj)
+{
+ qemuDomainSaveCookiePtr cookie = NULL;
+
+ if (qemuDomainInitialize() < 0)
+ goto error;
+
+ if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
+ goto error;
+
+ *obj = (virObjectPtr) cookie;
+ return 0;
+
+ error:
+ virObjectUnref(cookie);
+ return -1;
+}
+
+
+static int
+qemuDomainSaveCookieFormat(virBufferPtr buf ATTRIBUTE_UNUSED,
+ virObjectPtr obj ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
+
+virSaveCookieCallbacks virQEMUDriverDomainSaveCookie = {
+ .parse = qemuDomainSaveCookieParse,
+ .format = qemuDomainSaveCookieFormat,
+};
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index d0e2e0628..cc2e21bdf 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -416,6 +416,14 @@ struct qemuProcessEvent {
typedef struct _qemuDomainLogContext qemuDomainLogContext;
typedef qemuDomainLogContext *qemuDomainLogContextPtr;
+typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
+typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
+struct _qemuDomainSaveCookie {
+ virObject parent;
+};
+
+qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);
+
const char *qemuDomainAsyncJobPhaseToString(qemuDomainAsyncJob job,
int phase);
int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job,
@@ -638,6 +646,7 @@ extern virDomainXMLPrivateDataCallbacks
virQEMUDriverPrivateDataCallbacks;
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
extern virDomainABIStability virQEMUDriverDomainABIStability;
+extern virSaveCookieCallbacks virQEMUDriverDomainSaveCookie;
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
virDomainObjPtr vm, int asyncJob);
--
2.13.0