[PATCH 13/8] save: wire up trivial restoreFlags implementations

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

 



For all hypervisors that support restore, the new API now performs
the same functions as the old.

* src/libxl/libxl_driver.c (libxlDomainRestore): Move guts...
(libxlDomainRestoreFlags): ...to new function.
* src/qemu/qemu_driver.c (qemuDomainRestore)
(qemuDomainRestoreFlags): Likewise.
* src/test/test_driver.c (testDomainRestore)
(testDomainRestoreFlags): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainRestore)
(xenUnifiedDomainRestoreFlags): Likewise.
---

Again, this might be worth merging into 3/8.

 src/libxl/libxl_driver.c |   17 ++++++++++++++++-
 src/qemu/qemu_driver.c   |   21 +++++++++++++++++++--
 src/test/test_driver.c   |   22 ++++++++++++++++++++--
 src/xen/xen_driver.c     |   17 ++++++++++++++++-
 4 files changed, 71 insertions(+), 6 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index d26cba4..a11a3bb 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1952,7 +1952,8 @@ libxlDomainSave(virDomainPtr dom, const char *to)
 }

 static int
-libxlDomainRestore(virConnectPtr conn, const char *from)
+libxlDomainRestoreFlags(virConnectPtr conn, const char *from,
+                        const char *dxml, unsigned int flags)
 {
     libxlDriverPrivatePtr driver = conn->privateData;
     virDomainObjPtr vm = NULL;
@@ -1961,6 +1962,13 @@ libxlDomainRestore(virConnectPtr conn, const char *from)
     int fd = -1;
     int ret = -1;

+    virCheckFlags(0, -1);
+    if (dxml) {
+        libxlError(VIR_ERR_INVALID_ARG, "%s",
+                   _("xml modification unsupported"));
+        return -1;
+    }
+
     libxlDriverLock(driver);

     fd = libxlSaveImageOpen(driver, from, &def, &hdr);
@@ -1992,6 +2000,12 @@ cleanup:
 }

 static int
+libxlDomainRestore(virConnectPtr conn, const char *from)
+{
+    return libxlDomainRestoreFlags(conn, from, NULL, 0);
+}
+
+static int
 libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
 {
     libxlDriverPrivatePtr driver = dom->conn->privateData;
@@ -3849,6 +3863,7 @@ static virDriver libxlDriver = {
     .domainSave = libxlDomainSave, /* 0.9.2 */
     .domainSaveFlags = libxlDomainSaveFlags, /* 0.9.4 */
     .domainRestore = libxlDomainRestore, /* 0.9.2 */
+    .domainRestoreFlags = libxlDomainRestoreFlags, /* 0.9.4 */
     .domainCoreDump = libxlDomainCoreDump, /* 0.9.2 */
     .domainSetVcpus = libxlDomainSetVcpus, /* 0.9.0 */
     .domainSetVcpusFlags = libxlDomainSetVcpusFlags, /* 0.9.0 */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 10e1fd8..122365f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3800,8 +3800,10 @@ out:
 }

 static int
-qemuDomainRestore(virConnectPtr conn,
-                  const char *path)
+qemuDomainRestoreFlags(virConnectPtr conn,
+                       const char *path,
+                       const char *dxml,
+                       unsigned int flags)
 {
     struct qemud_driver *driver = conn->privateData;
     virDomainDefPtr def = NULL;
@@ -3810,6 +3812,13 @@ qemuDomainRestore(virConnectPtr conn,
     int ret = -1;
     struct qemud_save_header header;

+    virCheckFlags(0, -1);
+    if (dxml) {
+        qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+                        _("xml modification unsupported"));
+        return -1;
+    }
+
     qemuDriverLock(driver);

     fd = qemuDomainSaveImageOpen(driver, path, &def, &header);
@@ -3849,6 +3858,13 @@ cleanup:
 }

 static int
+qemuDomainRestore(virConnectPtr conn,
+                  const char *path)
+{
+    return qemuDomainRestoreFlags(conn, path, NULL, 0);
+}
+
+static int
 qemuDomainObjRestore(virConnectPtr conn,
                      struct qemud_driver *driver,
                      virDomainObjPtr vm,
@@ -8570,6 +8586,7 @@ static virDriver qemuDriver = {
     .domainSave = qemuDomainSave, /* 0.2.0 */
     .domainSaveFlags = qemuDomainSaveFlags, /* 0.9.4 */
     .domainRestore = qemuDomainRestore, /* 0.2.0 */
+    .domainRestoreFlags = qemuDomainRestoreFlags, /* 0.9.4 */
     .domainCoreDump = qemudDomainCoreDump, /* 0.7.0 */
     .domainScreenshot = qemuDomainScreenshot, /* 0.9.2 */
     .domainSetVcpus = qemuDomainSetVcpus, /* 0.4.4 */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 74a1d26..e1621f9 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1835,8 +1835,11 @@ testDomainSave(virDomainPtr domain,
     return testDomainSaveFlags(domain, path, NULL, 0);
 }

-static int testDomainRestore(virConnectPtr conn,
-                             const char *path)
+static int
+testDomainRestoreFlags(virConnectPtr conn,
+                       const char *path,
+                       const char *dxml,
+                       unsigned int flags)
 {
     testConnPtr privconn = conn->privateData;
     char *xml = NULL;
@@ -1848,6 +1851,13 @@ static int testDomainRestore(virConnectPtr conn,
     virDomainEventPtr event = NULL;
     int ret = -1;

+    virCheckFlags(0, -1);
+    if (dxml) {
+        testError(VIR_ERR_INVALID_ARG, "%s",
+                  _("xml modification unsupported"));
+        return -1;
+    }
+
     if ((fd = open(path, O_RDONLY)) < 0) {
         virReportSystemError(errno,
                              _("cannot read domain image '%s'"),
@@ -1924,6 +1934,13 @@ cleanup:
     return ret;
 }

+static int
+testDomainRestore(virConnectPtr conn,
+                  const char *path)
+{
+    return testDomainRestoreFlags(conn, path, NULL, 0);
+}
+
 static int testDomainCoreDump(virDomainPtr domain,
                               const char *to,
                               unsigned int flags)
@@ -5573,6 +5590,7 @@ static virDriver testDriver = {
     .domainSave = testDomainSave, /* 0.3.2 */
     .domainSaveFlags = testDomainSaveFlags, /* 0.9.4 */
     .domainRestore = testDomainRestore, /* 0.3.2 */
+    .domainRestoreFlags = testDomainRestoreFlags, /* 0.9.4 */
     .domainCoreDump = testDomainCoreDump, /* 0.3.2 */
     .domainSetVcpus = testSetVcpus, /* 0.1.4 */
     .domainSetVcpusFlags = testDomainSetVcpusFlags, /* 0.8.5 */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index e7f1eb6..542777e 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1080,11 +1080,19 @@ xenUnifiedDomainSave(virDomainPtr dom, const char *to)
 }

 static int
-xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
+xenUnifiedDomainRestoreFlags(virConnectPtr conn, const char *from,
+                             const char *dxml, unsigned int flags)
 {
     GET_PRIVATE(conn);
     int i;

+    virCheckFlags(0, -1);
+    if (dxml) {
+        xenUnifiedError(VIR_ERR_INVALID_ARG, "%s",
+                        _("xml modification unsupported"));
+        return -1;
+    }
+
     for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
         if (priv->opened[i] &&
             drivers[i]->domainRestore &&
@@ -1095,6 +1103,12 @@ xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
 }

 static int
+xenUnifiedDomainRestore (virConnectPtr conn, const char *from)
+{
+    return xenUnifiedDomainRestoreFlags(conn, from, NULL, 0);
+}
+
+static int
 xenUnifiedDomainCoreDump (virDomainPtr dom, const char *to, unsigned int flags)
 {
     GET_PRIVATE(dom->conn);
@@ -2215,6 +2229,7 @@ static virDriver xenUnifiedDriver = {
     .domainSave = xenUnifiedDomainSave, /* 0.0.3 */
     .domainSaveFlags = xenUnifiedDomainSaveFlags, /* 0.9.4 */
     .domainRestore = xenUnifiedDomainRestore, /* 0.0.3 */
+    .domainRestoreFlags = xenUnifiedDomainRestoreFlags, /* 0.9.4 */
     .domainCoreDump = xenUnifiedDomainCoreDump, /* 0.1.9 */
     .domainSetVcpus = xenUnifiedDomainSetVcpus, /* 0.1.4 */
     .domainSetVcpusFlags = xenUnifiedDomainSetVcpusFlags, /* 0.8.5 */
-- 
1.7.4.4

--
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]