Since the previous commit introduced configuration sections, we can
now group more configuration settings together in these sections.
This is just a renaming of certain fields.
---
generator/p2v_config.ml | 46 ++++++++++-------
p2v/conversion.c | 18 +++----
p2v/gui.c | 96 ++++++++++++++++++------------------
p2v/kernel.c | 44 ++++++++---------
p2v/main.c | 6 +--
p2v/ssh.c | 56 ++++++++++-----------
p2v/test-virt-p2v-cmdline.sh | 18 +++----
7 files changed, 146 insertions(+), 138 deletions(-)
diff --git a/generator/p2v_config.ml b/generator/p2v_config.ml
index 1f998fd7c..e0347d6c2 100644
--- a/generator/p2v_config.ml
+++ b/generator/p2v_config.ml
@@ -34,7 +34,7 @@ type config_entry =
| ConfigInt of string * int (* field name, initial value *)
| ConfigUnsigned of string
| ConfigUInt64 of string
- | ConfigEnum of string
+ | ConfigEnum of string * string (* field name, enum *)
| ConfigBool of string
| ConfigStringList of string
| ConfigSection of string * config_entry list
@@ -55,14 +55,20 @@ let enums = [
(* Configuration fields. *)
let fields = [
- ConfigString "server";
- ConfigInt ("port", 22);
- ConfigString "username";
- ConfigString "password";
- ConfigString "identity_url";
- ConfigString "identity_file";
- ConfigBool "identity_file_needs_update";
- ConfigBool "sudo";
+ ConfigSection ("remote", [
+ ConfigString "server";
+ ConfigInt ("port", 22);
+ ]);
+ ConfigSection ("auth", [
+ ConfigString "username";
+ ConfigString "password";
+ ConfigSection ("identity", [
+ ConfigString "url";
+ ConfigString "file";
+ ConfigBool "file_needs_update";
+ ]);
+ ConfigBool "sudo";
+ ]);
ConfigString "guestname";
ConfigInt ("vcpus", 0);
ConfigUInt64 "memory";
@@ -77,18 +83,20 @@ let fields = [
ConfigBool "pae";
]);
ConfigSection ("rtc", [
- ConfigEnum "basis";
+ ConfigEnum ("basis", "basis");
ConfigInt ("offset", 0);
]);
ConfigStringList "disks";
ConfigStringList "removable";
ConfigStringList "interfaces";
ConfigStringList "network_map";
- ConfigString "output";
- ConfigEnum "output_allocation";
- ConfigString "output_connection";
- ConfigString "output_format";
- ConfigString "output_storage";
+ ConfigSection ("output", [
+ ConfigString "type";
+ ConfigEnum ("allocation",
"output_allocation");
+ ConfigString "connection";
+ ConfigString "format";
+ ConfigString "storage";
+ ]);
]
let name_of_config_entry = function
@@ -96,7 +104,7 @@ let name_of_config_entry = function
| ConfigInt (n, _)
| ConfigUnsigned n
| ConfigUInt64 n
- | ConfigEnum n
+ | ConfigEnum (n, _)
| ConfigBool n
| ConfigStringList n
| ConfigSection (n, _) -> n
@@ -156,7 +164,7 @@ and generate_config_struct name fields =
| ConfigInt (n, _) -> pr " int %s;\n" n
| ConfigUnsigned n -> pr " unsigned %s;\n" n
| ConfigUInt64 n -> pr " uint64_t %s;\n" n
- | ConfigEnum n -> pr " enum %s %s;\n" n n
+ | ConfigEnum (n, enum) -> pr " enum %s %s;\n" enum n
| ConfigBool n -> pr " bool %s;\n" n
| ConfigStringList n -> pr " char **%s;\n" n
| ConfigSection (n, _) -> pr " struct %s_config %s;\n" n n
@@ -365,9 +373,9 @@ and generate_field_print prefix v fields =
| ConfigUInt64 n ->
pr " fprintf (fp, \"%%-20s %%\" PRIu64
\"\\n\",\n";
pr " \"%s\", %s%s);\n" printable_name v n
- | ConfigEnum n ->
+ | ConfigEnum (n, enum) ->
pr " fprintf (fp, \"%%-20s \", \"%s\");\n"
printable_name;
- pr " print_%s (%s%s, fp);\n" n v n;
+ pr " print_%s (%s%s, fp);\n" enum v n;
pr " fprintf (fp, \"\\n\");\n"
| ConfigBool n ->
pr " fprintf (fp, \"%%-20s %%s\\n\",\n";
diff --git a/p2v/conversion.c b/p2v/conversion.c
index b9da033db..dd056c69a 100644
--- a/p2v/conversion.c
+++ b/p2v/conversion.c
@@ -498,19 +498,19 @@ generate_wrapper_script (struct config *config, const char
*remote_dir,
/* The virt-v2v command, as a shell function called "v2v". */
fprintf (fp, "v2v ()\n");
fprintf (fp, "{\n");
- if (config->sudo)
+ if (config->auth.sudo)
fprintf (fp, "sudo -n ");
fprintf (fp, "virt-v2v -v -x");
if (feature_colours_option)
fprintf (fp, " --colours");
fprintf (fp, " -i libvirtxml");
- if (config->output) { /* -o */
+ if (config->output.type) { /* -o */
fprintf (fp, " -o ");
- print_quoted (fp, config->output);
+ print_quoted (fp, config->output.type);
}
- switch (config->output_allocation) { /* -oa */
+ switch (config->output.allocation) { /* -oa */
case OUTPUT_ALLOCATION_NONE:
/* nothing */
break;
@@ -524,14 +524,14 @@ generate_wrapper_script (struct config *config, const char
*remote_dir,
abort ();
}
- if (config->output_format) { /* -of */
+ if (config->output.format) { /* -of */
fprintf (fp, " -of ");
- print_quoted (fp, config->output_format);
+ print_quoted (fp, config->output.format);
}
- if (config->output_storage) { /* -os */
+ if (config->output.storage) { /* -os */
fprintf (fp, " -os ");
- print_quoted (fp, config->output_storage);
+ print_quoted (fp, config->output.storage);
}
fprintf (fp, " --root first");
@@ -562,7 +562,7 @@ generate_wrapper_script (struct config *config, const char
*remote_dir,
fprintf (fp,
"# Log the version of virt-v2v (for information only).\n");
- if (config->sudo)
+ if (config->auth.sudo)
fprintf (fp, "sudo -n ");
fprintf (fp, "virt-v2v --version > v2v-version\n");
fprintf (fp, "\n");
diff --git a/p2v/gui.c b/p2v/gui.c
index f596890c2..7ec2900a8 100644
--- a/p2v/gui.c
+++ b/p2v/gui.c
@@ -228,12 +228,12 @@ create_connection_dialog (struct config *config)
hbox_new (server_hbox, FALSE, 4);
server_entry = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (server_label), server_entry);
- if (config->server != NULL)
- gtk_entry_set_text (GTK_ENTRY (server_entry), config->server);
+ if (config->remote.server != NULL)
+ gtk_entry_set_text (GTK_ENTRY (server_entry), config->remote.server);
port_colon_label = gtk_label_new (":");
port_entry = gtk_entry_new ();
gtk_entry_set_width_chars (GTK_ENTRY (port_entry), 6);
- snprintf (port_str, sizeof port_str, "%d", config->port);
+ snprintf (port_str, sizeof port_str, "%d", config->remote.port);
gtk_entry_set_text (GTK_ENTRY (port_entry), port_str);
gtk_box_pack_start (GTK_BOX (server_hbox), server_entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (server_hbox), port_colon_label, FALSE, FALSE, 0);
@@ -247,8 +247,8 @@ create_connection_dialog (struct config *config)
set_alignment (username_label, 1., 0.5);
username_entry = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (username_label), username_entry);
- if (config->username != NULL)
- gtk_entry_set_text (GTK_ENTRY (username_entry), config->username);
+ if (config->auth.username != NULL)
+ gtk_entry_set_text (GTK_ENTRY (username_entry), config->auth.username);
else
gtk_entry_set_text (GTK_ENTRY (username_entry), "root");
table_attach (table, username_entry,
@@ -265,8 +265,8 @@ create_connection_dialog (struct config *config)
gtk_entry_set_input_purpose (GTK_ENTRY (password_entry),
GTK_INPUT_PURPOSE_PASSWORD);
#endif
- if (config->password != NULL)
- gtk_entry_set_text (GTK_ENTRY (password_entry), config->password);
+ if (config->auth.password != NULL)
+ gtk_entry_set_text (GTK_ENTRY (password_entry), config->auth.password);
table_attach (table, password_entry,
1, 2, 2, 3, GTK_EXPAND|GTK_FILL, GTK_FILL, 4, 4);
@@ -276,15 +276,15 @@ create_connection_dialog (struct config *config)
set_alignment (identity_label, 1., 0.5);
identity_entry = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (identity_label), identity_entry);
- if (config->identity_url != NULL)
- gtk_entry_set_text (GTK_ENTRY (identity_entry), config->identity_url);
+ if (config->auth.identity.url != NULL)
+ gtk_entry_set_text (GTK_ENTRY (identity_entry), config->auth.identity.url);
table_attach (table, identity_entry,
1, 2, 3, 4, GTK_EXPAND|GTK_FILL, GTK_FILL, 4, 4);
sudo_button =
gtk_check_button_new_with_mnemonic (_("Use su_do when running virt-v2v"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sudo_button),
- config->sudo);
+ config->auth.sudo);
table_attach (table, sudo_button,
1, 2, 4, 5, GTK_FILL, GTK_FILL, 4, 4);
@@ -446,42 +446,42 @@ test_connection_clicked (GtkWidget *w, gpointer data)
#endif
/* Get the fields from the various widgets. */
- free (config->server);
- config->server = strdup (gtk_entry_get_text (GTK_ENTRY (server_entry)));
- if (STREQ (config->server, "")) {
+ free (config->remote.server);
+ config->remote.server = strdup (gtk_entry_get_text (GTK_ENTRY (server_entry)));
+ if (STREQ (config->remote.server, "")) {
gtk_label_set_text (GTK_LABEL (spinner_message),
_("error: No conversion server given."));
gtk_widget_grab_focus (server_entry);
errors++;
}
port_str = gtk_entry_get_text (GTK_ENTRY (port_entry));
- if (sscanf (port_str, "%d", &config->port) != 1 ||
- config->port <= 0 || config->port >= 65536) {
+ if (sscanf (port_str, "%d", &config->remote.port) != 1 ||
+ config->remote.port <= 0 || config->remote.port >= 65536) {
gtk_label_set_text (GTK_LABEL (spinner_message),
_("error: Invalid port number. If in doubt, use
\"22\"."));
gtk_widget_grab_focus (port_entry);
errors++;
}
- free (config->username);
- config->username = strdup (gtk_entry_get_text (GTK_ENTRY (username_entry)));
- if (STREQ (config->username, "")) {
+ free (config->auth.username);
+ config->auth.username = strdup (gtk_entry_get_text (GTK_ENTRY (username_entry)));
+ if (STREQ (config->auth.username, "")) {
gtk_label_set_text (GTK_LABEL (spinner_message),
_("error: No user name. If in doubt, use
\"root\"."));
gtk_widget_grab_focus (username_entry);
errors++;
}
- free (config->password);
- config->password = strdup (gtk_entry_get_text (GTK_ENTRY (password_entry)));
+ free (config->auth.password);
+ config->auth.password = strdup (gtk_entry_get_text (GTK_ENTRY (password_entry)));
- free (config->identity_url);
+ free (config->auth.identity.url);
identity_str = gtk_entry_get_text (GTK_ENTRY (identity_entry));
if (identity_str && STRNEQ (identity_str, ""))
- config->identity_url = strdup (identity_str);
+ config->auth.identity.url = strdup (identity_str);
else
- config->identity_url = NULL;
- config->identity_file_needs_update = 1;
+ config->auth.identity.url = NULL;
+ config->auth.identity.file_needs_update = 1;
- config->sudo = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sudo_button));
+ config->auth.sudo = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sudo_button));
if (errors)
return;
@@ -839,8 +839,8 @@ create_conversion_dialog (struct config *config)
oc_entry = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (oc_label), oc_entry);
gtk_widget_set_tooltip_markup (oc_entry, _("For <b>libvirt</b> only,
the libvirt connection URI, or leave blank to add the guest to the default libvirt
instance on the conversion server. For others, leave this field blank."));
- if (config->output_connection != NULL)
- gtk_entry_set_text (GTK_ENTRY (oc_entry), config->output_connection);
+ if (config->output.connection != NULL)
+ gtk_entry_set_text (GTK_ENTRY (oc_entry), config->output.connection);
table_attach (output_tbl, oc_entry,
1, 2, 1, 2, GTK_FILL, GTK_FILL, 1, 1);
@@ -851,8 +851,8 @@ create_conversion_dialog (struct config *config)
os_entry = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (os_label), os_entry);
gtk_widget_set_tooltip_markup (os_entry, _("For <b>local</b>, put the
directory name on the conversion server. For <b>rhv</b>, put the Export
Storage Domain (server:/mountpoint). For others, leave this field blank."));
- if (config->output_storage != NULL)
- gtk_entry_set_text (GTK_ENTRY (os_entry), config->output_storage);
+ if (config->output.storage != NULL)
+ gtk_entry_set_text (GTK_ENTRY (os_entry), config->output.storage);
table_attach (output_tbl, os_entry,
1, 2, 2, 3, GTK_FILL, GTK_FILL, 1, 1);
@@ -863,8 +863,8 @@ create_conversion_dialog (struct config *config)
of_entry = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (of_label), of_entry);
gtk_widget_set_tooltip_markup (of_entry, _("The output disk format, typically
<b>raw</b> or <b>qcow2</b>. If blank, defaults to
<b>raw</b>."));
- if (config->output_format != NULL)
- gtk_entry_set_text (GTK_ENTRY (of_entry), config->output_format);
+ if (config->output.format != NULL)
+ gtk_entry_set_text (GTK_ENTRY (of_entry), config->output.format);
table_attach (output_tbl, of_entry,
1, 2, 3, 4, GTK_FILL, GTK_FILL, 1, 1);
@@ -878,7 +878,7 @@ create_conversion_dialog (struct config *config)
"sparse");
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (oa_combo),
"preallocated");
- switch (config->output_allocation) {
+ switch (config->output.allocation) {
case OUTPUT_ALLOCATION_PREALLOCATED:
gtk_combo_box_set_active (GTK_COMBO_BOX (oa_combo), 1);
break;
@@ -1034,8 +1034,8 @@ repopulate_output_combo (struct config *config)
size_t i;
/* Which driver is currently selected? */
- if (config && config->output)
- output = strdup (config->output);
+ if (config && config->output.type)
+ output = strdup (config->output.type);
else
output = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (o_combo));
@@ -1981,40 +1981,40 @@ start_conversion_clicked (GtkWidget *w, gpointer data)
set_network_map_from_ui (config);
/* Output selection. */
- free (config->output);
- config->output =
+ free (config->output.type);
+ config->output.type =
gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (o_combo));
- config->output_allocation = OUTPUT_ALLOCATION_NONE;
+ config->output.allocation = OUTPUT_ALLOCATION_NONE;
str2 = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (oa_combo));
if (str2) {
if (STREQ (str2, "sparse"))
- config->output_allocation = OUTPUT_ALLOCATION_SPARSE;
+ config->output.allocation = OUTPUT_ALLOCATION_SPARSE;
else if (STREQ (str2, "preallocated"))
- config->output_allocation = OUTPUT_ALLOCATION_PREALLOCATED;
+ config->output.allocation = OUTPUT_ALLOCATION_PREALLOCATED;
free (str2);
}
- free (config->output_connection);
+ free (config->output.connection);
str = gtk_entry_get_text (GTK_ENTRY (oc_entry));
if (str && STRNEQ (str, ""))
- config->output_connection = strdup (str);
+ config->output.connection = strdup (str);
else
- config->output_connection = NULL;
+ config->output.connection = NULL;
- free (config->output_format);
+ free (config->output.format);
str = gtk_entry_get_text (GTK_ENTRY (of_entry));
if (str && STRNEQ (str, ""))
- config->output_format = strdup (str);
+ config->output.format = strdup (str);
else
- config->output_format = NULL;
+ config->output.format = NULL;
- free (config->output_storage);
+ free (config->output.storage);
str = gtk_entry_get_text (GTK_ENTRY (os_entry));
if (str && STRNEQ (str, ""))
- config->output_storage = strdup (str);
+ config->output.storage = strdup (str);
else
- config->output_storage = NULL;
+ config->output.storage = NULL;
/* Display the UI for conversion. */
show_running_dialog ();
diff --git a/p2v/kernel.c b/p2v/kernel.c
index 5da80808b..4f999755e 100644
--- a/p2v/kernel.c
+++ b/p2v/kernel.c
@@ -49,39 +49,39 @@ update_config_from_kernel_cmdline (struct config *config, char
**cmdline)
p = get_cmdline_key (cmdline, "p2v.server");
if (p) {
- free (config->server);
- config->server = strdup (p);
+ free (config->remote.server);
+ config->remote.server = strdup (p);
}
p = get_cmdline_key (cmdline, "p2v.port");
if (p) {
- if (sscanf (p, "%d", &config->port) != 1)
+ if (sscanf (p, "%d", &config->remote.port) != 1)
error (EXIT_FAILURE, 0,
"cannot parse p2v.port from kernel command line");
}
p = get_cmdline_key (cmdline, "p2v.username");
if (p) {
- free (config->username);
- config->username = strdup (p);
+ free (config->auth.username);
+ config->auth.username = strdup (p);
}
p = get_cmdline_key (cmdline, "p2v.password");
if (p) {
- free (config->password);
- config->password = strdup (p);
+ free (config->auth.password);
+ config->auth.password = strdup (p);
}
p = get_cmdline_key (cmdline, "p2v.identity");
if (p) {
- free (config->identity_url);
- config->identity_url = strdup (p);
- config->identity_file_needs_update = 1;
+ free (config->auth.identity.url);
+ config->auth.identity.url = strdup (p);
+ config->auth.identity.file_needs_update = 1;
}
p = get_cmdline_key (cmdline, "p2v.sudo");
if (p)
- config->sudo = 1;
+ config->auth.sudo = 1;
p = get_cmdline_key (cmdline, "p2v.name");
if (p) {
@@ -153,16 +153,16 @@ update_config_from_kernel_cmdline (struct config *config, char
**cmdline)
p = get_cmdline_key (cmdline, "p2v.o");
if (p) {
- free (config->output);
- config->output = strdup (p);
+ free (config->output.type);
+ config->output.type = strdup (p);
}
p = get_cmdline_key (cmdline, "p2v.oa");
if (p) {
if (STREQ (p, "sparse"))
- config->output_allocation = OUTPUT_ALLOCATION_SPARSE;
+ config->output.allocation = OUTPUT_ALLOCATION_SPARSE;
else if (STREQ (p, "preallocated"))
- config->output_allocation = OUTPUT_ALLOCATION_PREALLOCATED;
+ config->output.allocation = OUTPUT_ALLOCATION_PREALLOCATED;
else
fprintf (stderr, "%s: warning: don't know what p2v.oa=%s means\n",
getprogname (), p);
@@ -170,20 +170,20 @@ update_config_from_kernel_cmdline (struct config *config, char
**cmdline)
p = get_cmdline_key (cmdline, "p2v.oc");
if (p) {
- free (config->output_connection);
- config->output_connection = strdup (p);
+ free (config->output.connection);
+ config->output.connection = strdup (p);
}
p = get_cmdline_key (cmdline, "p2v.of");
if (p) {
- free (config->output_format);
- config->output_format = strdup (p);
+ free (config->output.format);
+ config->output.format = strdup (p);
}
p = get_cmdline_key (cmdline, "p2v.os");
if (p) {
- free (config->output_storage);
- config->output_storage = strdup (p);
+ free (config->output.storage);
+ config->output.storage = strdup (p);
}
/* Undocumented command line parameter used for testing command line
@@ -216,7 +216,7 @@ kernel_conversion (struct config *config, char **cmdline, int
cmdline_source)
error (EXIT_FAILURE, 0,
"error opening control connection to %s:%d: %s",
- config->server, config->port, err);
+ config->remote.server, config->remote.port, err);
}
}
diff --git a/p2v/main.c b/p2v/main.c
index 3c8572bda..a5f13924e 100644
--- a/p2v/main.c
+++ b/p2v/main.c
@@ -249,7 +249,7 @@ main (int argc, char *argv[])
/* If p2v.server exists, then we use the non-interactive kernel
* conversion. Otherwise we run the GUI.
*/
- if (config->server != NULL)
+ if (config->remote.server != NULL)
kernel_conversion (config, cmdline, cmdline_source);
else {
if (!gui_possible)
@@ -372,8 +372,8 @@ set_config_defaults (struct config *config)
/* Default output drops the guest onto /var/tmp on the conversion
* server, a hopefully safe default.
*/
- config->output = strdup ("local");
- config->output_storage = strdup ("/var/tmp");
+ config->output.type = strdup ("local");
+ config->output.storage = strdup ("/var/tmp");
}
static int
diff --git a/p2v/ssh.c b/p2v/ssh.c
index 15f53b692..db43c42a3 100644
--- a/p2v/ssh.c
+++ b/p2v/ssh.c
@@ -276,7 +276,7 @@ curl_download (const char *url, const char *local_file)
}
/**
- * Re-cache the C<config-E<gt>identity_url> if needed.
+ * Re-cache the C<config-E<gt>identity.url> if needed.
*/
static int
cache_ssh_identity (struct config *config)
@@ -284,25 +284,25 @@ cache_ssh_identity (struct config *config)
int fd;
/* If it doesn't need downloading, return. */
- if (config->identity_url == NULL ||
- !config->identity_file_needs_update)
+ if (config->auth.identity.url == NULL ||
+ !config->auth.identity.file_needs_update)
return 0;
/* Generate a random filename. */
- free (config->identity_file);
- config->identity_file = strdup ("/tmp/id.XXXXXX");
- if (config->identity_file == NULL)
+ free (config->auth.identity.file);
+ config->auth.identity.file = strdup ("/tmp/id.XXXXXX");
+ if (config->auth.identity.file == NULL)
error (EXIT_FAILURE, errno, "strdup");
- fd = mkstemp (config->identity_file);
+ fd = mkstemp (config->auth.identity.file);
if (fd == -1)
error (EXIT_FAILURE, errno, "mkstemp");
close (fd);
/* Curl download URL to file. */
- if (curl_download (config->identity_url, config->identity_file) == -1) {
- free (config->identity_file);
- config->identity_file = NULL;
- config->identity_file_needs_update = 1;
+ if (curl_download (config->auth.identity.url, config->auth.identity.file) == -1)
{
+ free (config->auth.identity.file);
+ config->auth.identity.file = NULL;
+ config->auth.identity.file_needs_update = 1;
return -1;
}
@@ -343,14 +343,14 @@ start_ssh (unsigned spawn_flags, struct config *config,
return NULL;
/* Are we using password or identity authentication? */
- using_password_auth = config->identity_file == NULL;
+ using_password_auth = config->auth.identity.file == NULL;
ADD_ARG (argv, i, "ssh");
ADD_ARG (argv, i, "-p"); /* Port. */
- snprintf (port_str, sizeof port_str, "%d", config->port);
+ snprintf (port_str, sizeof port_str, "%d", config->remote.port);
ADD_ARG (argv, i, port_str);
ADD_ARG (argv, i, "-l"); /* Username. */
- ADD_ARG (argv, i, config->username ? config->username : "root");
+ ADD_ARG (argv, i, config->auth.username ? config->auth.username :
"root");
ADD_ARG (argv, i, "-o"); /* Host key will always be novel. */
ADD_ARG (argv, i, "StrictHostKeyChecking=no");
ADD_ARG (argv, i, "-o"); /* ConnectTimeout */
@@ -371,13 +371,13 @@ start_ssh (unsigned spawn_flags, struct config *config,
ADD_ARG (argv, i, "-o");
ADD_ARG (argv, i, "PreferredAuthentications=publickey");
ADD_ARG (argv, i, "-i");
- ADD_ARG (argv, i, config->identity_file);
+ ADD_ARG (argv, i, config->auth.identity.file);
}
if (extra_args != NULL) {
for (size_t j = 0; extra_args[j] != NULL; ++j)
ADD_ARG (argv, i, extra_args[j]);
}
- ADD_ARG (argv, i, config->server); /* Conversion server. */
+ ADD_ARG (argv, i, config->remote.server); /* Conversion server. */
ADD_ARG (argv, i, NULL);
#if DEBUG_STDERR
@@ -408,7 +408,7 @@ start_ssh (unsigned spawn_flags, struct config *config,
mexp_set_timeout (h, SSH_TIMEOUT + 20);
if (using_password_auth &&
- config->password && strlen (config->password) > 0) {
+ config->auth.password && strlen (config->auth.password) > 0) {
CLEANUP_FREE char *ssh_message = NULL;
/* Wait for the password prompt. */
@@ -420,7 +420,7 @@ start_ssh (unsigned spawn_flags, struct config *config,
{ 0 }
}, ovector, ovecsize)) {
case 100: /* Got password prompt. */
- if (mexp_printf_password (h, "%s", config->password) == -1 ||
+ if (mexp_printf_password (h, "%s", config->auth.password) == -1 ||
mexp_printf (h, "\n") == -1) {
set_ssh_mexp_error ("mexp_printf");
mexp_close (h);
@@ -605,11 +605,11 @@ scp_file (struct config *config, const char *target, const char
*local, ...)
return -1;
/* Are we using password or identity authentication? */
- using_password_auth = config->identity_file == NULL;
+ using_password_auth = config->auth.identity.file == NULL;
ADD_ARG (argv, i, "scp");
ADD_ARG (argv, i, "-P"); /* Port. */
- snprintf (port_str, sizeof port_str, "%d", config->port);
+ snprintf (port_str, sizeof port_str, "%d", config->remote.port);
ADD_ARG (argv, i, port_str);
ADD_ARG (argv, i, "-o"); /* Host key will always be novel. */
ADD_ARG (argv, i, "StrictHostKeyChecking=no");
@@ -627,7 +627,7 @@ scp_file (struct config *config, const char *target, const char
*local, ...)
ADD_ARG (argv, i, "-o");
ADD_ARG (argv, i, "PreferredAuthentications=publickey");
ADD_ARG (argv, i, "-i");
- ADD_ARG (argv, i, config->identity_file);
+ ADD_ARG (argv, i, config->auth.identity.file);
}
/* Source files or directories.
@@ -643,8 +643,8 @@ scp_file (struct config *config, const char *target, const char
*local, ...)
* "username@server:target".
*/
if (asprintf (&remote, "%s@%s:%s",
- config->username ? config->username : "root",
- config->server, target) == -1)
+ config->auth.username ? config->auth.username : "root",
+ config->remote.server, target) == -1)
error (EXIT_FAILURE, errno, "asprintf");
ADD_ARG (argv, i, remote);
@@ -678,7 +678,7 @@ scp_file (struct config *config, const char *target, const char
*local, ...)
mexp_set_timeout (h, SSH_TIMEOUT + 20);
if (using_password_auth &&
- config->password && strlen (config->password) > 0) {
+ config->auth.password && strlen (config->auth.password) > 0) {
CLEANUP_FREE char *ssh_message = NULL;
/* Wait for the password prompt. */
@@ -690,7 +690,7 @@ scp_file (struct config *config, const char *target, const char
*local, ...)
{ 0 }
}, ovector, ovecsize)) {
case 100: /* Got password prompt. */
- if (mexp_printf_password (h, "%s", config->password) == -1 ||
+ if (mexp_printf_password (h, "%s", config->auth.password) == -1 ||
mexp_printf (h, "\n") == -1) {
set_ssh_mexp_error ("mexp_printf");
mexp_close (h);
@@ -793,7 +793,7 @@ test_connection (struct config *config)
*/
if (mexp_printf (h,
"%svirt-v2v --version\n",
- config->sudo ? "sudo -n " : "") == -1) {
+ config->auth.sudo ? "sudo -n " : "") == -1) {
set_ssh_mexp_error ("mexp_printf");
mexp_close (h);
return -1;
@@ -818,7 +818,7 @@ test_connection (struct config *config)
case 101:
set_ssh_error ("sudo for user \"%s\" requires a password. Edit
/etc/sudoers on the conversion server to ensure the \"NOPASSWD:\" option is set
for this user.",
- config->username);
+ config->auth.username);
mexp_close (h);
return -1;
@@ -871,7 +871,7 @@ test_connection (struct config *config)
/* Get virt-v2v features. See: v2v/cmdline.ml */
if (mexp_printf (h, "%svirt-v2v --machine-readable\n",
- config->sudo ? "sudo -n " : "") == -1) {
+ config->auth.sudo ? "sudo -n " : "") == -1) {
set_ssh_mexp_error ("mexp_printf");
mexp_close (h);
return -1;
diff --git a/p2v/test-virt-p2v-cmdline.sh b/p2v/test-virt-p2v-cmdline.sh
index f0077f750..2fbca1eb5 100755
--- a/p2v/test-virt-p2v-cmdline.sh
+++ b/p2v/test-virt-p2v-cmdline.sh
@@ -33,10 +33,10 @@ $VG virt-p2v --cmdline='p2v.server=localhost p2v.port=123
p2v.username=user p2v.
cat $out
# Check the output contains what we expect.
-grep "^server.*localhost" $out
-grep "^port.*123" $out
-grep "^username.*user" $out
-grep "^sudo.*false" $out
+grep "^remote\.server.*localhost" $out
+grep "^remote\.port.*123" $out
+grep "^auth\.username.*user" $out
+grep "^auth\.sudo.*false" $out
grep "^guestname.*test" $out
grep "^vcpus.*4" $out
grep "^memory.*"$((1024*1024*1024)) $out
@@ -44,10 +44,10 @@ grep "^disks.*sda sdb sdc" $out
grep "^removable.*sdd" $out
grep "^interfaces.*eth0 eth1" $out
grep "^network_map.*em1:wired other" $out
-grep "^output.*local" $out
-grep "^output_allocation.*sparse" $out
-grep "^output_connection.*qemu:///session" $out
-grep "^output_format.*raw" $out
-grep "^output_storage.*/var/tmp" $out
+grep "^output\.type.*local" $out
+grep "^output\.allocation.*sparse" $out
+grep "^output\.connection.*qemu:///session" $out
+grep "^output\.format.*raw" $out
+grep "^output\.storage.*/var/tmp" $out
rm $out
--
2.17.1