From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:32768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj6ZF-00066x-KJ for qemu-devel@nongnu.org; Tue, 19 Jul 2011 05:26:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qj6ZE-0003uR-GC for qemu-devel@nongnu.org; Tue, 19 Jul 2011 05:26:17 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:47761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qj6ZD-0003rp-LR for qemu-devel@nongnu.org; Tue, 19 Jul 2011 05:26:16 -0400 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by e28smtp06.in.ibm.com (8.14.4/8.13.1) with ESMTP id p6J9PlHM028990 for ; Tue, 19 Jul 2011 14:55:47 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6J9Ph8B2150406 for ; Tue, 19 Jul 2011 14:55:45 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6J9Phps008180 for ; Tue, 19 Jul 2011 14:55:43 +0530 Message-ID: <4E254D8E.6000601@linux.vnet.ibm.com> Date: Tue, 19 Jul 2011 17:25:34 +0800 From: Robert Wang MIME-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] External COW format for raw images List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Marcelo Tosatti , Stefan Hajnoczi , Ming M Shu As you known, raw image is very popular,but the raw image format does NOT support Copy-On-Write,a raw image file can NOT be used as a copy destination, then image streaming/Live Block Copy will NOT work. To fix this, we need to add a new block driver raw-cow to QEMU. If finished, we can use qemu-img like this: qemu-img create -f raw-cow -o backing_file=ubuntu.img,raw_file=my_vm.img my_vm.raw-cow 1) ubuntu.img is the backing file, my_vm.img is a raw file, my_vm.raw-cow stores a COW bitmap related to my_vm.img. 2) If the entire COW bitmap is set to dirty flag then we can get all information from my_vm.img and can ignore ubuntu.img and my_vm.raw-cow from now. To implement this, I think I can follow these steps: 1) Add a new member to BlockDriverState struct: char raw_file[1024]; This member will track raw_file parameter related to raw-cow file from command line. 2) * Create a new file block/raw-cow.c. It will be much more like the mixture of block/cow.c and block/raw.c. So I will change some functions in cow.c and raw.c to none-static, then raw-cow.c can re-use them. When read operation occurs, determine whether dirty flag in raw-cow image is set. If true, read directly from the raw file. After write operation, set related dirty flag in raw-cow image. And other functions might also be modified. * Of course, format_name member of BlockDriver struct will be "raw-cow". And in order to keep relationship with raw file( like my_vm.img) , raw_cow_header struct should be struct raw_cow_header { uint32_t magic; uint32_t version; char backing_file[1024]; char raw_file[1024];/* added*/ int32_t mtime; uint64_t size; uint32_t sectorsize; }; * Struct raw_cow_create_options should be one member plus based on cow_create_options: { .name = BLOCK_OPT_RAW_FILE, .type = OPT_STRING, .help = "Raw file name" }, 3) Add bdrv_get_raw_filename in img_info function of qemu-img.c. In bdrv_get_raw_filename, if the format of the image file is "raw-cow", print the related raw file. Do you think my approach is right? Thank you.