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
+#[derive(Clone, Debug, Default)]
+pub struct SchedBandwidth {
+pub period: Option,
+pub quota: Option,
+}
+
+#[derive(Clone, Debug, Default)]
+pub struct SchedulerInfo {