]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Implement 'domblkthreshold' command to call virDomainSetBlockThreshold
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Feb 2017 12:27:18 +0000 (13:27 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 27 Mar 2017 08:15:55 +0000 (10:15 +0200)
Add a simple wrapper which will allow to set the threshold for
delivering the event.

tools/virsh-domain.c
tools/virsh.pod

index d1d17c4520da96f4f44131b902d07aa0e8719725..2269146850433461b3ff59e02c919f7585453cbf 100644 (file)
@@ -7096,6 +7096,64 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd)
 }
 
 
+/*
+ * "domblkthreshold" command
+ */
+static const vshCmdInfo info_domblkthreshold[] = {
+    {.name = "help",
+     .data = N_("set the threshold for block-threshold event for a given block "
+                "device or it's backing chain element")
+    },
+    {.name = "desc",
+     .data = N_("set threshold for block-threshold event for a block device")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_domblkthreshold[] = {
+    VIRSH_COMMON_OPT_DOMAIN_FULL,
+    {.name = "dev",
+     .type = VSH_OT_DATA,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("device to set threshold for")
+    },
+    {.name = "threshold",
+     .type = VSH_OT_INT,
+     .flags = VSH_OFLAG_REQ,
+     .help = N_("threshold as a scaled number (by default bytes)")
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd)
+{
+    unsigned long long threshold;
+    const char *dev = NULL;
+    virDomainPtr dom;
+    bool ret = false;
+
+    if (vshCommandOptStringReq(ctl, cmd, "dev", &dev))
+        return false;
+
+    if (vshCommandOptScaledInt(ctl, cmd, "threshold",
+                               &threshold, 1, ULLONG_MAX) < 0)
+        return false;
+
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+        return false;
+
+    if (virDomainSetBlockThreshold(dom, dev, threshold, 0) < 0)
+        goto cleanup;
+
+    ret = true;
+
+ cleanup:
+    virDomainFree(dom);
+    return ret;
+}
+
+
 /*
  * "iothreadinfo" command
  */
@@ -14067,5 +14125,11 @@ const vshCmdDef domManagementCmds[] = {
      .info = info_setvcpu,
      .flags = 0
     },
+    {.name = "domblkthreshold",
+     .handler = cmdDomblkthreshold,
+     .opts = opts_domblkthreshold,
+     .info = info_domblkthreshold,
+     .flags = 0
+    },
     {.name = NULL}
 };
index ee790461136206c729f22daa26bf64afe94c39a8..48be1923466f708e68da429b6ac8708e22d751de 100644 (file)
@@ -1274,6 +1274,14 @@ I<--bytes> with a scaled value allows to use finer granularity. A scaled value
 used without I<--bytes> will be rounded down to MiB/s. Note that the
 I<--bytes> may be unsupported by the hypervisor.
 
+
+=item B<domblkthreshold> I<domain> I<dev> I<threshold>
+
+Set the threshold value for delivering the block-threshold event. I<dev>
+specifies the disk device target or backing chain element of given device using
+the 'target[1]' syntax. I<threshold> is a scaled value of the offset. If the
+block device should write beyond that offset the event will be delivered.
+
 =item B<blockresize> I<domain> I<path> I<size>
 
 Resize a block device of domain while the domain is running, I<path>