diff -urpN libvirt.0329/include/libvirt/libvirt.h libvirt.sched2/include/libvirt/libvirt.h --- libvirt.0329/include/libvirt/libvirt.h 2007-03-17 07:26:55.000000000 +0900 +++ libvirt.sched2/include/libvirt/libvirt.h 2007-03-29 19:48:13.000000000 +0900 @@ -547,6 +547,31 @@ int virNetworkGetAutostart (virNetwork int virNetworkSetAutostart (virNetworkPtr network, int autostart); +/** + * * virSchedInfoPtr: + * * + * * a virSchedInfo is a structure filled by virSchedGetInfo() + * */ + +typedef struct _virSchedInfo virSchedInfo; +typedef virSchedInfo *virSchedInfoPtr; + +struct _virSchedInfo { + unsigned int sched_id; /* the scheduler ID */ + unsigned int weight; /* the weight */ + unsigned int cap; /* the cap (CREDIT only) */ + unsigned long period; /* the period (SEDF only) */ + unsigned long slice; /* the slice (SEDF only) */ + unsigned long latency; /* the latency (SEDF only) */ + unsigned long extratime; /* the extratime (SEDF only) */ +}; + +/* + * * Scheduler informations + * */ +int virGetSchedInfo (virDomainPtr domain, + virSchedInfoPtr schedinfo); + #ifdef __cplusplus } #endif diff -urpN libvirt.0329/include/libvirt/libvirt.h.in libvirt.sched2/include/libvirt/libvirt.h.in --- libvirt.0329/include/libvirt/libvirt.h.in 2007-03-16 02:24:57.000000000 +0900 +++ libvirt.sched2/include/libvirt/libvirt.h.in 2007-03-29 19:48:13.000000000 +0900 @@ -547,6 +547,31 @@ int virNetworkGetAutostart (virNetwork int virNetworkSetAutostart (virNetworkPtr network, int autostart); +/** + * * virSchedInfoPtr: + * * + * * a virSchedInfo is a structure filled by virSchedGetInfo() + * */ + +typedef struct _virSchedInfo virSchedInfo; +typedef virSchedInfo *virSchedInfoPtr; + +struct _virSchedInfo { + unsigned int sched_id; /* the scheduler ID */ + unsigned int weight; /* the weight */ + unsigned int cap; /* the cap (CREDIT only) */ + unsigned long period; /* the period (SEDF only) */ + unsigned long slice; /* the slice (SEDF only) */ + unsigned long latency; /* the latency (SEDF only) */ + unsigned long extratime; /* the extratime (SEDF only) */ +}; + +/* + * * Scheduler informations + * */ +int virGetSchedInfo (virDomainPtr domain, + virSchedInfoPtr schedinfo); + #ifdef __cplusplus } #endif diff -urpN libvirt.0329/src/driver.h libvirt.sched2/src/driver.h --- libvirt.0329/src/driver.h 2007-03-16 02:24:57.000000000 +0900 +++ libvirt.sched2/src/driver.h 2007-03-29 19:48:04.000000000 +0900 @@ -146,6 +146,12 @@ typedef int typedef int (*virDrvDomainSetAutostart) (virDomainPtr domain, int autostart); +typedef int + (*virDrvDomainGetSchedInfo) (virDomainPtr domain, + int *autostart); +typedef int + (*virDrvDomainSetSchedInfo) (virDomainPtr domain, + int autostart); typedef struct _virDriver virDriver; typedef virDriver *virDriverPtr; @@ -200,6 +206,8 @@ struct _virDriver { virDrvDomainDetachDevice domainDetachDevice; virDrvDomainGetAutostart domainGetAutostart; virDrvDomainSetAutostart domainSetAutostart; + virDrvDomainGetSchedInfo domainGetSchedInfo; + virDrvDomainSetSchedInfo domainSetSchedInfo; }; typedef int diff -urpN libvirt.0329/src/libvirt.c libvirt.sched2/src/libvirt.c --- libvirt.0329/src/libvirt.c 2007-03-23 03:30:57.000000000 +0900 +++ libvirt.sched2/src/libvirt.c 2007-03-29 19:51:17.000000000 +0900 @@ -3005,6 +3005,46 @@ virNetworkSetAutostart(virNetworkPtr net return (-1); } +/** + * virSchedGetInfo + * @domain: domain information + * @schedinfo: scheduler parameter + * + * Get scheduler parameter + * + * Returns -1 in case of error, 0 in case of success + */ +int +virGetSchedInfo(virDomainPtr domain, virSchedInfoPtr schedinfo){ + int ret; + int i; + virConnectPtr conn; + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(domain, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + return (-1); + } + if (domain->conn->flags & VIR_CONNECT_RO) { + virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + return (-1); + } + conn = domain->conn; + + /* + * Go though the driver registered entry points + */ + for (i = 0;i < conn->nb_drivers;i++) { + if ((conn->drivers[i] != NULL) && + (conn->drivers[i]->domainGetSchedInfo != NULL)) { + ret = conn->drivers[i]->domainGetSchedInfo(domain, schedinfo); + if (ret >= 0) + return(ret); + } + } + virLibConnError(conn, VIR_ERR_CALL_FAILED, __FUNCTION__); + return (-1); + +} /* * vim: set tabstop=4: * vim: set shiftwidth=4: diff -urpN libvirt.0329/src/libvirt_sym.version libvirt.sched2/src/libvirt_sym.version --- libvirt.0329/src/libvirt_sym.version 2007-03-16 02:24:57.000000000 +0900 +++ libvirt.sched2/src/libvirt_sym.version 2007-03-29 19:48:13.000000000 +0900 @@ -84,6 +84,8 @@ virNetworkGetAutostart; virNetworkSetAutostart; + virGetSchedInfo; + __virConfNew; __virConfReadFile; __virConfReadMem; diff -urpN libvirt.0329/src/proxy_internal.c libvirt.sched2/src/proxy_internal.c --- libvirt.0329/src/proxy_internal.c 2007-03-16 02:24:57.000000000 +0900 +++ libvirt.sched2/src/proxy_internal.c 2007-03-29 19:48:13.000000000 +0900 @@ -86,6 +86,8 @@ static virDriver xenProxyDriver = { NULL, /* domainDetachDevice */ NULL, /* domainGetAutostart */ NULL, /* domainSetAutostart */ + NULL, /* domainGetSchedInfo */ + NULL, /* domainSetSchedInfo */ }; /** diff -urpN libvirt.0329/src/qemu_internal.c libvirt.sched2/src/qemu_internal.c --- libvirt.0329/src/qemu_internal.c 2007-03-16 03:23:00.000000000 +0900 +++ libvirt.sched2/src/qemu_internal.c 2007-03-29 19:48:13.000000000 +0900 @@ -1233,6 +1233,8 @@ static virDriver qemuDriver = { NULL, /* domainDetachDevice */ qemuDomainGetAutostart, /* domainGetAutostart */ qemuDomainSetAutostart, /* domainSetAutostart */ + NULL, /* domainGetSchedInfo */ + NULL, /* domainSetSchedInfo */ }; static virNetworkDriver qemuNetworkDriver = { diff -urpN libvirt.0329/src/virsh.c libvirt.sched2/src/virsh.c --- libvirt.0329/src/virsh.c 2007-03-24 01:15:07.000000000 +0900 +++ libvirt.sched2/src/virsh.c 2007-03-29 19:48:13.000000000 +0900 @@ -1147,10 +1147,13 @@ cmdDominfo(vshControl * ctl, vshCmd * cm { virDomainInfo info; virDomainPtr dom; + virSchedInfoPtr schedinfo; int ret = TRUE; unsigned int id; char *str, uuid[VIR_UUID_STRING_BUFLEN]; + schedinfo = malloc(sizeof(virSchedInfo)); + if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) return FALSE; @@ -1200,6 +1203,17 @@ cmdDominfo(vshControl * ctl, vshCmd * cm ret = FALSE; } + /* Scheduler Information */ + ret = virGetSchedInfo(dom, schedinfo); + if (!ret) { + vshPrint(ctl, "%-15s %u \n", _("SchedulerID:"), schedinfo->sched_id); + vshPrint(ctl, "%-15s %u \n", _("Weight:"), schedinfo->weight); + vshPrint(ctl, "%-15s %u \n", _("Cap:"), schedinfo->cap ); + + } else { + ret = FALSE; + } + virDomainFree(dom); return ret; } diff -urpN libvirt.0329/src/xen_internal.c libvirt.sched2/src/xen_internal.c --- libvirt.0329/src/xen_internal.c 2007-03-28 17:48:53.000000000 +0900 +++ libvirt.sched2/src/xen_internal.c 2007-03-29 19:48:13.000000000 +0900 @@ -377,6 +377,38 @@ typedef struct xen_v2_vcpuinfo xen_v2_vc typedef struct xen_v2_setvcpumap xen_v2_getvcpumap; /* + * from V2 the scheduler operation + */ +#define XEN_V2_OP_SCHEDULER 16 +/* Scheduler types. */ +#define XEN_SCHEDULER_SEDF 4 +#define XEN_SCHEDULER_CREDIT 5 +/* Set or get info? */ +#define XEN_DOMCTL_SCHEDOP_putinfo 0 +#define XEN_DOMCTL_SCHEDOP_getinfo 1 +#define uint64_aligned_t uint64_t + +struct xen_v2_setschedinfo { + uint32_t sched_id; /* XEN_SCHEDULER_* */ + uint32_t cmd; /* XEN_DOMCTL_SCHEDOP_* */ + union { + struct xen_domctl_sched_sedf { + uint64_aligned_t period; + uint64_aligned_t slice; + uint64_aligned_t latency; + uint32_t extratime; + uint32_t weight; + } sedf; + struct xen_domctl_sched_credit { + uint16_t weight; + uint16_t cap; + } credit; + } u; +}; +typedef struct xen_v2_setschedinfo xen_v2_setschedinfo; +typedef struct xen_v2_setschedinfo xen_v2_getschedinfo; + +/* * The hypercall operation structures also have changed on * changeset 86d26e6ec89b */ @@ -419,6 +451,8 @@ struct xen_op_v2_dom { xen_v2_setvcpumap setvcpumap; xen_v2_vcpuinfo getvcpuinfo; xen_v2_getvcpumap getvcpumap; + xen_v2_setschedinfo setschedinfo; + xen_v2_getschedinfo getschedinfo; uint8_t padding[128]; } u; }; @@ -482,6 +516,8 @@ static virDriver xenHypervisorDriver = { NULL, /* domainDetachDevice */ NULL, /* domainGetAutostart */ NULL, /* domainSetAutostart */ + xenHypervisorGetSchedInfo, /* domainGetSchedInfo */ + NULL, /* domainSetSchedInfo */ }; #endif /* !PROXY */ @@ -1171,6 +1207,41 @@ virXen_getvcpusinfo(int handle, int id, } /** + * virXen_getschedinfo: + * @handle: the hypervisor handle + * @id: the domain id + * @vcpu: the vcpu to map + * @cpumap: the bitmap for this vcpu + * @maplen: the size of the bitmap in bytes + * + * Do a low level hypercall to get scheduler information + * + * Returns 0 or -1 in case of failure + */ +static int +virXen_getschedinfo(int handle, int id, virSchedInfoPtr schedinfo) +{ + int ret = -1; + + if (hypervisor_version > 1) { + xen_op_v2_dom op; + + memset(&op, 0, sizeof(op)); + op.cmd = XEN_V2_OP_SCHEDULER; + op.domain = (domid_t) id; + op.u.getschedinfo.sched_id = XEN_SCHEDULER_CREDIT; + op.u.getschedinfo.cmd = XEN_DOMCTL_SCHEDOP_getinfo; + ret = xenHypervisorDoV2Dom(handle, &op); + printf("scheduler info %d %d %d\n",op.u.getschedinfo.sched_id, op.u.getschedinfo.u.credit.weight, op.u.getschedinfo.u.credit.cap); + schedinfo->sched_id = op.u.getschedinfo.sched_id; + schedinfo->weight = op.u.getschedinfo.u.credit.weight; + schedinfo->cap = op.u.getschedinfo.u.credit.cap; + } + + return(ret); +} + +/** * xenHypervisorInit: * * Initialize the hypervisor layer. Try to detect the kind of interface @@ -2005,10 +2076,28 @@ xenHypervisorGetDomInfo(virConnectPtr co if(info->maxMem != UINT_MAX) info->maxMem *= kb_per_pages; info->nrVirtCpu = XEN_GETDOMAININFO_CPUCOUNT(dominfo); + return (0); } /** + * xenHypervisorGetSchedInfo: + * @conn: pointer to the connection block + * + * Provides the number of active domains. + * + * Returns the number of domain found or -1 in case of error + */ +int +xenHypervisorGetSchedInfo(virDomainPtr domain, virSchedInfoPtr schedinfo){ + /* + * Get CPU scheduler parameter. + */ + virXen_getschedinfo(domain->conn->handle, domain->id, schedinfo); + return(0); +} + +/** * xenHypervisorGetDomainInfo: * @domain: pointer to the domain block * @info: the place where information should be stored diff -urpN libvirt.0329/src/xen_internal.h libvirt.sched2/src/xen_internal.h --- libvirt.0329/src/xen_internal.h 2007-03-27 23:45:17.000000000 +0900 +++ libvirt.sched2/src/xen_internal.h 2007-03-29 19:48:13.000000000 +0900 @@ -45,6 +45,8 @@ int xenHypervisorGetDomainInfo (virDomai int xenHypervisorGetDomInfo (virConnectPtr conn, int id, virDomainInfoPtr info); +int xenHypervisorGetSchedInfo (virDomainPtr domain, + virSchedInfoPtr schedinfo); int xenHypervisorSetMaxMemory (virDomainPtr domain, unsigned long memory); int xenHypervisorCheckID (virConnectPtr conn, diff -urpN libvirt.0329/src/xend_internal.c libvirt.sched2/src/xend_internal.c --- libvirt.0329/src/xend_internal.c 2007-03-24 01:15:07.000000000 +0900 +++ libvirt.sched2/src/xend_internal.c 2007-03-29 19:48:13.000000000 +0900 @@ -106,6 +106,8 @@ static virDriver xenDaemonDriver = { xenDaemonDetachDevice, /* domainDetachDevice */ NULL, /* domainGetAutostart */ NULL, /* domainSetAutostart */ + NULL, /* domainGetSchedInfo */ + NULL, /* domainSetSchedInfo */ }; /** diff -urpN libvirt.0329/src/xm_internal.c libvirt.sched2/src/xm_internal.c --- libvirt.0329/src/xm_internal.c 2007-03-23 03:30:58.000000000 +0900 +++ libvirt.sched2/src/xm_internal.c 2007-03-29 19:48:13.000000000 +0900 @@ -112,6 +112,8 @@ static virDriver xenXMDriver = { NULL, /* domainDetachDevice */ NULL, /* domainGetAutostart */ NULL, /* domainSetAutostart */ + NULL, /* domainGetSchedInfo */ + NULL, /* domainSetSchedInfo */ }; static void diff -urpN libvirt.0329/src/xs_internal.c libvirt.sched2/src/xs_internal.c --- libvirt.0329/src/xs_internal.c 2007-03-24 01:15:07.000000000 +0900 +++ libvirt.sched2/src/xs_internal.c 2007-03-29 19:48:13.000000000 +0900 @@ -81,6 +81,8 @@ static virDriver xenStoreDriver = { NULL, /* domainDetachDevice */ NULL, /* domainGetAutostart */ NULL, /* domainSetAutostart */ + NULL, /* domainGetSchedInfo */ + NULL, /* domainSetSchedInfo */ }; /**