]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
linuxDeployment.c: Suppress the telinit error if the first telinit commands
authorOliver Kurth <okurth@vmware.com>
Mon, 17 Jun 2019 18:41:38 +0000 (11:41 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 17 Jun 2019 18:41:38 +0000 (11:41 -0700)
                   has made VM reboot.

The code executes '/sbin/telinit 6' repeatedly to reboot VM.  VM will be
rebooting if the telinit command executed successfully(exitcode==0).
Observed the repeated telinit command might get error(exitcode==1) on some
GOSes, ex: Ubuntu18.04, RHEL7.4/7.5 and Fedora 29.
Observed no such error on older GOSes, ex: Ubuntu14.04, RHEL6.6

The error telinit log is confusing, actually it does NOT mean customization
failed.

This change does NOT log telinit error, and returns deployPkg status to
make sure the log is consistent with customization result when the first
'telinit 6' succeeded but one of the following 'telinit 6' command failed.

The following actions are unchanged with or without this change:
1. log telinit error, stop loop and exit 127 if the first 'telinit 6' fails.
2. repeatedly execute 'telinit 6' if previous one executed successfully
   (exitcode==0).

open-vm-tools/libDeployPkg/linuxDeployment.c

index 1127502faa4f75392631cdcd9bb4a7de2b7f7116..1af08936ee5397801271073c3d56e29b9ae689dc 100644 (file)
@@ -1408,15 +1408,27 @@ Deploy(const char* packageName)
 
          // Repeatedly try to reboot to workaround PR 530641 where
          // telinit 6 is overwritten by a telinit 2
-         int rebootComandResult = 0;
+         int rebootCommandResult;
+         bool isRebooting = false;
+         sLog(log_info, "Trigger reboot.\n");
          do {
-            sLog(log_info, "Rebooting.\n");
-            rebootComandResult = ForkExecAndWaitCommand("/sbin/telinit 6", false);
+            if (isRebooting) {
+               sLog(log_info, "Rebooting.\n");
+            }
+            rebootCommandResult =
+               ForkExecAndWaitCommand("/sbin/telinit 6", false);
+            isRebooting = (rebootCommandResult == 0) ?
+                          true : isRebooting;
             sleep(1);
-         } while (rebootComandResult == 0);
-         sLog(log_error, "telinit returned error %d.\n", rebootComandResult);
-
-         exit (127);
+         } while (rebootCommandResult == 0);
+         if (!isRebooting) {
+            sLog(log_error,
+                 "Failed to reboot, telinit returned error %d.\n",
+                 rebootCommandResult);
+            exit (127);
+         } else {
+            sLog(log_info, "Reboot has been triggered.\n");
+         }
       }
    }