Re: [libvirt] [rust PATCH] Domain: Implement scheduler information related APIs

2019-12-16 Thread Vineeth Remanan Pillai
Thanks Sahid.

Vineeth

On Mon, Dec 16, 2019 at 5:59 AM Sahid Orentino Ferdjaoui
 wrote:
>
> On Sat, Dec 14, 2019 at 01:38:56PM +, Vineeth Remanan Pillai wrote:
> > Implement the following:
> > - virDomainGetSchedulerType
> > - virDomainSetSchedulerParameters
> > - virDomainSetSchedulerParametersFlags
> > - virDomainGetSchedulerParameters
> > - virDomainGetSchedulerParametersFlags
> >
> > Signed-off-by: Vineeth Remanan Pillai 
> > ---
> >  examples/hello.rs |  38 +++
> >  src/domain.rs | 260 +++---
> >  2 files changed, 283 insertions(+), 15 deletions(-)
>
> Reviewed-by: Sahid Orentino Ferdjaoui 
>
> I will merge it and push a new release as soon as I can. Thank you for
> your contribution.
>
> s.


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



[libvirt] [rust PATCH] Domain: Implement scheduler information related APIs

2019-12-16 Thread Vineeth Remanan Pillai
Implement the following:
- virDomainGetSchedulerType
- virDomainSetSchedulerParameters
- virDomainSetSchedulerParametersFlags
- virDomainGetSchedulerParameters
- virDomainGetSchedulerParametersFlags

Signed-off-by: Vineeth Remanan Pillai 
---
 examples/hello.rs |  38 +++
 src/domain.rs | 260 +++---
 2 files changed, 283 insertions(+), 15 deletions(-)

diff --git a/examples/hello.rs b/examples/hello.rs
index e5ec6e4..1f336a9 100644
--- a/examples/hello.rs
+++ b/examples/hello.rs
@@ -89,6 +89,44 @@ fn show_domains(conn: ) -> Result<(), Error> {
  numa.node_set.unwrap_or(String::from("")));
 println!("Mode: {}", numa.mode.unwrap_or(0));
 }
+
+if let Ok((sched_type, nparams)) = 
dom.get_scheduler_type() {
+println!("SchedType: {}, nparams: {}",
+ sched_type, nparams);
+}
+
+if let Ok(sched_info) = dom.get_scheduler_parameters() {
+println!("Schedule Information:");
+println!("\tScheduler\t: {}", 
sched_info.scheduler_type);
+if let Some(shares) =  sched_info.cpu_shares {
+println!("\tcpu_shares\t: {}", shares);
+}
+if let Some(period) = sched_info.vcpu_bw.period {
+println!("\tvcpu_period\t: {}", period);
+}
+if let Some(quota) = sched_info.vcpu_bw.quota {
+println!("\tvcpu_quota\t: {}", quota);
+}
+if let Some(period) = sched_info.emulator_bw.period {
+println!("\temulator_period\t: {}", period);
+}
+if let Some(quota) = sched_info.emulator_bw.quota {
+println!("\temulator_quota\t: {}", quota);
+}
+if let Some(period) = sched_info.global_bw.period {
+println!("\tglobal_period\t: {}", period);
+}
+if let Some(quota) = sched_info.global_bw.quota {
+println!("\tglobal_quota\t: {}", quota);
+}
+if let Some(period) = sched_info.global_bw.period {
+println!("\tiothread_period\t: {}", period);
+}
+if let Some(quota) = sched_info.global_bw.quota {
+println!("\tiothread_quota\t: {}", quota);
+}
+}
+
 }
 }
 return Ok(());
diff --git a/src/domain.rs b/src/domain.rs
index acb9e6e..40a18d8 100644
--- a/src/domain.rs
+++ b/src/domain.rs
@@ -363,6 +363,29 @@ extern "C" {
  snaps: *mut *mut virDomainSnapshotPtr,
  flags: libc::c_uint)
  -> libc::c_int;
+
+fn virDomainGetSchedulerType(ptr: sys::virDomainPtr,
+ nparams: *mut libc::c_int)
+ -> *mut libc::c_char;
+fn virDomainGetSchedulerParameters(ptr: sys::virDomainPtr,
+   params: virTypedParameterPtr,
+   nparams: *mut libc::c_int)
+   -> libc::c_int;
+fn virDomainSetSchedulerParameters(ptr: sys::virDomainPtr,
+   params: virTypedParameterPtr,
+   nparams: libc::c_int)
+   -> libc::c_int;
+fn virDomainGetSchedulerParametersFlags(ptr: sys::virDomainPtr,
+params: virTypedParameterPtr,
+nparams: *mut libc::c_int,
+flags: libc::c_uint)
+-> libc::c_int;
+fn virDomainSetSchedulerParametersFlags(ptr: sys::virDomainPtr,
+params: virTypedParameterPtr,
+nparams: libc::c_int,
+flags: libc::c_uint)
+-> libc::c_int;
+
 }
 
 pub type DomainXMLFlags = self::libc::c_uint;
@@ -607,6 +630,124 @@ impl MemoryStats {
 }
 }
 
+/// Structure representing the CFS scheduler cpu bandwidth parameters
+/// see https://www.kernel.org/doc/html/latest/scheduler/sched-bwc.html