[PATCH v3 4/9] virsh: Add 'iothreads' command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

An active domain may return:

$ virsh iothreads $dom
 IOThread ID     CPU Affinity    Resource(s)
 -----------------------------------------------------------------
  1               2              /home/vm-images/f18
  2               3              /home/vm-images/iothr-vol1
  3               0

$ echo $?
0

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

$ virsh iothreads $dom
error: 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    Resource(s)
 ---------------------------------------------
  1               2              /home/vm-images/f18
  2               3              /home/vm-images/iothr-vol1
  3               0-1

$

Editing a domains configuration to assign both Resources
to IOThread ID 1 and then displaying again results in:

$ virsh iothreads f18iothr --config
 IOThread ID     CPU Affinity    Resource(s)
 -----------------------------------------------------------------
  1               2              /home/vm-images/f18
                                 /home/vm-images/iothr-vol1
  2               3
  3               0-1

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 tools/virsh-domain.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/virsh.pod      |  12 ++++++
 2 files changed, 113 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2506b89..ffb0392 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6797,6 +6797,101 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
 }
 
 /*
+ * "iothreads" 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;
+    virDomainIOThreadsInfoPtr *info;
+    size_t i, j;
+    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) {
+        vshError(ctl, _("No IOThreads found for the domain"));
+        goto cleanup;
+    }
+
+    vshPrintExtra(ctl, " %-15s %-15s %-15s\n",
+                  _("IOThread ID"), _("CPU Affinity"), _("Resource(s)"));
+    vshPrintExtra(ctl, "-----------------------------------------------------------------\n");
+    for (i = 0; i < niothreads; i++) {
+
+        vshPrintExtra(ctl, " %-15u ", info[i]->iothread_id);
+        ignore_value(vshPrintPinInfo(info[i]->cpumap, info[i]->cpumaplen,
+                                     maxcpu, 0));
+        for (j = 0; j < info[i]->nresources; j++) {
+            if (j == 0)
+                vshPrintExtra(ctl, "\t\t %s", info[i]->resources[j]);
+            else
+                vshPrintExtra(ctl, "\n %-15s %s\t\t %s",
+                              " ", " ", info[i]->resources[j]);
+        }
+        vshPrint(ctl, "\n");
+        virDomainIOThreadsInfoFree(info[i]);
+    }
+    VIR_FREE(info);
+
+ cleanup:
+    virDomainFree(dom);
+    return niothreads >= 0;
+}
+
+/*
  * "cpu-compare" command
  */
 static const vshCmdInfo info_cpu_compare[] = {
@@ -12697,6 +12792,12 @@ const vshCmdDef domManagementCmds[] = {
      .info = info_inject_nmi,
      .flags = 0
     },
+    {.name = "iothreads",
+     .handler = cmdIOThreadsInfo,
+     .opts = opts_iothreads,
+     .info = info_iothreads,
+     .flags = 0
+    },
     {.name = "send-key",
      .handler = cmdSendKey,
      .opts = opts_send_key,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 50de32c..22e988b 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1360,6 +1360,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<iothreads> I<domain> [[I<--live>] [I<--config>] | [I<--current>]]
+
+Display basic domain IOThreads information including the IOThread ID,
+the CPU Affinity, and Resources assigned to 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>]
 
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]