[PATCH 1/3] Add new parameters for blkiotune

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

 



This patch adds three parameters --live, --config and --current
for command blkiotune.
---
 include/libvirt/libvirt.h.in |    6 ++++++
 tools/virsh.c                |   26 +++++++++++++++++++++++---
 tools/virsh.pod              |    6 +++++-
 3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 7cd6e13..fe50d41 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -814,6 +814,12 @@ typedef enum {
     VIR_DOMAIN_BLKIO_PARAM_BOOLEAN = VIR_TYPED_PARAM_BOOLEAN,
 } virBlkioParameterType;
 
+typedef enum {
+    VIR_DOMAIN_BLKIO_PARAM_CURRENT = 0,        /* affect current domain state */
+    VIR_DOMAIN_BLKIO_PARAM_LIVE    = (1 << 0), /* affect active domain */
+    VIR_DOMAIN_BLKIO_PARAM_CONFIG  = (1 << 1)  /* affect next boot */
+} virBlkioParameterFlags;
+
 /**
  * VIR_DOMAIN_BLKIO_FIELD_LENGTH:
  *
diff --git a/tools/virsh.c b/tools/virsh.c
index de49489..2ecb2ea 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3171,6 +3171,9 @@ static const vshCmdOptDef opts_blkiotune[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"weight", VSH_OT_INT, VSH_OFLAG_NONE,
      N_("IO Weight in range [100, 1000]")},
+    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
+    {"live", VSH_OT_BOOL, 0, N_("affect running domain")},
+    {"current", VSH_OT_BOOL, 0, N_("affect current domain")},
     {NULL, 0, 0, NULL}
 };
 
@@ -3183,6 +3186,23 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
     unsigned int i = 0;
     virBlkioParameterPtr params = NULL, temp = NULL;
     bool ret = false;
+    unsigned int flags = 0;
+    int current = vshCommandOptBool(cmd, "current");
+    int config = vshCommandOptBool(cmd, "config");
+    int live = vshCommandOptBool(cmd, "live");
+
+    if (current) {
+        if (live || config) {
+            vshError(ctl, "%s", _("--current must be specified exclusively"));
+            return false;
+        }
+        flags = VIR_DOMAIN_BLKIO_PARAM_CURRENT;
+    } else {
+        if (config)
+            flags |= VIR_DOMAIN_BLKIO_PARAM_CONFIG;
+        if (live)
+            flags |= VIR_DOMAIN_BLKIO_PARAM_LIVE;
+    }
 
     if (!vshConnectionUsability(ctl, ctl->conn))
         return false;
@@ -3207,7 +3227,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
 
     if (nparams == 0) {
         /* get the number of blkio parameters */
-        if (virDomainGetBlkioParameters(dom, NULL, &nparams, 0) != 0) {
+        if (virDomainGetBlkioParameters(dom, NULL, &nparams, flags) != 0) {
             vshError(ctl, "%s",
                      _("Unable to get number of blkio parameters"));
             goto cleanup;
@@ -3221,7 +3241,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
 
         /* now go get all the blkio parameters */
         params = vshCalloc(ctl, nparams, sizeof(*params));
-        if (virDomainGetBlkioParameters(dom, params, &nparams, 0) != 0) {
+        if (virDomainGetBlkioParameters(dom, params, &nparams, flags) != 0) {
             vshError(ctl, "%s", _("Unable to get blkio parameters"));
             goto cleanup;
         }
@@ -3273,7 +3293,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
                 weight = 0;
             }
         }
-        if (virDomainSetBlkioParameters(dom, params, nparams, 0) != 0)
+        if (virDomainSetBlkioParameters(dom, params, nparams, flags) != 0)
             vshError(ctl, "%s", _("Unable to change blkio parameters"));
         else
             ret = true;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index ef01f41..b366ae7 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -674,11 +674,15 @@ value are kilobytes (i.e. blocks of 1024 bytes).
 
 =back
 
-=item B<blkiotune> I<domain-id> optional I<--weight> B<weight>
+=item B<blkiotune> I<domain-id> optional I<--weight> B<weight> I<--live> I<--config> I<--current>
 
 Display or set the blkio parameters. QEMU/KVM supports I<--weight>.
 I<--weight> is in range [100, 1000].
 
+If I<--live> is specified, get/set blkio parameters of a running guest.
+If I<--config> is specified, affect the next boot of a persistent guest.
+If I<--current> is specified, affect the current guest state.
+
 =item B<setvcpus> I<domain-id> I<count> optional I<--maximum> I<--config>
 I<--live>
 
-- 
1.7.3.1

--
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]