mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
virsh: Implement vshTable API to vcpupin, iothreadinfo, domfsinfo
Signed-off-by: Simon Kobyda <skobyda@redhat.com>
This commit is contained in:
parent
063509a193
commit
3072ded354
@ -59,6 +59,7 @@
|
|||||||
#include "virxml.h"
|
#include "virxml.h"
|
||||||
#include "virsh-nodedev.h"
|
#include "virsh-nodedev.h"
|
||||||
#include "viruri.h"
|
#include "viruri.h"
|
||||||
|
#include "vsh-table.h"
|
||||||
|
|
||||||
/* Gnulib doesn't guarantee SA_SIGINFO support. */
|
/* Gnulib doesn't guarantee SA_SIGINFO support. */
|
||||||
#ifndef SA_SIGINFO
|
#ifndef SA_SIGINFO
|
||||||
@ -6905,6 +6906,7 @@ virshVcpuPinQuery(vshControl *ctl,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int ncpus;
|
int ncpus;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
vshTablePtr table = NULL;
|
||||||
|
|
||||||
if ((ncpus = virshCPUCountCollect(ctl, dom, countFlags, true)) < 0) {
|
if ((ncpus = virshCPUCountCollect(ctl, dom, countFlags, true)) < 0) {
|
||||||
if (ncpus == -1) {
|
if (ncpus == -1) {
|
||||||
@ -6913,7 +6915,7 @@ virshVcpuPinQuery(vshControl *ctl,
|
|||||||
else
|
else
|
||||||
vshError(ctl, "%s", _("cannot get vcpupin for transient domain"));
|
vshError(ctl, "%s", _("cannot get vcpupin for transient domain"));
|
||||||
}
|
}
|
||||||
return false;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (got_vcpu && vcpu >= ncpus) {
|
if (got_vcpu && vcpu >= ncpus) {
|
||||||
@ -6927,28 +6929,39 @@ virshVcpuPinQuery(vshControl *ctl,
|
|||||||
vshError(ctl,
|
vshError(ctl,
|
||||||
_("vcpu %d is out of range of persistent cpu count %d"),
|
_("vcpu %d is out of range of persistent cpu count %d"),
|
||||||
vcpu, ncpus);
|
vcpu, ncpus);
|
||||||
return false;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
|
cpumaplen = VIR_CPU_MAPLEN(maxcpu);
|
||||||
cpumap = vshMalloc(ctl, ncpus * cpumaplen);
|
cpumap = vshMalloc(ctl, ncpus * cpumaplen);
|
||||||
if ((ncpus = virDomainGetVcpuPinInfo(dom, ncpus, cpumap,
|
if ((ncpus = virDomainGetVcpuPinInfo(dom, ncpus, cpumap,
|
||||||
cpumaplen, flags)) >= 0) {
|
cpumaplen, flags)) >= 0) {
|
||||||
vshPrintExtra(ctl, "%s %s\n", _("VCPU:"), _("CPU Affinity"));
|
table = vshTableNew(_("VCPU"), _("CPU Affinity"), NULL);
|
||||||
vshPrintExtra(ctl, "----------------------------------\n");
|
if (!table)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < ncpus; i++) {
|
for (i = 0; i < ncpus; i++) {
|
||||||
|
VIR_AUTOFREE(char *) pinInfo = NULL;
|
||||||
|
VIR_AUTOFREE(char *) vcpuStr = NULL;
|
||||||
if (got_vcpu && i != vcpu)
|
if (got_vcpu && i != vcpu)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vshPrint(ctl, "%4zu: ", i);
|
if (!(pinInfo = virBitmapDataFormat(cpumap, cpumaplen)))
|
||||||
ret = virshPrintPinInfo(ctl, VIR_GET_CPUMAP(cpumap, cpumaplen, i),
|
goto cleanup;
|
||||||
cpumaplen);
|
|
||||||
vshPrint(ctl, "\n");
|
if (virAsprintf(&vcpuStr, "%lu", i) < 0)
|
||||||
if (!ret)
|
goto cleanup;
|
||||||
break;
|
|
||||||
|
if (vshTableRowAppend(table, vcpuStr, pinInfo, NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vshTablePrintToStdout(table, ctl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
cleanup:
|
||||||
|
vshTableFree(table);
|
||||||
VIR_FREE(cpumap);
|
VIR_FREE(cpumap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -7520,6 +7533,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int maxcpu;
|
int maxcpu;
|
||||||
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
|
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
|
||||||
virshControlPtr priv = ctl->privData;
|
virshControlPtr priv = ctl->privData;
|
||||||
|
vshTablePtr table = NULL;
|
||||||
|
|
||||||
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
|
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
|
||||||
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
|
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
|
||||||
@ -7545,19 +7559,30 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshPrintExtra(ctl, " %-15s %-15s\n",
|
table = vshTableNew(_("IOThread ID"), _("CPU Affinity"), NULL);
|
||||||
_("IOThread ID"), _("CPU Affinity"));
|
if (!table)
|
||||||
vshPrintExtra(ctl, "---------------------------------------------------\n");
|
goto cleanup;
|
||||||
for (i = 0; i < niothreads; i++) {
|
|
||||||
|
|
||||||
vshPrint(ctl, " %-15u ", info[i]->iothread_id);
|
for (i = 0; i < niothreads; i++) {
|
||||||
ignore_value(virshPrintPinInfo(ctl, info[i]->cpumap, info[i]->cpumaplen));
|
VIR_AUTOFREE(char *) pinInfo = NULL;
|
||||||
vshPrint(ctl, "\n");
|
VIR_AUTOFREE(char *) iothreadIdStr = NULL;
|
||||||
virDomainIOThreadInfoFree(info[i]);
|
|
||||||
|
if (virAsprintf(&iothreadIdStr, "%u", info[i]->iothread_id) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ignore_value(pinInfo = virBitmapDataFormat(info[i]->cpumap, info[i]->cpumaplen));
|
||||||
|
|
||||||
|
if (vshTableRowAppend(table, iothreadIdStr, pinInfo ? pinInfo : "", NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(info);
|
|
||||||
|
vshTablePrintToStdout(table, ctl);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
for (i = 0; i < niothreads; i++)
|
||||||
|
virDomainIOThreadInfoFree(info[i]);
|
||||||
|
VIR_FREE(info);
|
||||||
|
vshTableFree(table);
|
||||||
virshDomainFree(dom);
|
virshDomainFree(dom);
|
||||||
return niothreads >= 0;
|
return niothreads >= 0;
|
||||||
}
|
}
|
||||||
@ -13778,6 +13803,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
virDomainFSInfoPtr *info;
|
virDomainFSInfoPtr *info;
|
||||||
|
vshTablePtr table = NULL;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
@ -13793,25 +13819,41 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (info) {
|
if (info) {
|
||||||
vshPrintExtra(ctl, "%-36s %-8s %-8s %s\n",
|
table = vshTableNew(_("Mountpoint"), _("Name"), _("Type"), _("Target"), NULL);
|
||||||
_("Mountpoint"), _("Name"), _("Type"), _("Target"));
|
if (!table)
|
||||||
vshPrintExtra(ctl, "-------------------------------------------------------------------\n");
|
goto cleanup;
|
||||||
for (i = 0; i < ret; i++) {
|
|
||||||
vshPrint(ctl, "%-36s %-8s %-8s ",
|
|
||||||
info[i]->mountpoint, info[i]->name, info[i]->fstype);
|
|
||||||
for (j = 0; j < info[i]->ndevAlias; j++) {
|
|
||||||
vshPrint(ctl, "%s", info[i]->devAlias[j]);
|
|
||||||
if (j != info[i]->ndevAlias - 1)
|
|
||||||
vshPrint(ctl, ",");
|
|
||||||
}
|
|
||||||
vshPrint(ctl, "\n");
|
|
||||||
|
|
||||||
virDomainFSInfoFree(info[i]);
|
for (i = 0; i < ret; i++) {
|
||||||
|
virBuffer targetsBuff = VIR_BUFFER_INITIALIZER;
|
||||||
|
VIR_AUTOFREE(char *) targets = NULL;
|
||||||
|
|
||||||
|
for (j = 0; j < info[i]->ndevAlias; j++) {
|
||||||
|
virBufferAdd(&targetsBuff, info[i]->devAlias[j], -1);
|
||||||
|
if (j != info[i]->ndevAlias - 1)
|
||||||
|
virBufferAddChar(&targetsBuff, ',');
|
||||||
|
}
|
||||||
|
|
||||||
|
targets = virBufferContentAndReset(&targetsBuff);
|
||||||
|
|
||||||
|
if (vshTableRowAppend(table,
|
||||||
|
info[i]->mountpoint,
|
||||||
|
info[i]->name,
|
||||||
|
info[i]->fstype,
|
||||||
|
targets,
|
||||||
|
NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(info);
|
|
||||||
|
vshTablePrintToStdout(table, ctl);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (info) {
|
||||||
|
for (i = 0; i < ret; i++)
|
||||||
|
virDomainFSInfoFree(info[i]);
|
||||||
|
VIR_FREE(info);
|
||||||
|
}
|
||||||
|
vshTableFree(table);
|
||||||
virshDomainFree(dom);
|
virshDomainFree(dom);
|
||||||
return ret >= 0;
|
return ret >= 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user