static void print_activity (struct activity *activity) { if (activity->warning) ansi_red (); else ansi_green (); print_escaped_string (activity->name); ansi_restore (); printf (" %.1fms ±%.1fms ", activity->mean / 1000000, activity->sd / 1000000); if (activity->warning) ansi_red (); else ansi_green (); printf ("(%.1f%%) ", activity->percent); ansi_restore (); }
/* Perform conversion using the kernel method. */ void kernel_conversion (struct config *config, char **cmdline, int cmdline_source) { const char *p; /* Pre-conversion command. */ p = get_cmdline_key (cmdline, "p2v.pre"); if (p) run_command ("p2v.pre", p); /* Connect to and interrogate virt-v2v on the conversion server. */ p = get_cmdline_key (cmdline, "p2v.skip_test_connection"); if (!p) { wait_network_online (config); if (test_connection (config) == -1) { const char *err = get_ssh_error (); error (EXIT_FAILURE, 0, "error opening control connection to %s:%d: %s", config->remote.server, config->remote.port, err); } } /* Some disks must have been specified for conversion. */ if (config->disks == NULL || guestfs_int_count_strings (config->disks) == 0) error (EXIT_FAILURE, 0, "no non-removable disks were discovered on this machine.\n" "virt-p2v looked in /sys/block and in p2v.disks on the kernel command line.\n" "This is a fatal error and virt-p2v cannot continue."); /* Perform the conversion in text mode. */ if (start_conversion (config, notify_ui_callback) == -1) { const char *err = get_conversion_error (); fprintf (stderr, "%s: error during conversion: %s\n", getprogname (), err); p = get_cmdline_key (cmdline, "p2v.fail"); if (p) run_command ("p2v.fail", p); exit (EXIT_FAILURE); } ansi_green (stdout); printf ("Conversion finished successfully."); ansi_restore (stdout); putchar ('\n'); p = get_cmdline_key (cmdline, "p2v.post"); if (!p) { if (geteuid () == 0 && cmdline_source == CMDLINE_SOURCE_PROC_CMDLINE) p = "poweroff"; } if (p) run_command ("p2v.post", p); }