On Fri, Apr 10, 2015 at 17:36:24 -0400, John Ferlan wrote: > Add libvirt API's to manage adding and deleting IOThreads to/from the > domain > > Signed-off-by: John Ferlan <[email protected]> > --- > include/libvirt/libvirt-domain.h | 7 +++ > src/driver-hypervisor.h | 13 ++++ > src/libvirt-domain.c | 132 > +++++++++++++++++++++++++++++++++++++++ > src/libvirt_public.syms | 6 ++ > 4 files changed, 158 insertions(+) > > diff --git a/include/libvirt/libvirt-domain.h > b/include/libvirt/libvirt-domain.h > index 7be4219..472258c 100644 > --- a/include/libvirt/libvirt-domain.h > +++ b/include/libvirt/libvirt-domain.h > @@ -1615,6 +1615,13 @@ int virDomainPinIOThread(virDomainPtr > domain, > unsigned char *cpumap, > int maplen, > unsigned int flags); > +int virDomainAddIOThread(virDomainPtr domain, > + unsigned int iothread_id, > + const char *name, > + unsigned int flags); > +int virDomainDelIOThread(virDomainPtr domain, > + unsigned int iothread_id, > + unsigned int flags); > > /** > * VIR_USE_CPU: > diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h > index 1b92460..283562f 100644 > --- a/src/driver-hypervisor.h > +++ b/src/driver-hypervisor.h > @@ -393,6 +393,17 @@ typedef int > unsigned int flags); > > typedef int > +(*virDrvDomainAddIOThread)(virDomainPtr domain, > + unsigned int iothread_id, > + const char *name, > + unsigned int flags); > + > +typedef int > +(*virDrvDomainDelIOThread)(virDomainPtr domain, > + unsigned int iothread_id, > + unsigned int flags); > + > +typedef int > (*virDrvDomainGetSecurityLabel)(virDomainPtr domain, > virSecurityLabelPtr seclabel); > > @@ -1273,6 +1284,8 @@ struct _virHypervisorDriver { > virDrvDomainGetMaxVcpus domainGetMaxVcpus; > virDrvDomainGetIOThreadInfo domainGetIOThreadInfo; > virDrvDomainPinIOThread domainPinIOThread; > + virDrvDomainAddIOThread domainAddIOThread; > + virDrvDomainDelIOThread domainDelIOThread; > virDrvDomainGetSecurityLabel domainGetSecurityLabel; > virDrvDomainGetSecurityLabelList domainGetSecurityLabelList; > virDrvNodeGetSecurityModel nodeGetSecurityModel; > diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c > index 0acfd13..ffd50b3 100644 > --- a/src/libvirt-domain.c > +++ b/src/libvirt-domain.c > @@ -8020,6 +8020,138 @@ virDomainPinIOThread(virDomainPtr domain, > > > /** > + * virDomainAddIOThread: > + * @domain: a domain object > + * @iothread_id: the specific IOThread ID value to add > + * @name: optional additional naming string (NUL terminated) > + * @flags: bitwise-OR of virDomainModificationImpact > + * > + * Dynamically add an IOThread to the domain. If @iothread_id is a positive > + * non-zero value, then attempt to add the specific IOThread ID and error > + * out if the iothread id already exists. If the @name is NULL, then only > + * the default naming scheme is used. Any name containing "iothread" will > + * be rejected. > + * > + * Note that this call can fail if the underlying virtualization hypervisor > + * does not support it or if growing the number is arbitrarily limited. > + * This function may require privileged access to the hypervisor.
It requires, not may require.
> + *
> + * @flags may include VIR_DOMAIN_AFFECT_LIVE to affect a running
> + * domain (which may fail if domain is not active), or
> + * VIR_DOMAIN_AFFECT_CONFIG to affect the next boot via the XML
> + * description of the domain. Both flags may be set.
> + * If neither flag is specified (that is, @flags is
> VIR_DOMAIN_AFFECT_CURRENT),
> + * then an inactive domain modifies persistent setup, while an active domain
> + * is hypervisor-dependent on whether just live or both live and persistent
> + * state is changed.
I'd opt for a more sane explanation, where CURRENT with active VM means
the live definiton is modified.
> + *
> + * Not all hypervisors can support all flag combinations.
There are no flags this could potentially apply to yet.
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + */
> +int
> +virDomainAddIOThread(virDomainPtr domain,
> + unsigned int iothread_id,
> + const char *name,
> + unsigned int flags)
> +{
> + virConnectPtr conn;
> +
> + VIR_DOMAIN_DEBUG(domain, "iothread_id=%u, name=%p flags=%x",
> + iothread_id, name, flags);
> +
> + virResetLastError();
> +
> + virCheckDomainReturn(domain, -1);
> + virCheckReadOnlyGoto(domain->conn->flags, error);
> +
> + if ((unsigned short) iothread_id != iothread_id) {
> + virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"),
> iothread_id);
> + goto error;
Just store it as a full unsigned integer and kill this check.
> + }
> + conn = domain->conn;
> +
> + if (conn->driver->domainAddIOThread) {
> + int ret;
> + ret = conn->driver->domainAddIOThread(domain, iothread_id, name,
> 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
> + * @flags: bitwise-OR of virDomainModificationImpact
> + *
> + * Dynamically delete an IOThread from the domain. The @iothread_id to be
> + * deleted must not have a resource associated with it and can be any of
> + * the currently valid IOThread ID's.
> + *
> + * Note that this call can fail if the underlying virtualization hypervisor
> + * does not support it or if reducing the number is arbitrarily limited.
> + * This function may require privileged access to the hypervisor.
This function requires privileged access.
> + *
> + * @flags may include VIR_DOMAIN_AFFECT_LIVE to affect a running
> + * domain (which may fail if domain is not active), or
> + * VIR_DOMAIN_AFFECT_CONFIG to affect the next boot via the XML
> + * description of the domain. Both flags may be set.
> + * If neither flag is specified (that is, @flags is
> VIR_DOMAIN_AFFECT_CURRENT),
> + * then an inactive domain modifies persistent setup, while an active domain
> + * is hypervisor-dependent on whether just live or both live and persistent
> + * state is changed.
> + *
> + * Not all hypervisors can support all flag combinations.
... see above.
> + *
> + * Returns 0 in case of success, -1 in case of failure.
> + */
> +int
> +virDomainDelIOThread(virDomainPtr domain,
> + unsigned int iothread_id,
> + unsigned int flags)
> +{
> + virConnectPtr conn;
> +
> + VIR_DOMAIN_DEBUG(domain, "iothread_id=%u, flags=%x", iothread_id, flags);
> +
> + virResetLastError();
> +
> + virCheckDomainReturn(domain, -1);
> + virCheckReadOnlyGoto(domain->conn->flags, error);
> + virCheckNonZeroArgGoto(iothread_id, error);
> +
> + if ((unsigned short) iothread_id != iothread_id) {
> + virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"),
> iothread_id);
> + goto error;
See above.
> + }
> + conn = domain->conn;
> +
> + if (conn->driver->domainDelIOThread) {
> + int ret;
> + ret = conn->driver->domainDelIOThread(domain, iothread_id, flags);
> + if (ret < 0)
> + goto error;
> + return ret;
> + }
> +
> + virReportUnsupportedError();
> +
> + error:
> + virDispatchError(domain->conn);
> + return -1;
> +}
> +
> +
> +/**
> * virDomainGetSecurityLabel:
> * @domain: a domain object
> * @seclabel: pointer to a virSecurityLabel structure
Peter
signature.asc
Description: Digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
