From nobody Sun Feb 8 14:35:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 14876795172901007.1504235597413; Tue, 21 Feb 2017 04:18:37 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1LCFDLK005873; Tue, 21 Feb 2017 07:15:13 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1LCFC1U022556 for ; Tue, 21 Feb 2017 07:15:12 -0500 Received: from antique-work.brq.redhat.com (dhcp129-175.brq.redhat.com [10.34.129.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LCF9hF031008 for ; Tue, 21 Feb 2017 07:15:11 -0500 From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 21 Feb 2017 13:14:58 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/12] lib: introduce an API to add new iothread with parameters X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This basically copies and extend the existing virDomainAddIOThread API by adding support for parameters. This allows you to add a new iothread into a domain and also sets polling parameters along with the new iothread. Signed-off-by: Pavel Hrdina --- include/libvirt/libvirt-domain.h | 39 +++++++++++++++++++++ src/driver-hypervisor.h | 8 +++++ src/libvirt-domain.c | 75 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 5 +++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 20 ++++++++++- src/remote_protocol-structs | 10 ++++++ 7 files changed, 157 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index e303140a23..5ce974292e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1855,6 +1855,40 @@ int virDomainGetEmulatorPinInfo = (virDomainPtr domain, int maplen, unsigned int flags); =20 +/* IOThread parameters */ + +/** + * VIR_DOMAIN_IOTHREAD_POLL_ENABLED: + * + * Whether polling should be enabled or not. If omitted the default is set + * by hypervisor. + */ +# define VIR_DOMAIN_IOTHREAD_POLL_ENABLED "poll_enabled" + +/** + * VIR_DOMAIN_IOTHREAD_POLL_MAX_NS: + * + * The maximal polling time that can be used by polling algorithm in ns. + * If omitted the default is 0. + */ +# define VIR_DOMAIN_IOTHREAD_POLL_MAX_NS "poll_max_ns" + +/** + * VIR_DOMAIN_IOTHREAD_POLL_GROW: + * + * This tells the polling algorithm how many ns it should grow current + * polling time if it's not optimal anymore. If omitted the default is 0. + */ +# define VIR_DOMAIN_IOTHREAD_POLL_GROW "poll_grow" + +/** + * VIR_DOMAIN_IOTHREAD_POLL_SHRINK: + * + * This tells the polling algorithm how many ns it should shrink current + * polling time if it's not optimal anymore. If omitted the default is 0. + */ +# define VIR_DOMAIN_IOTHREAD_POLL_SHRINK "poll_shrink" + /** * virIOThreadInfo: * @@ -1882,6 +1916,11 @@ int virDomainPinIOThread(virDomainP= tr domain, int virDomainAddIOThread(virDomainPtr domain, unsigned int iothread_id, unsigned int flags); +int virDomainAddIOThreadParams(virDomainPtr domain, + unsigned int iothread_id, + virTypedParameterPtr param= s, + 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 51af73200b..9c7ce83cd3 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -399,6 +399,13 @@ typedef int unsigned int flags); =20 typedef int +(*virDrvDomainAddIOThreadParams)(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); @@ -1334,6 +1341,7 @@ struct _virHypervisorDriver { virDrvDomainGetIOThreadInfo domainGetIOThreadInfo; virDrvDomainPinIOThread domainPinIOThread; virDrvDomainAddIOThread domainAddIOThread; + virDrvDomainAddIOThreadParams domainAddIOThreadParams; virDrvDomainDelIOThread domainDelIOThread; virDrvDomainGetSecurityLabel domainGetSecurityLabel; virDrvDomainGetSecurityLabelList domainGetSecurityLabelList; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5b3e842058..691c72dedd 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -7751,6 +7751,81 @@ virDomainAddIOThread(virDomainPtr domain, =20 =20 /** + * virDomainAddIOThreadParams: + * @domain: a domain object + * @iothread_id: the specific IOThread ID value to add + * @params: pointer to IOThread parameter objects + * @nparams: number of IOThread parameters + * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameter= Flags + * + * Dynamically add an IOThread to the domain. It is left up to the + * underlying virtual hypervisor to determine the valid range for an + * @iothread_id and determining whether the @iothread_id already exists. + * + * The combination of parameters has some limitation: + * + * - If VIR_DOMAIN_IOTHREAD_POLL_ENABLED is set to true, + * VIR_DOMAIN_IOTHREAD_POLL_MAX_NS must be set as well. + * + * - If VIR_DOMAIN_IOTHREAD_POLL_MAX_NS is set to value > 0, + * VIR_DOMAIN_IOTHREAD_POLL_ENABLED is set to true. + * + * - If one of VIR_DOMAIN_IOTHREAD_POLL_GROW or VIR_DOMAIN_IOTHREAD_POLL_S= HRINK + * is set to value > 0, VIR_DOMAIN_IOTHREAD_POLL_MAX_NS must be set as w= ell. + * + * 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 +virDomainAddIOThreadParams(virDomainPtr domain, + unsigned int iothread_id, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "iothread_id=3D%u, params=3D%p, nparams=3D%d,= flags=3D%x", + iothread_id, params, nparams, flags); + VIR_TYPED_PARAMS_DEBUG(params, nparams); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D 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->domainAddIOThreadParams) { + int ret; + ret =3D conn->driver->domainAddIOThreadParams(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 62885ac415..edf72d23aa 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -753,4 +753,9 @@ LIBVIRT_3.0.0 { virConnectSecretEventDeregisterAny; } LIBVIRT_2.2.0; =20 +LIBVIRT_3.1.0 { + global: + virDomainAddIOThreadParams; +} 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 a3f7d9b0ba..f9e246b8bc 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8246,6 +8246,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainGetIOThreadInfo =3D remoteDomainGetIOThreadInfo, /* 1.2.14 */ .domainPinIOThread =3D remoteDomainPinIOThread, /* 1.2.14 */ .domainAddIOThread =3D remoteDomainAddIOThread, /* 1.2.15 */ + .domainAddIOThreadParams =3D remoteDomainAddIOThreadParams, /* 3.1.0 */ .domainDelIOThread =3D remoteDomainDelIOThread, /* 1.2.15 */ .domainGetSecurityLabel =3D remoteDomainGetSecurityLabel, /* 0.6.1 */ .domainGetSecurityLabelList =3D remoteDomainGetSecurityLabelList, /* 0= .10.0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index cd0a14cc69..146c38b3f4 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -253,6 +253,9 @@ const REMOTE_DOMAIN_IP_ADDR_MAX =3D 2048; /* Upper limit on number of guest vcpu information entries */ const REMOTE_DOMAIN_GUEST_VCPU_PARAMS_MAX =3D 64; =20 +/* Upper limit on number of IOThread information entries */ +const REMOTE_DOMAIN_IOTHREAD_PARAMS_MAX =3D 64; + /* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */ typedef opaque remote_uuid[VIR_UUID_BUFLEN]; =20 @@ -1227,6 +1230,13 @@ struct remote_domain_add_iothread_args { unsigned int flags; }; =20 +struct remote_domain_add_iothread_params_args { + remote_nonnull_domain dom; + unsigned int iothread_id; + remote_typed_param params; + unsigned int flags; +}; + struct remote_domain_del_iothread_args { remote_nonnull_domain dom; unsigned int iothread_id; @@ -6018,6 +6028,14 @@ enum remote_procedure { * @generate: both * @acl: none */ - REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED =3D 383 + REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED =3D 383, + + /** + * @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_ADD_IOTHREAD_PARAMS =3D 384 =20 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 0360600cfb..2e3245322f 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -857,6 +857,15 @@ struct remote_domain_add_iothread_args { u_int iothread_id; u_int flags; }; +struct remote_domain_add_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; @@ -3210,4 +3219,5 @@ enum remote_procedure { REMOTE_PROC_CONNECT_SECRET_EVENT_DEREGISTER_ANY =3D 381, REMOTE_PROC_SECRET_EVENT_LIFECYCLE =3D 382, REMOTE_PROC_SECRET_EVENT_VALUE_CHANGED =3D 383, + REMOTE_PROC_DOMAIN_ADD_IOTHREAD_PARAMS =3D 384, }; --=20 2.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list