Add libvirt API's to manage adding and deleting IOThreads to/from the
domain
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
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.
+ *
+ * @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.
+ *
+ * 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;
+ }
+ 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.
+ *
+ * @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.
+ *
+ * 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;
+ }
+ 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
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 28347c6..ef3d2f0 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -704,4 +704,10 @@ LIBVIRT_1.2.14 {
virDomainInterfaceFree;
} LIBVIRT_1.2.12;
+LIBVIRT_1.2.15 {
+ global:
+ virDomainAddIOThread;
+ virDomainDelIOThread;
+} LIBVIRT_1.2.14;
+
# .... define new API here using predicted next version number ....
--
2.1.0