2011/12/6 Paolo Bonzini <pbonz...@redhat.com> > 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).
Well, it's not "had to be redone", did it just to avoid passing too many parameters to nbd_setup. (otherwise, should pass "bs, dev_offset and fd_size to nbd_setup.) Can be moved out. > 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 > Nope. When device changes, both client thread and server thread should be refreshed. sockpath and sharing_fds[] is changed with different device. > - 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 > >