Skip to contentSkip to conversation

Question about block driver

Qemu-devel Wen Congyang 3 participants 5 messages Apr 30, 2015

lore
Share & tools
lore
#0 lore raw

Hi, all

Some drivers use bdrv_open, while the other dirvers use bdrv_file_open(). What is the difference between bdrv_open() and bdrv_file_open()?

Thanks
Wen Congyang

#1 lore raw

[Cc: qemu-block]

Am 30.04.2015 um 11:11 hat Wen Congyang geschrieben:

Quoted 2 lines

Some drivers use bdrv_open, while the other dirvers use bdrv_file_open(). What is the difference between bdrv_open() and bdrv_file_open()?

bdrv_file_open() is used by protocol drivers that don't need any other driver to work (e.g. raw-posix), bdrv_open() is used by format drivers that need a bs->file (e.g. raw or qcow2).

They used to have different parameters originally, but nowadays that's the only difference.

Kevin

#2 lore raw
Quoted 6 lines · Kevin Wolf

[Cc: qemu-block]

Am 30.04.2015 um 11:11 hat Wen Congyang geschrieben:

Quoted 2 lines

Some drivers use bdrv_open, while the other dirvers use bdrv_file_open(). What is the difference between bdrv_open() and bdrv_file_open()?

Quoted 6 lines

bdrv_file_open() is used by protocol drivers that don't need any other driver to work (e.g. raw-posix), bdrv_open() is used by format drivers that need a bs->file (e.g. raw or qcow2).

They used to have different parameters originally, but nowadays that's the only difference.

So, if the driver wants to open bs->file itself, it should use bdrv_file_open(), and the driver wants bs->file has already been opened before its open, it should use bdrv_open(). Is it right?

Thanks
Wen Congyang

Quoted 4 lines

Kevin
.

#3 lore raw

Am 30.04.2015 um 11:43 hat Wen Congyang geschrieben:

Quoted 11 lines · Kevin Wolf
Quoted 10 lines

[Cc: qemu-block]

Am 30.04.2015 um 11:11 hat Wen Congyang geschrieben:

Quoted 2 lines

Some drivers use bdrv_open, while the other dirvers use bdrv_file_open(). What is the difference between bdrv_open() and bdrv_file_open()?

bdrv_file_open() is used by protocol drivers that don't need any other driver to work (e.g. raw-posix), bdrv_open() is used by format drivers that need a bs->file (e.g. raw or qcow2).

Quoted 6 lines
Quoted 2 lines

They used to have different parameters originally, but nowadays that's the only difference.

So, if the driver wants to open bs->file itself, it should use bdrv_file_open(), and the driver wants bs->file has already been opened before its open, it should use bdrv_open(). Is it right?

Yes, that's how it works, even though I don't think a driver exists that opens bs->file by itself.

Kevin

#4 lore raw
Quoted 15 lines · Kevin Wolf

Am 30.04.2015 um 11:43 hat Wen Congyang geschrieben:

Quoted 14 lines · Kevin Wolf
Quoted 12 lines

[Cc: qemu-block]

Am 30.04.2015 um 11:11 hat Wen Congyang geschrieben:

Quoted 2 lines

Some drivers use bdrv_open, while the other dirvers use bdrv_file_open(). What is the difference between bdrv_open() and bdrv_file_open()?

bdrv_file_open() is used by protocol drivers that don't need any other driver to work (e.g. raw-posix), bdrv_open() is used by format drivers that need a bs->file (e.g. raw or qcow2).

They used to have different parameters originally, but nowadays that's the only difference.

Quoted 6 lines
Quoted 3 lines

So, if the driver wants to open bs->file itself, it should use bdrv_file_open(), and the driver wants bs->file has already been opened before its open, it should use bdrv_open(). Is it right?

Yes, that's how it works, even though I don't think a driver exists that opens bs->file by itself.

Some extra context about this statement: .bdrv_file_open() block drivers (aka "protocols") operate directly on a POSIX file descriptor, a socket, GlusterFS API, etc so they usually have no need for bs->file.

Stefan