[vbox-dev] Questions about VBOXHDDBACKEND functions

Klaus Espenlaub Klaus.Espenlaub at Sun.COM
Mon Feb 1 01:53:11 PST 2010

Christophe Devriese wrote:
> Hello,
> I'm trying to make a VBOXHDDBACKEND (a memory-backed disk) by way of an 
> exercise. I have a few questions about some of the functions :
>     /* pfnGetFileSize */
> return 0 in case of no file backend ?

Yes, 0 is on the safe side, and avoids any funny output by sloppy 
callers using this without checking if the backend is actually using files.

>     /* pfnGetPCHSGeometry */
> iscsihddbackend silently ignores this function call, not even setting 
> the pointer correctly ... is this a bug ?

Silently ignores? Certainly not, it returns VERR_VD_GEOMETRY_NOT_SET. 
Setting the pointer? Why should it, only the fields in the struct would 
need to be updated.

>     /* pfnSetPCHSGeometry */
> again iscsihddbackend silently ignores this, is this correct behavior ?

Again, it returns an error, indicating that it can't memorize any geometry.

>     /* pfnGetLCHSGeometry */
> again : silently ignored by iscsi ? is this correct behavior ?

See above.

>     /* pfnSetLCHSGeometry */
> again : silently ignored by iscsi ? is this correct behavior ?

See above.

Implementing the geometry handling for a non-persistent disk wouldn't be 
worth it. For other image formats the first priority is keeping LCHS 
(the BIOS disk geometry, capped at 255 heads and 63 sectors), as that 
avoids trouble when copying over an existing Windows image with unusual 
LCHS. If one doesn't preserve the geometry, then Windows will fail to 
boot really early.

If the geometry stuff isn't implemented, then VirtualBox uses some sane 
"autodetect" values.

BTW, did you notice that you can implement image format backends as 
shared libraries (.so/.dll) and that they automatically get picked up if 
you put them in the directory where the other libraries are? It's only a 
few lines more code (see VBoxHDD.cpp for what entry point is required, 
there's no sample IIRC), and it saves you from relinking VirtualBox all 
the time during development. Your choice.


More information about the vbox-dev mailing list