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>
This commit is contained in:
Dario Faggioli 2020-01-29 12:05:15 +01:00 committed by Jim Fehlig
parent f0f34056ab
commit 849052ec61

View File

@ -73,7 +73,7 @@ VIR_LOG_INIT("libxl.libxl_driver");
#define HYPERVISOR_CAPABILITIES "/proc/xen/capabilities" #define HYPERVISOR_CAPABILITIES "/proc/xen/capabilities"
#define HYPERVISOR_XENSTORED "/dev/xen/xenstored" #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 XEN_SCHED_CREDIT_NPARAM 2
#define LIBXL_CHECK_DOM0_GOTO(name, label) \ #define LIBXL_CHECK_DOM0_GOTO(name, label) \
@ -4586,6 +4586,8 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *nparams)
break; break;
case LIBXL_SCHEDULER_CREDIT2: case LIBXL_SCHEDULER_CREDIT2:
name = "credit2"; name = "credit2";
if (nparams)
*nparams = XEN_SCHED_CREDIT_NPARAM;
break; break;
case LIBXL_SCHEDULER_ARINC653: case LIBXL_SCHEDULER_ARINC653:
name = "arinc653"; name = "arinc653";
@ -4632,11 +4634,11 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
if (virDomainObjCheckActive(vm) < 0) if (virDomainObjCheckActive(vm) < 0)
goto cleanup; goto cleanup;
/* Only credit and credit2 are supported for now. */
sched_id = libxl_get_scheduler(cfg->ctx); sched_id = libxl_get_scheduler(cfg->ctx);
if (sched_id != LIBXL_SCHEDULER_CREDIT && sched_id != LIBXL_SCHEDULER_CREDIT2) {
if (sched_id != LIBXL_SCHEDULER_CREDIT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only 'credit' scheduler is supported")); _("Only 'credit' and 'credit2' schedulers are supported"));
goto cleanup; goto cleanup;
} }
@ -4709,11 +4711,11 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (virDomainObjCheckActive(vm) < 0) if (virDomainObjCheckActive(vm) < 0)
goto endjob; goto endjob;
/* Only credit and credit2 are supported for now. */
sched_id = libxl_get_scheduler(cfg->ctx); sched_id = libxl_get_scheduler(cfg->ctx);
if (sched_id != LIBXL_SCHEDULER_CREDIT && sched_id != LIBXL_SCHEDULER_CREDIT2) {
if (sched_id != LIBXL_SCHEDULER_CREDIT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only 'credit' scheduler is supported")); _("Only 'credit' and 'credit2' schedulers are supported"));
goto endjob; goto endjob;
} }