Skip to contentSkip to conversation

new block layer

Qemu-devel Fabrice Bellard 4 participants 5 messages Aug 3, 2004 – Aug 10, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi,

I commited the new disk image layer of QEMU which adds the following features:

- new disk image formats are easier to support

- new 'qcow' image format which supports:
* empty sector compression even if the filesystem does not support
holes (useful for Windows users)
* zlib based compression to directly use compressed disk images
(note: the written sectors are not compressed again, you must use qemu-img to compress a disk image).
* AES based encryption

- native VMware 3 and 4 read-only disk image support (untested - I need such images to test it).

- new 'all-in-one' tool 'qemu-img' to create, convert, compress and encrypt disk images with all the supported formats.

Note: the qcow disk image format may change without notice until the next release.

Fabrice.

#1 lore raw

Le Tue, 03 Aug 2004 23:41:46 +0200, Fabrice Bellard a écrit :

Quoted 18 lines

Hi,

I commited the new disk image layer of QEMU which adds the following features:

- new disk image formats are easier to support

- new 'qcow' image format which supports:
* empty sector compression even if the filesystem does not support
holes (useful for Windows users)
* zlib based compression to directly use compressed disk images
(note: the written sectors are not compressed again, you must use qemu-img to compress a disk image).
* AES based encryption

- native VMware 3 and 4 read-only disk image support (untested - I need such images to test it).

Quoted 7 lines

- new 'all-in-one' tool 'qemu-img' to create, convert, compress and encrypt disk images with all the supported formats.

Note: the qcow disk image format may change without notice until the next release.

Fabrice.

qemu.exe doesn't work for me, even if the build goes fine. I have tried it under xp. Passing -d to log does produce only an empty file. Good news: qemu-img works, I have created a raw and a qcow image.

#2 lore raw

qemu-img, BSD (was: Re: [Qemu-devel] new block layer)

In reply to Fabrice Bellard
Quoted 6 lines · Fabrice Bellard

Hi,

I commited the new disk image layer of QEMU which adds the following features:

...

First: How do you use qemu-img? If i try
qemu-img create -b /dev/ad0 -f qcow testcow 10M
I only get the usage back.

Second question: Has anyone patched the new block layer for BSD already?
At least FreeBSD can't access cdroms in 512 byte blocks, everything has to be done in the cd blocksize which is 2048. (A patch for this from the list for the old block layer is in the port; It also needs to use DIOCGMEDIASIZE but that was quick to re-add.)

Here is an update for the port, I send it here because I dont
think it should be committed until the cdrom issue is fixed...

If you want to look at the patches in the port and don't have a
FreeBSD ports tree on your system: you can check out the port from cvs by (for example) doing

CVSROOT=:pserver:[email protected]:/home/ncvs cvs co ports/emulators/qemu

(login with password anoncvs)

the FreeBSD patches are in the files/ dir; patch-aa and -ab are from
the list, patch-ac, patch-bd and patch-bf are FreeBSD only

(apply this on top of the port in cvs, then remove files/patch-ba,
files/patch-bb, files/patch-bg)

Oh and if you try this after today 2340 (iirc) Jerusalem time
you need to adjust the date in DISTNAME (and maybe more depending on what Fabrice commits...)

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/emulators/qemu/Makefile,v retrieving revision 1.13

Makefile +4 -3
diff -u -r1.13 Makefile
@@ -8,8 +8,9 @@
 PORTNAME=	qemu
 PORTVERSION=	0.6.0s
 CATEGORIES=	emulators
-MASTER_SITES=	http://dad-answers.com/qemu/FreeBSD/
-DISTNAME=	${PORTNAME}-snapshot-2004-07-15_23
+#MASTER_SITES=	http://dad-answers.com/qemu/FreeBSD/
+MASTER_SITES=	http://dad-answers.com/qemu/
+DISTNAME=	${PORTNAME}-snapshot-2004-08-03_23
 
 MAINTAINER=	[email protected]
 COMMENT=	QEMU CPU Emulator
@@ -26,7 +27,7 @@
 WRKSRC=		${WRKDIR}/${DISTNAME}
 PATCH_STRIP=	-p1
 CONFIGURE_ARGS+=	--prefix=${PREFIX} --cc=${CC}\ -I${PREFIX}/include
-MAN1=		qemu.1 qemu-mkcow.1
+MAN1=		qemu.1
 ONLY_FOR_ARCHS=	i386 amd64 powerpc
 
 post-install:

Index: distinfo
===================================================================
RCS file: /home/ncvs/ports/emulators/qemu/distinfo,v retrieving revision 1.10

distinfo +2 -2
diff -u -r1.10 distinfo
@@ -1,2 +1,2 @@
-MD5 (qemu-snapshot-2004-07-15_23.tar.bz2) = a45bec4f467f47401f745147091f1644
-SIZE (qemu-snapshot-2004-07-15_23.tar.bz2) = 747718
+MD5 (qemu-snapshot-2004-08-03_23.tar.bz2) = d93635596be9a94ec452f47505d73996
+SIZE (qemu-snapshot-2004-08-03_23.tar.bz2) = 770845

Index: pkg-plist
===================================================================
RCS file: /home/ncvs/ports/emulators/qemu/pkg-plist,v retrieving revision 1.6

pkg-plist +1 -2
diff -u -r1.6 pkg-plist
@@ -1,7 +1,6 @@
 bin/qemu
-bin/qemu-mkcow
+bin/qemu-img
 bin/qemu-system-ppc
-bin/vmdk2raw
 %%PORTDOCS%%%%DOCSDIR%%/qemu-doc.html
 %%PORTDOCS%%%%DOCSDIR%%/qemu-tech.html
 share/qemu/bios.bin

Index: files/patch-aa
===================================================================
RCS file: /home/ncvs/ports/emulators/qemu/files/patch-aa,v retrieving revision 1.2

patch-aa +0 -100

106 lines not on this page · raw message

patch-bl new file +35 -0
@@ -0,0 +1,35 @@
+Index: qemu/block.c
+@@ -21,6 +21,17 @@
+  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+  * THE SOFTWARE.
+  */
++
++#include "config-host.h"
++
++#ifdef _BSD
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/ioctl.h>
++#include <sys/queue.h>
++#include <sys/disk.h>
++#endif
++
+ #include "vl.h"
+ #include "block_int.h"
+ 
+@@ -514,6 +525,15 @@
+             return -1;
+         bs->read_only = 1;
+     }
++#ifdef _BSD
++    struct stat sb;
++    if (!fstat(fd,&sb) && (S_IFCHR & sb.st_mode)) {
++#ifdef DIOCGMEDIASIZE
++        if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
++#endif
++            size = lseek(fd, 0LL, SEEK_END);
++    } else
++#endif
+     size = lseek64(fd, 0, SEEK_END);
+     bs->total_sectors = size / 512;
+     s->fd = fd;
#3 lore raw

Re: qemu-img, BSD (was: Re: [Qemu-devel] new block layer)

Quoted 12 lines · Juergen Lock
Quoted 6 lines · Fabrice Bellard

Hi,

I commited the new disk image layer of QEMU which adds the following features:

...

First: How do you use qemu-img? If i try
qemu-img create -b /dev/ad0 -f qcow testcow 10M
I only get the usage back.

Quoted 5 lines

Second question: Has anyone patched the new block layer for BSD already?
At least FreeBSD can't access cdroms in 512 byte blocks, everything has to be done in the cd blocksize which is 2048. (A patch for this from the list for the old block layer is in the port; It also needs to use DIOCGMEDIASIZE but that was quick to re-add.)

I have a new patch for the new block layer - it defines a new block type (imaginately called 'dev') and the probe checks the DIOCGMEDIASIZE and DIOCGSECTORSIZE ioctls... It also ensures that I/O is done in multiples of the device sector size.

I'll have a new patch together for this soon...

On my machine (FreeBSD 5-NOT_SO_CURRENT), the slirp code causes a SIGBUS... I might investigate - it looks like it occurs near constructing the ethernet header... poor backtraces prevents me from finding exactly where.

Quoted 14 lines

Here is an update for the port, I send it here because I dont
think it should be committed until the cdrom issue is fixed...

If you want to look at the patches in the port and don't have a
FreeBSD ports tree on your system: you can check out the port from cvs by (for example) doing

CVSROOT=:pserver:[email protected]:/home/ncvs cvs co ports/emulators/qemu

(login with password anoncvs)

the FreeBSD patches are in the files/ dir; patch-aa and -ab are from
the list, patch-ac, patch-bd and patch-bf are FreeBSD only

Quoted 8 lines

(apply this on top of the port in cvs, then remove files/patch-ba,
files/patch-bb, files/patch-bg)

Oh and if you try this after today 2340 (iirc) Jerusalem time
you need to adjust the date in DISTNAME (and maybe more depending on what Fabrice commits...)

Index: Makefile

<snip - variant of old block patch which I originally hacked >

Signature · 3 lines
Antony T Curtis, BSc.                   UNIX, Linux, *BSD, Networking
[email protected]            C++, J2EE, Perl, MySQL, Apache
                                        IT Consultancy.
#4 lore raw

Re: qemu-img, BSD (was: Re: [Qemu-devel] new block layer)

In article <[email protected]> you write:

Quoted 7 lines · Juergen Lock
Quoted 6 lines · Fabrice Bellard
Quoted 5 lines

Hi,

I commited the new disk image layer of QEMU which adds the following features:

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

...

First: How do you use qemu-img? If i try
qemu-img create -b /dev/ad0 -f qcow testcow 10M
I only get the usage back.

I just looked at the source and found out that it expects getopt to support mixing args and options (it doesnt increment optind to skip over the command before calling getopt), if I change this it works:

Index: qemu/qemu-img.c
@@ -303,7 +303,6 @@

             break;
         }
     }
-    optind++;
     if (optind >= argc) 
         help();
     filename = argv[optind++];
@@ -367,7 +366,6 @@
             break;
         }
     }
-    optind++;
     if (optind >= argc) 
         help();
     filename = argv[optind++];
@@ -505,7 +503,6 @@
             break;
         }
     }
-    optind++;
     if (optind >= argc) 
         help();
     filename = argv[optind++];
@@ -633,7 +630,6 @@
             break;
         }
     }
-    optind++;
     if (optind >= argc) 
         help();
     filename = argv[optind++];
@@ -680,6 +676,7 @@
     if (argc < 2)
         help();
     cmd = argv[1];
+    ++optind;
     if (!strcmp(cmd, "create")) {
         img_create(argc, argv);
     } else if (!strcmp(cmd, "commit")) {
Quoted 6 lines
Quoted 5 lines

Second question: Has anyone patched the new block layer for BSD already?
At least FreeBSD can't access cdroms in 512 byte blocks, everything has to be done in the cd blocksize which is 2048. (A patch for this from the list for the old block layer is in the port; It also needs to use DIOCGMEDIASIZE but that was quick to re-add.)

Quoted 7 lines

I have a new patch for the new block layer - it defines a new block type (imaginately called 'dev') and the probe checks the DIOCGMEDIASIZE and DIOCGSECTORSIZE ioctls... It also ensures that I/O is done in multiples of the device sector size.

I'll have a new patch together for this soon...

Thanks, that would be cool.

Quoted 5 lines

On my machine (FreeBSD 5-NOT_SO_CURRENT), the slirp code causes a SIGBUS... I might investigate - it looks like it occurs near constructing the ethernet header... poor backtraces prevents me from finding exactly where.

Hmm, never seen that here (RELENG_5_2)...

Quoted 7 lines
Quoted 7 lines

Here is an update for the port, I send it here because I dont
think it should be committed until the cdrom issue is fixed...
...

Oh and if you try this after today 2340 (iirc) Jerusalem time
you need to adjust the date in DISTNAME (and maybe more depending on what Fabrice commits...)

You need to change lseek64 to lseek in files/patch-bl now btw.

Juergen