[libvirt] locking down struct size/layout in remote-protocol.x

This week we noticed that a change to struct remote_error was causing trouble (new member addition changed the size of the object being decoded -- bad for the protocol). In order to ensure that no such changes sneak in again, I'm planning to do the following. First, count how many structs must not change size or layout: $ grep -E '^struct remote_' src/*/remote_protocol.x|wc -l 318 Obviously not appropriate to do it manually. Running this (pdwtags is part of the dwarves package): pdwtags src/libvirt_driver_remote_la-remote_protocol.o prints, among other things, detailed type info for every struct: /* 89 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 8 */ remote_uuid uuid; /* 8 16 */ int id; /* 24 4 */ /* size: 32, cachelines: 1, members: 3 */ /* last cacheline: 32 bytes */ /* BRAIN FART ALERT! 32 != 28 + 0(holes), diff = 4 */ }; /* size: 32 */ /* 90 */ typedef struct remote_nonnull_domain remote_nonnull_domain; /* size: 32 */ /* 91 */ struct remote_nonnull_network { remote_nonnull_string name; /* 0 8 */ remote_uuid uuid; /* 8 16 */ /* size: 24, cachelines: 1, members: 2 */ /* last cacheline: 24 bytes */ }; /* size: 24 */ ----------------------------------------------------- A) For each of the above matching /^struct remote_/, print at the very least this sort of compile-time check: verify (sizeof (struct remote_nonnull_domain) == 32); verify (sizeof (struct remote_nonnull_network) == 24); B) Even better, verify member offsets, so that we'd detect reordered members (which often will not change struct size): verify (sizeof (struct remote_nonnull_domain) == 32); verify (offsetof (struct remote_nonnull_domain, name) == 0); verify (offsetof (struct remote_nonnull_domain, uuid) == 8); verify (offsetof (struct remote_nonnull_domain, id) == 24); verify (sizeof (struct remote_nonnull_network) == 24); verify (offsetof (struct remote_nonnull_network, name) == 0); verify (offsetof (struct remote_nonnull_network, uuid) == 16); C) Might as well verify member sizes as well. ----------------------------------------------------- Once we have a small script to generate that (RSN), include the generated, (and version-controlled) file from remote_protocol.c, and we're done. For reference, here's code to generate A): pdwtags src/libvirt_driver_remote_la-remote_protocol.o \ | perl -0777 -n \ -e 'foreach my $p (split m!\n\n/\* \d+ \*/\n!)' \ -e ' { $p =~ m!^struct (remote_\w+).*/\* size: (\d+) \*/!s' \ -e ' and print "verify (sizeof (struct $1) == $2);\n" }' And here's a sample of its output: verify (sizeof (struct remote_nonnull_domain) == 32); verify (sizeof (struct remote_nonnull_network) == 24); verify (sizeof (struct remote_nonnull_nwfilter) == 24); verify (sizeof (struct remote_nonnull_interface) == 16); verify (sizeof (struct remote_nonnull_storage_pool) == 24); verify (sizeof (struct remote_nonnull_storage_vol) == 24); verify (sizeof (struct remote_nonnull_node_device) == 8); ... verify (sizeof (struct remote_domain_has_current_snapshot_args) == 40); verify (sizeof (struct remote_domain_has_current_snapshot_ret) == 4); verify (sizeof (struct remote_domain_snapshot_current_args) == 40); verify (sizeof (struct remote_domain_snapshot_current_ret) == 40); verify (sizeof (struct remote_domain_revert_to_snapshot_args) == 48); verify (sizeof (struct remote_domain_snapshot_delete_args) == 48); verify (sizeof (struct remote_message_header) == 24);

On 05/06/2010 12:35 PM, Jim Meyering wrote:
This week we noticed that a change to struct remote_error was causing trouble (new member addition changed the size of the object being decoded -- bad for the protocol).
In order to ensure that no such changes sneak in again, I'm planning to do the following.
pdwtags src/libvirt_driver_remote_la-remote_protocol.o
prints, among other things, detailed type info for every struct:
/* 89 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 8 */ remote_uuid uuid; /* 8 16 */ int id; /* 24 4 */
/* size: 32, cachelines: 1, members: 3 */ /* last cacheline: 32 bytes */
/* BRAIN FART ALERT! 32 != 28 + 0(holes), diff = 4 */
}; /* size: 32 */
Ouch. Architecture sizing plays a role. On a 32-bit machine, the first struct is: /* 86 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 4 */ remote_uuid uuid; /* 4 16 */ int id; /* 20 4 */ /* size: 24, cachelines: 1, members: 3 */ /* last cacheline: 24 bytes */ }; /* size: 24 */ Are we sure migration between 32-bit and 64-bit hypervisors works? And if it does, then these structs don't quite match what is actually sent over the wire. At any rate,
And here's a sample of its output:
verify (sizeof (struct remote_nonnull_domain) == 32);
we'd have to make this output conditional on sizeof(void*) to be portable to both 32- and 64- bit machines. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
On 05/06/2010 12:35 PM, Jim Meyering wrote:
This week we noticed that a change to struct remote_error was causing trouble (new member addition changed the size of the object being decoded -- bad for the protocol).
In order to ensure that no such changes sneak in again, I'm planning to do the following.
pdwtags src/libvirt_driver_remote_la-remote_protocol.o
prints, among other things, detailed type info for every struct:
/* 89 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 8 */ remote_uuid uuid; /* 8 16 */ int id; /* 24 4 */
/* size: 32, cachelines: 1, members: 3 */ /* last cacheline: 32 bytes */
/* BRAIN FART ALERT! 32 != 28 + 0(holes), diff = 4 */
}; /* size: 32 */
Ouch. Architecture sizing plays a role. On a 32-bit machine, the first struct is:
There's a way out.
/* 86 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 4 */ remote_uuid uuid; /* 4 16 */ int id; /* 20 4 */
/* size: 24, cachelines: 1, members: 3 */ /* last cacheline: 24 bytes */ }; /* size: 24 */
Are we sure migration between 32-bit and 64-bit hypervisors works? And if it does, then these structs don't quite match what is actually sent over the wire. At any rate,
Not a problem. We don't send pointers over the wire. The types are designed to be used portably.
And here's a sample of its output:
verify (sizeof (struct remote_nonnull_domain) == 32);
we'd have to make this output conditional on sizeof(void*) to be portable to both 32- and 64- bit machines.
Right. There are a couple options: - maintain two sets of sizeof-verifying "verify" directives, one for 32-bit, the other for 64-bit. With this, the verification is performed at compile time and requires no special tools, in general. However, in the unusual event that we update remote_protocol.x and need to regenerate the directives, we'll have to run pdwtags on both i686 and x86_64. - maintain a textual representation of these structs and their members (including type names, but not sizes) and make pdwtags a requirement for running "make syntax-check", which would perform the verification. I.e., keep a copy of the output of pdwtags, but without the comments.

Jim Meyering wrote:
Eric Blake wrote:
On 05/06/2010 12:35 PM, Jim Meyering wrote:
This week we noticed that a change to struct remote_error was causing trouble (new member addition changed the size of the object being decoded -- bad for the protocol).
In order to ensure that no such changes sneak in again, I'm planning to do the following.
pdwtags src/libvirt_driver_remote_la-remote_protocol.o
prints, among other things, detailed type info for every struct:
/* 89 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 8 */ remote_uuid uuid; /* 8 16 */ int id; /* 24 4 */
/* size: 32, cachelines: 1, members: 3 */ /* last cacheline: 32 bytes */
/* BRAIN FART ALERT! 32 != 28 + 0(holes), diff = 4 */
}; /* size: 32 */
Ouch. Architecture sizing plays a role. On a 32-bit machine, the first struct is:
There's a way out.
/* 86 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 4 */ remote_uuid uuid; /* 4 16 */ int id; /* 20 4 */
/* size: 24, cachelines: 1, members: 3 */ /* last cacheline: 24 bytes */ }; /* size: 24 */
Are we sure migration between 32-bit and 64-bit hypervisors works? And if it does, then these structs don't quite match what is actually sent over the wire. At any rate,
Not a problem. We don't send pointers over the wire. The types are designed to be used portably.
And here's a sample of its output:
verify (sizeof (struct remote_nonnull_domain) == 32);
we'd have to make this output conditional on sizeof(void*) to be portable to both 32- and 64- bit machines.
Right. There are a couple options:
- maintain two sets of sizeof-verifying "verify" directives, one for 32-bit, the other for 64-bit. With this, the verification is performed at compile time and requires no special tools, in general. However, in the unusual event that we update remote_protocol.x and need to regenerate the directives, we'll have to run pdwtags on both i686 and x86_64.
- maintain a textual representation of these structs and their members (including type names, but not sizes) and make pdwtags a requirement for running "make syntax-check", which would perform the verification. I.e., keep a copy of the output of pdwtags, but without the comments.
FYI, here's code to generate the latter: pdwtags src/libvirt_driver_remote_la-remote_protocol.o \ |perl -0777 -n \ -e 'foreach my $p (split m!\n\n/\* \d+ \*/\n!)' \ -e ' { if ($p =~ /^struct remote_/) {' \ -e ' $p =~ s!\t*/\*.*?\*/!!sg;' \ -e ' $p =~ s!\s+\n!\n!sg;' \ -e ' print "$p\n" } }' \ > remote-protocol-structs IMHO, it would be sufficient to enable a check comparing this output to a version-controlled reference file, and making it part of "make check". Of course, this would add a dependency on pdwtags/dwarves, but it would be fine/easy to skip the check on non-Linux systems. Any objection to requiring the dwarves package for development on Linux?

On 05/07/2010 02:05 AM, Jim Meyering wrote:
There's a way out.
- maintain a textual representation of these structs and their members (including type names, but not sizes) and make pdwtags a requirement for running "make syntax-check", which would perform the verification. I.e., keep a copy of the output of pdwtags, but without the comments.
FYI, here's code to generate the latter:
pdwtags src/libvirt_driver_remote_la-remote_protocol.o \ |perl -0777 -n \ -e 'foreach my $p (split m!\n\n/\* \d+ \*/\n!)' \ -e ' { if ($p =~ /^struct remote_/) {' \ -e ' $p =~ s!\t*/\*.*?\*/!!sg;' \ -e ' $p =~ s!\s+\n!\n!sg;' \ -e ' print "$p\n" } }' \ > remote-protocol-structs
IMHO, it would be sufficient to enable a check comparing this output to a version-controlled reference file, and making it part of "make check".
I like it!
Of course, this would add a dependency on pdwtags/dwarves, but it would be fine/easy to skip the check on non-Linux systems.
The same as we do for cppi - make it an optional 'make syntax-check', so that those who have dwarves installed run it, and those who don't get a warning that they should consider installing dwarves.
Any objection to requiring the dwarves package for development on Linux?
No objection to an optional dependency from me. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
On 05/07/2010 02:05 AM, Jim Meyering wrote:
There's a way out.
- maintain a textual representation of these structs and their members (including type names, but not sizes) and make pdwtags a requirement for running "make syntax-check", which would perform the verification. I.e., keep a copy of the output of pdwtags, but without the comments.
FYI, here's code to generate the latter:
pdwtags src/libvirt_driver_remote_la-remote_protocol.o \ |perl -0777 -n \ -e 'foreach my $p (split m!\n\n/\* \d+ \*/\n!)' \ -e ' { if ($p =~ /^struct remote_/) {' \ -e ' $p =~ s!\t*/\*.*?\*/!!sg;' \ -e ' $p =~ s!\s+\n!\n!sg;' \ -e ' print "$p\n" } }' \ > remote-protocol-structs
IMHO, it would be sufficient to enable a check comparing this output to a version-controlled reference file, and making it part of "make check".
I like it!
Of course, this would add a dependency on pdwtags/dwarves, but it would be fine/easy to skip the check on non-Linux systems.
The same as we do for cppi - make it an optional 'make syntax-check', so that those who have dwarves installed run it, and those who don't get a warning that they should consider installing dwarves.
Any objection to requiring the dwarves package for development on Linux?
No objection to an optional dependency from me.
Thanks for the feedback. Here's a complete patch. I wrote it before the removal of the field from struct remote_error, and verified that it triggered upon removal, and that removing the matching name from the new remote_protocol-structs file made the test pass once again.
From 19d6d7aceddd3ad2c47154a908ae52ff06107db6 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Fri, 7 May 2010 16:01:26 +0200 Subject: [PATCH] help avoid accidental remote_protocol.x changes
Now, if you update remote_protocol.x without also updating remote_protocol-structs to match, then "make check" will fail. * src/Makefile.am (remote_protocol-structs): Extract list of structs and member names from remote_protocol.o. (check-local): Depend on it. * src/remote_protocol-structs: New file. --- src/Makefile.am | 19 + src/remote_protocol-structs | 1308 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1327 insertions(+), 0 deletions(-) create mode 100644 src/remote_protocol-structs diff --git a/src/Makefile.am b/src/Makefile.am index 1fdf81d..1c92460 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -155,6 +155,25 @@ REMOTE_DRIVER_SOURCES = \ remote/remote_protocol.c \ remote/remote_protocol.h +EXTRA_DIST += remote_protocol-structs +check-local: remote_protocol-structs +.PHONY: remote_protocol-structs +remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ + pdwtags libvirt_driver_remote_la-remote_protocol.$(OBJEXT) \ + | perl -0777 -n \ + -e 'foreach my $$p (split m!\n\n/\* \d+ \*/\n!)' \ + -e ' { if ($$p =~ /^struct remote_/) {' \ + -e ' $$p =~ s!\t*/\*.*?\*/!!sg;' \ + -e ' $$p =~ s!\s+\n!\n!sg;' \ + -e ' $$p =~ s!\s+$$!!;' \ + -e ' print "$$p\n" } }' \ + > $@-t; \ + diff -u $@-t $@; st=$$?; rm -f $@-t; exit $$st; \ + else \ + echo 'WARNING: you lack pdwtags; skipping the $@ test'; \ + fi + EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl # Mock driver, covering domains, storage, networks, etc diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs new file mode 100644 index 0000000..c8f81f3 --- /dev/null +++ b/src/remote_protocol-structs @@ -0,0 +1,1308 @@ +struct remote_nonnull_domain { + remote_nonnull_string name; + remote_uuid uuid; + int id; +}; +struct remote_nonnull_network { + remote_nonnull_string name; + remote_uuid uuid; +}; +struct remote_nonnull_nwfilter { + remote_nonnull_string name; + remote_uuid uuid; +}; +struct remote_nonnull_interface { + remote_nonnull_string name; + remote_nonnull_string mac; +}; +struct remote_nonnull_storage_pool { + remote_nonnull_string name; + remote_uuid uuid; +}; +struct remote_nonnull_storage_vol { + remote_nonnull_string pool; + remote_nonnull_string name; + remote_nonnull_string key; +}; +struct remote_nonnull_node_device { + remote_nonnull_string name; +}; +struct remote_nonnull_secret { + remote_uuid uuid; + int usageType; + remote_nonnull_string usageID; +}; +struct remote_nonnull_domain_snapshot { + remote_nonnull_string name; + remote_nonnull_domain domain; +}; +struct remote_error { + int code; + int domain; + remote_string message; + int level; + remote_domain dom; + remote_string str1; + remote_string str2; + remote_string str3; + int int1; + int int2; + remote_network net; +}; +struct remote_vcpu_info { + u_int number; + int state; + uint64_t cpu_time; + int cpu; +}; +struct remote_sched_param_value { + int type; + union { + int i; + u_int ui; + int64_t l; + uint64_t ul; + double d; + int b; + } remote_sched_param_value_u; +}; +struct remote_sched_param { + remote_nonnull_string field; + remote_sched_param_value value; +}; +struct remote_open_args { + remote_string name; + int flags; +}; +struct remote_supports_feature_args { + int feature; +}; +struct remote_supports_feature_ret { + int supported; +}; +struct remote_get_type_ret { + remote_nonnull_string type; +}; +struct remote_get_version_ret { + int64_t hv_ver; +}; +struct remote_get_lib_version_ret { + int64_t lib_ver; +}; +struct remote_get_hostname_ret { + remote_nonnull_string hostname; +}; +struct remote_get_uri_ret { + remote_nonnull_string uri; +}; +struct remote_get_max_vcpus_args { + remote_string type; +}; +struct remote_get_max_vcpus_ret { + int max_vcpus; +}; +struct remote_node_get_info_ret { + char model[32]; + int64_t memory; + int cpus; + int mhz; + int nodes; + int sockets; + int cores; + int threads; +}; +struct remote_get_capabilities_ret { + remote_nonnull_string capabilities; +}; +struct remote_node_get_cells_free_memory_args { + int startCell; + int maxCells; +}; +struct remote_node_get_cells_free_memory_ret { + struct { + u_int freeMems_len; + int64_t * freeMems_val; + } freeMems; +}; +struct remote_node_get_free_memory_ret { + int64_t freeMem; +}; +struct remote_domain_get_scheduler_type_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_scheduler_type_ret { + remote_nonnull_string type; + int nparams; +}; +struct remote_domain_get_scheduler_parameters_args { + remote_nonnull_domain dom; + int nparams; +}; +struct remote_domain_get_scheduler_parameters_ret { + struct { + u_int params_len; + remote_sched_param * params_val; + } params; +}; +struct remote_domain_set_scheduler_parameters_args { + remote_nonnull_domain dom; + struct { + u_int params_len; + remote_sched_param * params_val; + } params; +}; +struct remote_domain_block_stats_args { + remote_nonnull_domain dom; + remote_nonnull_string path; +}; +struct remote_domain_block_stats_ret { + int64_t rd_req; + int64_t rd_bytes; + int64_t wr_req; + int64_t wr_bytes; + int64_t errs; +}; +struct remote_domain_interface_stats_args { + remote_nonnull_domain dom; + remote_nonnull_string path; +}; +struct remote_domain_interface_stats_ret { + int64_t rx_bytes; + int64_t rx_packets; + int64_t rx_errs; + int64_t rx_drop; + int64_t tx_bytes; + int64_t tx_packets; + int64_t tx_errs; + int64_t tx_drop; +}; +struct remote_domain_memory_stats_args { + remote_nonnull_domain dom; + u_int maxStats; + u_int flags; +}; +struct remote_domain_memory_stat { + int tag; + uint64_t val; +}; +struct remote_domain_memory_stats_ret { + struct { + u_int stats_len; + remote_domain_memory_stat * stats_val; + } stats; +}; +struct remote_domain_block_peek_args { + remote_nonnull_domain dom; + remote_nonnull_string path; + uint64_t offset; + u_int size; + u_int flags; +}; +struct remote_domain_block_peek_ret { + struct { + u_int buffer_len; + char * buffer_val; + } buffer; +}; +struct remote_domain_memory_peek_args { + remote_nonnull_domain dom; + uint64_t offset; + u_int size; + u_int flags; +}; +struct remote_domain_memory_peek_ret { + struct { + u_int buffer_len; + char * buffer_val; + } buffer; +}; +struct remote_domain_get_block_info_args { + remote_nonnull_domain dom; + remote_nonnull_string path; + u_int flags; +}; +struct remote_domain_get_block_info_ret { + uint64_t allocation; + uint64_t capacity; + uint64_t physical; +}; +struct remote_list_domains_args { + int maxids; +}; +struct remote_list_domains_ret { + struct { + u_int ids_len; + int * ids_val; + } ids; +}; +struct remote_num_of_domains_ret { + int num; +}; +struct remote_domain_create_xml_args { + remote_nonnull_string xml_desc; + int flags; +}; +struct remote_domain_create_xml_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_lookup_by_id_args { + int id; +}; +struct remote_domain_lookup_by_id_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_domain_lookup_by_uuid_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_domain_lookup_by_name_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_suspend_args { + remote_nonnull_domain dom; +}; +struct remote_domain_resume_args { + remote_nonnull_domain dom; +}; +struct remote_domain_shutdown_args { + remote_nonnull_domain dom; +}; +struct remote_domain_reboot_args { + remote_nonnull_domain dom; + int flags; +}; +struct remote_domain_destroy_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_os_type_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_os_type_ret { + remote_nonnull_string type; +}; +struct remote_domain_get_max_memory_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_max_memory_ret { + uint64_t memory; +}; +struct remote_domain_set_max_memory_args { + remote_nonnull_domain dom; + uint64_t memory; +}; +struct remote_domain_set_memory_args { + remote_nonnull_domain dom; + uint64_t memory; +}; +struct remote_domain_get_info_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_info_ret { + u_char state; + uint64_t max_mem; + uint64_t memory; + u_short nr_virt_cpu; + uint64_t cpu_time; +}; +struct remote_domain_save_args { + remote_nonnull_domain dom; + remote_nonnull_string to; +}; +struct remote_domain_restore_args { + remote_nonnull_string from; +}; +struct remote_domain_core_dump_args { + remote_nonnull_domain dom; + remote_nonnull_string to; + int flags; +}; +struct remote_domain_dump_xml_args { + remote_nonnull_domain dom; + int flags; +}; +struct remote_domain_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_domain_migrate_prepare_args { + remote_string uri_in; + uint64_t flags; + remote_string dname; + uint64_t resource; +}; +struct remote_domain_migrate_prepare_ret { + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_string uri_out; +}; +struct remote_domain_migrate_perform_args { + remote_nonnull_domain dom; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; + remote_string dname; + uint64_t resource; +}; +struct remote_domain_migrate_finish_args { + remote_nonnull_string dname; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; +}; +struct remote_domain_migrate_finish_ret { + remote_nonnull_domain ddom; +}; +struct remote_domain_migrate_prepare2_args { + remote_string uri_in; + uint64_t flags; + remote_string dname; + uint64_t resource; + remote_nonnull_string dom_xml; +}; +struct remote_domain_migrate_prepare2_ret { + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_string uri_out; +}; +struct remote_domain_migrate_finish2_args { + remote_nonnull_string dname; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; + int retcode; +}; +struct remote_domain_migrate_finish2_ret { + remote_nonnull_domain ddom; +}; +struct remote_list_defined_domains_args { + int maxnames; +}; +struct remote_list_defined_domains_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_domains_ret { + int num; +}; +struct remote_domain_create_args { + remote_nonnull_domain dom; +}; +struct remote_domain_define_xml_args { + remote_nonnull_string xml; +}; +struct remote_domain_define_xml_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_undefine_args { + remote_nonnull_domain dom; +}; +struct remote_domain_set_vcpus_args { + remote_nonnull_domain dom; + int nvcpus; +}; +struct remote_domain_pin_vcpu_args { + remote_nonnull_domain dom; + int vcpu; + struct { + u_int cpumap_len; + char * cpumap_val; + } cpumap; +}; +struct remote_domain_get_vcpus_args { + remote_nonnull_domain dom; + int maxinfo; + int maplen; +}; +struct remote_domain_get_vcpus_ret { + struct { + u_int info_len; + remote_vcpu_info * info_val; + } info; + struct { + u_int cpumaps_len; + char * cpumaps_val; + } cpumaps; +}; +struct remote_domain_get_max_vcpus_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_max_vcpus_ret { + int num; +}; +struct remote_domain_get_security_label_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_security_label_ret { + struct { + u_int label_len; + char * label_val; + } label; + int enforcing; +}; +struct remote_node_get_security_model_ret { + struct { + u_int model_len; + char * model_val; + } model; + struct { + u_int doi_len; + char * doi_val; + } doi; +}; +struct remote_domain_attach_device_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; +}; +struct remote_domain_attach_device_flags_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_domain_detach_device_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; +}; +struct remote_domain_detach_device_flags_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_domain_update_device_flags_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_domain_get_autostart_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_autostart_ret { + int autostart; +}; +struct remote_domain_set_autostart_args { + remote_nonnull_domain dom; + int autostart; +}; +struct remote_num_of_networks_ret { + int num; +}; +struct remote_list_networks_args { + int maxnames; +}; +struct remote_list_networks_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_networks_ret { + int num; +}; +struct remote_list_defined_networks_args { + int maxnames; +}; +struct remote_list_defined_networks_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_network_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_network_lookup_by_uuid_ret { + remote_nonnull_network net; +}; +struct remote_network_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_network_lookup_by_name_ret { + remote_nonnull_network net; +}; +struct remote_network_create_xml_args { + remote_nonnull_string xml; +}; +struct remote_network_create_xml_ret { + remote_nonnull_network net; +}; +struct remote_network_define_xml_args { + remote_nonnull_string xml; +}; +struct remote_network_define_xml_ret { + remote_nonnull_network net; +}; +struct remote_network_undefine_args { + remote_nonnull_network net; +}; +struct remote_network_create_args { + remote_nonnull_network net; +}; +struct remote_network_destroy_args { + remote_nonnull_network net; +}; +struct remote_network_dump_xml_args { + remote_nonnull_network net; + int flags; +}; +struct remote_network_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_network_get_bridge_name_args { + remote_nonnull_network net; +}; +struct remote_network_get_bridge_name_ret { + remote_nonnull_string name; +}; +struct remote_network_get_autostart_args { + remote_nonnull_network net; +}; +struct remote_network_get_autostart_ret { + int autostart; +}; +struct remote_network_set_autostart_args { + remote_nonnull_network net; + int autostart; +}; +struct remote_num_of_nwfilters_ret { + int num; +}; +struct remote_list_nwfilters_args { + int maxnames; +}; +struct remote_list_nwfilters_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_nwfilter_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_nwfilter_lookup_by_uuid_ret { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_nwfilter_lookup_by_name_ret { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_define_xml_args { + remote_nonnull_string xml; +}; +struct remote_nwfilter_define_xml_ret { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_undefine_args { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_get_xml_desc_args { + remote_nonnull_nwfilter nwfilter; + int flags; +}; +struct remote_nwfilter_get_xml_desc_ret { + remote_nonnull_string xml; +}; +struct remote_num_of_interfaces_ret { + int num; +}; +struct remote_list_interfaces_args { + int maxnames; +}; +struct remote_list_interfaces_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_interfaces_ret { + int num; +}; +struct remote_list_defined_interfaces_args { + int maxnames; +}; +struct remote_list_defined_interfaces_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_interface_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_interface_lookup_by_name_ret { + remote_nonnull_interface iface; +}; +struct remote_interface_lookup_by_mac_string_args { + remote_nonnull_string mac; +}; +struct remote_interface_lookup_by_mac_string_ret { + remote_nonnull_interface iface; +}; +struct remote_interface_get_xml_desc_args { + remote_nonnull_interface iface; + u_int flags; +}; +struct remote_interface_get_xml_desc_ret { + remote_nonnull_string xml; +}; +struct remote_interface_define_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_interface_define_xml_ret { + remote_nonnull_interface iface; +}; +struct remote_interface_undefine_args { + remote_nonnull_interface iface; +}; +struct remote_interface_create_args { + remote_nonnull_interface iface; + u_int flags; +}; +struct remote_interface_destroy_args { + remote_nonnull_interface iface; + u_int flags; +}; +struct remote_auth_list_ret { + struct { + u_int types_len; + remote_auth_type * types_val; + } types; +}; +struct remote_auth_sasl_init_ret { + remote_nonnull_string mechlist; +}; +struct remote_auth_sasl_start_args { + remote_nonnull_string mech; + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_sasl_start_ret { + int complete; + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_sasl_step_args { + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_sasl_step_ret { + int complete; + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_polkit_ret { + int complete; +}; +struct remote_num_of_storage_pools_ret { + int num; +}; +struct remote_list_storage_pools_args { + int maxnames; +}; +struct remote_list_storage_pools_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_storage_pools_ret { + int num; +}; +struct remote_list_defined_storage_pools_args { + int maxnames; +}; +struct remote_list_defined_storage_pools_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_find_storage_pool_sources_args { + remote_nonnull_string type; + remote_string srcSpec; + u_int flags; +}; +struct remote_find_storage_pool_sources_ret { + remote_nonnull_string xml; +}; +struct remote_storage_pool_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_storage_pool_lookup_by_uuid_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_storage_pool_lookup_by_name_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_lookup_by_volume_args { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_pool_lookup_by_volume_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_create_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_storage_pool_create_xml_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_define_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_storage_pool_define_xml_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_build_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_undefine_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_create_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_destroy_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_delete_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_refresh_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_dump_xml_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_storage_pool_get_info_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_get_info_ret { + u_char state; + uint64_t capacity; + uint64_t allocation; + uint64_t available; +}; +struct remote_storage_pool_get_autostart_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_get_autostart_ret { + int autostart; +}; +struct remote_storage_pool_set_autostart_args { + remote_nonnull_storage_pool pool; + int autostart; +}; +struct remote_storage_pool_num_of_volumes_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_num_of_volumes_ret { + int num; +}; +struct remote_storage_pool_list_volumes_args { + remote_nonnull_storage_pool pool; + int maxnames; +}; +struct remote_storage_pool_list_volumes_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_storage_vol_lookup_by_name_args { + remote_nonnull_storage_pool pool; + remote_nonnull_string name; +}; +struct remote_storage_vol_lookup_by_name_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_lookup_by_key_args { + remote_nonnull_string key; +}; +struct remote_storage_vol_lookup_by_key_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_lookup_by_path_args { + remote_nonnull_string path; +}; +struct remote_storage_vol_lookup_by_path_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_create_xml_args { + remote_nonnull_storage_pool pool; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_storage_vol_create_xml_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_create_xml_from_args { + remote_nonnull_storage_pool pool; + remote_nonnull_string xml; + remote_nonnull_storage_vol clonevol; + u_int flags; +}; +struct remote_storage_vol_create_xml_from_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_delete_args { + remote_nonnull_storage_vol vol; + u_int flags; +}; +struct remote_storage_vol_wipe_args { + remote_nonnull_storage_vol vol; + u_int flags; +}; +struct remote_storage_vol_dump_xml_args { + remote_nonnull_storage_vol vol; + u_int flags; +}; +struct remote_storage_vol_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_storage_vol_get_info_args { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_get_info_ret { + char type; + uint64_t capacity; + uint64_t allocation; +}; +struct remote_storage_vol_get_path_args { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_get_path_ret { + remote_nonnull_string name; +}; +struct remote_node_num_of_devices_args { + remote_string cap; + u_int flags; +}; +struct remote_node_num_of_devices_ret { + int num; +}; +struct remote_node_list_devices_args { + remote_string cap; + int maxnames; + u_int flags; +}; +struct remote_node_list_devices_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_node_device_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_node_device_lookup_by_name_ret { + remote_nonnull_node_device dev; +}; +struct remote_node_device_dump_xml_args { + remote_nonnull_string name; + u_int flags; +}; +struct remote_node_device_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_node_device_get_parent_args { + remote_nonnull_string name; +}; +struct remote_node_device_get_parent_ret { + remote_string parent; +}; +struct remote_node_device_num_of_caps_args { + remote_nonnull_string name; +}; +struct remote_node_device_num_of_caps_ret { + int num; +}; +struct remote_node_device_list_caps_args { + remote_nonnull_string name; + int maxnames; +}; +struct remote_node_device_list_caps_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_node_device_dettach_args { + remote_nonnull_string name; +}; +struct remote_node_device_re_attach_args { + remote_nonnull_string name; +}; +struct remote_node_device_reset_args { + remote_nonnull_string name; +}; +struct remote_node_device_create_xml_args { + remote_nonnull_string xml_desc; + int flags; +}; +struct remote_node_device_create_xml_ret { + remote_nonnull_node_device dev; +}; +struct remote_node_device_destroy_args { + remote_nonnull_string name; +}; +struct remote_domain_events_register_ret { + int cb_registered; +}; +struct remote_domain_events_deregister_ret { + int cb_registered; +}; +struct remote_domain_event_lifecycle_msg { + remote_nonnull_domain dom; + int event; + int detail; +}; +struct remote_domain_xml_from_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string nativeConfig; + u_int flags; +}; +struct remote_domain_xml_from_native_ret { + remote_nonnull_string domainXml; +}; +struct remote_domain_xml_to_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string domainXml; + u_int flags; +}; +struct remote_domain_xml_to_native_ret { + remote_nonnull_string nativeConfig; +}; +struct remote_num_of_secrets_ret { + int num; +}; +struct remote_list_secrets_args { + int maxuuids; +}; +struct remote_list_secrets_ret { + struct { + u_int uuids_len; + remote_nonnull_string * uuids_val; + } uuids; +}; +struct remote_secret_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_secret_lookup_by_uuid_ret { + remote_nonnull_secret secret; +}; +struct remote_secret_define_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_secret_define_xml_ret { + remote_nonnull_secret secret; +}; +struct remote_secret_get_xml_desc_args { + remote_nonnull_secret secret; + u_int flags; +}; +struct remote_secret_get_xml_desc_ret { + remote_nonnull_string xml; +}; +struct remote_secret_set_value_args { + remote_nonnull_secret secret; + struct { + u_int value_len; + char * value_val; + } value; + u_int flags; +}; +struct remote_secret_get_value_args { + remote_nonnull_secret secret; + u_int flags; +}; +struct remote_secret_get_value_ret { + struct { + u_int value_len; + char * value_val; + } value; +}; +struct remote_secret_undefine_args { + remote_nonnull_secret secret; +}; +struct remote_secret_lookup_by_usage_args { + int usageType; + remote_nonnull_string usageID; +}; +struct remote_secret_lookup_by_usage_ret { + remote_nonnull_secret secret; +}; +struct remote_domain_migrate_prepare_tunnel_args { + uint64_t flags; + remote_string dname; + uint64_t resource; + remote_nonnull_string dom_xml; +}; +struct remote_is_secure_ret { + int secure; +}; +struct remote_domain_is_active_args { + remote_nonnull_domain dom; +}; +struct remote_domain_is_active_ret { + int active; +}; +struct remote_domain_is_persistent_args { + remote_nonnull_domain dom; +}; +struct remote_domain_is_persistent_ret { + int persistent; +}; +struct remote_network_is_active_args { + remote_nonnull_network net; +}; +struct remote_network_is_active_ret { + int active; +}; +struct remote_network_is_persistent_args { + remote_nonnull_network net; +}; +struct remote_network_is_persistent_ret { + int persistent; +}; +struct remote_storage_pool_is_active_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_is_active_ret { + int active; +}; +struct remote_storage_pool_is_persistent_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_is_persistent_ret { + int persistent; +}; +struct remote_interface_is_active_args { + remote_nonnull_interface iface; +}; +struct remote_interface_is_active_ret { + int active; +}; +struct remote_cpu_compare_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_cpu_compare_ret { + int result; +}; +struct remote_cpu_baseline_args { + struct { + u_int xmlCPUs_len; + remote_nonnull_string * xmlCPUs_val; + } xmlCPUs; + u_int flags; +}; +struct remote_cpu_baseline_ret { + remote_nonnull_string cpu; +}; +struct remote_domain_get_job_info_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_job_info_ret { + int type; + uint64_t timeElapsed; + uint64_t timeRemaining; + uint64_t dataTotal; + uint64_t dataProcessed; + uint64_t dataRemaining; + uint64_t memTotal; + uint64_t memProcessed; + uint64_t memRemaining; + uint64_t fileTotal; + uint64_t fileProcessed; + uint64_t fileRemaining; +}; +struct remote_domain_abort_job_args { + remote_nonnull_domain dom; +}; +struct remote_domain_migrate_set_max_downtime_args { + remote_nonnull_domain dom; + uint64_t downtime; + u_int flags; +}; +struct remote_domain_events_register_any_args { + int eventID; +}; +struct remote_domain_events_deregister_any_args { + int eventID; +}; +struct remote_domain_event_reboot_msg { + remote_nonnull_domain dom; +}; +struct remote_domain_event_rtc_change_msg { + remote_nonnull_domain dom; + int64_t offset; +}; +struct remote_domain_event_watchdog_msg { + remote_nonnull_domain dom; + int action; +}; +struct remote_domain_event_io_error_msg { + remote_nonnull_domain dom; + remote_nonnull_string srcPath; + remote_nonnull_string devAlias; + int action; +}; +struct remote_domain_event_io_error_reason_msg { + remote_nonnull_domain dom; + remote_nonnull_string srcPath; + remote_nonnull_string devAlias; + int action; + remote_nonnull_string reason; +}; +struct remote_domain_event_graphics_address { + int family; + remote_nonnull_string node; + remote_nonnull_string service; +}; +struct remote_domain_event_graphics_identity { + remote_nonnull_string type; + remote_nonnull_string name; +}; +struct remote_domain_event_graphics_msg { + remote_nonnull_domain dom; + int phase; + remote_domain_event_graphics_address local; + remote_domain_event_graphics_address remote; + remote_nonnull_string authScheme; + struct { + u_int subject_len; + remote_domain_event_graphics_identity * subject_val; + } subject; +}; +struct remote_domain_managed_save_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_has_managed_save_image_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_has_managed_save_image_ret { + int ret; +}; +struct remote_domain_managed_save_remove_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_snapshot_create_xml_args { + remote_nonnull_domain domain; + remote_nonnull_string xml_desc; + int flags; +}; +struct remote_domain_snapshot_create_xml_ret { + remote_nonnull_domain_snapshot snap; +}; +struct remote_domain_snapshot_dump_xml_args { + remote_nonnull_domain_snapshot snap; + int flags; +}; +struct remote_domain_snapshot_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_domain_snapshot_num_args { + remote_nonnull_domain domain; + int flags; +}; +struct remote_domain_snapshot_num_ret { + int num; +}; +struct remote_domain_snapshot_list_names_args { + remote_nonnull_domain domain; + int nameslen; + int flags; +}; +struct remote_domain_snapshot_list_names_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_domain_snapshot_lookup_by_name_args { + remote_nonnull_domain domain; + remote_nonnull_string name; + int flags; +}; +struct remote_domain_snapshot_lookup_by_name_ret { + remote_nonnull_domain_snapshot snap; +}; +struct remote_domain_has_current_snapshot_args { + remote_nonnull_domain domain; + int flags; +}; +struct remote_domain_has_current_snapshot_ret { + int result; +}; +struct remote_domain_snapshot_current_args { + remote_nonnull_domain domain; + int flags; +}; +struct remote_domain_snapshot_current_ret { + remote_nonnull_domain_snapshot snap; +}; +struct remote_domain_revert_to_snapshot_args { + remote_nonnull_domain_snapshot snap; + int flags; +}; +struct remote_domain_snapshot_delete_args { + remote_nonnull_domain_snapshot snap; + int flags; +}; +struct remote_message_header { + u_int prog; + u_int vers; + remote_procedure proc; + remote_message_type type; + u_int serial; + remote_message_status status; +}; -- 1.7.1.166.gf2086

Jim Meyering wrote:
Eric Blake wrote: ... remote/remote_protocol.c \ remote/remote_protocol.h
+EXTRA_DIST += remote_protocol-structs +check-local: remote_protocol-structs +.PHONY: remote_protocol-structs +remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ + pdwtags libvirt_driver_remote_la-remote_protocol.$(OBJEXT) \ + | perl -0777 -n \ + -e 'foreach my $$p (split m!\n\n/\* \d+ \*/\n!)' \ + -e ' { if ($$p =~ /^struct remote_/) {' \ + -e ' $$p =~ s!\t*/\*.*?\*/!!sg;' \ + -e ' $$p =~ s!\s+\n!\n!sg;' \ + -e ' $$p =~ s!\s+$$!!;' \ + -e ' print "$$p\n" } }' \ + > $@-t; \ + diff -u $@-t $@; st=$$?; rm -f $@-t; exit $$st; \ + else \ + echo 'WARNING: you lack pdwtags; skipping the $@ test'; \ + fi + EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl
# Mock driver, covering domains, storage, networks, etc diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs new file mode 100644 index 0000000..c8f81f3
Here's an incremental change that adds comments, moves the EXTRA_DIST assignment for remote_protocol.x "up" to be nearer the related code, and changes the new check to mention the name of the "dwarves" package with the skip warning. diff --git a/src/Makefile.am b/src/Makefile.am index 1c92460..fe33cea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -155,8 +155,18 @@ REMOTE_DRIVER_SOURCES = \ remote/remote_protocol.c \ remote/remote_protocol.h -EXTRA_DIST += remote_protocol-structs -check-local: remote_protocol-structs +EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl + +# Ensure that we don't change the struct or member names or member ordering +# in remote_protocol.x The embedded perl below needs a few comments, and +# presumes you know what pdwtags output looks like: +# * use -0777 -n to slurp the entire file into $_. +# * the "split" splits on the /* DD */ comments, so that $p iterates +# through the struct definitions. +# * process only "struct remote_..." entries +# * remove comments and preceding TAB throughout +# * remove empty lines throughout +# * remove white space at end of buffer .PHONY: remote_protocol-structs remote_protocol-structs: $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ @@ -172,9 +182,10 @@ remote_protocol-structs: diff -u $@-t $@; st=$$?; rm -f $@-t; exit $$st; \ else \ echo 'WARNING: you lack pdwtags; skipping the $@ test'; \ + echo 'WARNING: install the dwarves package to get pdwtags'; \ fi - -EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl +EXTRA_DIST += remote_protocol-structs +check-local: remote_protocol-structs # Mock driver, covering domains, storage, networks, etc TEST_DRIVER_SOURCES = \ --------------------------- In case it helps, here's the full, amended patch:
From 180d4b2b3b79c768f4a6444181d7f021771fab66 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Fri, 7 May 2010 16:01:26 +0200 Subject: [PATCH] help avoid accidental remote_protocol.x changes
Now, if you update remote_protocol.x without also updating remote_protocol-structs to match, then "make check" will fail. * src/Makefile.am (remote_protocol-structs): Extract list of structs and member names from remote_protocol.o. (check-local): Depend on it. * src/remote_protocol-structs: New file. --- src/Makefile.am | 30 + src/remote_protocol-structs | 1308 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1338 insertions(+), 0 deletions(-) create mode 100644 src/remote_protocol-structs diff --git a/src/Makefile.am b/src/Makefile.am index 1fdf81d..fe33cea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -157,6 +157,36 @@ REMOTE_DRIVER_SOURCES = \ EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl +# Ensure that we don't change the struct or member names or member ordering +# in remote_protocol.x The embedded perl below needs a few comments, and +# presumes you know what pdwtags output looks like: +# * use -0777 -n to slurp the entire file into $_. +# * the "split" splits on the /* DD */ comments, so that $p iterates +# through the struct definitions. +# * process only "struct remote_..." entries +# * remove comments and preceding TAB throughout +# * remove empty lines throughout +# * remove white space at end of buffer +.PHONY: remote_protocol-structs +remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ + pdwtags libvirt_driver_remote_la-remote_protocol.$(OBJEXT) \ + | perl -0777 -n \ + -e 'foreach my $$p (split m!\n\n/\* \d+ \*/\n!)' \ + -e ' { if ($$p =~ /^struct remote_/) {' \ + -e ' $$p =~ s!\t*/\*.*?\*/!!sg;' \ + -e ' $$p =~ s!\s+\n!\n!sg;' \ + -e ' $$p =~ s!\s+$$!!;' \ + -e ' print "$$p\n" } }' \ + > $@-t; \ + diff -u $@-t $@; st=$$?; rm -f $@-t; exit $$st; \ + else \ + echo 'WARNING: you lack pdwtags; skipping the $@ test'; \ + echo 'WARNING: install the dwarves package to get pdwtags'; \ + fi +EXTRA_DIST += remote_protocol-structs +check-local: remote_protocol-structs + # Mock driver, covering domains, storage, networks, etc TEST_DRIVER_SOURCES = \ test/test_driver.c test/test_driver.h diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs new file mode 100644 index 0000000..c8f81f3 --- /dev/null +++ b/src/remote_protocol-structs @@ -0,0 +1,1308 @@ +struct remote_nonnull_domain { + remote_nonnull_string name; + remote_uuid uuid; + int id; +}; +struct remote_nonnull_network { + remote_nonnull_string name; + remote_uuid uuid; +}; +struct remote_nonnull_nwfilter { + remote_nonnull_string name; + remote_uuid uuid; +}; +struct remote_nonnull_interface { + remote_nonnull_string name; + remote_nonnull_string mac; +}; +struct remote_nonnull_storage_pool { + remote_nonnull_string name; + remote_uuid uuid; +}; +struct remote_nonnull_storage_vol { + remote_nonnull_string pool; + remote_nonnull_string name; + remote_nonnull_string key; +}; +struct remote_nonnull_node_device { + remote_nonnull_string name; +}; +struct remote_nonnull_secret { + remote_uuid uuid; + int usageType; + remote_nonnull_string usageID; +}; +struct remote_nonnull_domain_snapshot { + remote_nonnull_string name; + remote_nonnull_domain domain; +}; +struct remote_error { + int code; + int domain; + remote_string message; + int level; + remote_domain dom; + remote_string str1; + remote_string str2; + remote_string str3; + int int1; + int int2; + remote_network net; +}; +struct remote_vcpu_info { + u_int number; + int state; + uint64_t cpu_time; + int cpu; +}; +struct remote_sched_param_value { + int type; + union { + int i; + u_int ui; + int64_t l; + uint64_t ul; + double d; + int b; + } remote_sched_param_value_u; +}; +struct remote_sched_param { + remote_nonnull_string field; + remote_sched_param_value value; +}; +struct remote_open_args { + remote_string name; + int flags; +}; +struct remote_supports_feature_args { + int feature; +}; +struct remote_supports_feature_ret { + int supported; +}; +struct remote_get_type_ret { + remote_nonnull_string type; +}; +struct remote_get_version_ret { + int64_t hv_ver; +}; +struct remote_get_lib_version_ret { + int64_t lib_ver; +}; +struct remote_get_hostname_ret { + remote_nonnull_string hostname; +}; +struct remote_get_uri_ret { + remote_nonnull_string uri; +}; +struct remote_get_max_vcpus_args { + remote_string type; +}; +struct remote_get_max_vcpus_ret { + int max_vcpus; +}; +struct remote_node_get_info_ret { + char model[32]; + int64_t memory; + int cpus; + int mhz; + int nodes; + int sockets; + int cores; + int threads; +}; +struct remote_get_capabilities_ret { + remote_nonnull_string capabilities; +}; +struct remote_node_get_cells_free_memory_args { + int startCell; + int maxCells; +}; +struct remote_node_get_cells_free_memory_ret { + struct { + u_int freeMems_len; + int64_t * freeMems_val; + } freeMems; +}; +struct remote_node_get_free_memory_ret { + int64_t freeMem; +}; +struct remote_domain_get_scheduler_type_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_scheduler_type_ret { + remote_nonnull_string type; + int nparams; +}; +struct remote_domain_get_scheduler_parameters_args { + remote_nonnull_domain dom; + int nparams; +}; +struct remote_domain_get_scheduler_parameters_ret { + struct { + u_int params_len; + remote_sched_param * params_val; + } params; +}; +struct remote_domain_set_scheduler_parameters_args { + remote_nonnull_domain dom; + struct { + u_int params_len; + remote_sched_param * params_val; + } params; +}; +struct remote_domain_block_stats_args { + remote_nonnull_domain dom; + remote_nonnull_string path; +}; +struct remote_domain_block_stats_ret { + int64_t rd_req; + int64_t rd_bytes; + int64_t wr_req; + int64_t wr_bytes; + int64_t errs; +}; +struct remote_domain_interface_stats_args { + remote_nonnull_domain dom; + remote_nonnull_string path; +}; +struct remote_domain_interface_stats_ret { + int64_t rx_bytes; + int64_t rx_packets; + int64_t rx_errs; + int64_t rx_drop; + int64_t tx_bytes; + int64_t tx_packets; + int64_t tx_errs; + int64_t tx_drop; +}; +struct remote_domain_memory_stats_args { + remote_nonnull_domain dom; + u_int maxStats; + u_int flags; +}; +struct remote_domain_memory_stat { + int tag; + uint64_t val; +}; +struct remote_domain_memory_stats_ret { + struct { + u_int stats_len; + remote_domain_memory_stat * stats_val; + } stats; +}; +struct remote_domain_block_peek_args { + remote_nonnull_domain dom; + remote_nonnull_string path; + uint64_t offset; + u_int size; + u_int flags; +}; +struct remote_domain_block_peek_ret { + struct { + u_int buffer_len; + char * buffer_val; + } buffer; +}; +struct remote_domain_memory_peek_args { + remote_nonnull_domain dom; + uint64_t offset; + u_int size; + u_int flags; +}; +struct remote_domain_memory_peek_ret { + struct { + u_int buffer_len; + char * buffer_val; + } buffer; +}; +struct remote_domain_get_block_info_args { + remote_nonnull_domain dom; + remote_nonnull_string path; + u_int flags; +}; +struct remote_domain_get_block_info_ret { + uint64_t allocation; + uint64_t capacity; + uint64_t physical; +}; +struct remote_list_domains_args { + int maxids; +}; +struct remote_list_domains_ret { + struct { + u_int ids_len; + int * ids_val; + } ids; +}; +struct remote_num_of_domains_ret { + int num; +}; +struct remote_domain_create_xml_args { + remote_nonnull_string xml_desc; + int flags; +}; +struct remote_domain_create_xml_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_lookup_by_id_args { + int id; +}; +struct remote_domain_lookup_by_id_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_domain_lookup_by_uuid_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_domain_lookup_by_name_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_suspend_args { + remote_nonnull_domain dom; +}; +struct remote_domain_resume_args { + remote_nonnull_domain dom; +}; +struct remote_domain_shutdown_args { + remote_nonnull_domain dom; +}; +struct remote_domain_reboot_args { + remote_nonnull_domain dom; + int flags; +}; +struct remote_domain_destroy_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_os_type_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_os_type_ret { + remote_nonnull_string type; +}; +struct remote_domain_get_max_memory_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_max_memory_ret { + uint64_t memory; +}; +struct remote_domain_set_max_memory_args { + remote_nonnull_domain dom; + uint64_t memory; +}; +struct remote_domain_set_memory_args { + remote_nonnull_domain dom; + uint64_t memory; +}; +struct remote_domain_get_info_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_info_ret { + u_char state; + uint64_t max_mem; + uint64_t memory; + u_short nr_virt_cpu; + uint64_t cpu_time; +}; +struct remote_domain_save_args { + remote_nonnull_domain dom; + remote_nonnull_string to; +}; +struct remote_domain_restore_args { + remote_nonnull_string from; +}; +struct remote_domain_core_dump_args { + remote_nonnull_domain dom; + remote_nonnull_string to; + int flags; +}; +struct remote_domain_dump_xml_args { + remote_nonnull_domain dom; + int flags; +}; +struct remote_domain_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_domain_migrate_prepare_args { + remote_string uri_in; + uint64_t flags; + remote_string dname; + uint64_t resource; +}; +struct remote_domain_migrate_prepare_ret { + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_string uri_out; +}; +struct remote_domain_migrate_perform_args { + remote_nonnull_domain dom; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; + remote_string dname; + uint64_t resource; +}; +struct remote_domain_migrate_finish_args { + remote_nonnull_string dname; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; +}; +struct remote_domain_migrate_finish_ret { + remote_nonnull_domain ddom; +}; +struct remote_domain_migrate_prepare2_args { + remote_string uri_in; + uint64_t flags; + remote_string dname; + uint64_t resource; + remote_nonnull_string dom_xml; +}; +struct remote_domain_migrate_prepare2_ret { + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_string uri_out; +}; +struct remote_domain_migrate_finish2_args { + remote_nonnull_string dname; + struct { + u_int cookie_len; + char * cookie_val; + } cookie; + remote_nonnull_string uri; + uint64_t flags; + int retcode; +}; +struct remote_domain_migrate_finish2_ret { + remote_nonnull_domain ddom; +}; +struct remote_list_defined_domains_args { + int maxnames; +}; +struct remote_list_defined_domains_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_domains_ret { + int num; +}; +struct remote_domain_create_args { + remote_nonnull_domain dom; +}; +struct remote_domain_define_xml_args { + remote_nonnull_string xml; +}; +struct remote_domain_define_xml_ret { + remote_nonnull_domain dom; +}; +struct remote_domain_undefine_args { + remote_nonnull_domain dom; +}; +struct remote_domain_set_vcpus_args { + remote_nonnull_domain dom; + int nvcpus; +}; +struct remote_domain_pin_vcpu_args { + remote_nonnull_domain dom; + int vcpu; + struct { + u_int cpumap_len; + char * cpumap_val; + } cpumap; +}; +struct remote_domain_get_vcpus_args { + remote_nonnull_domain dom; + int maxinfo; + int maplen; +}; +struct remote_domain_get_vcpus_ret { + struct { + u_int info_len; + remote_vcpu_info * info_val; + } info; + struct { + u_int cpumaps_len; + char * cpumaps_val; + } cpumaps; +}; +struct remote_domain_get_max_vcpus_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_max_vcpus_ret { + int num; +}; +struct remote_domain_get_security_label_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_security_label_ret { + struct { + u_int label_len; + char * label_val; + } label; + int enforcing; +}; +struct remote_node_get_security_model_ret { + struct { + u_int model_len; + char * model_val; + } model; + struct { + u_int doi_len; + char * doi_val; + } doi; +}; +struct remote_domain_attach_device_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; +}; +struct remote_domain_attach_device_flags_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_domain_detach_device_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; +}; +struct remote_domain_detach_device_flags_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_domain_update_device_flags_args { + remote_nonnull_domain dom; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_domain_get_autostart_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_autostart_ret { + int autostart; +}; +struct remote_domain_set_autostart_args { + remote_nonnull_domain dom; + int autostart; +}; +struct remote_num_of_networks_ret { + int num; +}; +struct remote_list_networks_args { + int maxnames; +}; +struct remote_list_networks_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_networks_ret { + int num; +}; +struct remote_list_defined_networks_args { + int maxnames; +}; +struct remote_list_defined_networks_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_network_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_network_lookup_by_uuid_ret { + remote_nonnull_network net; +}; +struct remote_network_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_network_lookup_by_name_ret { + remote_nonnull_network net; +}; +struct remote_network_create_xml_args { + remote_nonnull_string xml; +}; +struct remote_network_create_xml_ret { + remote_nonnull_network net; +}; +struct remote_network_define_xml_args { + remote_nonnull_string xml; +}; +struct remote_network_define_xml_ret { + remote_nonnull_network net; +}; +struct remote_network_undefine_args { + remote_nonnull_network net; +}; +struct remote_network_create_args { + remote_nonnull_network net; +}; +struct remote_network_destroy_args { + remote_nonnull_network net; +}; +struct remote_network_dump_xml_args { + remote_nonnull_network net; + int flags; +}; +struct remote_network_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_network_get_bridge_name_args { + remote_nonnull_network net; +}; +struct remote_network_get_bridge_name_ret { + remote_nonnull_string name; +}; +struct remote_network_get_autostart_args { + remote_nonnull_network net; +}; +struct remote_network_get_autostart_ret { + int autostart; +}; +struct remote_network_set_autostart_args { + remote_nonnull_network net; + int autostart; +}; +struct remote_num_of_nwfilters_ret { + int num; +}; +struct remote_list_nwfilters_args { + int maxnames; +}; +struct remote_list_nwfilters_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_nwfilter_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_nwfilter_lookup_by_uuid_ret { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_nwfilter_lookup_by_name_ret { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_define_xml_args { + remote_nonnull_string xml; +}; +struct remote_nwfilter_define_xml_ret { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_undefine_args { + remote_nonnull_nwfilter nwfilter; +}; +struct remote_nwfilter_get_xml_desc_args { + remote_nonnull_nwfilter nwfilter; + int flags; +}; +struct remote_nwfilter_get_xml_desc_ret { + remote_nonnull_string xml; +}; +struct remote_num_of_interfaces_ret { + int num; +}; +struct remote_list_interfaces_args { + int maxnames; +}; +struct remote_list_interfaces_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_interfaces_ret { + int num; +}; +struct remote_list_defined_interfaces_args { + int maxnames; +}; +struct remote_list_defined_interfaces_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_interface_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_interface_lookup_by_name_ret { + remote_nonnull_interface iface; +}; +struct remote_interface_lookup_by_mac_string_args { + remote_nonnull_string mac; +}; +struct remote_interface_lookup_by_mac_string_ret { + remote_nonnull_interface iface; +}; +struct remote_interface_get_xml_desc_args { + remote_nonnull_interface iface; + u_int flags; +}; +struct remote_interface_get_xml_desc_ret { + remote_nonnull_string xml; +}; +struct remote_interface_define_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_interface_define_xml_ret { + remote_nonnull_interface iface; +}; +struct remote_interface_undefine_args { + remote_nonnull_interface iface; +}; +struct remote_interface_create_args { + remote_nonnull_interface iface; + u_int flags; +}; +struct remote_interface_destroy_args { + remote_nonnull_interface iface; + u_int flags; +}; +struct remote_auth_list_ret { + struct { + u_int types_len; + remote_auth_type * types_val; + } types; +}; +struct remote_auth_sasl_init_ret { + remote_nonnull_string mechlist; +}; +struct remote_auth_sasl_start_args { + remote_nonnull_string mech; + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_sasl_start_ret { + int complete; + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_sasl_step_args { + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_sasl_step_ret { + int complete; + int nil; + struct { + u_int data_len; + char * data_val; + } data; +}; +struct remote_auth_polkit_ret { + int complete; +}; +struct remote_num_of_storage_pools_ret { + int num; +}; +struct remote_list_storage_pools_args { + int maxnames; +}; +struct remote_list_storage_pools_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_num_of_defined_storage_pools_ret { + int num; +}; +struct remote_list_defined_storage_pools_args { + int maxnames; +}; +struct remote_list_defined_storage_pools_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_find_storage_pool_sources_args { + remote_nonnull_string type; + remote_string srcSpec; + u_int flags; +}; +struct remote_find_storage_pool_sources_ret { + remote_nonnull_string xml; +}; +struct remote_storage_pool_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_storage_pool_lookup_by_uuid_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_storage_pool_lookup_by_name_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_lookup_by_volume_args { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_pool_lookup_by_volume_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_create_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_storage_pool_create_xml_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_define_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_storage_pool_define_xml_ret { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_build_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_undefine_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_create_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_destroy_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_delete_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_refresh_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_dump_xml_args { + remote_nonnull_storage_pool pool; + u_int flags; +}; +struct remote_storage_pool_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_storage_pool_get_info_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_get_info_ret { + u_char state; + uint64_t capacity; + uint64_t allocation; + uint64_t available; +}; +struct remote_storage_pool_get_autostart_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_get_autostart_ret { + int autostart; +}; +struct remote_storage_pool_set_autostart_args { + remote_nonnull_storage_pool pool; + int autostart; +}; +struct remote_storage_pool_num_of_volumes_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_num_of_volumes_ret { + int num; +}; +struct remote_storage_pool_list_volumes_args { + remote_nonnull_storage_pool pool; + int maxnames; +}; +struct remote_storage_pool_list_volumes_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_storage_vol_lookup_by_name_args { + remote_nonnull_storage_pool pool; + remote_nonnull_string name; +}; +struct remote_storage_vol_lookup_by_name_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_lookup_by_key_args { + remote_nonnull_string key; +}; +struct remote_storage_vol_lookup_by_key_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_lookup_by_path_args { + remote_nonnull_string path; +}; +struct remote_storage_vol_lookup_by_path_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_create_xml_args { + remote_nonnull_storage_pool pool; + remote_nonnull_string xml; + u_int flags; +}; +struct remote_storage_vol_create_xml_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_create_xml_from_args { + remote_nonnull_storage_pool pool; + remote_nonnull_string xml; + remote_nonnull_storage_vol clonevol; + u_int flags; +}; +struct remote_storage_vol_create_xml_from_ret { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_delete_args { + remote_nonnull_storage_vol vol; + u_int flags; +}; +struct remote_storage_vol_wipe_args { + remote_nonnull_storage_vol vol; + u_int flags; +}; +struct remote_storage_vol_dump_xml_args { + remote_nonnull_storage_vol vol; + u_int flags; +}; +struct remote_storage_vol_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_storage_vol_get_info_args { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_get_info_ret { + char type; + uint64_t capacity; + uint64_t allocation; +}; +struct remote_storage_vol_get_path_args { + remote_nonnull_storage_vol vol; +}; +struct remote_storage_vol_get_path_ret { + remote_nonnull_string name; +}; +struct remote_node_num_of_devices_args { + remote_string cap; + u_int flags; +}; +struct remote_node_num_of_devices_ret { + int num; +}; +struct remote_node_list_devices_args { + remote_string cap; + int maxnames; + u_int flags; +}; +struct remote_node_list_devices_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_node_device_lookup_by_name_args { + remote_nonnull_string name; +}; +struct remote_node_device_lookup_by_name_ret { + remote_nonnull_node_device dev; +}; +struct remote_node_device_dump_xml_args { + remote_nonnull_string name; + u_int flags; +}; +struct remote_node_device_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_node_device_get_parent_args { + remote_nonnull_string name; +}; +struct remote_node_device_get_parent_ret { + remote_string parent; +}; +struct remote_node_device_num_of_caps_args { + remote_nonnull_string name; +}; +struct remote_node_device_num_of_caps_ret { + int num; +}; +struct remote_node_device_list_caps_args { + remote_nonnull_string name; + int maxnames; +}; +struct remote_node_device_list_caps_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_node_device_dettach_args { + remote_nonnull_string name; +}; +struct remote_node_device_re_attach_args { + remote_nonnull_string name; +}; +struct remote_node_device_reset_args { + remote_nonnull_string name; +}; +struct remote_node_device_create_xml_args { + remote_nonnull_string xml_desc; + int flags; +}; +struct remote_node_device_create_xml_ret { + remote_nonnull_node_device dev; +}; +struct remote_node_device_destroy_args { + remote_nonnull_string name; +}; +struct remote_domain_events_register_ret { + int cb_registered; +}; +struct remote_domain_events_deregister_ret { + int cb_registered; +}; +struct remote_domain_event_lifecycle_msg { + remote_nonnull_domain dom; + int event; + int detail; +}; +struct remote_domain_xml_from_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string nativeConfig; + u_int flags; +}; +struct remote_domain_xml_from_native_ret { + remote_nonnull_string domainXml; +}; +struct remote_domain_xml_to_native_args { + remote_nonnull_string nativeFormat; + remote_nonnull_string domainXml; + u_int flags; +}; +struct remote_domain_xml_to_native_ret { + remote_nonnull_string nativeConfig; +}; +struct remote_num_of_secrets_ret { + int num; +}; +struct remote_list_secrets_args { + int maxuuids; +}; +struct remote_list_secrets_ret { + struct { + u_int uuids_len; + remote_nonnull_string * uuids_val; + } uuids; +}; +struct remote_secret_lookup_by_uuid_args { + remote_uuid uuid; +}; +struct remote_secret_lookup_by_uuid_ret { + remote_nonnull_secret secret; +}; +struct remote_secret_define_xml_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_secret_define_xml_ret { + remote_nonnull_secret secret; +}; +struct remote_secret_get_xml_desc_args { + remote_nonnull_secret secret; + u_int flags; +}; +struct remote_secret_get_xml_desc_ret { + remote_nonnull_string xml; +}; +struct remote_secret_set_value_args { + remote_nonnull_secret secret; + struct { + u_int value_len; + char * value_val; + } value; + u_int flags; +}; +struct remote_secret_get_value_args { + remote_nonnull_secret secret; + u_int flags; +}; +struct remote_secret_get_value_ret { + struct { + u_int value_len; + char * value_val; + } value; +}; +struct remote_secret_undefine_args { + remote_nonnull_secret secret; +}; +struct remote_secret_lookup_by_usage_args { + int usageType; + remote_nonnull_string usageID; +}; +struct remote_secret_lookup_by_usage_ret { + remote_nonnull_secret secret; +}; +struct remote_domain_migrate_prepare_tunnel_args { + uint64_t flags; + remote_string dname; + uint64_t resource; + remote_nonnull_string dom_xml; +}; +struct remote_is_secure_ret { + int secure; +}; +struct remote_domain_is_active_args { + remote_nonnull_domain dom; +}; +struct remote_domain_is_active_ret { + int active; +}; +struct remote_domain_is_persistent_args { + remote_nonnull_domain dom; +}; +struct remote_domain_is_persistent_ret { + int persistent; +}; +struct remote_network_is_active_args { + remote_nonnull_network net; +}; +struct remote_network_is_active_ret { + int active; +}; +struct remote_network_is_persistent_args { + remote_nonnull_network net; +}; +struct remote_network_is_persistent_ret { + int persistent; +}; +struct remote_storage_pool_is_active_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_is_active_ret { + int active; +}; +struct remote_storage_pool_is_persistent_args { + remote_nonnull_storage_pool pool; +}; +struct remote_storage_pool_is_persistent_ret { + int persistent; +}; +struct remote_interface_is_active_args { + remote_nonnull_interface iface; +}; +struct remote_interface_is_active_ret { + int active; +}; +struct remote_cpu_compare_args { + remote_nonnull_string xml; + u_int flags; +}; +struct remote_cpu_compare_ret { + int result; +}; +struct remote_cpu_baseline_args { + struct { + u_int xmlCPUs_len; + remote_nonnull_string * xmlCPUs_val; + } xmlCPUs; + u_int flags; +}; +struct remote_cpu_baseline_ret { + remote_nonnull_string cpu; +}; +struct remote_domain_get_job_info_args { + remote_nonnull_domain dom; +}; +struct remote_domain_get_job_info_ret { + int type; + uint64_t timeElapsed; + uint64_t timeRemaining; + uint64_t dataTotal; + uint64_t dataProcessed; + uint64_t dataRemaining; + uint64_t memTotal; + uint64_t memProcessed; + uint64_t memRemaining; + uint64_t fileTotal; + uint64_t fileProcessed; + uint64_t fileRemaining; +}; +struct remote_domain_abort_job_args { + remote_nonnull_domain dom; +}; +struct remote_domain_migrate_set_max_downtime_args { + remote_nonnull_domain dom; + uint64_t downtime; + u_int flags; +}; +struct remote_domain_events_register_any_args { + int eventID; +}; +struct remote_domain_events_deregister_any_args { + int eventID; +}; +struct remote_domain_event_reboot_msg { + remote_nonnull_domain dom; +}; +struct remote_domain_event_rtc_change_msg { + remote_nonnull_domain dom; + int64_t offset; +}; +struct remote_domain_event_watchdog_msg { + remote_nonnull_domain dom; + int action; +}; +struct remote_domain_event_io_error_msg { + remote_nonnull_domain dom; + remote_nonnull_string srcPath; + remote_nonnull_string devAlias; + int action; +}; +struct remote_domain_event_io_error_reason_msg { + remote_nonnull_domain dom; + remote_nonnull_string srcPath; + remote_nonnull_string devAlias; + int action; + remote_nonnull_string reason; +}; +struct remote_domain_event_graphics_address { + int family; + remote_nonnull_string node; + remote_nonnull_string service; +}; +struct remote_domain_event_graphics_identity { + remote_nonnull_string type; + remote_nonnull_string name; +}; +struct remote_domain_event_graphics_msg { + remote_nonnull_domain dom; + int phase; + remote_domain_event_graphics_address local; + remote_domain_event_graphics_address remote; + remote_nonnull_string authScheme; + struct { + u_int subject_len; + remote_domain_event_graphics_identity * subject_val; + } subject; +}; +struct remote_domain_managed_save_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_has_managed_save_image_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_has_managed_save_image_ret { + int ret; +}; +struct remote_domain_managed_save_remove_args { + remote_nonnull_domain dom; + u_int flags; +}; +struct remote_domain_snapshot_create_xml_args { + remote_nonnull_domain domain; + remote_nonnull_string xml_desc; + int flags; +}; +struct remote_domain_snapshot_create_xml_ret { + remote_nonnull_domain_snapshot snap; +}; +struct remote_domain_snapshot_dump_xml_args { + remote_nonnull_domain_snapshot snap; + int flags; +}; +struct remote_domain_snapshot_dump_xml_ret { + remote_nonnull_string xml; +}; +struct remote_domain_snapshot_num_args { + remote_nonnull_domain domain; + int flags; +}; +struct remote_domain_snapshot_num_ret { + int num; +}; +struct remote_domain_snapshot_list_names_args { + remote_nonnull_domain domain; + int nameslen; + int flags; +}; +struct remote_domain_snapshot_list_names_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; +}; +struct remote_domain_snapshot_lookup_by_name_args { + remote_nonnull_domain domain; + remote_nonnull_string name; + int flags; +}; +struct remote_domain_snapshot_lookup_by_name_ret { + remote_nonnull_domain_snapshot snap; +}; +struct remote_domain_has_current_snapshot_args { + remote_nonnull_domain domain; + int flags; +}; +struct remote_domain_has_current_snapshot_ret { + int result; +}; +struct remote_domain_snapshot_current_args { + remote_nonnull_domain domain; + int flags; +}; +struct remote_domain_snapshot_current_ret { + remote_nonnull_domain_snapshot snap; +}; +struct remote_domain_revert_to_snapshot_args { + remote_nonnull_domain_snapshot snap; + int flags; +}; +struct remote_domain_snapshot_delete_args { + remote_nonnull_domain_snapshot snap; + int flags; +}; +struct remote_message_header { + u_int prog; + u_int vers; + remote_procedure proc; + remote_message_type type; + u_int serial; + remote_message_status status; +}; -- 1.7.1.166.gf2086

Jim Meyering wrote:
Jim Meyering wrote:
Eric Blake wrote: ... remote/remote_protocol.c \ remote/remote_protocol.h
+EXTRA_DIST += remote_protocol-structs +check-local: remote_protocol-structs +.PHONY: remote_protocol-structs +remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ + pdwtags libvirt_driver_remote_la-remote_protocol.$(OBJEXT) \ + | perl -0777 -n \ + -e 'foreach my $$p (split m!\n\n/\* \d+ \*/\n!)' \ + -e ' { if ($$p =~ /^struct remote_/) {' \ + -e ' $$p =~ s!\t*/\*.*?\*/!!sg;' \ + -e ' $$p =~ s!\s+\n!\n!sg;' \ + -e ' $$p =~ s!\s+$$!!;' \ + -e ' print "$$p\n" } }' \ + > $@-t; \ + diff -u $@-t $@; st=$$?; rm -f $@-t; exit $$st; \ + else \ + echo 'WARNING: you lack pdwtags; skipping the $@ test'; \ + fi + EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl
# Mock driver, covering domains, storage, networks, etc diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs new file mode 100644 index 0000000..c8f81f3
Here's an incremental change that adds comments, moves the EXTRA_DIST assignment for remote_protocol.x "up" to be nearer the related code, and changes the new check to mention the name of the "dwarves" package with the skip warning.
diff --git a/src/Makefile.am b/src/Makefile.am index 1c92460..fe33cea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -155,8 +155,18 @@ REMOTE_DRIVER_SOURCES = \ remote/remote_protocol.c \ remote/remote_protocol.h
-EXTRA_DIST += remote_protocol-structs -check-local: remote_protocol-structs +EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl + +# Ensure that we don't change the struct or member names or member ordering +# in remote_protocol.x The embedded perl below needs a few comments, and +# presumes you know what pdwtags output looks like: +# * use -0777 -n to slurp the entire file into $_. +# * the "split" splits on the /* DD */ comments, so that $p iterates +# through the struct definitions. +# * process only "struct remote_..." entries +# * remove comments and preceding TAB throughout +# * remove empty lines throughout +# * remove white space at end of buffer .PHONY: remote_protocol-structs remote_protocol-structs: $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ @@ -172,9 +182,10 @@ remote_protocol-structs: diff -u $@-t $@; st=$$?; rm -f $@-t; exit $$st; \ else \ echo 'WARNING: you lack pdwtags; skipping the $@ test'; \ + echo 'WARNING: install the dwarves package to get pdwtags'; \ fi - -EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl +EXTRA_DIST += remote_protocol-structs +check-local: remote_protocol-structs
# Mock driver, covering domains, storage, networks, etc TEST_DRIVER_SOURCES = \
--------------------------- In case it helps, here's the full, amended patch:
From 180d4b2b3b79c768f4a6444181d7f021771fab66 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Fri, 7 May 2010 16:01:26 +0200 Subject: [PATCH] help avoid accidental remote_protocol.x changes
Daniel Veillard ACK'd this privately, so I've pushed it.

On 05/07/2010 03:23 PM, Jim Meyering wrote:
+remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \
Some shells (at least Solaris /bin/sh) are noisy in spite of the redirections, when a program doesn't exist. I'm proposing a followup patch to clean up this invocation to use a subshell, and also to fix the subshell for cppi in cfg.mk. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Some shells warn about missing programs before redirection; the idiomatic way to silence them is to run the program check inside a subshell, with the redirections outside the subshell. * cfg.mk (sc_preprocessor_indentation): Use correct subshell. * src/Makefile.am (remote_protocol-structs): Use subshell. --- cfg.mk | 2 +- src/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cfg.mk b/cfg.mk index d1f8485..fbc0433 100644 --- a/cfg.mk +++ b/cfg.mk @@ -252,7 +252,7 @@ sc_prohibit_trailing_blank_lines: preprocessor_exempt = (remote_(driver|protocol)\.h)$$ # Enforce recommended preprocessor indentation style. sc_preprocessor_indentation: - @if (cppi --version >/dev/null 2>&1); then \ + @if (cppi --version) >/dev/null 2>&1; then \ $(VC_LIST_EXCEPT) | grep '\.[ch]$$' \ | grep -vE '$(preprocessor_exempt)' | xargs cppi -a -c \ || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \ diff --git a/src/Makefile.am b/src/Makefile.am index fe33cea..1542ab1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -169,7 +169,7 @@ EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl # * remove white space at end of buffer .PHONY: remote_protocol-structs remote_protocol-structs: - $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ + $(AM_V_GEN)if (pdwtags --help) > /dev/null 2>&1; then \ pdwtags libvirt_driver_remote_la-remote_protocol.$(OBJEXT) \ | perl -0777 -n \ -e 'foreach my $$p (split m!\n\n/\* \d+ \*/\n!)' \ -- 1.7.0.1

On 05/10/2010 02:19 PM, Eric Blake wrote:
Some shells warn about missing programs before redirection; the idiomatic way to silence them is to run the program check inside a subshell, with the redirections outside the subshell.
+++ b/cfg.mk @@ -252,7 +252,7 @@ sc_prohibit_trailing_blank_lines: preprocessor_exempt = (remote_(driver|protocol)\.h)$$ # Enforce recommended preprocessor indentation style. sc_preprocessor_indentation: - @if (cppi --version >/dev/null 2>&1); then \ + @if (cppi --version) >/dev/null 2>&1; then \
Offlist, Jim reminded me that cfg.mk is only for developers with nice environments, where we shouldn't need the subshell at all...
$(VC_LIST_EXCEPT) | grep '\.[ch]$$' \ | grep -vE '$(preprocessor_exempt)' | xargs cppi -a -c \ || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \ diff --git a/src/Makefile.am b/src/Makefile.am index fe33cea..1542ab1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -169,7 +169,7 @@ EXTRA_DIST += remote/remote_protocol.x remote/rpcgen_fix.pl # * remove white space at end of buffer .PHONY: remote_protocol-structs remote_protocol-structs: - $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \ + $(AM_V_GEN)if (pdwtags --help) > /dev/null 2>&1; then \
But here, not only is Solaris /bin/sh noisy (which we are starting to care less about these days, because it is so crufty), but so is FreeBSD 8.0 /bin/sh, which is a lot newer. And since it appears as part of the user's Makefile, rather than development-specific, it should be silent. Given that analysis, Jim gave the off-list ACK. So I've kept the second hunk as-is, modified the first to drop the subshell altogether, and pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
On 05/07/2010 03:23 PM, Jim Meyering wrote:
+remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \
Some shells (at least Solaris /bin/sh) are noisy in spite of the redirections, when a program doesn't exist. I'm proposing a followup patch to clean up this invocation to use a subshell, and also to fix the subshell for cppi in cfg.mk.
Or you could consider the noise a two-pronged feature: - notify user that their $(SHELL) is inferior - more noise about lack of a useful developer tool (pdwtags or cppi)

On 05/10/2010 02:36 PM, Jim Meyering wrote:
Eric Blake wrote:
On 05/07/2010 03:23 PM, Jim Meyering wrote:
+remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \
Some shells (at least Solaris /bin/sh) are noisy in spite of the redirections, when a program doesn't exist. I'm proposing a followup patch to clean up this invocation to use a subshell, and also to fix the subshell for cppi in cfg.mk.
Or you could consider the noise a two-pronged feature: - notify user that their $(SHELL) is inferior - more noise about lack of a useful developer tool (pdwtags or cppi)
In which case, your pdwtags usage is fine, and I should modify my patch to just drop the cppi subshell altogether? -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote:
On 05/10/2010 02:36 PM, Jim Meyering wrote:
Eric Blake wrote:
On 05/07/2010 03:23 PM, Jim Meyering wrote:
+remote_protocol-structs: + $(AM_V_GEN)if pdwtags --help > /dev/null 2>&1; then \
Some shells (at least Solaris /bin/sh) are noisy in spite of the redirections, when a program doesn't exist. I'm proposing a followup patch to clean up this invocation to use a subshell, and also to fix the subshell for cppi in cfg.mk.
Or you could consider the noise a two-pronged feature:
That was semi-tongue-in-cheek.
- notify user that their $(SHELL) is inferior - more noise about lack of a useful developer tool (pdwtags or cppi)
In which case, your pdwtags usage is fine, and I should modify my patch to just drop the cppi subshell altogether?
"make syntax-check" (via maint.mk, cfg.mk etc) already relies on shell features not available in Solaris' /bin/sh (e.g., $(command)) so dropping the cppi subshell would be fine. It is important for readability (and my mental health ;-) to assume a good POSIX shell for those rules, and that is fine, since only "developers" run "make syntax-check", and we can require that they run "make" with SHELL=/usr/local/bin/bash in a pinch. pdwtags, however, is used as part of a rule run by "make check", which is nominally subject to a higher standard. I was going to say it *could* use a subshell, but then found that there are uses of $(command) in "regular" makefiles, too: $ git grep '\$\$(' cfg.mk: '\<$(func_re) *\([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \ ... cfg.mk: stamp="$$($(_submodule_hash) $(_curr_status) 2>/dev/null)"; \ docs/Makefile.am: rm $(DESTDIR)$(DEVHELP_DIR)/$$(basename $$f); \ src/Makefile.am: $$(echo '$(libvirt_la_LDFLAGS)' \ Those last two would provoke syntax errors when building with Solaris' /bin/sh, ... So perhaps we really can just forget about those draconian Solaris /bin/sh portability restrictions, at least here in libvirt.

On Thu, May 06, 2010 at 04:09:25PM -0600, Eric Blake wrote:
On 05/06/2010 12:35 PM, Jim Meyering wrote:
This week we noticed that a change to struct remote_error was causing trouble (new member addition changed the size of the object being decoded -- bad for the protocol).
In order to ensure that no such changes sneak in again, I'm planning to do the following.
pdwtags src/libvirt_driver_remote_la-remote_protocol.o
prints, among other things, detailed type info for every struct:
/* 89 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 8 */ remote_uuid uuid; /* 8 16 */ int id; /* 24 4 */
/* size: 32, cachelines: 1, members: 3 */ /* last cacheline: 32 bytes */
/* BRAIN FART ALERT! 32 != 28 + 0(holes), diff = 4 */
}; /* size: 32 */
Ouch. Architecture sizing plays a role. On a 32-bit machine, the first struct is:
/* 86 */ struct remote_nonnull_domain { remote_nonnull_string name; /* 0 4 */ remote_uuid uuid; /* 4 16 */ int id; /* 20 4 */
/* size: 24, cachelines: 1, members: 3 */ /* last cacheline: 24 bytes */ }; /* size: 24 */
Are we sure migration between 32-bit and 64-bit hypervisors works? And if it does, then these structs don't quite match what is actually sent over the wire. At any rate,
Yes, the XDR protocol encoding is architecture + wordsize independant. The struct sizes won't match what is sent on the wire, and the latter is the thing we actually need to verify. Perhaps marking all structs with __attribute__((packed)) will make then architecture invariant enough for checking of the struct to suffice. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On 05/07/2010 04:14 AM, Daniel P. Berrange wrote:
Are we sure migration between 32-bit and 64-bit hypervisors works? And if it does, then these structs don't quite match what is actually sent over the wire. At any rate,
Yes, the XDR protocol encoding is architecture + wordsize independant. The struct sizes won't match what is sent on the wire, and the latter is the thing we actually need to verify.
Perhaps marking all structs with __attribute__((packed)) will make then architecture invariant enough for checking of the struct to suffice.
No, __attribute__((packed)) won't help; the fundamental difference is that pointers change from 4 bytes to 8 bytes between the two platforms, whether or not you also pack out the extra holes when passing things like uint8_t. But Jim's suggestion of just normalizing field names and types is reasonable, since the whole point of the .x file is that names and types are enough to generate the code that does the conversion from struct to on-the-wire format. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Jim Meyering