diff --git a/src/driver.h b/src/driver.h index fe21ea39bf944ffa2bc41f921c3330603f1cf29e..8c5d97dae219bdca0188efe839e7f964b36d2c5a 100644 --- a/src/driver.h +++ b/src/driver.h @@ -373,6 +373,10 @@ typedef char * unsigned int ncpus, unsigned int flags); +typedef int + (*virDrvDomainGetJobInfo)(virDomainPtr domain, + virDomainJobInfoPtr info); + /** * _virDriver: * @@ -464,6 +468,7 @@ struct _virDriver { virDrvDomainIsPersistent domainIsPersistent; virDrvCPUCompare cpuCompare; virDrvCPUBaseline cpuBaseline; + virDrvDomainGetJobInfo domainGetJobInfo; }; typedef int diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index e125a09b25e9f8a76c5ced3679cf3180928aec72..226a6a0dfbf5d46d3dad3ce42220952f4b246bd9 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -3404,6 +3404,7 @@ static virDriver esxDriver = { esxDomainIsPersistent, /* domainIsPersistent */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; diff --git a/src/libvirt.c b/src/libvirt.c index 9d50c92a9fbe8f91cd512b345b10cf40a40d583b..4585a4902e3070a410ebc93491317f811f424049 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -11159,3 +11159,51 @@ error: virDispatchError(conn); return NULL; } + + +/** + * virDomainGetJobInfo: + * @domain: a domain object + * @info: pointer to a virDomainJobInfo structure allocated by the user + * + * Extract information about progress of a background job on a domain. + * Will return an error if the domain is not active. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info) +{ + virConnectPtr conn; + DEBUG("domain=%p, info=%p", domain, info); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return (-1); + } + if (info == NULL) { + virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__); + goto error; + } + + memset(info, 0, sizeof(virDomainJobInfo)); + + conn = domain->conn; + + if (conn->driver->domainGetJobInfo) { + int ret; + ret = conn->driver->domainGetJobInfo (domain, info); + if (ret < 0) + goto error; + return ret; + } + + virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + virDispatchError(domain->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 152aae4ce57994f3ea92e846f3e07cd92ec14e94..6997b7b4b539e1b3a3bd709623accdcb584d20e3 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -354,6 +354,7 @@ LIBVIRT_0.7.7 { virDomainAttachDeviceFlags; virDomainDetachDeviceFlags; virConnectBaselineCPU; + virDomainGetJobInfo; } LIBVIRT_0.7.5; # .... define new API here using predicted next version number .... diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f7e9c7d34062d7427043ebfbcba44e3f5475d6d5..2613bd5621d104bd10616681f68171d407529c6b 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2451,6 +2451,7 @@ static virDriver lxcDriver = { lxcDomainIsPersistent, NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; static virStateDriver lxcStateDriver = { diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index 57825d5a346a74a60add60f1e9c15395144b463b..5ffc5eb2edcb38aff3c2ee66f86c2663854e3586 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -786,6 +786,7 @@ static virDriver oneDriver = { NULL, /* domainIsPersistent */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; static virStateDriver oneStateDriver = { diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 4673b6c5ae9cbaeaef46d50b65eb9d67a4eff6a4..f0d8c95bae0b40a73a101aa275422bae5851bc0a 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1538,6 +1538,7 @@ static virDriver openvzDriver = { openvzDomainIsPersistent, NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; int openvzRegister(void) { diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 3fc5a0c27e506830b594a39a728221cba2c08a04..1fe4261d62627072f629e45196397d2d88f622be 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1654,6 +1654,7 @@ virDriver phypDriver = { NULL, /* domainIsPersistent */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 329ba6a75d88c73b07ebc74e56cc5557cd7d9cbf..4161d87b5172cb19ed1e0680228972578bbde104 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8773,6 +8773,7 @@ static virDriver qemuDriver = { qemuDomainIsPersistent, qemuCPUCompare, /* cpuCompare */ qemuCPUBaseline, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index def4617b5feb39e3f25e7ff0b57243aa8737454c..a5af698c645246d2d677441a8f0b92c020092e5f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -9060,6 +9060,7 @@ static virDriver remote_driver = { remoteDomainIsPersistent, /* domainIsPersistent */ remoteCPUCompare, /* cpuCompare */ remoteCPUBaseline, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; static virNetworkDriver network_driver = { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e4720efcbf579c117e07983ae90ab23c035387b8..e0c4f89169a0f9aed07382e77b6b4e7238a1324b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5243,6 +5243,7 @@ static virDriver testDriver = { testDomainIsPersistent, /* domainIsPersistent */ NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; static virNetworkDriver testNetworkDriver = { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 10268dbbdc8f0f09b15e7a05ce6759b507876486..e2be5b332e415390eded26d87d248e3dc88a5196 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1920,6 +1920,7 @@ static virDriver umlDriver = { umlDomainIsPersistent, NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index c414fb812abfdf0af19a0b3fd202e11d671bfcf0..2d1cca1749517e0d25ff7e7efed2dd3e520bb031 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -7063,6 +7063,7 @@ virDriver NAME(Driver) = { vboxDomainIsPersistent, NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; virNetworkDriver NAME(NetworkDriver) = { diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 700682cec7a28da7bc821d085f5f6f5393b7ffc3..3e796d3e2518fc94562b359971ff56104f87a2e7 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1904,6 +1904,7 @@ static virDriver xenUnifiedDriver = { xenUnifiedDomainisPersistent, NULL, /* cpuCompare */ NULL, /* cpuBaseline */ + NULL, /* domainGetJobInfo */ }; /**