Similar to domainSaveImageGetXMLDesc this commit adds 
domainManagedSaveGetXMLDesc
API which allows to get the xml of managed save state domain.

Signed-off-by: Kothapally Madhu Pavan <k...@linux.vnet.ibm.com>
---
 include/libvirt/libvirt-domain.h |  2 ++
 src/driver-hypervisor.h          |  5 ++++
 src/libvirt-domain.c             | 49 ++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  5 ++++
 src/remote/remote_driver.c       |  1 +
 src/remote/remote_protocol.x     | 19 ++++++++++++++--
 src/remote_protocol-structs      |  8 +++++++
 7 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index a3bb9cb..8ede912 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1209,6 +1209,8 @@ int                    
virDomainHasManagedSaveImage(virDomainPtr dom,
                                                     unsigned int flags);
 int                    virDomainManagedSaveRemove(virDomainPtr dom,
                                                   unsigned int flags);
+char *                 virDomainManagedSaveGetXMLDesc(virDomainPtr domain,
+                                                      unsigned int flags);
 
 /*
  * Domain core dump
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 3053d7a..598fc06 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -745,6 +745,10 @@ typedef int
 (*virDrvDomainManagedSaveRemove)(virDomainPtr domain,
                                  unsigned int flags);
 
+typedef char *
+(*virDrvDomainManagedSaveGetXMLDesc)(virDomainPtr domain,
+                                     unsigned int flags);
+
 typedef virDomainSnapshotPtr
 (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain,
                                  const char *xmlDesc,
@@ -1422,6 +1426,7 @@ struct _virHypervisorDriver {
     virDrvDomainManagedSave domainManagedSave;
     virDrvDomainHasManagedSaveImage domainHasManagedSaveImage;
     virDrvDomainManagedSaveRemove domainManagedSaveRemove;
+    virDrvDomainManagedSaveGetXMLDesc domainManagedSaveGetXMLDesc;
     virDrvDomainSnapshotCreateXML domainSnapshotCreateXML;
     virDrvDomainSnapshotGetXMLDesc domainSnapshotGetXMLDesc;
     virDrvDomainSnapshotNum domainSnapshotNum;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 87fca29..cb260e2 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9298,6 +9298,55 @@ virDomainManagedSaveRemove(virDomainPtr dom, unsigned 
int flags)
 }
 
 
+/**
+ * virDomainManagedSaveGetXMLDesc:
+ * @domain: a domain object
+ * @flags: bitwise-OR of subset of virDomainXMLFlags
+ *
+ * This method will extract the XML description of the managed save
+ * state file of a domain.
+ *
+ * No security-sensitive data will be included unless @flags contains
+ * VIR_DOMAIN_XML_SECURE; this flag is rejected on read-only
+ * connections.  For this API, @flags should not contain either
+ * VIR_DOMAIN_XML_INACTIVE or VIR_DOMAIN_XML_UPDATE_CPU.
+ *
+ * Returns a 0 terminated UTF-8 encoded XML instance, or NULL in case of
+ * error.  The caller must free() the returned value.
+ */
+char *
+virDomainManagedSaveGetXMLDesc(virDomainPtr domain, unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "flags=%x", flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, NULL);
+    conn = domain->conn;
+
+    if ((conn->flags & VIR_CONNECT_RO) && (flags & VIR_DOMAIN_XML_SECURE)) {
+        virReportError(VIR_ERR_OPERATION_DENIED, "%s",
+                       _("virDomainManagedSaveGetXMLDesc with secure flag"));
+        goto error;
+    }
+
+    if (conn->driver->domainManagedSaveGetXMLDesc) {
+        char *ret;
+        ret = conn->driver->domainManagedSaveGetXMLDesc(domain, flags);
+        if (!ret)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return NULL;
+}
+
 
 /**
  * virDomainOpenConsole:
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index fac77fb..b38d0bb 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -768,4 +768,9 @@ LIBVIRT_3.4.0 {
         virStreamSparseSendAll;
 } LIBVIRT_3.1.0;
 
+LIBVIRT_3.7.0 {
+    global:
+        virDomainManagedSaveGetXMLDesc;
+} LIBVIRT_3.4.0;
+
 # .... define new API here using predicted next version number ....
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a57d25f..7a74b87 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8410,6 +8410,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainManagedSave = remoteDomainManagedSave, /* 0.8.0 */
     .domainHasManagedSaveImage = remoteDomainHasManagedSaveImage, /* 0.8.0 */
     .domainManagedSaveRemove = remoteDomainManagedSaveRemove, /* 0.8.0 */
+    .domainManagedSaveGetXMLDesc = remoteDomainManagedSaveGetXMLDesc, /* 3.7.0 
*/
     .domainSnapshotCreateXML = remoteDomainSnapshotCreateXML, /* 0.8.0 */
     .domainSnapshotGetXMLDesc = remoteDomainSnapshotGetXMLDesc, /* 0.8.0 */
     .domainSnapshotNum = remoteDomainSnapshotNum, /* 0.8.0 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 0943208..67d518c 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2547,6 +2547,15 @@ struct remote_domain_managed_save_remove_args {
     unsigned int flags;
 };
 
+struct remote_domain_managed_save_get_xml_desc_args {
+    remote_nonnull_domain dom;
+    unsigned int flags;
+};
+
+struct remote_domain_managed_save_get_xml_desc_ret {
+    remote_nonnull_string xml;
+};
+
 struct remote_domain_snapshot_create_xml_args {
     remote_nonnull_domain dom;
     remote_nonnull_string xml_desc;
@@ -6064,7 +6073,13 @@ enum remote_procedure {
      * @generate: both
      * @acl: domain:write
      */
-    REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD = 386
-
+    REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD = 386,
 
+    /**
+     * @generate: both
+     * @priority: high
+     * @acl: domain:read
+     * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE
+     */
+    REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 387
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index a46fe37..27f95ac 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1963,6 +1963,13 @@ struct remote_domain_managed_save_remove_args {
         remote_nonnull_domain      dom;
         u_int                      flags;
 };
+struct remote_domain_managed_save_get_xml_desc_args {
+        remote_nonnull_domain      dom;
+        u_int                      flags;
+};
+struct remote_domain_managed_save_get_xml_desc_ret {
+        remote_nonnull_string      xml;
+};
 struct remote_domain_snapshot_create_xml_args {
         remote_nonnull_domain      dom;
         remote_nonnull_string      xml_desc;
@@ -3233,4 +3240,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_SET_VCPU = 384,
         REMOTE_PROC_DOMAIN_EVENT_BLOCK_THRESHOLD = 385,
         REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD = 386,
+        REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 387
 };
-- 
1.8.3.1

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

Reply via email to