Skip to contentSkip to conversation

Move block format drivers to new directory 'bdrv'

PATCH In review Avi Kivity 9 participants 20 messages Apr 26, 2009 – May 2, 2009 Kbuild

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 Move block format drivers to new directory 'bdrv'

Instead of crowding the top-level directory, give block format drivers their very own subdirectory.

---
 Makefile                              |   10 +++++-----
 Makefile.target                       |    4 ++--
 block-bochs.c => bdrv/bochs.c         |    0
 block-cloop.c => bdrv/cloop.c         |    0
 block-cow.c => bdrv/cow.c             |    0
 block-dmg.c => bdrv/dmg.c             |    0
 block-nbd.c => bdrv/nbd.c             |    0
 block-parallels.c => bdrv/parallels.c |    0
 block-qcow.c => bdrv/qcow.c           |    0
 block-qcow2.c => bdrv/qcow2.c         |    0
 block-raw-posix.c => bdrv/raw-posix.c |    0
 block-raw-win32.c => bdrv/raw-win32.c |    0
 block-vmdk.c => bdrv/vmdk.c           |    0
 block-vpc.c => bdrv/vpc.c             |    0
 block-vvfat.c => bdrv/vvfat.c         |    0
 15 files changed, 7 insertions(+), 7 deletions(-)
 rename block-bochs.c => bdrv/bochs.c (100%)
 rename block-cloop.c => bdrv/cloop.c (100%)
 rename block-cow.c => bdrv/cow.c (100%)
 rename block-dmg.c => bdrv/dmg.c (100%)
 rename block-nbd.c => bdrv/nbd.c (100%)
 rename block-parallels.c => bdrv/parallels.c (100%)
 rename block-qcow.c => bdrv/qcow.c (100%)
 rename block-qcow2.c => bdrv/qcow2.c (100%)
 rename block-raw-posix.c => bdrv/raw-posix.c (100%)
 rename block-raw-win32.c => bdrv/raw-win32.c (100%)
 rename block-vmdk.c => bdrv/vmdk.c (100%)
 rename block-vpc.c => bdrv/vpc.c (100%)
 rename block-vvfat.c => bdrv/vvfat.c (100%)
Makefile +5 -5
index 0f40cda..95d8cd0 100644
@@ -63,18 +63,18 @@ recurse-all: $(SUBDIR_RULES)
 # BLOCK_OBJS is code used by both qemu system emulation and qemu-img
 
 BLOCK_OBJS=cutils.o qemu-malloc.o
-BLOCK_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
-BLOCK_OBJS+=block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
-BLOCK_OBJS+=block-qcow2.o block-parallels.o block-nbd.o
+BLOCK_OBJS+=bdrv/cow.o bdrv/qcow.o aes.o bdrv/vmdk.o bdrv/cloop.o
+BLOCK_OBJS+=bdrv/dmg.o bdrv/bochs.o bdrv/vpc.o bdrv/vvfat.o
+BLOCK_OBJS+=bdrv/qcow2.o bdrv/parallels.o bdrv/nbd.o
 BLOCK_OBJS+=nbd.o block.o aio.o
 
 ifdef CONFIG_WIN32
-BLOCK_OBJS += block-raw-win32.o
+BLOCK_OBJS += bdrv/raw-win32.o
 else
 ifdef CONFIG_AIO
 BLOCK_OBJS += posix-aio-compat.o
 endif
-BLOCK_OBJS += block-raw-posix.o
+BLOCK_OBJS += bdrv/raw-posix.o
 endif
 
 ######################################################################
Makefile.target +2 -2
index 82ada5a..fd70c8d 100644
@@ -507,12 +507,12 @@ ifdef CONFIG_KVM
 OBJS+=kvm.o kvm-all.o
 endif
 ifdef CONFIG_WIN32
-OBJS+=block-raw-win32.o
+OBJS+=bdrv/raw-win32.o
 else
 ifdef CONFIG_AIO
 OBJS+=posix-aio-compat.o
 endif
-OBJS+=block-raw-posix.o
+OBJS+=bdrv/raw-posix.o
 endif
 
 LIBS+=-lz
bdrv/bochs.c renamed from block-bochs.c +0 -0
similarity index 100%
rename from block-bochs.c
rename to bdrv/bochs.c
bdrv/cloop.c renamed from block-cloop.c +0 -0
similarity index 100%
rename from block-cloop.c
rename to bdrv/cloop.c
bdrv/cow.c renamed from block-cow.c +0 -0
similarity index 100%
rename from block-cow.c
rename to bdrv/cow.c
bdrv/dmg.c renamed from block-dmg.c +0 -0
similarity index 100%
rename from block-dmg.c
rename to bdrv/dmg.c
bdrv/nbd.c renamed from block-nbd.c +0 -0
similarity index 100%
rename from block-nbd.c
rename to bdrv/nbd.c
bdrv/parallels.c renamed from block-parallels.c +0 -0
similarity index 100%
rename from block-parallels.c
rename to bdrv/parallels.c
bdrv/qcow.c renamed from block-qcow.c +0 -0
similarity index 100%
rename from block-qcow.c
rename to bdrv/qcow.c
bdrv/qcow2.c renamed from block-qcow2.c +0 -0
similarity index 100%
rename from block-qcow2.c
rename to bdrv/qcow2.c
bdrv/raw-posix.c renamed from block-raw-posix.c +0 -0
similarity index 100%
rename from block-raw-posix.c
rename to bdrv/raw-posix.c
bdrv/raw-win32.c renamed from block-raw-win32.c +0 -0
similarity index 100%
rename from block-raw-win32.c
rename to bdrv/raw-win32.c
bdrv/vmdk.c renamed from block-vmdk.c +0 -0
similarity index 100%
rename from block-vmdk.c
rename to bdrv/vmdk.c
bdrv/vpc.c renamed from block-vpc.c +0 -0
similarity index 100%
rename from block-vpc.c
rename to bdrv/vpc.c
bdrv/vvfat.c renamed from block-vvfat.c +0 -0
similarity index 100%
rename from block-vvfat.c
rename to bdrv/vvfat.c
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 2 lines · Avi Kivity

Instead of crowding the top-level directory, give block format drivers their very own subdirectory.

Please also move block.c. Also block/*.c would match the existing convention, not that I care too much.

author
#2 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Avi Kivity

Instead of crowding the top-level directory, give block format drivers their very own subdirectory.

Please also move block.c. Also block/*.c would match the existing convention, not that I care too much.

That was deliberate - I wanted to keep the block core in the top level directory, and move the block format drivers away. I'll change it if there's consensus that block/*.c (including block.c) is preferable.

Signature · 1 line
error compiling committee.c: too many arguments to function
#3 lore raw
Quoted 11 lines · Avi Kivity
Quoted 4 lines · Christoph Hellwig
Quoted 1 line · Avi Kivity

Instead of crowding the top-level directory, give block format drivers

their

Quoted 4 lines
Quoted 3 lines

very own subdirectory.

Quoted 8 lines
Quoted 4 lines

Please also move block.c. Also block/*.c would match the existing convention, not that I care too much.

That was deliberate - I wanted to keep the block core in the top level
directory, and move the block format drivers away. I'll change it if there's consensus that block/*.c (including block.c) is preferable.

Taking one step further, why not introduce directories similar to VirtualBox:
http://www.virtualbox.org/browser/trunk/src/VBox

Or in our style: host/block/, host/net/slirp/, host/usb/, host/bluetooth/ (trying to match subdirectory names in Linux drivers directory)?

#5 lore raw
Quoted 10 lines · Avi Kivity
Quoted 1 line · Blue Swirl

Taking one step further, why not introduce directories similar to

VirtualBox:

Quoted 4 lines

http://www.virtualbox.org/browser/trunk/src/VBox

No objection, but let's go one step at a time.

Yes, but it's good to see the big picture.

So the new 'host' directory would be like:

.

|-- audio
|-- block
|-- bluetooth
|-- crypto
|-- net
|   `-- slirp
|-- parport
|-- scsi
|-- serial
|-- usb

`-- video

audio and slirp are current directories. SDL and VNC go to video, aes and d3des to crypto.

author
#6 lore raw
Quoted 15 lines · Blue Swirl

Yes, but it's good to see the big picture.

So the new 'host' directory would be like:

.

|-- audio
|-- block
|-- bluetooth
|-- crypto
|-- net
|   `-- slirp
|-- parport
|-- scsi
|-- serial
|-- usb
Quoted 5 lines

`-- video

audio and slirp are current directories. SDL and VNC go to video, aes and d3des to crypto.

I find it too sparse. Most of these directories would hold one or two files.

Signature · 1 line
error compiling committee.c: too many arguments to function
#7 lore raw
In reply to Blue Swirl
Quoted 32 lines · Blue Swirl
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Blue Swirl

Taking one step further, why not introduce directories similar to

Quoted 9 lines

VirtualBox:

Quoted 5 lines

http://www.virtualbox.org/browser/trunk/src/VBox

No objection, but let's go one step at a time.

Yes, but it's good to see the big picture.

So the new 'host' directory would be like:

.

|-- audio
|-- block
|-- bluetooth
|-- crypto
|-- net
|   `-- slirp
|-- parport
|-- scsi
|-- serial
|-- usb
Quoted 2 lines

`-- video

There's an awful lot of code refactoring needed before such a layout would make sense. In general, I think until there are at least 3 files in the form something-foo.c, it doesn't make sense to convert to something/foo.c

Regards,

Anthony Liguori

Quoted 5 lines

audio and slirp are current directories. SDL and VNC go to video, aes and d3des to crypto.

#8 lore raw
Quoted 13 lines · Anthony Liguori
Quoted 10 lines
|-- audio
|-- block
|-- bluetooth
|-- crypto
|-- net
|   `-- slirp
|-- parport
|-- scsi
|-- serial
|-- usb
Quoted 2 lines

`-- video

Quoted 4 lines

There's an awful lot of code refactoring needed before such a layout would make sense. In general, I think until there are at least 3 files in the form something-foo.c, it doesn't make sense to convert to something/foo.c

I agree. Useful subdirectories I can see currently are:

- usb
- net
- bluetooth
- block
- vnc

after looking at the code again I would also include the various scsi files in the block directoty, they are pretty closely related and will get even more interwinded with things like SG_IO passthrough for virtio.

author
#9 lore raw
Quoted 5 lines · Christoph Hellwig

after looking at the code again I would also include the various scsi files in the block directoty, they are pretty closely related and will get even more interwinded with things like SG_IO passthrough for virtio.

maybe

block (core)
block/formats (format drivers)

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#11 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 3 lines · Avi Kivity
Quoted 1 line · Blue Swirl

Taking one step further, why not introduce directories similar to

VirtualBox:

Quoted 5 lines
Quoted 4 lines

http://www.virtualbox.org/browser/trunk/src/VBox

Quoted 5 lines
Quoted 2 lines

No objection, but let's go one step at a time.

I was going to suggest exactly the same thing. It would be good for
someone to look at making a more logical layout in hw/.

hw could be arranged the same way, renamed to 'target':

target

|-- audio
|-- block
|-- bluetooth
|-- boards
|   |-- alpha
|   |-- arm
|   |-- cris
|   |-- i386
|   |-- m68k
|   |-- mips
|   |-- ppc
|   |-- sh4
|   |-- sparc
|   |-- sparc64
|   `-- x86_64
|-- input
|-- irq
|-- isa
|-- mtd
|-- net
|-- pci
|-- scsi
|-- serial
|-- timer
|-- usb
|-- video

`-- xen

#12 lore raw
Quoted 53 lines · Blue Swirl
Quoted 15 lines · Anthony Liguori
Quoted 5 lines · Avi Kivity
Quoted 2 lines · Blue Swirl

Taking one step further, why not introduce directories similar to

VirtualBox:

Quoted 5 lines
Quoted 5 lines

http://www.virtualbox.org/browser/trunk/src/VBox

Quoted 6 lines
Quoted 3 lines

No objection, but let's go one step at a time.

I was going to suggest exactly the same thing. It would be good for
someone to look at making a more logical layout in hw/.

hw could be arranged the same way, renamed to 'target':

target

|-- audio
|-- block
|-- bluetooth
|-- boards
|   |-- alpha
|   |-- arm
|   |-- cris
|   |-- i386
|   |-- m68k
|   |-- mips
|   |-- ppc
|   |-- sh4
|   |-- sparc
|   |-- sparc64
|   `-- x86_64
|-- input
|-- irq
|-- isa
|-- mtd
|-- net
|-- pci
|-- scsi
|-- serial
|-- timer
|-- usb
|-- video
Quoted 4 lines

`-- xen

... or similar to linux kernel structure?

target

|-- arch
|   |-- ...
|-- drivers
|   |-- ...

Then it's clearer where the emulation code for a PC board (i386 or x86_64?), a network card (pci or net?) or others should be placed.

#13 lore raw
In reply to Blue Swirl
Quoted 29 lines · Blue Swirl

hw could be arranged the same way, renamed to 'target':

target

|-- audio
|-- block
|-- bluetooth
|-- boards
|   |-- alpha
|   |-- arm
|   |-- cris
|   |-- i386
|   |-- m68k
|   |-- mips
|   |-- ppc
|   |-- sh4
|   |-- sparc
|   |-- sparc64
|   `-- x86_64
|-- input
|-- irq
|-- isa
|-- mtd
|-- net
|-- pci
|-- scsi
|-- serial
|-- timer
|-- usb
|-- video
Quoted 1 line

`-- xen

We should be careful not to put each file into its own directory. A layout is good if it helps me to find the right file more quickly. If I have the same problem finding the right directory (or just having to change the working directory all the time) afterwards, I think it's not worth the effort.

Kevin

#14 lore raw
Quoted 5 lines · Kevin Wolf

We should be careful not to put each file into its own directory. A layout is good if it helps me to find the right file more quickly. If I have the same problem finding the right directory (or just having to change the working directory all the time) afterwards, I think it's not worth the effort.

The way Linux dealt with this is long ago there were only a few directories in drivers/ and a few top-level directories. Block devices went in drivers/block/, most other devices in drivers/char, and there were only a few top-level directories.

That went on for many years. Then as the number of drivers and kernel subsystems grew too big, they added more and more specialised directories. Now we have a lot of directories under drivers/, and a few more at the top level.

With GIT handling renames, adding more directories in future as needed and moving things into them might be quite straightforward, I'm not sure.

-- Jamie

#15 lore raw

In message: <[email protected]>
Jamie Lokier <[email protected]> writes:
: With GIT handling renames, adding more directories in future as needed : and moving things into them might be quite straightforward, I'm not : sure.

Yes. It does. Any of the more modern (post cvs) VCS do this.

Warner

#16 lore raw
In reply to Avi Kivity
Quoted 4 lines · Avi Kivity

Instead of crowding the top-level directory, give block format drivers their very own subdirectory.

I like this idea. In fact, I was going to suggest something like this myself. And a good next step would be to split up (too) large source files, e.g. into qcow2-snapshot.c, qcow2-refcount.c and so on.

Kevin

author
#17 lore raw
Quoted 7 lines · Kevin Wolf
Quoted 4 lines · Avi Kivity

Instead of crowding the top-level directory, give block format drivers their very own subdirectory.

I like this idea. In fact, I was going to suggest something like this myself. And a good next step would be to split up (too) large source files, e.g. into qcow2-snapshot.c, qcow2-refcount.c and so on.

qcow2/snapshot.c qcow2/refcount.c ...

Signature · 1 line
error compiling committee.c: too many arguments to function
#18 lore raw
Quoted 10 lines · Avi Kivity
Quoted 7 lines · Kevin Wolf
Quoted 4 lines · Avi Kivity

Instead of crowding the top-level directory, give block format drivers their very own subdirectory.

I like this idea. In fact, I was going to suggest something like this myself. And a good next step would be to split up (too) large source files, e.g. into qcow2-snapshot.c, qcow2-refcount.c and so on.

qcow2/snapshot.c qcow2/refcount.c ...

I'm not sure about that one. A less crowded top level directory is a good thing, but building a directory labyrinth is not, IMHO.

Kevin

#19 lore raw
In reply to Kevin Wolf
Quoted 5 lines · Kevin Wolf
Quoted 2 lines · Avi Kivity

Instead of crowding the top-level directory, give block format drivers their very own subdirectory.

I like this idea.

Well, if we're agreed that this is a good idea, is there anything stopping it from happening? :)

Signature · 1 line
Stuart Brady