On 11/18/2011 06:32 AM, Stefan Berger wrote: > Use scripts for the renaming and cleaning up of chains. This allows us to get > rid of some of the code that is only capable of renaming and removing chains > whose names are hardcoded. > > +static const char ebtables_script_func_collect_chains[] = > + "collect_chains()\n" > + "{\n" > + " for tmp2 in $*; do\n" > + " for tmp in $(%s -t %s -L $tmp2 | \\\n" > + " sed -n \"/Bridge chain/,\\$ s/.*-j \\\\([%s]-.*\\\\)/\\\\1/p\");\n" No need to change this unless you want, but this could be written in fewer bytes as: " sed -n '/Bridge chain/,$ s/.*-j \\([%s]-.*\\)/\\1/p')\n" > + virBufferAsprintf(buf, NWFILTER_FUNC_SET_IFS); > + virBufferAddLit(buf, "a=\"$(collect_chains "); > + for (i = 0; chains[i] != 0; i++) { > + PRINT_ROOT_CHAIN(rootchain, chains[i], ifname); > + virBufferAsprintf(buf, "%s ", rootchain); > + } > + virBufferAddLit(buf, ")\"\n"); As written, you generate: a="$(collect_chains a b )" with an odd space before ). I also think the name $a is rather terse; it might be better to use something a bit less cryptic. What you have works, but you could also make this tweak if you'd like: virBufferAddLit(buf, "chains=\"$(collect_chains"); for ... virBufferAsprintf(buf, " %s", rootchain); virBufferAddLit(buf, ")\"\n"); ... virBufferAddLit(buf, "rm_chains $chains\n"); -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list