[Libvir] [PATCH][RFC] shows scheduler information

Hi, This patch intends add a showing function of scheduler information. If apply this patch to current revision 1.490 and type virsh dominfo 0 then shows following scheduler information. Currently I assume credit scheduler only. getting function is implemented but setting function is not yet. I just waiting for comments. Id: 0 Name: Domain-0 UUID: 00000000-0000-0000-0000-000000000000 OS Type: linux State: running CPU(s): 1 CPU time: 432.7s Max memory: no limit Used memory: 1933312 kB scheduler info 5 256 0 SchedulerID: 5 Weight: 256 Cap: 0 Thanks Atsushi SAKAI

Atsushi SAKAI wrote:
Hi,
This patch intends add a showing function of scheduler information. If apply this patch to current revision 1.490 and type virsh dominfo 0 then shows following scheduler information. Currently I assume credit scheduler only. getting function is implemented but setting function is not yet. I just waiting for comments.
Is this part of the patch correct? 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; My more general comment would be how Xen-specific is this? What scheduler could be used by other drivers? (Obviously qemu just uses the Linux scheduler. However I don't know what kvm uses - whether it also schedules using the Linux scheduler, or some other method). Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in UK and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

Hi, Rich Thank you for your comments. (The primary motivation is take a comments!) I am wondering the libvirt policy about scheduer. And I just know the Xen scheduler only. Is any good idea to support this? Thanks Atsushi SAKAI "Richard W.M. Jones" <rjones@redhat.com> wrote:
Atsushi SAKAI wrote:
Hi,
This patch intends add a showing function of scheduler information. If apply this patch to current revision 1.490 and type virsh dominfo 0 then shows following scheduler information. Currently I assume credit scheduler only. getting function is implemented but setting function is not yet. I just waiting for comments.
Is this part of the patch correct?
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;
My more general comment would be how Xen-specific is this? What scheduler could be used by other drivers? (Obviously qemu just uses the Linux scheduler. However I don't know what kvm uses - whether it also schedules using the Linux scheduler, or some other method).
Rich.
-- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in UK and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

On Thu, Mar 29, 2007 at 09:16:05PM +0900, Atsushi SAKAI wrote:
Hi, Rich
Thank you for your comments. (The primary motivation is take a comments!)
I am wondering the libvirt policy about scheduer. And I just know the Xen scheduler only. Is any good idea to support this?
So far I'm really wondering. Basically you have virtualization specific scheduling only if the virtualization mechanism has its own scheduler and that's only the case for Xen at the moment unless I'm mistaken. All others reuse the scheduler of the primary Os directly, and unless you start playing with that scheduler there is nothing really to tune, but those changes affects far more than just purely the virtualization side. How would you map the API you propose with say the linux normal scheduler APIs ? I'm a bit worried if the proposed operations are really only making sense in a setup with the Xen hypervisor. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Hi, Daniel and Rich Thanks for various comments. Qemu and Qemu with KVM uses default Linux scheduler. (struct sched_param) And Xen uses original scheduler. At this moment, we should support xen (sedf, credit) and Linux scheduler(sched_param). Is this enough? Or We should consider other parameters from Linux scheduler API? (Realtime etc...) Anyway this should be Linux scheduler related issue. So we should define Linux scheduler related struct for qemu related issue. Thanks Atsushi SAKAI Daniel Veillard <veillard@redhat.com> wrote:
On Thu, Mar 29, 2007 at 09:16:05PM +0900, Atsushi SAKAI wrote:
Hi, Rich
Thank you for your comments. (The primary motivation is take a comments!)
I am wondering the libvirt policy about scheduer. And I just know the Xen scheduler only. Is any good idea to support this?
So far I'm really wondering. Basically you have virtualization specific scheduling only if the virtualization mechanism has its own scheduler and that's only the case for Xen at the moment unless I'm mistaken. All others reuse the scheduler of the primary Os directly, and unless you start playing with that scheduler there is nothing really to tune, but those changes affects far more than just purely the virtualization side. How would you map the API you propose with say the linux normal scheduler APIs ? I'm a bit worried if the proposed operations are really only making sense in a setup with the Xen hypervisor.
Daniel
-- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Mon, Apr 02, 2007 at 04:10:53PM +0900, Atsushi SAKAI wrote:
Hi, Daniel and Rich
Thanks for various comments.
Qemu and Qemu with KVM uses default Linux scheduler. (struct sched_param) And Xen uses original scheduler.
At this moment, we should support xen (sedf, credit) and Linux scheduler(sched_param). Is this enough?
Or We should consider other parameters from Linux scheduler API? (Realtime etc...) Anyway this should be Linux scheduler related issue. So we should define Linux scheduler related struct for qemu related issue.
I don't think using structs with explicit members for each schedular parameter is viable over the long term. We have already seen Xen go through 3 different schedulars over the course of 1+1/2 years, each one requiring different parameters. I wouldn't be at all surprised it more changes appear in the next 1+1/2 years because the Xen schedular is really very young/immature at this time. I think it is unavoidable that every impl is going to express the schedular parameters in a completely different way. Thus if we're going to have an API for fetching/updating schedular parameters then I think we need to have a weakly typed system which is extensible to an new arbitrary fields without requiring any API changes. Applications themselves will obviously have to be updated to understand any new schedular types that come along, but as I said before I think this is unavoidable unless we crippled the API to make it look generic. enum { VIR_DOMAIN_SCHED_FIELD_INT, VIR_DOMAIN_SCHED_FIELD_LONG, VIR_DOMAIN_SCHED_FIELD_DOUBLE, VIR_DOMAIN_SCHED_FIELD_BOOLEAN, }; struct virDomainSchedParameter { char field[VIR_DOMAIN SCHED_FIELD_LENGTH] int type; union { int i; long long int l; double d; char b; } value; }; typedef struct virDomainSchedParameter virDomainSchedParameter; And each the API take an array of these eg /* Return schedular type in effect 'sedf', 'credit', 'linux' */ const char *virDomainGetSchedularType(virDomainPtr conn); /* Fetch schedular parameters, caller allocates 'params' field of size 'nparams' */ int virDomainGetSchedularParameters(virDomainPtr dom, virSchedParameter *params, int nparams); /* Change schedular parameters */ int virDomainSetSchedularParameters(virDomainPtr dom, virSchedParameter *params, int nparams); Linux only appears to have 2 schedula parameters at this time - 'priority' and 'type' thje latter being one of FIFO, RR, Other, Batch. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Daniel P. Berrange wrote:
I think it is unavoidable that every impl is going to express the schedular parameters in a completely different way. Thus if we're going to have an API for fetching/updating schedular parameters then I think we need to have a weakly typed system which is extensible to an new arbitrary fields without requiring any API changes.
Eeeek, weak.typing-- If there is a point at which we have to say, 'sorry but libvirt does not cover this very specialised functionality of this particular hypervisor', then this may be it. At the moment there is only really one hypervisor with scheduling: Xen. The Linux scheduler exists and is used by qemu/kvm but also by many other processes in the whole system, so it may be better for libvirt not to fiddle with it. By choosing not to support this in libvirt *at this time*, we aren't preventing people from issuing direct xm commands. We're also not closing off future possibilities. If in the future other hypervisors come along which also have schedulers, then we can look at whether it is possible to abstract something across all of them, and implement it in libvirt. This is, of course, just IMHO. Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

Hi, This patch intends Scheduler related API and its 1/3 of Dan Suggested. It adds scheduler type API for libvirt. Other functions like scheduler parameter show and handle are plan to make. This patch includes "virsh dominfo" can see the scheduler type It can be seen if you type virsh dominfo 0 on Xen(sedf or credit) Other scheduler does not show the scheduler information. Anyway, previous Rich question. src/driver.h has a driver interface and these functions should use typedef. So following function definition is correct. +typedef int + (*virDrvDomainGetSchedInfo) (virDomainPtr domain, Signed-off-by: Atsushi SAKAI <sakaia@jp.fujitsu.com> Thanks Atsushi SAKAI

Atsushi SAKAI wrote:
Hi,
This patch intends Scheduler related API and its 1/3 of Dan Suggested. It adds scheduler type API for libvirt. Other functions like scheduler parameter show and handle are plan to make.
This patch includes "virsh dominfo" can see the scheduler type It can be seen if you type virsh dominfo 0 on Xen(sedf or credit) Other scheduler does not show the scheduler information.
Returning a simple string naming the scheduler seems OK to me. However it would be nice (for the remote case) if the string can be freed up by the caller. That is, it should be allocated using strdup / malloc in libvirt, and the caller should be asked to explicitly free it. In the remote case static strings are a pain. Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

Atsushi SAKAI wrote: [...] Actually there's another point. Can you try out the Xen unified patch + Dan's fixes[1][2] and see if they work for you? I notice that your patch depends on the current libvirt.c "multiple-driver" behaviour. Rich. [1] https://www.redhat.com/archives/libvir-list/2007-March/msg00409.html [2] https://www.redhat.com/archives/libvir-list/2007-April/msg00007.html -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

Hi, Rich Thank you for your comments. I am not checked with your & Dan patch. I just checked with latest revision. I will check scheduler_get_set_parameter patch with above patch before posting. I hope I plan to post within this week. Thanks Atsushi SAKAI "Richard W.M. Jones" <rjones@redhat.com> wrote:
Atsushi SAKAI wrote: [...]
Actually there's another point. Can you try out the Xen unified patch + Dan's fixes[1][2] and see if they work for you? I notice that your patch depends on the current libvirt.c "multiple-driver" behaviour.
Rich.
[1] https://www.redhat.com/archives/libvir-list/2007-March/msg00409.html [2] https://www.redhat.com/archives/libvir-list/2007-April/msg00007.html
-- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

Hi, This patch intends to see and handle scheduler parameters. This is based on ML discussion. This patch just support Xen/Credit for Type/Parameters Xen/SEDF for Type only. And other scheduler is not supported but it will be easy to add it. ===How to use (at commandline)=== virsh schedinfo 0 (to see Type/Parameters) virsh schedinfo 0 --weight 512 (to set weight and to show changed Type/Parameters) virsh schedinfo 0 --cap 50 (to set cap and to show changed Type/Parameters) ===Related to API=== I make API based on Dan's mail. But I have added a little bit changes. 1)virSchedParameter Add Unsigned Int and Unsigned Long Long 2)virDomainGetSchedulerType Add variable to return the number of parameters. This purposes allocate virSchedParameter memory on virsh not in libvirt. ===Others=== 0)xen_unified.c tabspace seems 2, it should be fixed. If needed, I will post it as another patch. Thanks Atsushi SAKAI

On Fri, Apr 06, 2007 at 06:20:08PM +0900, Atsushi SAKAI wrote:
Hi,
This patch intends to see and handle scheduler parameters. This is based on ML discussion. This patch just support Xen/Credit for Type/Parameters Xen/SEDF for Type only. And other scheduler is not supported but it will be easy to add it.
Okay, this look okay, so I'm tempted to apply it (I will reread it though) I still have a few comments: - the function comments for the entry points should probably be augmented a bit to explain the parameters, this is extremely flexible but a couple of line of explanations would help - the proxy entry points should be augmented, and the proxy sources too to allow the Get operation from a normal user - I don't think the python bindings can be automatically generated, and the conversions of the parameters to Python types should be looked at a bit IMHO.
===How to use (at commandline)=== virsh schedinfo 0 (to see Type/Parameters)
virsh schedinfo 0 --weight 512 (to set weight and to show changed Type/Parameters)
virsh schedinfo 0 --cap 50 (to set cap and to show changed Type/Parameters)
Using 'schedinfo' to set the parameters sounds a bit bizarre, I would expect an info to be an output only.
===Related to API=== I make API based on Dan's mail. But I have added a little bit changes.
1)virSchedParameter Add Unsigned Int and Unsigned Long Long
2)virDomainGetSchedulerType Add variable to return the number of parameters. This purposes allocate virSchedParameter memory on virsh not in libvirt.
Sounds sensible to me.
===Others=== 0)xen_unified.c tabspace seems 2, it should be fixed. If needed, I will post it as another patch.
I use the following command to indent libvirt code: paphio:~/libvirt -> cat ~/bin/cb #!/bin/sh indent -bad -bap -bbb -bli4 -br -ce -brs -cs -i4 -l75 -lc75 -nut -sbi4 -psl -saf -sai -saw -sbi4 -ss -sc -cdw -cli4 -npcs -nbc paphio:~/libvirt -> using GNU indent command. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Hi, Daniel Thank you for various comments. Anyway I have several questions. 0)Is there any documents about libvirt/python/generator.py? It seems make python bindings from XML API description. 1)PROXY-API seems to be not fully supported to various read (for example vcpuinfo). This is just work is going or it is just a policy Anyway, this issue seems to be another work. I hope someone will do it consistently. If nobody do this, I will do it. And one more, Who attend the XenSummit? I plan to go to the XenSummit. Thanks Atsushi SAKAI Daniel Veillard <veillard@redhat.com> wrote:
On Fri, Apr 06, 2007 at 06:20:08PM +0900, Atsushi SAKAI wrote:
Hi,
This patch intends to see and handle scheduler parameters. This is based on ML discussion. This patch just support Xen/Credit for Type/Parameters Xen/SEDF for Type only. And other scheduler is not supported but it will be easy to add it.
Okay, this look okay, so I'm tempted to apply it (I will reread it though) I still have a few comments: - the function comments for the entry points should probably be augmented a bit to explain the parameters, this is extremely flexible but a couple of line of explanations would help - the proxy entry points should be augmented, and the proxy sources too to allow the Get operation from a normal user - I don't think the python bindings can be automatically generated, and the conversions of the parameters to Python types should be looked at a bit IMHO.
===How to use (at commandline)=== virsh schedinfo 0 (to see Type/Parameters)
virsh schedinfo 0 --weight 512 (to set weight and to show changed Type/Parameters)
virsh schedinfo 0 --cap 50 (to set cap and to show changed Type/Parameters)
Using 'schedinfo' to set the parameters sounds a bit bizarre, I would expect an info to be an output only.
===Related to API=== I make API based on Dan's mail. But I have added a little bit changes.
1)virSchedParameter Add Unsigned Int and Unsigned Long Long
2)virDomainGetSchedulerType Add variable to return the number of parameters. This purposes allocate virSchedParameter memory on virsh not in libvirt.
Sounds sensible to me.
===Others=== 0)xen_unified.c tabspace seems 2, it should be fixed. If needed, I will post it as another patch.
I use the following command to indent libvirt code:
paphio:~/libvirt -> cat ~/bin/cb #!/bin/sh indent -bad -bap -bbb -bli4 -br -ce -brs -cs -i4 -l75 -lc75 -nut -sbi4 -psl -saf -sai -saw -sbi4 -ss -sc -cdw -cli4 -npcs -nbc paphio:~/libvirt ->
using GNU indent command.
Daniel
-- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Hi, Daniel I add argument description for libvirt.c/xen_internal.c virDomainGetSchedulerType virDomainGetSchedulerParameters virDomainSetSchedulerParameters xenHypervisorGetSchedulerType xenHypervisorGetSchedulerParameters xenHypervisorSetSchedulerParameters Anyway Where should I describe these functions document ? It seems wrong to write libvirt-api.xml directly. Thanks Atsushi SAKAI

On Mon, Apr 09, 2007 at 04:35:15PM +0900, Atsushi SAKAI wrote:
Hi, Daniel
I add argument description for libvirt.c/xen_internal.c
virDomainGetSchedulerType virDomainGetSchedulerParameters virDomainSetSchedulerParameters
xenHypervisorGetSchedulerType xenHypervisorGetSchedulerParameters xenHypervisorSetSchedulerParameters
Okay, cool, this gets close to something I should commit, I will probably do this today.
Anyway Where should I describe these functions document ? It seems wrong to write libvirt-api.xml directly.
yeah we should use the generator, but it may have a problem, I will look Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Mon, Apr 09, 2007 at 10:57:20AM +0900, Atsushi SAKAI wrote:
Hi, Daniel
Hi Atsushi, sorry I'm just back from a long week-end here ...
Thank you for various comments.
Anyway I have several questions. 0)Is there any documents about libvirt/python/generator.py? It seems make python bindings from XML API description.
Right. I don't really have documentation for it, sorry :-\
1)PROXY-API seems to be not fully supported to various read (for example vcpuinfo). This is just work is going or it is just a policy Anyway, this issue seems to be another work. I hope someone will do it consistently. If nobody do this, I will do it.
I tend to think most read-only operations which don't generate security data leak should be added to the proxy,
And one more, Who attend the XenSummit? I plan to go to the XenSummit.
I won't go, BTW I wasn't invited I let you guess why ;-) I think others are going though (Dan Berrange if I remember correctly) Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Atsushi SAKAI wrote:
0)Is there any documents about libvirt/python/generator.py? It seems make python bindings from XML API description.
No there isn't! I learned about it by reading the code & Makefile. It's not that hard to understand, but the naming of the files is quite illogical so it's hard to remember which files are automatically generated and what each does. Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

Hi, Rich Thank you for your comments. The purpose for asking is, if I get a comment soon. It will shorten my working for this issue. But finally I read through the code. Anyway, the method for building XML document in libvirt is interesting for me. Thanks Atsushi SAKAI "Richard W.M. Jones" <rjones@redhat.com> wrote:
Atsushi SAKAI wrote:
0)Is there any documents about libvirt/python/generator.py? It seems make python bindings from XML API description.
No there isn't!
I learned about it by reading the code & Makefile. It's not that hard to understand, but the naming of the files is quite illogical so it's hard to remember which files are automatically generated and what each does.
Rich.
-- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

Hi, I add comments to libvirt.h and libvirt.h.in. This purposes is apibuild.py can correctly generate libvirt-api.xml&libvirt-refs.xml. But if I use "union", apibuild.py does not work and libvirt-api.xml is not included in union case. Is there any good idea? Thanks Atsushi SAKAI Atsushi SAKAI <sakaia@jp.fujitsu.com> wrote:
Hi,
This patch intends to see and handle scheduler parameters. This is based on ML discussion. This patch just support Xen/Credit for Type/Parameters Xen/SEDF for Type only. And other scheduler is not supported but it will be easy to add it.
===How to use (at commandline)=== virsh schedinfo 0 (to see Type/Parameters)
virsh schedinfo 0 --weight 512 (to set weight and to show changed Type/Parameters)
virsh schedinfo 0 --cap 50 (to set cap and to show changed Type/Parameters)
===Related to API=== I make API based on Dan's mail. But I have added a little bit changes.
1)virSchedParameter Add Unsigned Int and Unsigned Long Long
2)virDomainGetSchedulerType Add variable to return the number of parameters. This purposes allocate virSchedParameter memory on virsh not in libvirt.
===Others=== 0)xen_unified.c tabspace seems 2, it should be fixed. If needed, I will post it as another patch.
Thanks Atsushi SAKAI

On Tue, Apr 10, 2007 at 02:18:56PM +0900, Atsushi SAKAI wrote:
Hi,
I add comments to libvirt.h and libvirt.h.in. This purposes is apibuild.py can correctly generate libvirt-api.xml&libvirt-refs.xml.
Actually apibuild.py extracts the comments from the C files after having scanned the .h files.
But if I use "union", apibuild.py does not work and libvirt-api.xml is not included in union case. Is there any good idea?
I need to fix the generator. I'm always a bit vary of unions in APIs for the reason that different compilers may handle them a bit differently (same thing for enums arguments to functions). I guess in that case it will be hard to do without an union, so I better fix the generator. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Atsushi SAKAI wrote:
0)xen_unified.c tabspace seems 2, it should be fixed. If needed, I will post it as another patch.
That's actually a mistake on my part. I meant to make it 4 spaces. Will fix ... Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

--- libvirt.orig/src/libvirt.c 2007-04-04 23:19:49.000000000 +0900 +++ libvirt.sched/src/libvirt.c 2007-04-06 14:06:08.000000000 +0900 @@ -1423,6 +1423,113 @@ virConnectGetCapabilities (virConnectPtr return NULL; } +/** + * virDomainGetSchedulerType: + * @dom: pointer to the hypervisor connection + * + * Get the scheduler type. + * + * Returns NULL in case of error. + */ +const char * +virDomainGetSchedulerType(virDomainPtr domain, int *nparams) [...] /* + * xenHypervisorGetSchedulerType: + * @domain: pointer to the Xen Hypervisor block + * + * Do a low level hypercall to get scheduler type + * + * Returns scheduler name or NULL in case of failure + */ +const char * +xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams) +{ [...] + switch (op.u.getschedulerid.sched_id){ + case XEN_SCHEDULER_SEDF: + schedulertype = "sedf"; + *nparams = 6; + break; + case XEN_SCHEDULER_CREDIT: + schedulertype = "credit"; + *nparams = 2; + break; Please don't return static strings from functions. It does not work well in the remote case. I don't like the dynamic typing going on in this patch altogether, but with the above statically allocated strings, I think this patch should not go in in its current form. Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

See also: http://www.redhat.com/archives/libvir-list/2007-February/msg00096.html Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

On Wed, Apr 11, 2007 at 02:22:43PM +0100, Richard W.M. Jones wrote:
Please don't return static strings from functions. It does not work well in the remote case.
I don't like the dynamic typing going on in this patch altogether, but with the above statically allocated strings, I think this patch should not go in in its current form.
I'm not enthusiastic about the dynamic typing either, but the const char * return value is relatively easilly fixable, just need to strdup() the value and change the API to char * and document that the return value should be freed. Would you still be against with such a change ? Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Hi, Rich Thank you for your suggestion. I fixed it. Changes 1)changes static to dynamic. (like sedf, credit, weight, cap) 2)virsh printf added various print patterns for scheduler parameters. 3)Tab space changed(from 2 to 4) in xen_unified.c part Thanks Atsushi SAKAI "Richard W.M. Jones" <rjones@redhat.com> wrote:
--- libvirt.orig/src/libvirt.c 2007-04-04 23:19:49.000000000 +0900 +++ libvirt.sched/src/libvirt.c 2007-04-06 14:06:08.000000000 +0900 @@ -1423,6 +1423,113 @@ virConnectGetCapabilities (virConnectPtr return NULL; }
+/** + * virDomainGetSchedulerType: + * @dom: pointer to the hypervisor connection + * + * Get the scheduler type. + * + * Returns NULL in case of error. + */ +const char * +virDomainGetSchedulerType(virDomainPtr domain, int *nparams)
[...]
/* + * xenHypervisorGetSchedulerType: + * @domain: pointer to the Xen Hypervisor block + * + * Do a low level hypercall to get scheduler type + * + * Returns scheduler name or NULL in case of failure + */ +const char * +xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams) +{ [...] + switch (op.u.getschedulerid.sched_id){ + case XEN_SCHEDULER_SEDF: + schedulertype = "sedf"; + *nparams = 6; + break; + case XEN_SCHEDULER_CREDIT: + schedulertype = "credit"; + *nparams = 2; + break;
Please don't return static strings from functions. It does not work well in the remote case.
I don't like the dynamic typing going on in this patch altogether, but with the above statically allocated strings, I think this patch should not go in in its current form.
Rich.
-- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)

On Thu, Apr 12, 2007 at 05:40:23PM +0900, Atsushi SAKAI wrote:
Hi, Rich
Thank you for your suggestion. I fixed it.
Changes 1)changes static to dynamic. (like sedf, credit, weight, cap) 2)virsh printf added various print patterns for scheduler parameters. 3)Tab space changed(from 2 to 4) in xen_unified.c part
Hum, I still see +const char * virDomainGetSchedulerType (virDomainPtr domain, + int *nparams); and in virsh.c I still see + schedulertype = virDomainGetSchedulerType(dom, nparams); and schedulertype is not freed So I guess that doesn't address Richard's point, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (4)
-
Atsushi SAKAI
-
Daniel P. Berrange
-
Daniel Veillard
-
Richard W.M. Jones