From: Ian Campbell Subject: Re: xl create PV guest with qcow/qcow2 disk images fail Date: Wed, 9 Nov 2011 09:36:10 +0000 Message-ID: <1320831370.955.114.camel@zakaz.uk.xensource.com> References: <1319808450-9617-1-git-send-email-cyliu@suse.com> <4EB184DE020000660000603E@novprvlin0050.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , Chunyan Liu List-Id: xen-devel@lists.xenproject.org On Wed, 2011-11-09 at 09:27 +0000, Stefano Stabellini wrote: > On Wed, 9 Nov 2011, Chunyan Liu wrote: > > In a following email you wrote that without the sleep the device is > > "not prepared yet". > > What do you mean by that? > > The device is present but reading/writing to it returns an error? > > > > If so, rather than a sleep we need an explicit wait for the device > > to be ready. Even trying to read from the device in a loop until it > > succeeds would be better than a sleep. At least we would know exactly > > what we are doing and why we are doing it. > > > > > > OK, after checking qemu-nbd source code, I think I know where the problem is. I tried to fork_exec "qemu-nbd -c /dev/nbd0 > > disk.img", with this command option, qemu-nbd will call daemon(3) to run in background and itself should exit immediately, > > that's why waitpid can successfully wait the exit of qemu-nbd pid and fork_exec will return 0. The problem is that I > > should not use fork_exec return value to decide if the disk.img is already connected to nbd device. That's not correct. > > Good. > > > > This is not great. I would read /proc/partitions instead. > > > > Thanks, that's a better way to find if a nbd device is free. The whole thing (find a free nbd device and connect disk.img > > to that nbd device) seems better to write a script to do that and in libxl call that script. Really this is the sort of thing qemu-nbd should do for us (c.f. "losetup -f"). I think it would be worth getting such a patch upstream even if we can't yet make use of it. Ian. > > Maybe, but I think it makes sense for it to be in libxl and after all > reading/writing a file can be done quite well in a library too. > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel