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

Jim Meyering jim at meyering.net
Mon May 10 19:35:59 UTC 2010


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 at 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.




More information about the libvir-list mailing list