From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JIQJu-00019o-9d for qemu-devel@nongnu.org; Fri, 25 Jan 2008 10:18:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JIQJs-00019J-Qg for qemu-devel@nongnu.org; Fri, 25 Jan 2008 10:18:17 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JIQJs-00019D-He for qemu-devel@nongnu.org; Fri, 25 Jan 2008 10:18:16 -0500 Received: from rv-out-0910.google.com ([209.85.198.191]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JIQJs-0006gN-4A for qemu-devel@nongnu.org; Fri, 25 Jan 2008 10:18:16 -0500 Received: by rv-out-0910.google.com with SMTP id g11so1596251rvb.22 for ; Fri, 25 Jan 2008 07:18:11 -0800 (PST) Message-ID: <4799FDBE.6030502@codemonkey.ws> Date: Fri, 25 Jan 2008 09:18:22 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH][RFC] To mount qemu disk image on the host References: <1201264245.4114.42.camel@frecb07144> In-Reply-To: <1201264245.4114.42.camel@frecb07144> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Laurent Vivier wrote: > Hi, > > this patch allows to mount qemu disk images on the host. > Note, the general problem with this approach is that mounting a NBD device locally with write access can lead to dead locks. If you look through the mailing list archives, you'll find a number of conversations on the topic. Regards, Anthony Liguori > It is based on the Network Block Device protocol and allows qemu-img to > become an NBD server (Yes, Anthony, userspace block device is the right > way to do that... :-P ). > > Once you've applied the attached patch to Qemu and build the binaries, > you can use it like that: > > # ./qemu-img server -d 1234 etch.qcow2 > > This starts an NBD server on port 1234. This server will expose > the disk image etch.qcow2. "-d" means it will be daemonize and will run > in background. > > Then you need to connect the block device to the server: > > # nbd-client localhost 1234 /dev/nbd0 > Negotiation: ..size = 4194304KB > bs=1024, sz=4194304 > > This will link etch.qcow2 to /dev/nbd0. > > Then to see partitions, you can use kpartx, as explained Daniel, or my > patched loop modules (I can send an updated and bug free version). > ... > # kpartx -a /dev/nbd0 > ... > or > ... > # rmmod loop > # insmod drivers/block/loop.ko max_part=64 > # losetup -f /dev/nbd0 > ... > # mount /dev/loop0p1 /mnt > # ls /mnt > bench cdrom etc initrd.img media proc selinux tmp vmlinuz > bin clients home lib mnt root srv usr > boot dev initrd lost+found opt sbin sys var > # cd > # umount /mnt > # losetup -d /dev/loop0 > # nbd-client -d /dev/nbd0 > > TODO: security/host client checking, device lock... > > As usual all comments are welcome, > have fun, > Laurent >