xl: xl network-attach -N (dry run) option
authorMathieu Gagne <mgagne@iweb.com>
Tue, 17 Apr 2012 18:13:52 +0000 (19:13 +0100)
committerMathieu Gagne <mgagne@iweb.com>
Tue, 17 Apr 2012 18:13:52 +0000 (19:13 +0100)
Add dryrun for testing and debugging purposes.

Signed-off-by: Mathieu Gagne <mgagne@iweb.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxl/xl_cmdimpl.c
tools/libxl/xl_cmdtable.c

index 4febe25cb64fd0a815a301a88fde7cfecaa59288..5703512d24d43ff2832a4ee5ff8c5710b5bca885 100644 (file)
@@ -4916,6 +4916,16 @@ int main_networkattach(int argc, char **argv)
             return 1;
         }
     }
+
+    if (dryrun_only) {
+        char *json = libxl_device_nic_to_json(ctx, &nic);
+        printf("vif: %s\n", json);
+        free(json);
+        libxl_device_nic_dispose(&nic);
+        if (ferror(stdout) || fflush(stdout)) { perror("stdout"); exit(-1); }
+        return 0;
+    }
+
     if (libxl_device_nic_add(ctx, domid, &nic)) {
         fprintf(stderr, "libxl_device_nic_add failed.\n");
         return 1;
index f461a2a1b52e10c727f9e0bfa298527beec9004b..736a8366ed2facf6a36090c5053cbd4556ad3eb4 100644 (file)
@@ -288,7 +288,7 @@ struct cmd_spec cmd_table[] = {
       "",
     },
     { "network-attach",
-      &main_networkattach, 0,
+      &main_networkattach, 1,
       "Create a new virtual network device",
       "<Domain> [type=<type>] [mac=<mac>] [bridge=<bridge>] "
       "[ip=<ip>] [script=<script>] [backend=<BackDomain>] [vifname=<name>] "