This series introduces 2 new APIs to allow long running jobs to
be monitored and cancelled. This applies to virDomainMigrate,
virDomainSave, virDomainRestore and virDomainCoreDump at least.
The implementation is provided for QEMU only, any others that
are able to implementation can do so as desired.
Usefulness of these new APIs requires use of multiple threads on
a single connection, or multiple connections, since the main
API calls are still all fully blocking. Instead a parallel thread
or process can monitor. This can be seen with virsh
In termainl 1
$ virsh save demo demo.img
In terminal 2
$ ./virsh domjobinfo demo
Job type: Unbounded
Time elapsed: 795 ms
Data processed: 22446080 bytes
Data remaining: 219119616 bytes
Data total: 241565696 bytes
Memory processed: 22446080 bytes
Memory remaining: 219119616 bytes
Memory total: 241565696 bytes
$ ./virsh domjobinfo demo
Job type: Unbounded
Time elapsed: 1669 ms
Data processed: 139784192 bytes
Data remaining: 101781504 bytes
Data total: 241565696 bytes
Memory processed: 139784192 bytes
Memory remaining: 101781504 bytes
Memory total: 241565696 bytes
$ ./virsh domjobabort demo
Back in terminal 1
error: Failed to save domain demo to demo.img
error: operation failed: Migration was cancelled by client
Daniel P. Berrange —
2010年02月05日 星期五 01时25分07秒
The new virDomainAbortJob() method provides a way for a second
thread to abort an ongoing job run by another thread. This
extends to any API with which the virDomainGetJobInfo() API
is intended to work. Cancellation is not guarenteed, rather best
effort on part of the hypervisor and not required to be implmented.
* include/libvirt/libvirt.h.in: Define virDomainAbortJob()
---
include/libvirt/libvirt.h.in | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 5058bc0..0ffcf11 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1804,6 +1804,8 @@ struct _virDomainJobInfo {
int virDomainGetJobInfo(virDomainPtr dom,
virDomainJobInfoPtr info);+int virDomainAbortJob(virDomainPtr dom);
+
#ifdef __cplusplus
}
#endif
Daniel P. Berrange —
2010年02月05日 星期五 01时25分09秒
Introduce support for virDomainGetJobInfo in the QEMU driver. This
allows for monitoring of any API that uses the 'info migrate' monitor
command. ie virDomainMigrate, virDomainSave and virDomainCoreDump
Unfortunately QEMU does not provide a way to monitor incoming migration
so we can't wire up virDomainRestore yet.
The virsh tool gets a new command 'domjobinfo' to query status