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

[libvirt] [PATCH 2/3] Remove virFileAbsPath() from virDomainSave*() and virDomainCoreDump() calls



Change the semantics of '--file' parameter user provides in cmdline from a
relative/absolute filesystem path to an id which is to be converted in
driver to form a filesystem path.

* src/libvirt.c: remove virFileAbsPath() calls

Signed-off-by: Hong Xiang <hxiang linux vnet ibm com>
---
 src/libvirt.c |   84 +++++----------------------------------------------------
 1 files changed, 7 insertions(+), 77 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index a6bcee6..5de60c7 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2470,18 +2470,8 @@ virDomainSave(virDomainPtr domain, const char *to)
 
     if (conn->driver->domainSave) {
         int ret;
-        char *absolute_to;
 
-        /* We must absolutize the file path as the save is done out of process */
-        if (virFileAbsPath(to, &absolute_to) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                            _("could not build absolute output file path"));
-            goto error;
-        }
-
-        ret = conn->driver->domainSave(domain, absolute_to);
-
-        VIR_FREE(absolute_to);
+        ret = conn->driver->domainSave(domain, to);
 
         if (ret < 0)
             goto error;
@@ -2564,18 +2554,8 @@ virDomainSaveFlags(virDomainPtr domain, const char *to,
 
     if (conn->driver->domainSaveFlags) {
         int ret;
-        char *absolute_to;
-
-        /* We must absolutize the file path as the save is done out of process */
-        if (virFileAbsPath(to, &absolute_to) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                            _("could not build absolute output file path"));
-            goto error;
-        }
 
-        ret = conn->driver->domainSaveFlags(domain, absolute_to, dxml, flags);
-
-        VIR_FREE(absolute_to);
+        ret = conn->driver->domainSaveFlags(domain, to, dxml, flags);
 
         if (ret < 0)
             goto error;
@@ -2623,18 +2603,8 @@ virDomainRestore(virConnectPtr conn, const char *from)
 
     if (conn->driver->domainRestore) {
         int ret;
-        char *absolute_from;
-
-        /* We must absolutize the file path as the restore is done out of process */
-        if (virFileAbsPath(from, &absolute_from) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                            _("could not build absolute input file path"));
-            goto error;
-        }
 
-        ret = conn->driver->domainRestore(conn, absolute_from);
-
-        VIR_FREE(absolute_from);
+        ret = conn->driver->domainRestore(conn, from);
 
         if (ret < 0)
             goto error;
@@ -2708,20 +2678,10 @@ virDomainRestoreFlags(virConnectPtr conn, const char *from, const char *dxml,
 
     if (conn->driver->domainRestoreFlags) {
         int ret;
-        char *absolute_from;
-
-        /* We must absolutize the file path as the restore is done out of process */
-        if (virFileAbsPath(from, &absolute_from) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                            _("could not build absolute input file path"));
-            goto error;
-        }
 
-        ret = conn->driver->domainRestoreFlags(conn, absolute_from, dxml,
+        ret = conn->driver->domainRestoreFlags(conn, from, dxml,
                                                flags);
 
-        VIR_FREE(absolute_from);
-
         if (ret < 0)
             goto error;
         return ret;
@@ -2779,20 +2739,10 @@ virDomainSaveImageGetXMLDesc(virConnectPtr conn, const char *file,
 
     if (conn->driver->domainSaveImageGetXMLDesc) {
         char *ret;
-        char *absolute_file;
 
-        /* We must absolutize the file path as the read is done out of process */
-        if (virFileAbsPath(file, &absolute_file) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                            _("could not build absolute input file path"));
-            goto error;
-        }
-
-        ret = conn->driver->domainSaveImageGetXMLDesc(conn, absolute_file,
+        ret = conn->driver->domainSaveImageGetXMLDesc(conn, file,
                                                       flags);
 
-        VIR_FREE(absolute_file);
-
         if (!ret)
             goto error;
         return ret;
@@ -2862,20 +2812,10 @@ virDomainSaveImageDefineXML(virConnectPtr conn, const char *file,
 
     if (conn->driver->domainSaveImageDefineXML) {
         int ret;
-        char *absolute_file;
-
-        /* We must absolutize the file path as the read is done out of process */
-        if (virFileAbsPath(file, &absolute_file) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                            _("could not build absolute input file path"));
-            goto error;
-        }
 
-        ret = conn->driver->domainSaveImageDefineXML(conn, absolute_file,
+        ret = conn->driver->domainSaveImageDefineXML(conn, file,
                                                      dxml, flags);
 
-        VIR_FREE(absolute_file);
-
         if (ret < 0)
             goto error;
         return ret;
@@ -2957,18 +2897,8 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags)
 
     if (conn->driver->domainCoreDump) {
         int ret;
-        char *absolute_to;
-
-        /* We must absolutize the file path as the save is done out of process */
-        if (virFileAbsPath(to, &absolute_to) < 0) {
-            virLibConnError(VIR_ERR_INTERNAL_ERROR,
-                            _("could not build absolute core file path"));
-            goto error;
-        }
-
-        ret = conn->driver->domainCoreDump(domain, absolute_to, flags);
 
-        VIR_FREE(absolute_to);
+        ret = conn->driver->domainCoreDump(domain, to, flags);
 
         if (ret < 0)
             goto error;
-- 
1.7.1


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