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

[libvirt] [PATCH v5 2/7] lib: Add API to edit domain's managed save state xml configuration



From: Kothapally Madhu Pavan <kmp linux vnet ibm com>

Similar to domainSaveImageDefineXML this commit adds domainManagedSaveDefineXML
API which allows to edit domain's managed save state xml configuration.

Signed-off-by: Kothapally Madhu Pavan <kmp linux vnet ibm com>
---
 include/libvirt/libvirt-domain.h |  4 +++
 src/driver-hypervisor.h          |  6 +++++
 src/libvirt-domain.c             | 57 ++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  1 +
 src/remote/remote_driver.c       |  1 +
 src/remote/remote_protocol.x     | 15 ++++++++++-
 src/remote_protocol-structs      |  6 +++++
 7 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 4c5a7f7b5..030a62c43 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1215,6 +1215,10 @@ int                    virDomainManagedSaveRemove(virDomainPtr dom,
                                                   unsigned int flags);
 char *                 virDomainManagedSaveGetXMLDesc(virDomainPtr domain,
                                                       unsigned int flags);
+int                    virDomainManagedSaveDefineXML(virDomainPtr domain,
+                                                     const char *dxml,
+                                                     unsigned int flags);
+

 /*
  * Domain core dump
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index a3f9cbc31..6c3f7d795 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -754,6 +754,11 @@ typedef char *
 (*virDrvDomainManagedSaveGetXMLDesc)(virDomainPtr domain,
                                      unsigned int flags);

+typedef int
+(*virDrvDomainManagedSaveDefineXML)(virDomainPtr domain,
+                                    const char *dxml,
+                                    unsigned int flags);
+
 typedef virDomainSnapshotPtr
 (*virDrvDomainSnapshotCreateXML)(virDomainPtr domain,
                                  const char *xmlDesc,
@@ -1433,6 +1438,7 @@ struct _virHypervisorDriver {
     virDrvDomainHasManagedSaveImage domainHasManagedSaveImage;
     virDrvDomainManagedSaveRemove domainManagedSaveRemove;
     virDrvDomainManagedSaveGetXMLDesc domainManagedSaveGetXMLDesc;
+    virDrvDomainManagedSaveDefineXML domainManagedSaveDefineXML;
     virDrvDomainSnapshotCreateXML domainSnapshotCreateXML;
     virDrvDomainSnapshotGetXMLDesc domainSnapshotGetXMLDesc;
     virDrvDomainSnapshotNum domainSnapshotNum;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index f43ab2478..ca5a1536a 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9389,6 +9389,63 @@ virDomainManagedSaveGetXMLDesc(virDomainPtr domain, unsigned int flags)
 }


+/**
+ * virDomainManagedSaveDefineXML:
+ * @domain: a domain object
+ * @dxml: XML config for adjusting guest xml used on restore
+ * @flags: bitwise-OR of virDomainSaveRestoreFlags
+ *
+ * This updates the definition of a domain stored in a saved state
+ * file.
+ *
+ * @dxml can be used to alter host-specific portions of the domain XML
+ * that will be used on the next start of the domain. For example, it is
+ * possible to alter the backing filename that is associated with a
+ * disk device.
+ *
+ * Normally, the saved state file will remember whether the domain was
+ * running or paused, and restore defaults to the same state.
+ * Specifying VIR_DOMAIN_SAVE_RUNNING or VIR_DOMAIN_SAVE_PAUSED in
+ * @flags will override the default saved into the file; omitting both
+ * leaves the file's default unchanged.  These two flags are mutually
+ * exclusive.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainManagedSaveDefineXML(virDomainPtr domain, const char *dxml,
+                              unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "flags=%x", flags);
+
+    virResetLastError();
+
+    VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_SAVE_RUNNING,
+                             VIR_DOMAIN_SAVE_PAUSED,
+                             error);
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+
+    if (conn->driver->domainManagedSaveDefineXML) {
+        int ret;
+        ret = conn->driver->domainManagedSaveDefineXML(domain, dxml, flags);
+
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
+
+
 /**
  * virDomainOpenConsole:
  * @dom: a domain object
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 58b9b4910..498601943 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -772,5 +772,6 @@ LIBVIRT_3.7.0 {
     global:
         virDomainMigrateGetMaxDowntime;
         virDomainManagedSaveGetXMLDesc;
+        virDomainManagedSaveDefineXML;
 } 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 c64f5b337..7f814cd4f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8412,6 +8412,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainHasManagedSaveImage = remoteDomainHasManagedSaveImage, /* 0.8.0 */
     .domainManagedSaveRemove = remoteDomainManagedSaveRemove, /* 0.8.0 */
     .domainManagedSaveGetXMLDesc = remoteDomainManagedSaveGetXMLDesc, /* 3.7.0 */
+    .domainManagedSaveDefineXML = remoteDomainManagedSaveDefineXML, /* 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 76033acc9..07463b781 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2565,6 +2565,12 @@ struct remote_domain_managed_save_get_xml_desc_ret {
     remote_nonnull_string xml;
 };

+struct remote_domain_managed_save_define_xml_args {
+    remote_nonnull_domain dom;
+    remote_string dxml;
+    unsigned int flags;
+};
+
 struct remote_domain_snapshot_create_xml_args {
     remote_nonnull_domain dom;
     remote_nonnull_string xml_desc;
@@ -6095,5 +6101,12 @@ enum remote_procedure {
      * @acl: domain:read
      * @acl: domain:read_secure:VIR_DOMAIN_XML_SECURE
      */
-    REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 388
+    REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 388,
+
+    /**
+     * @generate: both
+     * @acl: domain:write
+     * @acl: domain:hibernate
+     */
+    REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML = 389
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 4803a46f2..6038bf138 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1977,6 +1977,11 @@ struct remote_domain_managed_save_get_xml_desc_args {
 struct remote_domain_managed_save_get_xml_desc_ret {
         remote_nonnull_string      xml;
 };
+struct remote_domain_managed_save_define_xml_args {
+        remote_nonnull_domain      dom;
+        remote_string              dxml;
+        u_int                      flags;
+};
 struct remote_domain_snapshot_create_xml_args {
         remote_nonnull_domain      dom;
         remote_nonnull_string      xml_desc;
@@ -3249,4 +3254,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_SET_BLOCK_THRESHOLD = 386,
         REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_DOWNTIME = 387,
         REMOTE_PROC_DOMAIN_MANAGED_SAVE_GET_XML_DESC = 388,
+        REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML = 389,
 };
-- 
2.14.1


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