virsh: Add 'iothreadsinfo' command

Add the 'iothreadsinfo' command to display IOThread Info data. Allow for
[--live] or [--config] options in order to display live or config data
for an active domain.

$ virsh iothreadsinfo --help
  NAME
    iothreadsinfo - view domain IOThreads

  SYNOPSIS
    iothreadsinfo <domain> [--config] [--live] [--current]

  DESCRIPTION
    Returns basic information about the domain IOThreads.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain

An active domain may return:

$ virsh iothreads $dom
 IOThread ID     CPU Affinity
---------------------------------------------------
  1               2
  2               3
  3               0

$ echo $?
0

For domains which don't have IOThreads the following is returned:

$ virsh iothreads $dom
No IOThreads found for the domain

$ echo $?
0

For domains which are not running the following is returned:

$ virsh iothreads $dom --live
error: Unable to get domain IOThreads information
error: Requested operation is not valid: domain is not running

$ echo $?
1

Editing a domains configuration and modifying the iothreadpin data for
thread 3 from nothing provided to setting a cpuset of '0-1' and then
displaying using --config would display:

$ virsh iothreads f18iothr --config
 IOThread ID     CPU Affinity
 ----------------------------
  1               2
  2               3
  3               0-1

$

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2015-02-11 15:29:22 -05:00
parent 82649eb7f1
commit f41a5b844f
2 changed files with 106 additions and 0 deletions

View File

@ -6789,6 +6789,94 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
return ret;
}
/*
* "iothreadsinfo" command
*/
static const vshCmdInfo info_iothreads[] = {
{.name = "help",
.data = N_("view domain IOThreads")
},
{.name = "desc",
.data = N_("Returns basic information about the domain IOThreads.")
},
{.name = NULL}
};
static const vshCmdOptDef opts_iothreads[] = {
{.name = "domain",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.help = N_("domain name, id or uuid")
},
{.name = "config",
.type = VSH_OT_BOOL,
.help = N_("affect next boot")
},
{.name = "live",
.type = VSH_OT_BOOL,
.help = N_("affect running domain")
},
{.name = "current",
.type = VSH_OT_BOOL,
.help = N_("affect current domain")
},
{.name = NULL}
};
static bool
cmdIOThreadsInfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
int niothreads = 0;
virDomainIOThreadInfoPtr *info;
size_t i;
int maxcpu;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
if (config)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (live)
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
goto cleanup;
if ((niothreads = virDomainGetIOThreadsInfo(dom, &info, flags)) < 0) {
vshError(ctl, _("Unable to get domain IOThreads information"));
goto cleanup;
}
if (niothreads == 0) {
vshPrintExtra(ctl, _("No IOThreads found for the domain"));
goto cleanup;
}
vshPrintExtra(ctl, " %-15s %-15s\n",
_("IOThread ID"), _("CPU Affinity"));
vshPrintExtra(ctl, "---------------------------------------------------\n");
for (i = 0; i < niothreads; i++) {
vshPrint(ctl, " %-15u ", info[i]->iothread_id);
ignore_value(vshPrintPinInfo(info[i]->cpumap, info[i]->cpumaplen,
maxcpu, 0));
vshPrint(ctl, "\n");
virDomainIOThreadsInfoFree(info[i]);
}
VIR_FREE(info);
cleanup:
virDomainFree(dom);
return niothreads >= 0;
}
/*
* "cpu-compare" command
*/
@ -12692,6 +12780,12 @@ const vshCmdDef domManagementCmds[] = {
.info = info_inject_nmi,
.flags = 0
},
{.name = "iothreadsinfo",
.handler = cmdIOThreadsInfo,
.opts = opts_iothreads,
.info = info_iothreads,
.flags = 0
},
{.name = "send-key",
.handler = cmdSendKey,
.opts = opts_send_key,

View File

@ -1361,6 +1361,18 @@ If I<--timeout> is specified, the command gives up waiting for events
after I<seconds> have elapsed. With I<--loop>, the command prints all
events until a timeout or interrupt key.
=item B<iothreadsinfo> I<domain> [[I<--live>] [I<--config>] | [I<--current>]]
Display basic domain IOThreads information including the IOThread ID and
the CPU Affinity for each IOThread.
If I<--live> is specified, get the IOThreads data from the running guest. If
the guest is not running, an error is returned.
If I<--config> is specified, get the IOThreads data from the next boot of
a persistent guest.
If I<--current> is specified or I<--live> and I<--config> are not specified,
then get the IOThread data based on the current guest state.
=item B<managedsave> I<domain> [I<--bypass-cache>]
[{I<--running> | I<--paused>}] [I<--verbose>]