From a083d44c87fd0bedccb2b8d06f461dcf3a69e9cf Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Tue, 10 May 2011 16:26:05 +0800 Subject: [PATCH] inject-nmi: Expose the new API in virsh --- tools/virsh.c | 35 +++++++++++++++++++++++++++++++++++ tools/virsh.pod | 4 ++++ 2 files changed, 39 insertions(+) diff --git a/tools/virsh.c b/tools/virsh.c index 8b5572c810..fbeb7c88f0 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -2911,6 +2911,40 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) return ret; } +/* + * "inject-nmi" command + */ +static const vshCmdInfo info_inject_nmi[] = { + {"help", N_("Inject NMI to the guest")}, + {"desc", N_("Inject NMI to the guest domain.")}, + {NULL, NULL} +}; + +static const vshCmdOptDef opts_inject_nmi[] = { + {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, + {NULL, 0, 0, NULL} +}; + + +static bool +cmdInjectNMI(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom; + int ret = true; + + if (!vshConnectionUsability(ctl, ctl->conn)) + return false; + + if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (virDomainInjectNMI(dom, 0) < 0) + ret = false; + + virDomainFree(dom); + return ret; +} + /* * "setmemory" command */ @@ -10720,6 +10754,7 @@ static const vshCmdDef domManagementCmds[] = { {"setmaxmem", cmdSetmaxmem, opts_setmaxmem, info_setmaxmem}, {"setmem", cmdSetmem, opts_setmem, info_setmem}, {"setvcpus", cmdSetvcpus, opts_setvcpus, info_setvcpus}, + {"inject-nmi", cmdInjectNMI, opts_inject_nmi, info_inject_nmi}, {"shutdown", cmdShutdown, opts_shutdown, info_shutdown}, {"start", cmdStart, opts_start, info_start}, {"suspend", cmdSuspend, opts_suspend, info_suspend}, diff --git a/tools/virsh.pod b/tools/virsh.pod index 2a708f6603..f317c5729a 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -290,6 +290,10 @@ running B. When in a paused state the domain will still consume allocated resources like memory, but will not be eligible for scheduling by the hypervisor. +=item B I + +Inject NMI to the guest + =item B The domain is in the process of shutting down, i.e. the guest operating system