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

[libvirt] [PATCH 03/12] lib: introduce an API to modify parameters of existing iothread



This allows to modify polling parameters of existing iothread.

Signed-off-by: Pavel Hrdina <phrdina redhat com>
---
 include/libvirt/libvirt-domain.h |  5 ++++
 src/driver-hypervisor.h          |  8 +++++
 src/libvirt-domain.c             | 65 ++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  1 +
 src/remote/remote_driver.c       |  1 +
 src/remote/remote_protocol.x     | 16 +++++++++-
 src/remote_protocol-structs      | 10 +++++++
 7 files changed, 105 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 5ce974292e..aa769760f1 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1921,6 +1921,11 @@ int                  virDomainAddIOThreadParams(virDomainPtr domain,
                                                 virTypedParameterPtr params,
                                                 int nparams,
                                                 unsigned int flags);
+int                  virDomainModIOThreadParams(virDomainPtr domain,
+                                                unsigned int iothread_id,
+                                                virTypedParameterPtr params,
+                                                int nparams,
+                                                unsigned int flags);
 int                  virDomainDelIOThread(virDomainPtr domain,
                                           unsigned int iothread_id,
                                           unsigned int flags);
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 9c7ce83cd3..02c8e23e66 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -406,6 +406,13 @@ typedef int
                                  unsigned int flags);
 
 typedef int
+(*virDrvDomainModIOThreadParams)(virDomainPtr domain,
+                                 unsigned int iothread_id,
+                                 virTypedParameterPtr params,
+                                 int nparams,
+                                 unsigned int flags);
+
+typedef int
 (*virDrvDomainDelIOThread)(virDomainPtr domain,
                            unsigned int iothread_id,
                            unsigned int flags);
@@ -1342,6 +1349,7 @@ struct _virHypervisorDriver {
     virDrvDomainPinIOThread domainPinIOThread;
     virDrvDomainAddIOThread domainAddIOThread;
     virDrvDomainAddIOThreadParams domainAddIOThreadParams;
+    virDrvDomainModIOThreadParams domainModIOThreadParams;
     virDrvDomainDelIOThread domainDelIOThread;
     virDrvDomainGetSecurityLabel domainGetSecurityLabel;
     virDrvDomainGetSecurityLabelList domainGetSecurityLabelList;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 691c72dedd..d661e68d5e 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -7826,6 +7826,71 @@ virDomainAddIOThreadParams(virDomainPtr domain,
 
 
 /**
+ * virDomainModIOThreadParams:
+ * @domain: a domain object
+ * @iothread_id: the specific IOThread ID value to modify
+ * @params: pointer to IOThread parameter objects
+ * @nparams: number of IOThread parameters
+ * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
+ *
+ * Modifies parameters of existing IOThread ID specified by @iothread_id.
+ *
+ * The combination of parameters has some limitation,
+ * see virDomainAddIOThreadParams for detailed description.
+ *
+ * See VIR_DOMAIN_IOTHREAD_* for detailed description of accepted IOThread
+ * parameters.
+ *
+ * Note that this call can fail if the underlying virtualization hypervisor
+ * does not support it or if growing the number of iothreads is arbitrarily
+ * limited.  This function requires privileged access to the hypervisor.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+int
+virDomainModIOThreadParams(virDomainPtr domain,
+                           unsigned int iothread_id,
+                           virTypedParameterPtr params,
+                           int nparams,
+                           unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "iothread_id=%u, params=%p, nparams=%d, flags=%x",
+                     iothread_id, params, nparams, flags);
+    VIR_TYPED_PARAMS_DEBUG(params, nparams);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+
+    virCheckReadOnlyGoto(conn->flags, error);
+    virCheckNonNegativeArgGoto(nparams, error);
+    if (nparams)
+        virCheckNonNullArgGoto(params, error);
+
+    if (virTypedParameterValidateSet(conn, params, nparams) < 0)
+        goto error;
+
+    if (conn->driver->domainModIOThreadParams) {
+        int ret;
+        ret = conn->driver->domainModIOThreadParams(domain, iothread_id,
+                                                    params, nparams, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
+
+
+/**
  * virDomainDelIOThread:
  * @domain: a domain object
  * @iothread_id: the specific IOThread ID value to delete
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index edf72d23aa..de7f344d0d 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -756,6 +756,7 @@ LIBVIRT_3.0.0 {
 LIBVIRT_3.1.0 {
     global:
         virDomainAddIOThreadParams;
+        virDomainModIOThreadParams;
 } LIBVIRT_3.0.0;
 
 # .... define new API here using predicted next version number ....
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f9e246b8bc..5086a678eb 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8247,6 +8247,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainPinIOThread = remoteDomainPinIOThread, /* 1.2.14 */
     .domainAddIOThread = remoteDomainAddIOThread, /* 1.2.15 */
     .domainAddIOThreadParams = remoteDomainAddIOThreadParams, /* 3.1.0 */
+    .domainModIOThreadParams = remoteDomainModIOThreadParams, /* 3.1.0 */
     .domainDelIOThread = remoteDomainDelIOThread, /* 1.2.15 */
     .domainGetSecurityLabel = remoteDomainGetSecurityLabel, /* 0.6.1 */
     .domainGetSecurityLabelList = remoteDomainGetSecurityLabelList, /* 0.10.0 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 146c38b3f4..238a29b481 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1237,6 +1237,13 @@ struct remote_domain_add_iothread_params_args {
     unsigned int flags;
 };
 
+struct remote_domain_mod_iothread_params_args {
+    remote_nonnull_domain dom;
+    unsigned int iothread_id;
+    remote_typed_param params<REMOTE_DOMAIN_IOTHREAD_PARAMS_MAX>;
+    unsigned int flags;
+};
+
 struct remote_domain_del_iothread_args {
     remote_nonnull_domain dom;
     unsigned int iothread_id;
@@ -6036,6 +6043,13 @@ enum remote_procedure {
      * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE
      * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG
      */
-    REMOTE_PROC_DOMAIN_ADD_IOTHREAD_PARAMS = 384
+    REMOTE_PROC_DOMAIN_ADD_IOTHREAD_PARAMS = 384,
 
+    /**
+     * @generate: both
+     * @acl: domain:write
+     * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE
+     * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG
+     */
+    REMOTE_PROC_DOMAIN_MOD_IOTHREAD_PARAMS = 385
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 2e3245322f..7672110578 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -866,6 +866,15 @@ struct remote_domain_add_iothread_params_args {
         } params;
         u_int                      flags;
 };
+struct remote_domain_mod_iothread_params_args {
+        remote_nonnull_domain      dom;
+        u_int                      iothread_id;
+        struct {
+                u_int              params_len;
+                remote_typed_param * params_val;
+        } params;
+        u_int                      flags;
+};
 struct remote_domain_del_iothread_args {
         remote_nonnull_domain      dom;
         u_int                      iothread_id;
@@ -3220,4 +3229,5 @@ enum remote_procedure {
         REMOTE_PROC_SECRET_EVENT_LIFECYCLE = 382,
         REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED = 383,
         REMOTE_PROC_DOMAIN_ADD_IOTHREAD_PARAMS = 384,
+        REMOTE_PROC_DOMAIN_MOD_IOTHREAD_PARAMS = 385,
 };
-- 
2.11.1


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