[libvirt] [PATCH] remote: drop code for migrating config files from pre-XDG dir layout

Daniel P. Berrangé posted 1 patch 4 years, 10 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190619133743.13244-1-berrange@redhat.com
src/remote/remote_daemon.c | 79 --------------------------------------
1 file changed, 79 deletions(-)
[libvirt] [PATCH] remote: drop code for migrating config files from pre-XDG dir layout
Posted by Daniel P. Berrangé 4 years, 10 months ago
The unprivileged libvirtd daemon switched to use the XDG dir layout in
the 0.9.13 release, and included code for moving config files from the
old location. The chances of someone upgrading libvirt from <= 0.9.12
directly to libvirt >= 5.5.0 is close enough to zero that we can
reasonably drop the back compat code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/remote/remote_daemon.c | 79 --------------------------------------
 1 file changed, 79 deletions(-)

diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index c3782971f1..c1544ba914 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -845,79 +845,6 @@ static int daemonStateInit(virNetDaemonPtr dmn)
     return 0;
 }
 
-static int migrateProfile(void)
-{
-    char *old_base = NULL;
-    char *updated = NULL;
-    char *home = NULL;
-    char *xdg_dir = NULL;
-    char *config_dir = NULL;
-    const char *config_home;
-    int ret = -1;
-    mode_t old_umask;
-
-    VIR_DEBUG("Checking if user profile needs migrating");
-
-    if (!(home = virGetUserDirectory()))
-        goto cleanup;
-
-    if (virAsprintf(&old_base, "%s/.libvirt", home) < 0)
-        goto cleanup;
-
-    /* if the new directory is there or the old one is not: do nothing */
-    if (!(config_dir = virGetUserConfigDirectory()))
-        goto cleanup;
-
-    if (!virFileIsDir(old_base) || virFileExists(config_dir)) {
-        VIR_DEBUG("No old profile in '%s' / "
-                  "new profile directory already present '%s'",
-                  old_base, config_dir);
-        ret = 0;
-        goto cleanup;
-    }
-
-    /* test if we already attempted to migrate first */
-    if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0)
-        goto cleanup;
-    if (virFileExists(updated))
-        goto cleanup;
-
-    config_home = virGetEnvBlockSUID("XDG_CONFIG_HOME");
-    if (config_home && config_home[0] != '\0') {
-        if (VIR_STRDUP(xdg_dir, config_home) < 0)
-            goto cleanup;
-    } else {
-        if (virAsprintf(&xdg_dir, "%s/.config", home) < 0)
-            goto cleanup;
-    }
-
-    old_umask = umask(077);
-    if (virFileMakePath(xdg_dir) < 0) {
-        umask(old_umask);
-        goto cleanup;
-    }
-    umask(old_umask);
-
-    if (rename(old_base, config_dir) < 0) {
-        int fd = creat(updated, 0600);
-        VIR_FORCE_CLOSE(fd);
-        VIR_ERROR(_("Unable to migrate %s to %s"), old_base, config_dir);
-        goto cleanup;
-    }
-
-    VIR_DEBUG("Profile migrated from %s to %s", old_base, config_dir);
-    ret = 0;
-
- cleanup:
-    VIR_FREE(home);
-    VIR_FREE(old_base);
-    VIR_FREE(xdg_dir);
-    VIR_FREE(config_dir);
-    VIR_FREE(updated);
-
-    return ret;
-}
-
 static int
 daemonSetupHostUUID(const struct daemonConfig *config)
 {
@@ -1162,12 +1089,6 @@ int main(int argc, char **argv) {
         exit(EXIT_FAILURE);
     }
 
-    if (!privileged &&
-        migrateProfile() < 0) {
-        VIR_ERROR(_("Exiting due to failure to migrate profile"));
-        exit(EXIT_FAILURE);
-    }
-
     if (daemonSetupHostUUID(config) < 0) {
         VIR_ERROR(_("Can't setup host uuid"));
         exit(EXIT_FAILURE);
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] remote: drop code for migrating config files from pre-XDG dir layout
Posted by Andrea Bolognani 4 years, 10 months ago
On Wed, 2019-06-19 at 14:37 +0100, Daniel P. Berrangé wrote:
> The unprivileged libvirtd daemon switched to use the XDG dir layout in
> the 0.9.13 release, and included code for moving config files from the
> old location. The chances of someone upgrading libvirt from <= 0.9.12
> directly to libvirt >= 5.5.0 is close enough to zero that we can
> reasonably drop the back compat code.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  src/remote/remote_daemon.c | 79 --------------------------------------
>  1 file changed, 79 deletions(-)

Maybe one day we'll even have a formalized policy for compatibility
with old libvirt versions, same as we already have for QEMU... O:-)

For the time being,

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

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