mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Asynchronous event for BlockJob completion
When an operation started by virDomainBlockPull completes (either with success or with failure), raise an event to indicate the final status. This API allow users to avoid polling on virDomainGetBlockJobInfo if they would prefer to use an event mechanism. * daemon/remote.c: Dispatch events to client * include/libvirt/libvirt.h.in: Define event ID and callback signature * src/conf/domain_event.c, src/conf/domain_event.h, src/libvirt_private.syms: Extend API to handle the new event * src/qemu/qemu_driver.c: Connect to the QEMU monitor event for block_stream completion and emit a libvirt block pull event * src/remote/remote_driver.c: Receive and dispatch events to application * src/remote/remote_protocol.x: Wire protocol definition for the event * src/remote_protocol-structs: structure definitions for protocol verification * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_json.c: Watch for BLOCK_STREAM_COMPLETED event from QEMU monitor
This commit is contained in:
committed by
Daniel Veillard
parent
f50750b2d0
commit
d489b04628
@@ -339,6 +339,36 @@ static int remoteRelayDomainEventGraphics(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int remoteRelayDomainEventBlockJob(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virDomainPtr dom,
|
||||
const char *path,
|
||||
int type,
|
||||
int status,
|
||||
void *opaque)
|
||||
{
|
||||
virNetServerClientPtr client = opaque;
|
||||
remote_domain_event_block_job_msg data;
|
||||
|
||||
if (!client)
|
||||
return -1;
|
||||
|
||||
VIR_DEBUG("Relaying domain block job event %s %d %s %i, %i",
|
||||
dom->name, dom->id, path, type, status);
|
||||
|
||||
/* build return data */
|
||||
memset(&data, 0, sizeof data);
|
||||
make_nonnull_domain(&data.dom, dom);
|
||||
data.path = (char*)path;
|
||||
data.type = type;
|
||||
data.status = status;
|
||||
|
||||
remoteDispatchDomainEventSend(client, remoteProgram,
|
||||
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB,
|
||||
(xdrproc_t)xdr_remote_domain_event_block_job_msg, &data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int remoteRelayDomainEventControlError(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virDomainPtr dom,
|
||||
@@ -373,6 +403,7 @@ static virConnectDomainEventGenericCallback domainEventCallbacks[] = {
|
||||
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventGraphics),
|
||||
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventIOErrorReason),
|
||||
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventControlError),
|
||||
VIR_DOMAIN_EVENT_CALLBACK(remoteRelayDomainEventBlockJob),
|
||||
};
|
||||
|
||||
verify(ARRAY_CARDINALITY(domainEventCallbacks) == VIR_DOMAIN_EVENT_ID_LAST);
|
||||
|
||||
Reference in New Issue
Block a user