|
From: | Chun Yan Liu |
Subject: | Re: [Qemu-devel] [PATCH] Add -f option to qemu-nbd |
Date: | Thu, 17 Nov 2011 04:34:12 -0700 |
Thanks for your suggestions. For the usage "qemu-nbd -f disk.img", adding some code could implement it. I think it could be like "losetup -f" usage. #qemu-nbd -f show the first free nbd device at this moment. user can choose to issue "qemu-nbd -c THAT_DEVICE disk.img" or not. #qemu-nbd -f disk.img find a free nbd device and connect disk.img to that device. How do you think? For the race conditions caused by executing multiple qemu-nbd -f at the same time, I've tried both ways (1. lock; 2. if one device not work, trying other devices until one works). In my testing, the 2nd way has problem. When issuing "qemu-nbd -c /dev/nbd0 disk.img -v" and "qemu-nbd -c /dev/nbd0 disk1.img -v" at the same time, the latter one will eventually exit with EXIT_FAILURE, but the first one cannot work normally as well, it cannot show disk partitions. Executing multiple "qemu-nbd -f" has same problem. So, it seems using lock from a earlier time is more proper. In my testing, I'm using file lock (fcntl). For "qemu-nbd -c" case, if lock failed, qemu-nbd exits directly. For "qemu-nbd -f" case, if lock failed, redo find_free_nbd_device (there might be updates) and then try to connectdisk.img to the new free device. Will post V2 soon.
|
[Prev in Thread] | Current Thread | [Next in Thread] |