[libvirt] [PATCH 6/9] Wire up internal entry points for virDomainAbortJob API

Daniel P. Berrange berrange at redhat.com
Thu Feb 4 17:25:28 UTC 2010


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               |   45 +++++++++++++++++++++++++++++++++++++++++++
 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, 61 insertions(+), 0 deletions(-)

diff --git a/src/driver.h b/src/driver.h
index 8f8592a..390b87e 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -364,6 +364,9 @@ typedef int
     (*virDrvDomainGetJobInfo)(virDomainPtr domain,
                               virDomainJobInfoPtr info);
 
+typedef int
+    (*virDrvDomainAbortJob)(virDomainPtr domain);
+
 /**
  * _virDriver:
  *
@@ -453,6 +456,7 @@ struct _virDriver {
     virDrvDomainIsPersistent   domainIsPersistent;
     virDrvCPUCompare            cpuCompare;
     virDrvDomainGetJobInfo     domainGetJobInfo;
+    virDrvDomainAbortJob     domainAbortJob;
 };
 
 typedef int
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index e7312a7..b375527 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3402,6 +3402,7 @@ static virDriver esxDriver = {
     esxDomainIsPersistent,           /* domainIsPersistent */
     NULL,                            /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 
diff --git a/src/libvirt.c b/src/libvirt.c
index a5dedf7..b7c4622 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -11031,3 +11031,48 @@ error:
 }
 
 
+/**
+ * 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 7afdc05..c40ded1 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -352,6 +352,7 @@ LIBVIRT_0.7.5 {
 LIBVIRT_0.7.7 {
     global:
         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 983cab7..b299549 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2457,6 +2457,7 @@ static virDriver lxcDriver = {
     lxcDomainIsPersistent,
     NULL, /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 static virStateDriver lxcStateDriver = {
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index 2c1dd52..9def5f3 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -784,6 +784,7 @@ static virDriver oneDriver = {
     NULL, /* domainIsPersistent */
     NULL, /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 static virStateDriver oneStateDriver = {
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index a7bf72d..88229af 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1536,6 +1536,7 @@ static virDriver openvzDriver = {
     openvzDomainIsPersistent,
     NULL, /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 int openvzRegister(void) {
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index f723f03..05f7bf2 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1652,6 +1652,7 @@ virDriver phypDriver = {
     NULL,                       /* domainIsPersistent */
     NULL,                       /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 int
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 540558f..171670a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8748,6 +8748,7 @@ static virDriver qemuDriver = {
     qemuDomainIsPersistent,
     qemuCPUCompare, /* cpuCompare */
     qemuDomainGetJobInfo, /* domainGetJobInfo */
+    NULL, /* domainFinishJob */
 };
 
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f45bcae..dd0bf9a 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8965,6 +8965,7 @@ static virDriver remote_driver = {
     remoteDomainIsPersistent, /* domainIsPersistent */
     remoteCPUCompare, /* cpuCompare */
     remoteDomainGetJobInfo, /* domainGetJobInfo */
+    NULL, /* domainFinishJob */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index d23fb68..361c061 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5239,6 +5239,7 @@ static virDriver testDriver = {
     testDomainIsPersistent, /* domainIsPersistent */
     NULL, /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 static virNetworkDriver testNetworkDriver = {
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index de42e26..be7f912 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1925,6 +1925,7 @@ static virDriver umlDriver = {
     umlDomainIsPersistent,
     NULL, /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 5abb9f2..88c5d99 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -7036,6 +7036,7 @@ virDriver NAME(Driver) = {
     vboxDomainIsPersistent,
     NULL, /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 virNetworkDriver NAME(NetworkDriver) = {
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 71fc9e9..975d34a 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1865,6 +1865,7 @@ static virDriver xenUnifiedDriver = {
     xenUnifiedDomainisPersistent,
     NULL, /* cpuCompare */
     NULL, /* domainGetJobInfo */
+    NULL, /* domainAbortJob */
 };
 
 /**
-- 
1.6.6




More information about the libvir-list mailing list