Received: from eggs.gnu.org ([2001:4830:134:3::10]:34950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ynqfa-00043b-L4 for qemu-devel@nongnu.org; Thu, 30 Apr 2015 11:46:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnqfZ-0007Ru-OR for qemu-devel@nongnu.org; Thu, 30 Apr 2015 11:46:34 -0400 Date: Thu, 30 Apr 2015 16:46:26 +0100 From: Stefan Hajnoczi Message-ID: <20150430154626.GB26469@stefanha-thinkpad.redhat.com> References: <5541F1B3.6040501@cn.fujitsu.com> <20150430093310.GA3368@noname.redhat.com> <5541F934.8010100@cn.fujitsu.com> <20150430095201.GB3368@noname.redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="OwLcNYc0lM97+oe1" Content-Disposition: inline In-Reply-To: <20150430095201.GB3368@noname.redhat.com> Subject: Re: [Qemu-devel] Question about block driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, Fam Zheng , qemu-devl --OwLcNYc0lM97+oe1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 30, 2015 at 11:52:01AM +0200, Kevin Wolf wrote: > Am 30.04.2015 um 11:43 hat Wen Congyang geschrieben: > > On 04/30/2015 05:33 PM, Kevin Wolf wrote: > > > [Cc: qemu-block] > > >=20 > > > Am 30.04.2015 um 11:11 hat Wen Congyang geschrieben: > > >> Some drivers use bdrv_open, while the other dirvers use bdrv_file_op= en(). > > >> What is the difference between bdrv_open() and bdrv_file_open()? > > >=20 > > > 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). > > >=20 > > > They used to have different parameters originally, but nowadays that's > > > the only difference. > >=20 > > So, if the driver wants to open bs->file itself, it should use bdrv_fil= e_open(), > > and the driver wants bs->file has already been opened before its open, = it should > > use bdrv_open(). Is it right? >=20 > 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 --OwLcNYc0lM97+oe1 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVQk5SAAoJEJykq7OBq3PIuUkH/iCyfunaVCbJUhqd1bjMC4By /NWUMBp9lkdmyXjE5jYlWAlxalEoblzqa1jMsY0W/Xf8b8eERe340noacbcguZbZ 4oVAceC1buy+2XV3ifbkDVeanXIan4wOmKin7i4ZrYlNG1Ew6iZgb+50H/wKS59s doBk/SRQyWIaS/15lBflVCRjbzdnJSeqZiywn15rCE8PieNlrM8xG7xtoMkIO5yE Um/7HePlq0Rx1j98pYDArCcqNPurb+3eCC6aNUXH/Vvlz6xYITyCq8TDZLnw1add +R8a/0UnppQFNtqruSMXUf1u+FmvvlzcIYKBqIMK1vvfnVonJEx33BiNkXkYfJ0= =bgJH -----END PGP SIGNATURE----- --OwLcNYc0lM97+oe1--