kvm tool: add QCOW verions 1 read/write support
PATCH 1/1 kvm tool: add QCOW verions 1 read/write support
The patch only implements the basic read write support for QCOW version 1 images. Many of the QCOW features are not implmented, for example
- image creation
- snapshot
- copy-on-write
- encryption
Renamed the file CREDITS-Git to CREDITS and added QEMU credits to CREDITS file.
--- tools/kvm/CREDITS | 46 +++++ tools/kvm/Makefile | 2 + tools/kvm/disk-image.c | 7 + tools/kvm/include/kvm/qcow.h | 55 ++++++ tools/kvm/include/linux/byteorder.h | 7 + tools/kvm/include/linux/types.h | 19 ++ tools/kvm/qcow.c | 123 +++++++++++++ tools/kvm/qcow1.c | 325 +++++++++++++++++++++++++++++++++++ 8 files changed, 584 insertions(+), 0 deletions(-) create mode 100644 tools/kvm/CREDITS create mode 100644 tools/kvm/include/kvm/qcow.h create mode 100644 tools/kvm/include/linux/byteorder.h create mode 100644 tools/kvm/qcow.c create mode 100644 tools/kvm/qcow1.c
tools/kvm/CREDITS new file +46 -0
@@ -0,0 +1,46 @@ +Perf/Git: +Most of the infrastructure that 'perf' uses here has been reused +from the Git project, as of version: + + 66996ec: Sync with 1.6.2.4 + +Here is an (incomplete!) list of main contributors to those files +in util/* and elsewhere: + + Alex Riesen + Christian Couder + Dmitry Potapov + Jeff King + Johannes Schindelin + Johannes Sixt + Junio C Hamano + Linus Torvalds + Matthias Kestenholz + Michal Ostrowski + Miklos Vajna + Petr Baudis + Pierre Habouzit + René Scharfe + Samuel Tardieu + Shawn O. Pearce + Steffen Prohaska + Steve Haslam + +Thanks guys! + +The full history of the files can be found in the upstream Git commits. + + +QEMU +The source code of the QEMU was referenced while developing the QCOW support +for the kvm tool. The relevant QEMU commits were + +66f82ce block: Open the underlying image file in generic code +ea2384d new disk image layer + +Here is a possibly incomplete list of main contributors + Kevin Wolf <[email protected]> + Fabrice Bellard + Stefan Hajnoczi <[email protected]> + +Thanks a lot all!
tools/kvm/Makefile +2 -0
@@ -34,6 +34,8 @@ OBJS += util/strbuf.o OBJS += kvm-help.o OBJS += kvm-cmd.o OBJS += kvm-run.o +OBJS += qcow.o +OBJS += qcow1.o DEPS := $(patsubst %.o,%.d,$(OBJS))
tools/kvm/disk-image.c +7 -0
@@ -13,6 +13,9 @@#include <unistd.h> #include <fcntl.h> +#include <linux/types.h> +#include <kvm/qcow.h> +struct disk_image *disk_image__new (int fd,uint64_t size,struct disk_image_operations *ops) {struct disk_image *self;
@@ -124,6 +127,10 @@ struct disk_image *disk_image__open(const char *filename, bool readonly)if (fd <0 )return NULL ; + self =qcow_probe (fd); +if (self) +return self; + self =raw_image__probe (fd, readonly);if (self)return self;
tools/kvm/include/kvm/qcow.h new file +55 -0
55 lines not on this page · raw message
tools/kvm/include/linux/byteorder.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __BYTE_ORDER_H__ +#define __BYTE_ORDER_H__ + +#include <asm/byteorder.h> +#include <linux/byteorder/generic.h> + +#endif
tools/kvm/include/linux/types.h +19 -0
@@ -27,4 +27,23 @@ typedef __s16 s16;typedef __u8 u8 ;typedef __s8 s8 ; +#ifdef __CHECKER__ +#define __bitwise__ __attribute__((bitwise)) +#else +#define __bitwise__ +#endif +#ifdef __CHECK_ENDIAN__ +#define __bitwise __bitwise__ +#else +#define __bitwise +#endif + + +typedef __u16 __bitwise __le16 ; +typedef __u16 __bitwise __be16 ; +typedef __u32 __bitwise __le32 ; +typedef __u32 __bitwise __be32 ; +typedef __u64 __bitwise __le64 ; +typedef __u64 __bitwise __be64 ; +#endif /* LINUX_TYPES_H */
tools/kvm/qcow.c new file +123 -0
123 lines not on this page · raw message
tools/kvm/qcow1.c new file +325 -0
325 lines not on this page · raw message
Signature · 1 line
1.7.1
Quoted 16 lines · Prasad Joshi
tools/kvm/qcow.c new file +13
-0@@ -0,0 +1,123 @@ +/* +* This file contains code copied from QEMU source code +* +* Copyright (c) 2004-2006 Fabrice Bellard +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in
tools/kvm/qcow.c line 23
Quoted 10 lines
tools/kvm/qcow.c new file +10
-0+* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/
Heh, almost there. Lets just drop these from the individual files now that we have attributions in CREDITS. Now you get the impression that the files are directly taken from QEMU which is not the case at all.
Pekka
Quoted 2 lines · Prasad Joshi
The patch only implements the basic read write support for QCOW version 1 images. Many of the QCOW features are not implmented, for example
What's the point? Qcow1 has been deprecated for a long time.
Hi Christoph,
Quoted 2 lines · Prasad Joshi
Quoted 2 lines
The patch only implements the basic read write support for QCOW version 1 images. Many of the QCOW features are not implmented, for example
Quoted 1 line · Christoph Hellwig
What's the point? Qcow1 has been deprecated for a long time.
We're going to add QCOW2 too. Do you think there's no value in supporting QCOW1 and we should drop it completely? I have no objections in being QCOW2-only.
Pekka
Am 15.04.2011 08:24, schrieb Pekka Enberg:
Quoted 6 lines
Hi Christoph,
Quoted 2 lines · Prasad Joshi
Quoted 2 lines
The patch only implements the basic read write support for QCOW version 1 images. Many of the QCOW features are not implmented, for example
Quoted 6 lines
Quoted 1 line · Christoph Hellwig
What's the point? Qcow1 has been deprecated for a long time.
We're going to add QCOW2 too. Do you think there's no value in supporting QCOW1 and we should drop it completely? I have no objections in being QCOW2-only.
We're not going to remove it from qemu soon, but the main point for keeping it is conversion of old qcow1 images to current formats.
Kevin
Quoted 6 lines · Pekka Enberg
Hi Christoph,
Quoted 2 lines · Prasad Joshi
Quoted 2 lines
The patch only implements the basic read write support for QCOW version 1 images. Many of the QCOW features are not implmented, for example
Quoted 6 lines
Quoted 1 line · Christoph Hellwig
What's the point? Qcow1 has been deprecated for a long time.
We're going to add QCOW2 too. Do you think there's no value in supporting QCOW1 and we should drop it completely? I have no objections in being QCOW2-only.
I'm curious about that too. Christoph?
Thanks,
Ingo