diff mbox series

[v3,4/4] xl: add new xl command get-parameters

Message ID 20190509154128.9196-5-vliaskovitis@suse.com (mailing list archive)
State Superseded
Headers show
Series Support for reading runtime hypervisor parameters | expand

Commit Message

Vasilis LIaskovitis May 9, 2019, 3:41 p.m. UTC
Add a new xl command "get-parameters" to get hypervisor runtime parameters.

Examples:

xl get-parameters "gnttab_max_frames gnttab_max_maptrack_frames"
gnttab_max_frames gnttab_max_maptrack_frames : 64 1024

xl set-parameters gnttab_max_frames=128

xl get-parameters gnttab_max_frames
gnttab_max_frames : 128

xl get-parameters "gnttab_max_frames gnttab_max_maptrack_frames"
gnttab_max_frames gnttab_max_maptrack_frames : 128 1024

Signed-off-by: Vasilis Liaskovitis <vliaskovitis@suse.com>
---
 docs/man/xl.1.pod.in   |  5 +++++
 tools/xl/xl.h          |  1 +
 tools/xl/xl_cmdtable.c |  5 +++++
 tools/xl/xl_misc.c     | 25 +++++++++++++++++++++++++
 4 files changed, 36 insertions(+)
diff mbox series

Patch

diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
index 4310fcd818..a1fff4d382 100644
--- a/docs/man/xl.1.pod.in
+++ b/docs/man/xl.1.pod.in
@@ -827,6 +827,11 @@  Send debug I<keys> to Xen. It is the same as pressing the Xen
 Set hypervisor parameters as specified in I<params>. This allows for some
 boot parameters of the hypervisor to be modified in the running systems.
 
+=item B<get-parameters> I<params>
+
+Get hypervisor parameters as specified in I<params>. This allows for some
+boot parameters of the hypervisor to be read in the running systems.
+
 =item B<dmesg> [I<OPTIONS>]
 
 Reads the Xen message buffer, similar to dmesg on a Linux system.  The
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index cf4202bc89..af3843e5b0 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -219,6 +219,7 @@  int main_psr_mba_set(int argc, char **argv);
 int main_psr_mba_show(int argc, char **argv);
 #endif
 int main_qemu_monitor_command(int argc, char **argv);
+int main_get_parameters(int argc, char **argv);
 
 void help(const char *command);
 
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 89716badcb..a18481619b 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -662,6 +662,11 @@  struct cmd_spec cmd_table[] = {
       "Issue a qemu monitor command to the device model of a domain",
       "<Domain> <Command>",
     },
+    { "get-parameters",
+      &main_get_parameters, 0, 1,
+      "Get hypervisor parameters",
+      "<Params>",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c
index dcf940a6d4..811f231b78 100644
--- a/tools/xl/xl_misc.c
+++ b/tools/xl/xl_misc.c
@@ -364,6 +364,31 @@  int main_config_update(int argc, char **argv)
     return 0;
 }
 
+int main_get_parameters(int argc, char **argv)
+{
+    int opt, ret;
+    char *params;
+    char values[1023];
+
+    SWITCH_FOREACH_OPT(opt, "", NULL, "get-parameters", 1) {
+        /* No options */
+    }
+
+    params = argv[optind];
+
+    if (!params) {
+	fprintf(stderr, "no parameter specified\n");
+	return EXIT_FAILURE;
+    }
+    else if ((ret = libxl_get_parameters(ctx, params, values))) {
+        fprintf(stderr, "cannot get parameters: %s : %d\n", params, ret);
+        fprintf(stderr, "Use \"xl dmesg\" to look for possible reason.\n");
+        return EXIT_FAILURE;
+    }
+    fprintf(stderr, "%s : %s\n", params, values);
+
+    return EXIT_SUCCESS;
+}
 /*
  * Local variables:
  * mode: C