[libvirt] [PATCH 1/4] storage: Introduce virStorageVolAbortJob

2012-03-13 Thread Michal Privoznik
This API can be used to terminate long running jobs
on a volume like its building, resizing, wiping.
Moreover, like virDomainAbortJob() calling this API
will block until job has either completed or aborted.
---
 include/libvirt/libvirt.h.in |3 ++
 src/driver.h |5 
 src/libvirt.c|   49 ++
 src/libvirt_public.syms  |1 +
 src/remote/remote_driver.c   |1 +
 src/remote/remote_protocol.x |8 ++-
 src/remote_protocol-structs  |5 
 7 files changed, 71 insertions(+), 1 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 7d41642..77ec3f0 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2513,6 +2513,9 @@ int virStorageVolResize 
(virStorageVolPtr vol,
  unsigned long long 
capacity,
  unsigned int flags);
 
+int virStorageVolAbortJob   (virStorageVolPtr vol,
+ unsigned int flags);
+
 
 /**
  * virKeycodeSet:
diff --git a/src/driver.h b/src/driver.h
index 03d249b..7845b06 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1314,6 +1314,10 @@ typedef int
unsigned int flags);
 
 typedef int
+(*virDrvStorageVolAbortJob) (virStorageVolPtr vol,
+ unsigned int flags);
+
+typedef int
 (*virDrvStoragePoolIsActive)(virStoragePoolPtr pool);
 typedef int
 (*virDrvStoragePoolIsPersistent)(virStoragePoolPtr pool);
@@ -1377,6 +1381,7 @@ struct _virStorageDriver {
 virDrvStorageVolResize volResize;
 virDrvStoragePoolIsActive   poolIsActive;
 virDrvStoragePoolIsPersistent   poolIsPersistent;
+virDrvStorageVolAbortJobvolAbortJob;
 };
 
 # ifdef WITH_LIBVIRTD
diff --git a/src/libvirt.c b/src/libvirt.c
index e916aa0..8ce3234 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -13343,6 +13343,55 @@ error:
 }
 
 /**
+ * virStorageVolAbortJob:
+ * @vol: pointer to storage volume
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * 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
+ *  -1 otherwise
+ */
+int
+virStorageVolAbortJob(virStorageVolPtr vol,
+  unsigned int flags)
+{
+virConnectPtr conn;
+VIR_DEBUG(vol=%p flags=%x, vol, flags);
+
+virResetLastError();
+
+if (!VIR_IS_STORAGE_VOL(vol)) {
+virLibStorageVolError(VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+virDispatchError(NULL);
+return -1;
+}
+
+conn = vol-conn;
+
+if (conn-flags  VIR_CONNECT_RO) {
+   virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+   goto error;
+}
+
+if (conn-storageDriver  conn-storageDriver-volAbortJob) {
+int ret;
+ret = conn-storageDriver-volAbortJob(vol, flags);
+if (ret  0)
+goto error;
+return ret;
+}
+
+virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+virDispatchError(vol-conn);
+return -1;
+}
+
+/**
  * virNodeNumOfDevices:
  * @conn: pointer to the hypervisor connection
  * @cap: capability name
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 46c13fb..cd3e2a6 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -532,6 +532,7 @@ LIBVIRT_0.9.10 {
 LIBVIRT_0.9.11 {
 global:
 virDomainPMWakeup;
+virStorageVolAbortJob;
 } LIBVIRT_0.9.10;
 
 #  define new API here using predicted next version number 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 031167a..3534ac0 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5013,6 +5013,7 @@ static virStorageDriver storage_driver = {
 .volResize = remoteStorageVolResize, /* 0.9.10 */
 .poolIsActive = remoteStoragePoolIsActive, /* 0.7.3 */
 .poolIsPersistent = remoteStoragePoolIsPersistent, /* 0.7.3 */
+.volAbortJob = remoteStorageVolAbortJob, /* 0.9.11 */
 };
 
 static virSecretDriver secret_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 4d845e7..014eade 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1754,6 +1754,11 @@ struct remote_storage_vol_resize_args {
 unsigned int flags;
 };
 
+struct remote_storage_vol_abort_job_args {
+remote_nonnull_storage_vol vol;
+unsigned int flags;
+};
+
 /* Node driver calls: */
 
 struct remote_node_num_of_devices_args {
@@ -2765,7 +2770,8 @@ enum remote_procedure {
 REMOTE_PROC_DOMAIN_SET_METADATA = 264, /* autogen autogen */
 REMOTE_PROC_DOMAIN_GET_METADATA = 265, /* autogen autogen */
 

Re: [libvirt] [PATCH 1/4] storage: Introduce virStorageVolAbortJob

2012-03-13 Thread Daniel P. Berrange
On Tue, Mar 13, 2012 at 03:35:29PM +0100, Michal Privoznik wrote:
 This API can be used to terminate long running jobs
 on a volume like its building, resizing, wiping.
 Moreover, like virDomainAbortJob() calling this API
 will block until job has either completed or aborted.
 ---
  include/libvirt/libvirt.h.in |3 ++
  src/driver.h |5 
  src/libvirt.c|   49 
 ++
  src/libvirt_public.syms  |1 +
  src/remote/remote_driver.c   |1 +
  src/remote/remote_protocol.x |8 ++-
  src/remote_protocol-structs  |5 
  7 files changed, 71 insertions(+), 1 deletions(-)
 
 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index 7d41642..77ec3f0 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -2513,6 +2513,9 @@ int virStorageVolResize 
 (virStorageVolPtr vol,
   unsigned long long 
 capacity,
   unsigned int flags);
  
 +int virStorageVolAbortJob   (virStorageVolPtr 
 vol,
 + unsigned int flags);
 +

No,  virStorageVolGetJobInfo()  API to go with it ?   IMHO we should have
both, so we mirror the virDomain job API design.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/4] storage: Introduce virStorageVolAbortJob

2012-03-13 Thread Michal Privoznik
On 13.03.2012 15:48, Daniel P. Berrange wrote:
 On Tue, Mar 13, 2012 at 03:35:29PM +0100, Michal Privoznik wrote:
 This API can be used to terminate long running jobs
 on a volume like its building, resizing, wiping.
 Moreover, like virDomainAbortJob() calling this API
 will block until job has either completed or aborted.
 ---
  include/libvirt/libvirt.h.in |3 ++
  src/driver.h |5 
  src/libvirt.c|   49 
 ++
  src/libvirt_public.syms  |1 +
  src/remote/remote_driver.c   |1 +
  src/remote/remote_protocol.x |8 ++-
  src/remote_protocol-structs  |5 
  7 files changed, 71 insertions(+), 1 deletions(-)

 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index 7d41642..77ec3f0 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -2513,6 +2513,9 @@ int virStorageVolResize
  (virStorageVolPtr vol,
   unsigned long long 
 capacity,
   unsigned int 
 flags);
  
 +int virStorageVolAbortJob   (virStorageVolPtr 
 vol,
 + unsigned int 
 flags);
 +
 
 No,  virStorageVolGetJobInfo()  API to go with it ?   IMHO we should have
 both, so we mirror the virDomain job API design.
 
 Regards,
 Daniel

yeah, virStorageVolGetJobInfo() is one of the improvements I'm
mentioning in cover letter. But I've decided to not implement it for now
as another huge bunch of code would have to be rewritten make this patch
set unbearable big. But if it is a show stopper I can rewrite and post v2.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list