On Fri, Dec 18, 2009 at 09:36:11AM -0600, Adam Litke wrote:
On Fri, 2009-12-18 at 10:30 +0000, Daniel P. Berrange wrote:
On Thu, Dec 17, 2009 at 05:41:45PM -0500, Adam Litke wrote:
Use a dynamically sized xdr_array to pass memory stats on the wire. This supports the addition of future memory stats and reduces the message size since only supported statistics are returned.
Signed-off-by: Adam Litke <agl@us.ibm.com> To: libvirt list <libvir-list@redhat.com> Cc: Daniel Veillard <veillard@redhat.com> Cc: Daniel P. Berrange <berrange@redhat.com> --- daemon/remote.c | 56 ++++++++++++++++++++++++++++++++++++++++++ src/remote/remote_driver.c | 44 ++++++++++++++++++++++++++++++++- src/remote/remote_protocol.c | 35 ++++++++++++++++++++++++++ src/remote/remote_protocol.h | 25 ++++++++++++++++++ src/remote/remote_protocol.x | 18 ++++++++++++- 5 files changed, 176 insertions(+), 2 deletions(-)
+struct remote_domain_memory_stats_ret { + u_int len; + struct remote_domain_memory_stat *stats; +}; +typedef struct remote_domain_memory_stats_ret remote_domain_memory_stats_ret;
+ +struct remote_domain_memory_stats_ret { + u_int len; + remote_domain_memory_stat<REMOTE_DOMAIN_MEMORY_STATS_MAX>; +};
Something odd happened in the RPC generated code here, because rpcgen should create you an explicit length field without you needing one. I think it is because I forgot the param name on the array in the example I gave you. Basically it should work just like the existing 'struct remote_domain_get_scheduler_parameters_ret' definition
I explicitly added the len parameter because I need to return the number of elements actually updated back to the remote caller (see remoteDomainMemoryStats). Is there another way to extract this data using xdr without my explicit variable?
struct remote_domain_memory_stats_ret { remote_domain_memory_stat stats<REMOTE_DOMAIN_MEMORY_STATS_MAX>; };
Take a look at the header file generated when you use this style. The 'stats' variable should end up with two fields 'stats_len' and 'stats_val' The end result is ultimately the same as yours, but this is the explicit XDR array syntax Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|