
Hi, I've a number of servers running XEN and am trying to write some code to monitor them through libvirt. (Xeon/Dual Core/Ubuntu Gutsy/Xen 3.1) All was going well until I got to virDomainBlockStats and it simply refused to accept my coding .. My solution (the code now works) is to change the following; src/stats_linux.c: #ifndef XENVBD_MAJOR #define XENVBD_MAJOR 3 // <--- I changed this! /*#define XENVBD_MAJOR 202*/ #endif device = XENVBD_MAJOR * 256 + 1 + minor /* * 16 */; <-- this too! It now seems to give me some meaningful numbers without feeding my any error messages. Can anyone tell me "why" I needed to do this? I'm using "xvda" as the device path .. tried every other device name I could think of with out any good results ... ????? tia Gareth.

Gareth Bult wrote:
Hi,
I've a number of servers running XEN and am trying to write some code to monitor them through libvirt. (Xeon/Dual Core/Ubuntu Gutsy/Xen 3.1)
All was going well until I got to virDomainBlockStats and it simply refused to accept my coding ..
My solution (the code now works) is to change the following;
src/stats_linux.c:
#ifndef XENVBD_MAJOR #define XENVBD_MAJOR 3 // <--- I changed this! /*#define XENVBD_MAJOR 202*/ #endif
device = XENVBD_MAJOR * 256 + 1 + minor /* * 16 */; <-- this too!
It now seems to give me some meaningful numbers without feeding my any error messages. Can anyone tell me "why" I needed to do this?
I'm using "xvda" as the device path .. tried every other device name I could think of with out any good results ...
Gareth, What does it print when you do: ls -l /dev/xvda* from within the guest? Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ 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. 03798903

root@bronze-1:~# ls -l /dev/xvda* ls: /dev/xvda*: No such file or directory
(!) ----- Original Message ----- step 3.: "Richard W.M. Jones" <rjones@redhat.com> To: "Gareth Bult" <gareth@encryptec.net> Cc: libvir-list@redhat.com Sent: 17 January 2008 17:39:25 o'clock (GMT) Europe/London Subject: Re: [Libvir] Re; virDomainBlockStats Gareth Bult wrote:
Hi,
I've a number of servers running XEN and am trying to write some code to monitor them through libvirt. (Xeon/Dual Core/Ubuntu Gutsy/Xen 3.1)
All was going well until I got to virDomainBlockStats and it simply refused to accept my coding ..
My solution (the code now works) is to change the following;
src/stats_linux.c:
#ifndef XENVBD_MAJOR #define XENVBD_MAJOR 3 // <--- I changed this! /*#define XENVBD_MAJOR 202*/ #endif
device = XENVBD_MAJOR * 256 + 1 + minor /* * 16 */; <-- this too!
It now seems to give me some meaningful numbers without feeding my any error messages. Can anyone tell me "why" I needed to do this?
I'm using "xvda" as the device path .. tried every other device name I could think of with out any good results ...
Gareth, What does it print when you do: ls -l /dev/xvda* from within the guest? Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ 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. 03798903

On Thu, Jan 17, 2008 at 04:44:31PM +0000, Gareth Bult wrote:
Hi,
I've a number of servers running XEN and am trying to write some code to monitor them through libvirt. (Xeon/Dual Core/Ubuntu Gutsy/Xen 3.1)
All was going well until I got to virDomainBlockStats and it simply refused to accept my coding ..
My solution (the code now works) is to change the following;
src/stats_linux.c:
#ifndef XENVBD_MAJOR #define XENVBD_MAJOR 3 // <--- I changed this! /*#define XENVBD_MAJOR 202*/ #endif
device = XENVBD_MAJOR * 256 + 1 + minor /* * 16 */; <-- this too!
It now seems to give me some meaningful numbers without feeding my any error messages. Can anyone tell me "why" I needed to do this?
Can you capture the output of 'xenstore-ls'. The major/minor number is used to calculate the node in xenstore where we lookup the stats. The formula we have here has to match the same code in XenD and AFAIK, we do match, unless Ubuntu has patched/changed XenD code. 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 -=|

On Thu, Jan 17, 2008 at 04:44:31PM +0000, Gareth Bult wrote:
Hi,
I've a number of servers running XEN and am trying to write some code to monitor them through libvirt. (Xeon/Dual Core/Ubuntu Gutsy/Xen 3.1)
All was going well until I got to virDomainBlockStats and it simply refused to accept my coding ..
My solution (the code now works) is to change the following;
src/stats_linux.c:
#ifndef XENVBD_MAJOR #define XENVBD_MAJOR 3 // <--- I changed this! /*#define XENVBD_MAJOR 202*/ #endif
device = XENVBD_MAJOR * 256 + 1 + minor /* * 16 */; <-- this too!
It now seems to give me some meaningful numbers without feeding my any error messages. Can anyone tell me "why" I needed to do this?
I'm using "xvda" as the device path .. tried every other device name I could think of with out any good results ...
Actually looking at the xenstore-ls output that you sent me (offlist), you are not using xvda - you're using hda1 9 = "" 769 = "" domain = "mgm" frontend = "/local/domain/9/device/vbd/769" uuid = "d6d17ae3-c08c-8a5b-fbc6-3258ea5e06bf" dev = "hda1" state = "4" params = "/cluster/images/domains/mgm/disk.img" mode = "w" online = "1" frontend-id = "9" type = "file" node = "/dev/loop13" physical-device = "7:d" hotplug-status = "connected" feature-barrier = "1" sectors = "4194304" info = "0" sector-size = "512" That is a minor detail though. The file: vs tap:aio: is actually a red herring. Having examined the code for calculating device numbers I see that it is flawed in multiple ways - It doesn't add in the partition number to device number. So 'hdc1' gets calculated as 'hdc' which fails - It uses completely wrong formula for IDE disks. It is not simply HD_MAJOR * 256 + minor * 16. There are in fact 10 IDE major numbers each holding 2 disks, with 63 partitions. - It doesn't handle SCSI disks at all. - It doesn't strip the leading /dev/ if given a fully qualified dev Basically only xvda -> xvdp with no partitions, and hda with no partitions was working. This is why it failed for you with 'hda1' and most other example disks. 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 -=|

Indeed! Any chance of someone re-working it? ;-) Gareth. ----- Original Message ----- step 3.: "Daniel P. Berrange" <berrange@redhat.com> To: "Gareth Bult" <gareth@encryptec.net> Cc: libvir-list@redhat.com Sent: 27 January 2008 20:21:06 o'clock (GMT) Europe/London Subject: Re: [Libvir] Re; virDomainBlockStats On Thu, Jan 17, 2008 at 04:44:31PM +0000, Gareth Bult wrote:
Hi,
I've a number of servers running XEN and am trying to write some code to monitor them through libvirt. (Xeon/Dual Core/Ubuntu Gutsy/Xen 3.1)
All was going well until I got to virDomainBlockStats and it simply refused to accept my coding ..
My solution (the code now works) is to change the following;
src/stats_linux.c:
#ifndef XENVBD_MAJOR #define XENVBD_MAJOR 3 // <--- I changed this! /*#define XENVBD_MAJOR 202*/ #endif
device = XENVBD_MAJOR * 256 + 1 + minor /* * 16 */; <-- this too!
It now seems to give me some meaningful numbers without feeding my any error messages. Can anyone tell me "why" I needed to do this?
I'm using "xvda" as the device path .. tried every other device name I could think of with out any good results ...
Actually looking at the xenstore-ls output that you sent me (offlist), you are not using xvda - you're using hda1 9 = "" 769 = "" domain = "mgm" frontend = "/local/domain/9/device/vbd/769" uuid = "d6d17ae3-c08c-8a5b-fbc6-3258ea5e06bf" dev = "hda1" state = "4" params = "/cluster/images/domains/mgm/disk.img" mode = "w" online = "1" frontend-id = "9" type = "file" node = "/dev/loop13" physical-device = "7:d" hotplug-status = "connected" feature-barrier = "1" sectors = "4194304" info = "0" sector-size = "512" That is a minor detail though. The file: vs tap:aio: is actually a red herring. Having examined the code for calculating device numbers I see that it is flawed in multiple ways - It doesn't add in the partition number to device number. So 'hdc1' gets calculated as 'hdc' which fails - It uses completely wrong formula for IDE disks. It is not simply HD_MAJOR * 256 + minor * 16. There are in fact 10 IDE major numbers each holding 2 disks, with 63 partitions. - It doesn't handle SCSI disks at all. - It doesn't strip the leading /dev/ if given a fully qualified dev Basically only xvda -> xvdp with no partitions, and hda with no partitions was working. This is why it failed for you with 'hda1' and most other example disks. 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 -=|

On Sun, Jan 27, 2008 at 08:23:48PM +0000, Gareth Bult wrote:
Indeed!
Any chance of someone re-working it?
See my patch on the list... 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 -=|
participants (3)
-
Daniel P. Berrange
-
Gareth Bult
-
Richard W.M. Jones