[PATCH] Add new API virDomainBlockPull* to header and drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Set up the types for the block pull functions and insert them into the
virDriver structure definition.  Because of static initializers, update every
driver and set the new fields to NULL.

* include/libvirt/libvirt.h.in: new API
* src/driver.h src/*/*_driver.c src/vbox/vbox_tmpl.c: add the new
  entry to the driver structure
* python/generator.py: fix compiler errors, the actual python bindings are
  implemented later

Signed-off-by: Adam Litke <agl@xxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |   92 ++++++++++++++++++++++++++++++++++++++++++
 python/generator.py          |    3 +
 src/driver.h                 |   21 ++++++++++
 src/esx/esx_driver.c         |    4 ++
 src/lxc/lxc_driver.c         |    4 ++
 src/openvz/openvz_driver.c   |    4 ++
 src/phyp/phyp_driver.c       |    4 ++
 src/qemu/qemu_driver.c       |    4 ++
 src/remote/remote_driver.c   |    4 ++
 src/test/test_driver.c       |    4 ++
 src/uml/uml_driver.c         |    4 ++
 src/vbox/vbox_tmpl.c         |    4 ++
 src/xen/xen_driver.c         |    4 ++
 13 files changed, 156 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 5783303..9af1b76 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1145,6 +1145,98 @@ int virDomainUpdateDeviceFlags(virDomainPtr domain,
                                const char *xml, unsigned int flags);
 
 /*
+ * BlockPull API
+ */
+
+/* An iterator for initiating and monitoring block pull operations */
+typedef unsigned long long virDomainBlockPullCursor;
+
+typedef struct _virDomainBlockPullInfo virDomainBlockPullInfo;
+struct _virDomainBlockPullInfo {
+    /*
+     * The following fields provide an indication of block pull progress.  @cur
+     * indicates the current position and will be between 0 and @end.  @end is
+     * the final cursor position for this operation and represents completion.
+     * To approximate progress, divide @cur by @end.
+     */
+    virDomainBlockPullCursor cur;
+    virDomainBlockPullCursor end;
+};
+typedef virDomainBlockPullInfo *virDomainBlockPullInfoPtr;
+
+/**
+ * virDomainBlockPull:
+ * @dom: pointer to domain object
+ * @path: Fully-qualified filename of disk
+ * @info: A pointer to a virDomainBlockPullInfo structure, or NULL
+ * @flags: currently unused, for future extension
+ *
+ * Populate a disk image with data from its backing image.  Once all data from
+ * its backing image has been pulled, the disk no longer depends on a backing
+ * image.  This function works incrementally, performing a small amount of work
+ * each time it is called.  When successful, @info is updated with the current
+ * progress.
+ *
+ * Returns -1 in case of failure, 0 when successful.
+ */
+int                 virDomainBlockPull(virDomainPtr dom,
+                                       const char *path,
+                                       virDomainBlockPullInfoPtr info,
+                                       unsigned int flags);
+
+/**
+ * virDomainBlockPullAll:
+ * @dom: pointer to domain object
+ * @path: Fully-qualified filename of disk
+ * @flags: currently unused, for future extension
+ *
+ * Populate a disk image with data from its backing image.  Once all data from
+ * its backing image has been pulled, the disk no longer depends on a backing
+ * image.  This function pulls data for the entire device in the background.
+ * Progress of the operation can be checked with virDomainGetBlockPullInfo() and
+ * the operation can be aborted with virDomainBlockPullAbort().  When finished,
+ * an asynchronous event is raised to indicate the final status.
+ *
+ * Returns 0 if the operation has started, -1 on failure.
+ */
+int                 virDomainBlockPullAll(virDomainPtr dom,
+                                          const char *path,
+                                          unsigned int flags);
+
+/**
+ * virDomainBlockPullAbort:
+ * @dom: pointer to domain object
+ * @path: fully-qualified filename of disk
+ * @flags: currently unused, for future extension
+ *
+ * Cancel a pull operation previously started by virDomainBlockPullAll().
+ *
+ * Returns -1 in case of failure, 0 when successful.
+ */
+int                 virDomainBlockPullAbort(virDomainPtr dom,
+                                            const char *path,
+                                            unsigned int flags);
+
+/**
+ * virDomainGetBlockPullInfo:
+ * @dom: pointer to domain object
+ * @path: fully-qualified filename of disk
+ * @info: pointer to a virDomainBlockPullInfo structure
+ * @flags: currently unused, for future extension
+ *
+ * Request progress information on a block pull operation that has been started
+ * with virDomainBlockPullAll().  If an operation is active for the given
+ * parameters, @info will be updated with the current progress.
+ *
+ * Returns -1 in case of failure, 0 when successful.
+ */
+int                 virDomainGetBlockPullInfo(virDomainPtr dom,
+                                              const char *path,
+                                              virDomainBlockPullInfoPtr info,
+                                              unsigned int flags);
+
+
+/*
  * NUMA support
  */
 
diff --git a/python/generator.py b/python/generator.py
index 4fa4f65..52be85d 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -166,6 +166,8 @@ def enum(type, name, value):
 functions_failed = []
 functions_skipped = [
     "virConnectListDomains",
+    'virDomainBlockPull',
+    'virDomainGetBlockPullInfo',
 ]
 
 skipped_modules = {
@@ -180,6 +182,7 @@ skipped_types = {
      'virConnectDomainEventIOErrorCallback': "No function types in python",
      'virConnectDomainEventGraphicsCallback': "No function types in python",
      'virEventAddHandleFunc': "No function types in python",
+     'virDomainBlockPullInfoPtr': "Not implemented yet",
 }
 
 #######################################################################
diff --git a/src/driver.h b/src/driver.h
index a8b79e6..3a0391d 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -515,6 +515,23 @@ typedef int
                                virStreamPtr st,
                                unsigned int flags);
 
+typedef int
+    (*virDrvDomainBlockPull)(virDomainPtr dom, const char *path,
+                             virDomainBlockPullInfoPtr info,
+                             unsigned int flags);
+
+typedef int
+    (*virDrvDomainBlockPullAll)(virDomainPtr dom, const char *path,
+                                unsigned int flags);
+
+typedef int
+    (*virDrvDomainBlockPullAbort)(virDomainPtr dom, const char *path,
+                                  unsigned int flags);
+
+typedef int
+    (*virDrvDomainGetBlockPullInfo)(virDomainPtr dom, const char *path,
+                                    virDomainBlockPullInfoPtr info,
+                                    unsigned int flags);
 
 /**
  * _virDriver:
@@ -639,6 +656,10 @@ struct _virDriver {
     virDrvDomainSnapshotDelete domainSnapshotDelete;
     virDrvQemuDomainMonitorCommand qemuDomainMonitorCommand;
     virDrvDomainOpenConsole domainOpenConsole;
+    virDrvDomainBlockPull domainBlockPull;
+    virDrvDomainBlockPullAll domainBlockPullAll;
+    virDrvDomainBlockPullAbort domainBlockPullAbort;
+    virDrvDomainGetBlockPullInfo domainGetBlockPullInfo;
 };
 
 typedef int
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 7933f11..adf75b9 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -4699,6 +4699,10 @@ static virDriver esxDriver = {
     esxDomainSnapshotDelete,         /* domainSnapshotDelete */
     NULL,                            /* qemuDomainMonitorCommand */
     NULL,                            /* domainOpenConsole */
+    NULL,                            /* domainBlockPull */
+    NULL,                            /* domainBlockPullAll */
+    NULL,                            /* domainBlockPullAbort */
+    NULL,                            /* domainGetBlockPullInfo */
 };
 
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index b94941d..7d3eb7a 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2905,6 +2905,10 @@ static virDriver lxcDriver = {
     NULL, /* domainSnapshotDelete */
     NULL, /* qemuDomainMonitorCommand */
     lxcDomainOpenConsole, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 static virStateDriver lxcStateDriver = {
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 0bd007a..fc3f7f0 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1667,6 +1667,10 @@ static virDriver openvzDriver = {
     NULL, /* domainSnapshotDelete */
     NULL, /* qemuDomainMonitorCommand */
     NULL, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 int openvzRegister(void) {
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 30d4adf..817d570 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3828,6 +3828,10 @@ static virDriver phypDriver = {
     NULL,                       /* domainSnapshotDelete */
     NULL,                       /* qemuMonitorCommand */
     NULL, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 static virStorageDriver phypStorageDriver = {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0fd0f10..cfbe199 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7192,6 +7192,10 @@ static virDriver qemuDriver = {
     qemuDomainSnapshotDelete, /* domainSnapshotDelete */
     qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
     qemuDomainOpenConsole, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d076a90..07bc629 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -6493,6 +6493,10 @@ static virDriver remote_driver = {
     remoteDomainSnapshotDelete, /* domainSnapshotDelete */
     remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
     remoteDomainOpenConsole, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 static virNetworkDriver network_driver = {
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 0978214..b35183d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5447,6 +5447,10 @@ static virDriver testDriver = {
     NULL, /* domainSnapshotDelete */
     NULL, /* qemuDomainMonitorCommand */
     NULL, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 static virNetworkDriver testNetworkDriver = {
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 33849a0..86356d5 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -2253,6 +2253,10 @@ static virDriver umlDriver = {
     NULL, /* domainSnapshotDelete */
     NULL, /* qemuDomainMonitorCommand */
     umlDomainOpenConsole, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 static int
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 8241d34..5c0da44 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -8652,6 +8652,10 @@ virDriver NAME(Driver) = {
     vboxDomainSnapshotDelete, /* domainSnapshotDelete */
     NULL, /* qemuDomainMonitorCommand */
     NULL, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 virNetworkDriver NAME(NetworkDriver) = {
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index dd94fbc..f218222 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -2208,6 +2208,10 @@ static virDriver xenUnifiedDriver = {
     NULL, /* domainSnapshotDelete */
     NULL, /* qemuDomainMonitorCommand */
     xenUnifiedDomainOpenConsole, /* domainOpenConsole */
+    NULL, /* domainBlockPull */
+    NULL, /* domainBlockPullAll */
+    NULL, /* domainBlockPullAbort */
+    NULL, /* domainGetBlockPullInfo */
 };
 
 /**
-- 
1.7.3

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]