[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OPTIONAL][PATCH for-4.5 v7 7/7] Add xen-hvm-param
A tool to get and set hvm param. Signed-off-by: Don Slutz <dslutz@xxxxxxxxxxx> --- v7: Was a later patch. Still optional. Fixed formatting. Adjust for drop of VMware RPC. .gitignore | 1 + tools/misc/Makefile | 7 +- tools/misc/xen-hvm-param.c | 169 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 tools/misc/xen-hvm-param.c diff --git a/.gitignore b/.gitignore index 7a908c4..938b10f 100644 --- a/.gitignore +++ b/.gitignore @@ -180,6 +180,7 @@ tools/misc/xen-tmem-list-parse tools/misc/xenperf tools/misc/xenpm tools/misc/xen-hvmctx +tools/misc/xen-hvm-param tools/misc/gtraceview tools/misc/gtracestat tools/misc/xenlockprof diff --git a/tools/misc/Makefile b/tools/misc/Makefile index 266fd16..e7c68df 100644 --- a/tools/misc/Makefile +++ b/tools/misc/Makefile @@ -12,7 +12,7 @@ CFLAGS += -I$(XEN_ROOT)/tools/libxc HDRS = $(wildcard *.h) TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xencov -TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvmcrash xen-lowmemd xen-mfndump +TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvm-param xen-hvmcrash xen-lowmemd xen-mfndump TARGETS-$(CONFIG_MIGRATE) += xen-hptool TARGETS := $(TARGETS-y) @@ -24,7 +24,7 @@ INSTALL_BIN := $(INSTALL_BIN-y) INSTALL_SBIN-y := xen-bugtool xen-python-path xenperf xenpm xen-tmem-list-parse gtraceview \ gtracestat xenlockprof xenwatchdogd xen-ringwatch xencov -INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvmcrash xen-lowmemd xen-mfndump +INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvm-param xen-hvmcrash xen-lowmemd xen-mfndump INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool INSTALL_SBIN := $(INSTALL_SBIN-y) @@ -59,6 +59,9 @@ clean: xen-hvmctx: xen-hvmctx.o $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) +xen-hvm-param: xen-hvm-param.o + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) + xen-hvmcrash: xen-hvmcrash.o $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) diff --git a/tools/misc/xen-hvm-param.c b/tools/misc/xen-hvm-param.c new file mode 100644 index 0000000..0496e45 --- /dev/null +++ b/tools/misc/xen-hvm-param.c @@ -0,0 +1,169 @@ +/* + * tools/misc/xen-hvm-param.c + * + * Copyright (C) 2014 Verizon Corporation + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License Version 2 (GPLv2) + * as published by the Free Software Foundation. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. <http://www.gnu.org/licenses/>. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <err.h> + +#include <xenctrl.h> + + +int +main(int argc, char **argv) +{ + xc_interface *xch; + int domid; + int start_param = 0; + int end_param = HVM_NR_PARAMS; + int param; + int ret = 0; + int i; + char hvm_param_name[HVM_NR_PARAMS][80]; + + unsigned long hvm_param = -1; + + if ( (argc < 2) || (argc > 4) ) + errx(1, "usage: %s domid [param [new]]", argv[0]); + + for ( i = 0; i < HVM_NR_PARAMS; i++ ) + snprintf(hvm_param_name[i], sizeof(hvm_param_name[i]), + "Unknown %d", i); + + snprintf(hvm_param_name[HVM_PARAM_CALLBACK_IRQ], + sizeof(hvm_param_name[HVM_PARAM_CALLBACK_IRQ]), "Callback_Irq"); + snprintf(hvm_param_name[HVM_PARAM_STORE_PFN], + sizeof(hvm_param_name[HVM_PARAM_STORE_PFN]), "Store_Pfn"); + snprintf(hvm_param_name[HVM_PARAM_STORE_EVTCHN], + sizeof(hvm_param_name[HVM_PARAM_STORE_EVTCHN]), "Store_Evtchn"); + snprintf(hvm_param_name[HVM_PARAM_PAE_ENABLED], + sizeof(hvm_param_name[HVM_PARAM_PAE_ENABLED]), "Pae_Enabled"); + snprintf(hvm_param_name[HVM_PARAM_IOREQ_PFN], + sizeof(hvm_param_name[HVM_PARAM_IOREQ_PFN]), "Ioreq_Pfn"); + snprintf(hvm_param_name[HVM_PARAM_BUFIOREQ_PFN], + sizeof(hvm_param_name[HVM_PARAM_BUFIOREQ_PFN]), "Bufioreq_Pfn"); + snprintf(hvm_param_name[HVM_PARAM_VIRIDIAN], + sizeof(hvm_param_name[HVM_PARAM_VIRIDIAN]), "Viridian"); + snprintf(hvm_param_name[HVM_PARAM_TIMER_MODE], + sizeof(hvm_param_name[HVM_PARAM_TIMER_MODE]), "Timer_Mode"); + snprintf(hvm_param_name[HVM_PARAM_HPET_ENABLED], + sizeof(hvm_param_name[HVM_PARAM_HPET_ENABLED]), "Hpet_Enabled"); + snprintf(hvm_param_name[HVM_PARAM_IDENT_PT], + sizeof(hvm_param_name[HVM_PARAM_IDENT_PT]), "Ident_Pt"); + snprintf(hvm_param_name[HVM_PARAM_DM_DOMAIN], + sizeof(hvm_param_name[HVM_PARAM_DM_DOMAIN]), "Dm_Domain"); + snprintf(hvm_param_name[HVM_PARAM_ACPI_S_STATE], + sizeof(hvm_param_name[HVM_PARAM_ACPI_S_STATE]), "Acpi_S_State"); + snprintf(hvm_param_name[HVM_PARAM_VM86_TSS], + sizeof(hvm_param_name[HVM_PARAM_VM86_TSS]), "Vm86_Tss"); + snprintf(hvm_param_name[HVM_PARAM_VPT_ALIGN], + sizeof(hvm_param_name[HVM_PARAM_VPT_ALIGN]), "Vpt_Align"); + snprintf(hvm_param_name[HVM_PARAM_CONSOLE_PFN], + sizeof(hvm_param_name[HVM_PARAM_CONSOLE_PFN]), "Console_Pfn"); + snprintf(hvm_param_name[HVM_PARAM_CONSOLE_EVTCHN], + sizeof(hvm_param_name[HVM_PARAM_CONSOLE_EVTCHN]), + "Console_Evtchn"); + snprintf(hvm_param_name[HVM_PARAM_ACPI_IOPORTS_LOCATION], + sizeof(hvm_param_name[HVM_PARAM_ACPI_IOPORTS_LOCATION]), + "Acpi_Ioports_Location"); + snprintf(hvm_param_name[HVM_PARAM_MEMORY_EVENT_CR0], + sizeof(hvm_param_name[HVM_PARAM_MEMORY_EVENT_CR0]), + "Memory_Event_Cr0"); + snprintf(hvm_param_name[HVM_PARAM_MEMORY_EVENT_CR3], + sizeof(hvm_param_name[HVM_PARAM_MEMORY_EVENT_CR3]), + "Memory_Event_Cr3"); + snprintf(hvm_param_name[HVM_PARAM_MEMORY_EVENT_CR4], + sizeof(hvm_param_name[HVM_PARAM_MEMORY_EVENT_CR4]), + "Memory_Event_Cr4"); + snprintf(hvm_param_name[HVM_PARAM_MEMORY_EVENT_INT3], + sizeof(hvm_param_name[HVM_PARAM_MEMORY_EVENT_INT3]), + "Memory_Event_Int3"); + snprintf(hvm_param_name[HVM_PARAM_NESTEDHVM], + sizeof(hvm_param_name[HVM_PARAM_NESTEDHVM]), "Nestedhvm"); + snprintf(hvm_param_name[HVM_PARAM_MEMORY_EVENT_SINGLE_STEP], + sizeof(hvm_param_name[HVM_PARAM_MEMORY_EVENT_SINGLE_STEP]), + "Memory_Event_Single_Step"); + snprintf(hvm_param_name[HVM_PARAM_BUFIOREQ_EVTCHN], + sizeof(hvm_param_name[HVM_PARAM_BUFIOREQ_EVTCHN]), + "Bufioreq_Evtchn"); + snprintf(hvm_param_name[HVM_PARAM_PAGING_RING_PFN], + sizeof(hvm_param_name[HVM_PARAM_PAGING_RING_PFN]), + "Paging_Ring_Pfn"); + snprintf(hvm_param_name[HVM_PARAM_ACCESS_RING_PFN], + sizeof(hvm_param_name[HVM_PARAM_ACCESS_RING_PFN]), + "Access_Ring_Pfn"); + snprintf(hvm_param_name[HVM_PARAM_SHARING_RING_PFN], + sizeof(hvm_param_name[HVM_PARAM_SHARING_RING_PFN]), + "Sharing_Ring_Pfn"); + snprintf(hvm_param_name[HVM_PARAM_VMWARE_HW], + sizeof(hvm_param_name[HVM_PARAM_VMWARE_HW]), "Vmware_Hw"); + + xch = xc_interface_open(0, 0, 0); + if ( !xch ) + err(1, "failed to open control interface"); + + domid = atoi(argv[1]); + if ( argc > 2 ) + { + start_param = strtol(argv[2], NULL, 0); + end_param = start_param + 1; + } + + for ( param = start_param; param < end_param; param++ ) + { + ret = xc_get_hvm_param(xch, domid, param, &hvm_param); + if ( ret ) + err(1, "failed to get hvm param %d for domid %d", param, domid); + else + { + if ( argc == 4 ) + { + long new = strtol(argv[3], NULL, 0); + + ret = xc_set_hvm_param(xch, domid, param, new); + if ( ret ) + err(1, "failed to set hvm param %d for domid %d", param, + domid); + else if ( (param >= 0) && (param < HVM_NR_PARAMS) ) + printf("hvm_param(%s)=0x%lx(%ld) was 0x%lx(%ld)\n", + hvm_param_name[param], new, new, hvm_param, + hvm_param); + else + printf("hvm_param(%d)=0x%lx(%ld) was 0x%lx(%ld)\n", + param, new, new, hvm_param, hvm_param); + } + else + { + if ( (param >= 0) && (param < HVM_NR_PARAMS) ) + printf("hvm_param(%s)=0x%lx(%ld)\n", + hvm_param_name[param], hvm_param, hvm_param); + else + printf("hvm_param(%d)=0x%lx(%ld)\n", param, hvm_param, + hvm_param); + } + } + } + xc_interface_close(xch); + + return ret; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ -- 1.8.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |