File 849052ec-libxl-support-credit2.patch of Package libvirt.16761

commit 849052ec61e18780713bec171748e859e32dfd6d
Author: Dario Faggioli <dfaggioli@suse.com>
Date:   Wed Jan 29 12:05:15 2020 +0100

    libxl: support getting and setting parameters for the Credit2
    
    With Credit2 being Xen default scheduler, it's definitely the case to
    allow Credit2's scheduling parameters to be get and set via libvirt.
    
    This is easy, as Credit and Credit2 have (at least as of now) the very
    same parameters ('weight' and 'cap'). So we can just let credit2 pass
    the scheduler-type check and the same code will work for both.
    
    Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
    Reviewed-by: Jim Fehlig <jfehlig@suse.com>

Index: libvirt-5.1.0/src/libxl/libxl_driver.c
===================================================================
--- libvirt-5.1.0.orig/src/libxl/libxl_driver.c
+++ libvirt-5.1.0/src/libxl/libxl_driver.c
@@ -74,7 +74,7 @@ VIR_LOG_INIT("libxl.libxl_driver");
 #define HYPERVISOR_CAPABILITIES "/proc/xen/capabilities"
 #define HYPERVISOR_XENSTORED "/dev/xen/xenstored"
 
-/* Number of Xen scheduler parameters */
+/* Number of Xen scheduler parameters. credit and credit2 both support 2 */
 #define XEN_SCHED_CREDIT_NPARAM   2
 
 #define LIBXL_CHECK_DOM0_GOTO(name, label) \
@@ -4559,6 +4559,8 @@ libxlDomainGetSchedulerType(virDomainPtr
         break;
     case LIBXL_SCHEDULER_CREDIT2:
         name = "credit2";
+        if (nparams)
+            *nparams = XEN_SCHED_CREDIT_NPARAM;
         break;
     case LIBXL_SCHEDULER_ARINC653:
         name = "arinc653";
@@ -4605,11 +4607,11 @@ libxlDomainGetSchedulerParametersFlags(v
     if (virDomainObjCheckActive(vm) < 0)
         goto cleanup;
 
+    /* Only credit and credit2 are supported for now. */
     sched_id = libxl_get_scheduler(cfg->ctx);
-
-    if (sched_id != LIBXL_SCHEDULER_CREDIT) {
+    if (sched_id != LIBXL_SCHEDULER_CREDIT && sched_id != LIBXL_SCHEDULER_CREDIT2) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Only 'credit' scheduler is supported"));
+                       _("Only 'credit' and 'credit2' schedulers are supported"));
         goto cleanup;
     }
 
@@ -4682,11 +4684,11 @@ libxlDomainSetSchedulerParametersFlags(v
     if (virDomainObjCheckActive(vm) < 0)
         goto endjob;
 
+    /* Only credit and credit2 are supported for now. */
     sched_id = libxl_get_scheduler(cfg->ctx);
-
-    if (sched_id != LIBXL_SCHEDULER_CREDIT) {
+    if (sched_id != LIBXL_SCHEDULER_CREDIT && sched_id != LIBXL_SCHEDULER_CREDIT2) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Only 'credit' scheduler is supported"));
+                       _("Only 'credit' and 'credit2' schedulers are supported"));
         goto endjob;
     }
openSUSE Build Service is sponsored by