*/
static int kexec_load(const char *l_image, const char *l_initrd,
- const char *args)
+ const char *args, int dry_run)
{
int result;
const char *argv[6];
*p++ = l_image; /* 5 */
*p++ = NULL; /* 6 */
- result = pb_run_cmd(argv, 1);
+ result = dry_run ? 0 : pb_run_cmd(argv, 1);
if (result)
pb_log("%s: failed: (%d)\n", __func__, result);
* Must only be called after a successful call to kexec_load().
*/
-static int kexec_reboot(void)
+static int kexec_reboot(int dry_run)
{
- int result;
+ int result = 0;
const char *argv[4];
const char **p;
*p++ = "now"; /* 3 */
*p++ = NULL; /* 4 */
- result = pb_run_cmd(argv, 1);
+ result = dry_run ? 0 : pb_run_cmd(argv, 1);
/* On error, force a kexec with the -e option */
* pb_run_kexec - Run kexec with the supplied boot options.
*/
-int pb_run_kexec(const struct pb_kexec_data *kd)
+int pb_run_kexec(const struct pb_kexec_data *kd, int dry_run)
{
int result;
char *l_image = NULL;
unsigned int clean_image = 0;
unsigned int clean_initrd = 0;
- pb_log("%s: image: '%s'\n", __func__, kd->image);
- pb_log("%s: initrd: '%s'\n", __func__, kd->initrd);
- pb_log("%s: args: '%s'\n", __func__, kd->args);
+ pb_log("%s: image: '%s'\n", __func__, kd->image);
+ pb_log("%s: initrd: '%s'\n", __func__, kd->initrd);
+ pb_log("%s: args: '%s'\n", __func__, kd->args);
+ pb_log("%s: dry_run: '%d'\n", __func__, dry_run);
result = -1;
if (!l_image && !l_initrd)
goto no_load;
- result = kexec_load(l_image, l_initrd, kd->args);
+ result = kexec_load(l_image, l_initrd, kd->args, dry_run);
no_load:
if (clean_image)
talloc_free(l_initrd);
if (!result)
- result = kexec_reboot();
+ result = kexec_reboot(dry_run);
return result;
}