From 0d8aa35f602a5f704c6eca2050744302d485044b Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 4 Feb 2010 16:16:35 +0000 Subject: [PATCH] Wire up internal entry points for virDomainAbortJob API This provides the internal glue for the driver API * src/driver.h: Internal API contract * src/libvirt.c, src/libvirt_public.syms: Connect public API to driver API * src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/opennebula/one_driver.c, src/openvz/openvz_driver.c, src/phyp/phyp_driver.c, src/qemu/qemu_driver.c, src/remote/remote_driver.c, src/test/test_driver.c src/uml/uml_driver.c, src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Stub out entry points --- src/driver.h | 4 ++++ src/esx/esx_driver.c | 1 + src/libvirt.c | 47 +++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + src/lxc/lxc_driver.c | 1 + src/opennebula/one_driver.c | 1 + src/openvz/openvz_driver.c | 1 + src/phyp/phyp_driver.c | 1 + src/qemu/qemu_driver.c | 1 + src/remote/remote_driver.c | 1 + src/test/test_driver.c | 1 + src/uml/uml_driver.c | 1 + src/vbox/vbox_tmpl.c | 1 + src/xen/xen_driver.c | 1 + 14 files changed, 63 insertions(+) diff --git a/src/driver.h b/src/driver.h index 8c5d97dae2..7b7dfeaccd 100644 --- a/src/driver.h +++ b/src/driver.h @@ -377,6 +377,9 @@ typedef int (*virDrvDomainGetJobInfo)(virDomainPtr domain, virDomainJobInfoPtr info); +typedef int + (*virDrvDomainAbortJob)(virDomainPtr domain); + /** * _virDriver: * @@ -469,6 +472,7 @@ struct _virDriver { virDrvCPUCompare cpuCompare; virDrvCPUBaseline cpuBaseline; virDrvDomainGetJobInfo domainGetJobInfo; + virDrvDomainAbortJob domainAbortJob; }; typedef int diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 226a6a0dfb..fc2e68c4f6 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -3405,6 +3405,7 @@ static virDriver esxDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; diff --git a/src/libvirt.c b/src/libvirt.c index 4585a4902e..d9242bce98 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -11207,3 +11207,50 @@ error: virDispatchError(domain->conn); return -1; } + + +/** + * virDomainAbortJob: + * @domain: a domain object + * + * Requests that the current background job be aborted at the + * soonest opportunity. This will block until the job has + * either completed, or aborted. + * + * Returns 0 in case of success and -1 in case of failure. + */ +int +virDomainAbortJob(virDomainPtr domain) +{ + virConnectPtr conn; + + DEBUG("domain=%p", domain); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return (-1); + } + + conn = domain->conn; + if (conn->flags & VIR_CONNECT_RO) { + virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + if (conn->driver->domainAbortJob) { + int ret; + ret = conn->driver->domainAbortJob(domain); + if (ret < 0) + goto error; + return ret; + } + + virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 6997b7b4b5..64e7505172 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -355,6 +355,7 @@ LIBVIRT_0.7.7 { virDomainDetachDeviceFlags; virConnectBaselineCPU; virDomainGetJobInfo; + virDomainAbortJob; } 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 2613bd5621..35c865973f 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2452,6 +2452,7 @@ static virDriver lxcDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; static virStateDriver lxcStateDriver = { diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index 5ffc5eb2ed..9fc0ada3e2 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -787,6 +787,7 @@ static virDriver oneDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; static virStateDriver oneStateDriver = { diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index f0d8c95bae..b7bc43b6fc 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1539,6 +1539,7 @@ static virDriver openvzDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; int openvzRegister(void) { diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 1fe4261d62..d3c8c19c05 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1655,6 +1655,7 @@ virDriver phypDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; int diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9d02e2a488..081b698f7f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8918,6 +8918,7 @@ static virDriver qemuDriver = { qemuCPUCompare, /* cpuCompare */ qemuCPUBaseline, /* cpuBaseline */ qemuDomainGetJobInfo, /* domainGetJobInfo */ + NULL, /* domainFinishJob */ }; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 70533e337e..74274bd6bb 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -9101,6 +9101,7 @@ static virDriver remote_driver = { remoteCPUCompare, /* cpuCompare */ remoteCPUBaseline, /* cpuBaseline */ remoteDomainGetJobInfo, /* domainGetJobInfo */ + NULL, /* domainFinishJob */ }; static virNetworkDriver network_driver = { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e0c4f89169..5807288a7a 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5244,6 +5244,7 @@ static virDriver testDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; static virNetworkDriver testNetworkDriver = { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index e2be5b332e..bbea4295f3 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1921,6 +1921,7 @@ static virDriver umlDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 2d1cca1749..a649df8228 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -7064,6 +7064,7 @@ virDriver NAME(Driver) = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; virNetworkDriver NAME(NetworkDriver) = { diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 3e796d3e25..0eb39275fc 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1905,6 +1905,7 @@ static virDriver xenUnifiedDriver = { NULL, /* cpuCompare */ NULL, /* cpuBaseline */ NULL, /* domainGetJobInfo */ + NULL, /* domainAbortJob */ }; /** -- GitLab