Linux::NBD::Client - client (device) side of a network block device
use Linux::NBD::Client;
WARNING: I talked to the author of the nbd driver because nbd is so extremely racy (right now, stopping it often causes oopses, a server crashing also often oopses etc..).
It turned out that he doesn't care at all and nbd is basically unmaintained, so YMMV when using this module, especially when writing servers.
He really should have said that on his nbd pages ;[.
OTOH, it works relatively reliable when you don't stop the servers, so watch out and keep your fingers crossed.
Create a new client.
Unless device is given, an unused device node is looked up using the
device method (this might result in an exception!).
Returns the current socket after setting a new one (if an argument is supplied). The socket MUST be a tcp socket. Believe me, bad things will happen if not.
The special argument undef will try to clear the socket, if any was
set.
Returns the current device node (e.g. /dev/nbd2) after setting a new one if
an argument is supplied.
If the argument is undef it will search for an unallocated nbd-device
and use it.
Tries to exit the server by sending a special disconnect message.
Clears the request queue, if possible. Should be used before setting a new socket.
Set the request timeout, in seconds.
Set the device block size in bytes, i.e. how big each block is (must be >512, <PAGESIZE and a power of two).
Also rounds down the device size to be a multiple of the block size.
Set the device size in block units.
Set the device size in octet units, will be rounded down to be a multiple of the block size.
Closes all file descriptors except the server socket and enters
the service loop (waits for read/write requests on the device and
forwards them over the given socket). Only returns when somebody calls
disconnect or the server is killed.
Runs the service loop asynchronously and returns the pid of the newly created service process.
Kills any running async service. Please note that this also kills the socket, so you need to re-set the socket after this call.
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/