From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXpwZ-0004CT-VM for qemu-devel@nongnu.org; Tue, 06 Dec 2011 03:00:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXpwZ-0006oP-1h for qemu-devel@nongnu.org; Tue, 06 Dec 2011 03:00:03 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:54876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXpwY-0006nU-SK for qemu-devel@nongnu.org; Tue, 06 Dec 2011 03:00:03 -0500 Received: by iakk32 with SMTP id k32so11401381iak.4 for ; Tue, 06 Dec 2011 00:00:02 -0800 (PST) Sender: Paolo Bonzini Message-ID: <4EDDCB7B.3060300@redhat.com> Date: Tue, 06 Dec 2011 08:59:55 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1322839676-7559-1-git-send-email-cyliu@suse.com> <1322839676-7559-2-git-send-email-cyliu@suse.com> <4ED8FDA7.3090901@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 2/3] Extract code to nbd_setup function to be used for many purposes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chunyan Liu Cc: Stefan Hajnoczi , qemu-devel@nongnu.org On 12/06/2011 07:56 AM, Chunyan Liu wrote: > > Currently, the nbd_setup needs parameters: device, srcpath, flags, > partition, dev_offset, nbdflags, sockpath, bindto, port, shared, > persistent, verbose, sigterm_rfd. More than 10 parameters. I still > didn't find a better way to reduce parameters. Making variables global > is a workaround to avoid nbd_setup taking too many parameters. Actually, > except for sigterm_rfd, all others are pared from command line options. Reading again this patch, I am not sure why you are doing it this way. There is no reason why bdrv_new/open/delete has to be redone for every /dev/nbdX we try (or if there is a reason, _that_ is what should be fixed first). Also the "tail" of nbd_setup, basically the select loop, should not be tried multiple times. I do not understand why you cannot simply do it like this: - in the server thread, do everything as it is now - pass "device" to the client thread instead of opening it in main() - in the client thread, either use "device" as it is or (if device == NULL, which implies find == 1) loop until nbd_init succeeds. Am I just confused? Paolo