提交 bc444666 编写于 作者: N Nikolay Shirokovskiy 提交者: Jiri Denemark

qemu: prepare blockjob complete event error usage

This patch pass event error up to the place where we can
use it. Error is passed only for sync blockjob event mode
as we can't use the error in async mode. In async mode we
just pass the event details to the client thru event API
but current blockjob event API can not carry extra parameter.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 7993554f
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "virthread.h" #include "virthread.h"
#include "virtime.h" #include "virtime.h"
#include "locking/domain_lock.h" #include "locking/domain_lock.h"
#include "viralloc.h"
#define VIR_FROM_THIS VIR_FROM_QEMU #define VIR_FROM_THIS VIR_FROM_QEMU
...@@ -66,6 +67,7 @@ qemuBlockJobUpdate(virQEMUDriverPtr driver, ...@@ -66,6 +67,7 @@ qemuBlockJobUpdate(virQEMUDriverPtr driver,
diskPriv->blockJobType, diskPriv->blockJobType,
diskPriv->blockJobStatus); diskPriv->blockJobStatus);
diskPriv->blockJobStatus = -1; diskPriv->blockJobStatus = -1;
VIR_FREE(diskPriv->blockJobError);
} }
return status; return status;
......
...@@ -892,6 +892,7 @@ qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo) ...@@ -892,6 +892,7 @@ qemuDomainSecretInfoFree(qemuDomainSecretInfoPtr *secinfo)
static virClassPtr qemuDomainDiskPrivateClass; static virClassPtr qemuDomainDiskPrivateClass;
static void qemuDomainDiskPrivateDispose(void *obj);
static int static int
qemuDomainDiskPrivateOnceInit(void) qemuDomainDiskPrivateOnceInit(void)
...@@ -899,7 +900,7 @@ qemuDomainDiskPrivateOnceInit(void) ...@@ -899,7 +900,7 @@ qemuDomainDiskPrivateOnceInit(void)
qemuDomainDiskPrivateClass = virClassNew(virClassForObject(), qemuDomainDiskPrivateClass = virClassNew(virClassForObject(),
"qemuDomainDiskPrivate", "qemuDomainDiskPrivate",
sizeof(qemuDomainDiskPrivate), sizeof(qemuDomainDiskPrivate),
NULL); qemuDomainDiskPrivateDispose);
if (!qemuDomainDiskPrivateClass) if (!qemuDomainDiskPrivateClass)
return -1; return -1;
else else
...@@ -922,6 +923,13 @@ qemuDomainDiskPrivateNew(void) ...@@ -922,6 +923,13 @@ qemuDomainDiskPrivateNew(void)
return (virObjectPtr) priv; return (virObjectPtr) priv;
} }
static void
qemuDomainDiskPrivateDispose(void *obj)
{
qemuDomainDiskPrivatePtr priv = obj;
VIR_FREE(priv->blockJobError);
}
static virClassPtr qemuDomainStorageSourcePrivateClass; static virClassPtr qemuDomainStorageSourcePrivateClass;
static void qemuDomainStorageSourcePrivateDispose(void *obj); static void qemuDomainStorageSourcePrivateDispose(void *obj);
......
...@@ -350,6 +350,7 @@ struct _qemuDomainDiskPrivate { ...@@ -350,6 +350,7 @@ struct _qemuDomainDiskPrivate {
/* for some synchronous block jobs, we need to notify the owner */ /* for some synchronous block jobs, we need to notify the owner */
int blockJobType; /* type of the block job from the event */ int blockJobType; /* type of the block job from the event */
int blockJobStatus; /* status of the finished block job */ int blockJobStatus; /* status of the finished block job */
char *blockJobError; /* block job completed event error */
bool blockJobSync; /* the block job needs synchronized termination */ bool blockJobSync; /* the block job needs synchronized termination */
bool migrating; /* the disk is being migrated */ bool migrating; /* the disk is being migrated */
......
...@@ -1515,13 +1515,14 @@ int ...@@ -1515,13 +1515,14 @@ int
qemuMonitorEmitBlockJob(qemuMonitorPtr mon, qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
const char *diskAlias, const char *diskAlias,
int type, int type,
int status) int status,
const char *error)
{ {
int ret = -1; int ret = -1;
VIR_DEBUG("mon=%p", mon); VIR_DEBUG("mon=%p", mon);
QEMU_MONITOR_CALLBACK(mon, ret, domainBlockJob, mon->vm, QEMU_MONITOR_CALLBACK(mon, ret, domainBlockJob, mon->vm,
diskAlias, type, status); diskAlias, type, status, error);
return ret; return ret;
} }
......
...@@ -176,6 +176,7 @@ typedef int (*qemuMonitorDomainBlockJobCallback)(qemuMonitorPtr mon, ...@@ -176,6 +176,7 @@ typedef int (*qemuMonitorDomainBlockJobCallback)(qemuMonitorPtr mon,
const char *diskAlias, const char *diskAlias,
int type, int type,
int status, int status,
const char *error,
void *opaque); void *opaque);
typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon, typedef int (*qemuMonitorDomainTrayChangeCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm, virDomainObjPtr vm,
...@@ -375,7 +376,8 @@ int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon); ...@@ -375,7 +376,8 @@ int qemuMonitorEmitPMSuspend(qemuMonitorPtr mon);
int qemuMonitorEmitBlockJob(qemuMonitorPtr mon, int qemuMonitorEmitBlockJob(qemuMonitorPtr mon,
const char *diskAlias, const char *diskAlias,
int type, int type,
int status); int status,
const char *error);
int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon, int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
unsigned long long actual); unsigned long long actual);
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon); int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
......
...@@ -851,6 +851,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon, ...@@ -851,6 +851,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
{ {
const char *device; const char *device;
const char *type_str; const char *type_str;
const char *error = NULL;
int type = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN; int type = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
unsigned long long offset, len; unsigned long long offset, len;
...@@ -883,6 +884,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon, ...@@ -883,6 +884,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
switch ((virConnectDomainEventBlockJobStatus) event) { switch ((virConnectDomainEventBlockJobStatus) event) {
case VIR_DOMAIN_BLOCK_JOB_COMPLETED: case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
error = virJSONValueObjectGetString(data, "error");
/* Make sure the whole device has been processed */ /* Make sure the whole device has been processed */
if (offset != len) if (offset != len)
event = VIR_DOMAIN_BLOCK_JOB_FAILED; event = VIR_DOMAIN_BLOCK_JOB_FAILED;
...@@ -897,7 +899,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon, ...@@ -897,7 +899,7 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
} }
out: out:
qemuMonitorEmitBlockJob(mon, device, type, event); qemuMonitorEmitBlockJob(mon, device, type, event, error);
} }
static void static void
......
...@@ -1000,6 +1000,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED, ...@@ -1000,6 +1000,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
const char *diskAlias, const char *diskAlias,
int type, int type,
int status, int status,
const char *error,
void *opaque) void *opaque)
{ {
virQEMUDriverPtr driver = opaque; virQEMUDriverPtr driver = opaque;
...@@ -1021,6 +1022,8 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED, ...@@ -1021,6 +1022,8 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
/* We have a SYNC API waiting for this event, dispatch it back */ /* We have a SYNC API waiting for this event, dispatch it back */
diskPriv->blockJobType = type; diskPriv->blockJobType = type;
diskPriv->blockJobStatus = status; diskPriv->blockJobStatus = status;
VIR_FREE(diskPriv->blockJobError);
ignore_value(VIR_STRDUP_QUIET(diskPriv->blockJobError, error));
virDomainObjBroadcast(vm); virDomainObjBroadcast(vm);
} else { } else {
/* there is no waiting SYNC API, dispatch the update to a thread */ /* there is no waiting SYNC API, dispatch the update to a thread */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册