History | View | Annotate | Download (14.9 kB)
nbd: do not include block_int.h
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
nbd: consistently check for <0 or >=0
This prepares for the following patch, which changes -1 return valuesto negative errno.
nbd: consistently return negative errno values
In the next patch we need to look at the return code of nbd_wr_sync.To avoid percolating the socket_error() ugliness all around, let'shandle errors by returning negative errno values.
open /dev/nbd in nbd_client_thread
do not chdir(/) in qemu-nbd before opening all files
When qemu-nbd becomes a daemon it calls daemon(3) withnochdir=0, so daemon(3) changes current directory to /.But at this time, qemu-nbd did not open any user-specifiedfiles yet, so by changing current directory, all non-absolute...
qemu-nbd: drop loop which can never loop
For some reason nbd_client_thread() has a do..while loop which can neverloop, the condition is bogus because we would take a goto instead. Dropthe loop.
Reported-by: Dr David Alan Gilbert <davidagilbert@uk.ibm.com>...
qemu-nbd: use common main loop
Using a single main loop for sockets will help yielding from the socketcoroutine back to the main loop, and later reentering it.
qemu-nbd: move client handling to nbd.c
This patch sets up the fd handler in nbd.c instead of qemu-nbd.c. Itintroduces NBDClient, which wraps the arguments to nbd_trip in a singlestructure, so that we can add a notifier to it. This way, qemu-nbd canknow about disconnections....
qemu-nbd: remove offset argument to nbd_trip
The argument is write-only.
qemu-nbd: remove data_size argument to nbd_trip
The size of the buffer is in practice part of the protocol.
qemu-nbd: introduce NBDExport
Wrap the common parameters of nbd_trip and nbd_negotiate in asingle opaque struct.
qemu-nbd: trap SIGTERM
The client process right now uses SIGTERM to interrupt the server side.This does not affect the exit status of "qemu-nbd -v -c" because theserver is a child process. This will change when both sides will bein the same process, and anyway cleaning up things nicely upon SIGTERM...
qemu-nbd: rename socket variable
It will be moved to a global variable by the next patch, and itwould conflict with the socket function.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-nbd: move client to a thread
This avoids that qemu-nbd uses both forking and threads, which donot behave well together.
qemu-nbd is already Unix only, and there is no qemu_thread_join,so for now use pthreads.
Since the parent and child no longer have separate file descriptors,...
qemu-nbd: print error messages from the daemon through a pipe
In order to get nice error messages, keep the qemu-nbd process runninguntil before issuing NBD_DO_IT and connected to the daemon with a pipe.This lets the qemu-nbd process relay error messages from the daemon and...
qemu-nbd: fix socket creation race
Now that the client and server are in the same process, there isno need to race on the creation of the socket. We can open thelistening socket before starting the client thread.
This avoids that "qemu-nbd -v -c" prints this once before connecting...
qemu-nbd: open the block device after starting the client thread
This is cleaner, because we do not need to close the block device whenthere is an error opening /dev/nbdX. It was done this way only toprint errors before daemonizing.
At the same time, use atexit to ensure that the block device is closed...
nbd: support feature negotiation
nbd supports writing flags in bytes 24...27 of the header,and uses that for the read-only flag. Add support for itin qemu-nbd.
Fix include statements for qemu-common.h
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Darwin: Fix compilation warning regarding the deprecated daemon() function
Changes since v1: create a wrapper function named qemu_daemon() in oslib-posix.cinstead of putting the OS specific workaround in qemu-nbd.c directly.
On OSX >= 10.5, daemon() is deprecated, resulting in the following warning:...
block: clarify the meaning of BDRV_O_NOCACHE
Change BDRV_O_NOCACHE to only imply bypassing the host OS file cache,but no writeback semantics. All existing callers are changed to alsospecify BDRV_O_CACHE_WB to give them writeback semantics.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
Remove NULL checks for bdrv_new return value
It's an indirect call to qemu_malloc, which never returns an error.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
use qemu_blockalign consistently
Use qemu_blockalign for all allocations in the block layer. This allowsincreasing the required alignment, which is need to support O_DIRECT ondevices with large block sizes.
nbd: correctly manage default port
block/nbd.c: use default port number when none is specifiedqemu-nbd.c: use IANA-assigned port number: 10809
Signed-off-by: Laurent Vivier <laurent@vivier.eu>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Merge remote branch 'kwolf/for-anthony' into staging
Respect return value from nbd_client()
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Remove unused argument for nbd_client()
nbd: Introduce NBD named exports.
This patch allows to connect Qemu using NBD protocol to an nbd-serverusing named exports.
For instance, if on the host "isoserver", in /etc/nbd-server/config, you have:
[generic][debian-500-ppc-netinst] exportname = /ISO/debian-500-powerpc-netinst.iso...
qemu-nbd: Improve error reporting
- use err(3) instead of errx(3) if errno is available to report why failed- let fail prior to daemon(3) if opening a nbd file is likely to fail after daemonizing to avoid silent failure exit- add missing 'ret = 1' when unix_socket_outgoing failed...
Replace calls of old bdrv_open
What is known today as bdrv_open2 becomes the new bdrv_open. All remainingcallers of the old function are converted to the new one. In some places theyeven know the right format, so they should have used bdrv_open2 from the...
qemu-nbd: Fix invalid usage of the first argument of errx
errx takes the exit status of a process as the firstargument. Passing errno to it is wrong. Instead thepatch lets errx take EXIT_FAILURE.
Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
qemu-nbd: Fix return value handling of bdrv_open
bdrv_open may return -errno so we have to checkif the return value is '< 0', not '== -1'.
read-only: minor cleanup
Really use read-only flags for opening the file when asked for read-only
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
win32: pair qemu_memalign() with qemu_vfree()
Win32 suffers from a very big memory leak when dealing with SCSI devices.Each read/write request allocates memory with qemu_memalign (ieVirtualAlloc) but frees it with qemu_free (ie free).Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks....
Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY gone (and so is BDRV_O_ACCESS). Default value for bdrv_flags (0/zero) is READ-ONLY. Need to explicitly request READ-WRITE.
Instead of using the field 'readonly' of the BlockDriverState struct for passing the request,...
qemu-nbd: fix OpenBSD linker warning
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Compile qemu-nbd also on OpenBSD and Solaris
basename() needs #include <libgen.h>.
No prototype for daemon() is available on Solaris, but linksucceeds.
Fix Sparse warnings: "Using plain integer as NULL pointer"
Update to a hopefully more future proof FSF address
Fix warning in qemu-nbd.c
qemu-nbd.c:349: error: ignoring return value of 'daemon', declared with attribute warn_unused_result
toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)
Signed-off-by: Avi Kivity <avi@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6531 c046a42c-6fe2-441c-8c8c-71466251a162
qemu-nbd: fix options: -b (--bind) expects an argument (IFACE) (Uri Lublin)
Rebased for qemu tree.
Signed-off-by: Uri Lublin <uril@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6246 c046a42c-6fe2-441c-8c8c-71466251a162
Update FSF address in GPL/LGPL boilerplate
The attached patch updates the FSF address in the GPL/LGPL boilerplatein most GPL/LGPLed files, and also in COPYING.LIB.
Signed-off-by: Stuart Brady <stuart.brady@gmail.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>...
Fix undeclared symbol warnings from sparse
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5539 c046a42c-6fe2-441c-8c8c-71466251a162
Expand cache= option and use write-through caching by default
This patch changes the cache= option to accept none, writeback, or writethoughto control the host page cache behavior. By default, writethrough caching isnow used which internally is implemented by using O_DSYNC to open the disk...
qemu-nbd: remove useless parameter from nbd_negotiate() (Laurent Vivier)
This patch removes "BlockDriverState *bs" from nbd_negotiate() becauseit is not used.
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.fr>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>...
Allow qemu-nbd --version to show the application name dynamically, byCarlo Marcelo Arenas Belon.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4893 c046a42c-6fe2-441c-8c8c-71466251a162
Allow QEMU to connect directly to an NBD server, by Laurent Vivier.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4838 c046a42c-6fe2-441c-8c8c-71466251a162
Allow to share a disk image via nbd, by Laurent Vivier.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4837 c046a42c-6fe2-441c-8c8c-71466251a162
Add a parameter to disable host cache, by Laurent Vivier.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4836 c046a42c-6fe2-441c-8c8c-71466251a162
Merge NBD client/server, by Laurent Vivier.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4834 c046a42c-6fe2-441c-8c8c-71466251a162
Cleanup qemu-nbd related code, by Laurent Vivier.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4829 c046a42c-6fe2-441c-8c8c-71466251a162
qemu-nbd tool (Anthony Liguori)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4596 c046a42c-6fe2-441c-8c8c-71466251a162