[PATCH 1/7] Implement public API for virDomainIOThreadsSet

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

 



Add virDomainIOThreadsSet to allow setting the number of IOThreads for
a domain.

The API supports updating both the --live domain and the --config data.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h |  3 ++
 src/driver-hypervisor.h          |  6 ++++
 src/libvirt-domain.c             | 60 ++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  1 +
 4 files changed, 70 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 5d1d868..d7ce6f8 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1615,6 +1615,9 @@ int                  virDomainPinIOThread(virDomainPtr domain,
                                           unsigned char *cpumap,
                                           int maplen,
                                           unsigned int flags);
+int                  virDomainSetIOThreads(virDomainPtr domain,
+                                           unsigned int niothreads,
+                                           unsigned int flags);
 
 /**
  * VIR_USE_CPU:
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 3f9bf02..2e4104b 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -393,6 +393,11 @@ typedef int
                            unsigned int flags);
 
 typedef int
+(*virDrvDomainSetIOThreads)(virDomainPtr domain,
+                            unsigned int iothreads,
+                            unsigned int flags);
+
+typedef int
 (*virDrvDomainGetSecurityLabel)(virDomainPtr domain,
                                 virSecurityLabelPtr seclabel);
 
@@ -1273,6 +1278,7 @@ struct _virHypervisorDriver {
     virDrvDomainGetMaxVcpus domainGetMaxVcpus;
     virDrvDomainGetIOThreadsInfo domainGetIOThreadsInfo;
     virDrvDomainPinIOThread domainPinIOThread;
+    virDrvDomainSetIOThreads domainSetIOThreads;
     virDrvDomainGetSecurityLabel domainGetSecurityLabel;
     virDrvDomainGetSecurityLabelList domainGetSecurityLabelList;
     virDrvNodeGetSecurityModel nodeGetSecurityModel;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 0bd9274..7176301 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -8042,6 +8042,66 @@ virDomainPinIOThread(virDomainPtr domain,
 
 
 /**
+ * virDomainSetIOThreads:
+ * @domain: pointer to domain object
+ * @niothreads: the new number of IOThreads for this domain
+ * @flags: bitwise-OR of virDomainModificationImpact
+ *
+ * Dynamically change the number of IOThreads used by the domain.
+ * Note that this call faiy 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
+virDomainSetIOThreads(virDomainPtr domain,
+                      unsigned int niothreads,
+                      unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "niothreads=%u, flags=%x", niothreads, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    virCheckReadOnlyGoto(domain->conn->flags, error);
+
+    if ((unsigned short) niothreads != niothreads) {
+        virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"), niothreads);
+        goto error;
+    }
+    conn = domain->conn;
+
+    if (conn->driver->domainSetIOThreads) {
+        int ret;
+        ret = conn->driver->domainSetIOThreads(domain, niothreads, 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 e4cf7ed..fdcbd6f 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -702,6 +702,7 @@ LIBVIRT_1.2.14 {
         virDomainPinIOThread;
         virDomainInterfaceAddresses;
         virDomainInterfaceFree;
+        virDomainSetIOThreads;
 } LIBVIRT_1.2.12;
 
 # .... define new API here using predicted next version number ....
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]