Received: from eggs.gnu.org ([2001:4830:134:3::10]:43484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un2vi-0006w0-DM for qemu-devel@nongnu.org; Thu, 13 Jun 2013 04:30:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Un2vg-0008Iy-5k for qemu-devel@nongnu.org; Thu, 13 Jun 2013 04:30:50 -0400 Received: from mail-we0-x232.google.com ([2a00:1450:400c:c03::232]:46804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Un2vf-0008Ii-Rd for qemu-devel@nongnu.org; Thu, 13 Jun 2013 04:30:48 -0400 Received: by mail-we0-f178.google.com with SMTP id u53so7554489wes.23 for ; Thu, 13 Jun 2013 01:30:47 -0700 (PDT) Date: Thu, 13 Jun 2013 10:30:44 +0200 From: Stefan Hajnoczi Message-ID: <20130613083044.GB2633@stefanha-thinkpad.redhat.com> References: <1370674687-13849-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1370674687-13849-6-git-send-email-xiawenc@linux.vnet.ibm.com> <20130611091405.GF18312@stefanha-thinkpad.redhat.com> <51B959A9.1080709@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <51B959A9.1080709@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH 05/11] snapshot: add paired functions for internal snapshot id and name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, phrdina@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com On Thu, Jun 13, 2013 at 01:33:29PM +0800, Wenchao Xia wrote: > 于 2013-6-11 17:14, Stefan Hajnoczi 写道: > >On Sat, Jun 08, 2013 at 02:58:01PM +0800, Wenchao Xia wrote: > >>+ > >>+/* Following function generate id string, used by block driver, such as qcow2. > >>+ Since no better place to go, place the funtion here for now. */ > >>+void snapshot_id_string_generate(int id, char *id_str, int id_str_size) > >>+{ > >>+ snprintf(id_str, id_str_size, "%d", id); > >>+} > > > >Since the caller has to manage id, this function doesn't really abstract > >anything. I would keep the snprintf() inline, there's only one caller. > > > Its purpose is move the id rules from one implemention(qcow2) into > generic. If not, it would be a question why snapshot_name_wellformed() > could make sure name not conflict with ID, then reader find the answer > in qcow2... > I think at least a document is needed about how should implemention > under ./block generate snapshot ID. I see your point. Maybe keep the function. I was not sure because the caller still has the int id and has to increment it. Therefore it doesn't fully handle id generation. Stefan