]> git.proxmox.com Git - qemu.git/blobdiff - qga/main.c
qga: save state directory in ga_install_service()
[qemu.git] / qga / main.c
index 5f2d1414316c64d0dc7ccd2aeee8721b0e883c8a..0e04e7395c52b8f5b89bc952d9d20ad1713d3951 100644 (file)
@@ -1022,7 +1022,16 @@ int main(int argc, char **argv)
         case 's':
             service = optarg;
             if (strcmp(service, "install") == 0) {
-                return ga_install_service(path, log_filepath);
+                const char *fixed_state_dir;
+
+                /* If the user passed the "-t" option, we save that state dir
+                 * in the service. Otherwise we let the service fetch the state
+                 * dir from the environment when it starts.
+                 */
+                fixed_state_dir = (state_dir == dfl_pathnames.state_dir) ?
+                                  NULL :
+                                  state_dir;
+                return ga_install_service(path, log_filepath, fixed_state_dir);
             } else if (strcmp(service, "uninstall") == 0) {
                 return ga_uninstall_service();
             } else {