From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWJMZ-00006Y-Ho for qemu-devel@nongnu.org; Thu, 18 Feb 2016 02:51:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWJMV-0004sG-Up for qemu-devel@nongnu.org; Thu, 18 Feb 2016 02:50:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWJMV-0004rz-NQ for qemu-devel@nongnu.org; Thu, 18 Feb 2016 02:50:55 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 44D1EC00071A for ; Thu, 18 Feb 2016 07:50:55 +0000 (UTC) Date: Thu, 18 Feb 2016 15:50:38 +0800 From: Peter Xu Message-ID: <20160218075038.GF5411@pxdev.xzpeter.org> References: <1455772616-8668-1-git-send-email-peterx@redhat.com> <87a8mymqbv.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87a8mymqbv.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] [PATCH v7 00/11] Add basic "detach" support for dump-guest-memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: drjones@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, lersek@redhat.com On Thu, Feb 18, 2016 at 08:26:44AM +0100, Markus Armbruster wrote: > Peter Xu writes: > > > Changes from v7: > > - patch 8: use s->dump_info.page_size not TARGET_PAGE_SIZE > > - patch 10: change DUMP_STATUS_MAX to DUMP_STATUS__MAX (this is to > > fix compile error for rebasing to latest master branch, still do > > not know why we need this change from generating "_MAX" to > > "__MAX" for enum types...) > > Don't ask yourself why something was done, ask git :) Sorry for my laziness... But it seems that it luckily brings me another "-S" git trick. Lots of things to learn. :-) > > $ git-log -S__MAX > [...] > commit 7fb1cf1606c78c9d5b538f29176fd5a101726a9d > Author: Eric Blake > Date: Wed Nov 18 01:52:57 2015 -0700 > > ---> qapi: Don't let implicit enum MAX member collide > > Now that we guarantee the user doesn't have any enum values > beginning with a single underscore, we can use that for our > own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious > that the sentinel is generated. > > This patch was mostly generated by applying a temporary patch: > > |diff --git a/scripts/qapi.py b/scripts/qapi.py > |index e6d014b..b862ec9 100644 > |--- a/scripts/qapi.py > |+++ b/scripts/qapi.py > |@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] = { > | max_index = c_enum_const(name, 'MAX', prefix) > | ret += mcgen(''' > | [%(max_index)s] = NULL, > |+// %(max_index)s > | }; > | ''', > | max_index=max_index) > > then running: > > $ cat qapi-{types,event}.c tests/test-qapi-types.c | > sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list > $ git grep -l _MAX | xargs sed -i -f list > > The only things not generated are the changes in scripts/qapi.py. > > Rejecting enum members named 'MAX' is now useless, and will be dropped > in the next patch. > > Signed-off-by: Eric Blake > Message-Id: <1447836791-369-23-git-send-email-eblake@redhat.com> > Reviewed-by: Juan Quintela > [Rebased to current master, commit message tweaked] > Signed-off-by: Markus Armbruster > > I guess this isn't perfectly clear without more context, so let me add > some. > > The implicit FOO_MAX could collide with the user's FOO_MAX for QAPI > enumeration values 'max', or case variations thereof. Commit cf39359 > added extra code to catch that. > > Renaming the implict FOO_MAX to FOO__MAX removes the need for the > special rule "you can't use 'max' as an enumeration value", because the > general rule "names starting with '_' are reserved" suffices then. > > Fewer rules is better. Yah. The commit is reasonable and explanation is clear. Thanks! Peter > > [...]