提交 4479bd46 编写于 作者: P Peter Krempa

qemu: blockjob: Turn struct qemuBlockJobData into a virObject

Reference counting will simplify semantics of the lifecycle of the
object.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 466b78ac
...@@ -42,14 +42,37 @@ ...@@ -42,14 +42,37 @@
VIR_LOG_INIT("qemu.qemu_blockjob"); VIR_LOG_INIT("qemu.qemu_blockjob");
void static virClassPtr qemuBlockJobDataClass;
qemuBlockJobDataFree(qemuBlockJobDataPtr job)
static void
qemuBlockJobDataDispose(void *obj)
{ {
if (!job) qemuBlockJobDataPtr job = obj;
return;
VIR_FREE(job->errmsg); VIR_FREE(job->errmsg);
VIR_FREE(job); }
static int
qemuBlockJobDataOnceInit(void)
{
if (!VIR_CLASS_NEW(qemuBlockJobData, virClassForObject()))
return -1;
return 0;
}
VIR_ONCE_GLOBAL_INIT(qemuBlockJobData)
qemuBlockJobDataPtr
qemuBlockJobDataNew(void)
{
if (qemuBlockJobDataInitialize() < 0)
return NULL;
return virObjectNew(qemuBlockJobDataClass);
} }
......
...@@ -30,6 +30,8 @@ typedef struct _qemuBlockJobData qemuBlockJobData; ...@@ -30,6 +30,8 @@ typedef struct _qemuBlockJobData qemuBlockJobData;
typedef qemuBlockJobData *qemuBlockJobDataPtr; typedef qemuBlockJobData *qemuBlockJobDataPtr;
struct _qemuBlockJobData { struct _qemuBlockJobData {
virObject parent;
bool started; bool started;
int type; int type;
int status; int status;
...@@ -37,8 +39,7 @@ struct _qemuBlockJobData { ...@@ -37,8 +39,7 @@ struct _qemuBlockJobData {
bool synchronous; /* API call is waiting for this job */ bool synchronous; /* API call is waiting for this job */
}; };
void qemuBlockJobDataPtr qemuBlockJobDataNew(void);
qemuBlockJobDataFree(qemuBlockJobDataPtr job);
int qemuBlockJobUpdateDisk(virDomainObjPtr vm, int qemuBlockJobUpdateDisk(virDomainObjPtr vm,
int asyncJob, int asyncJob,
......
...@@ -1063,7 +1063,7 @@ qemuDomainDiskPrivateNew(void) ...@@ -1063,7 +1063,7 @@ qemuDomainDiskPrivateNew(void)
if (!(priv = virObjectNew(qemuDomainDiskPrivateClass))) if (!(priv = virObjectNew(qemuDomainDiskPrivateClass)))
return NULL; return NULL;
if (VIR_ALLOC(priv->blockjob) < 0) { if (!(priv->blockjob = qemuBlockJobDataNew())) {
virObjectUnref(priv); virObjectUnref(priv);
priv = NULL; priv = NULL;
} }
...@@ -1079,7 +1079,7 @@ qemuDomainDiskPrivateDispose(void *obj) ...@@ -1079,7 +1079,7 @@ qemuDomainDiskPrivateDispose(void *obj)
virStorageSourceFree(priv->migrSource); virStorageSourceFree(priv->migrSource);
VIR_FREE(priv->qomName); VIR_FREE(priv->qomName);
VIR_FREE(priv->nodeCopyOnRead); VIR_FREE(priv->nodeCopyOnRead);
qemuBlockJobDataFree(priv->blockjob); virObjectUnref(priv->blockjob);
} }
static virClassPtr qemuDomainStorageSourcePrivateClass; static virClassPtr qemuDomainStorageSourcePrivateClass;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册