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 | 6 ++
src/driver-hypervisor.h | 12 ++++
src/libvirt-domain.c | 118 +++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 6 ++
4 files changed, 142 insertions(+)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 5c0a382..0f465b9 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1615,6 +1615,12 @@ int virDomainPinIOThread(virDomainPtr domain,
unsigned char *cpumap,
int maplen,
unsigned int flags);
+int virDomainAddIOThread(virDomainPtr domain,
+ unsigned int iothread_id,
+ 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..8b8d031 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -393,6 +393,16 @@ typedef int
unsigned int flags);
typedef int
+(*virDrvDomainAddIOThread)(virDomainPtr domain,
+ unsigned int iothread_id,
+ unsigned int flags);
+
+typedef int
+(*virDrvDomainDelIOThread)(virDomainPtr domain,
+ unsigned int iothread_id,
+ unsigned int flags);
+
+typedef int
(*virDrvDomainGetSecurityLabel)(virDomainPtr domain,
virSecurityLabelPtr seclabel);
@@ -1273,6 +1283,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 ccacdb4..ec5e2ff 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -8020,6 +8020,124 @@ virDomainPinIOThread(virDomainPtr domain,
/**
+ * virDomainAddIOThread:
+ * @domain: a domain object
+ * @iothread_id: the specific IOThread ID value to add
+ * @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.
+ *
+ * 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 requires privileged access to the hypervisor.
+ *
+ * @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
+ * Both flags may be set.
+ * If VIR_DOMAIN_AFFECT_LIVE is set, the change affects a running domain
+ * and may fail if domain is not alive.
+ * If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
+ * and will fail for transient domains. 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.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+int
+virDomainAddIOThread(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);
+
+ conn = domain->conn;
+
+ if (conn->driver->domainAddIOThread) {
+ int ret;
+ ret = conn->driver->domainAddIOThread(domain, iothread_id, 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 requires privileged access to the hypervisor.
+ *
+ * @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
+ * Both flags may be set.
+ * If VIR_DOMAIN_AFFECT_LIVE is set, the change affects a running domain
+ * and may fail if domain is not alive.
+ * If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
+ * and will fail for transient domains. 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.
+ *
+ * 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);
+
+ 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