Statistics
| Branch: | Revision:

root / qemu-nbd.c @ c09015dd

History | View | Annotate | Download (14.8 kB)

# Date Author Comment
dc10e8b3 01/06/2012 05:09 pm Stefan Hajnoczi

qemu-nbd: drop loop which can never loop

For some reason nbd_client_thread() has a do..while loop which can never
loop, the condition is bogus because we would take a goto instead. Drop
the loop.

Reported-by: Dr David Alan Gilbert <>...

a61c6782 12/22/2011 12:53 pm Paolo Bonzini

qemu-nbd: use common main loop

Using a single main loop for sockets will help yielding from the socket
coroutine back to the main loop, and later reentering it.

Signed-off-by: Paolo Bonzini <>

1743b515 12/22/2011 12:53 pm Paolo Bonzini

qemu-nbd: move client handling to nbd.c

This patch sets up the fd handler in nbd.c instead of qemu-nbd.c. It
introduces NBDClient, which wraps the arguments to nbd_trip in a single
structure, so that we can add a notifier to it. This way, qemu-nbd can
know about disconnections....

94607e7a 12/22/2011 12:53 pm Paolo Bonzini

qemu-nbd: remove offset argument to nbd_trip

The argument is write-only.

Signed-off-by: Paolo Bonzini <>

3777b09f 12/22/2011 12:53 pm Paolo Bonzini

qemu-nbd: remove data_size argument to nbd_trip

The size of the buffer is in practice part of the protocol.

Signed-off-by: Paolo Bonzini <>

af49bbbe 12/22/2011 12:53 pm Paolo Bonzini

qemu-nbd: introduce NBDExport

Wrap the common parameters of nbd_trip and nbd_negotiate in a
single opaque struct.

Signed-off-by: Paolo Bonzini <>

bb345110 11/11/2011 03:02 pm Paolo Bonzini

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 the
server is a child process. This will change when both sides will be
in the same process, and anyway cleaning up things nicely upon SIGTERM...

b32f6c28 11/11/2011 03:02 pm Paolo Bonzini

qemu-nbd: rename socket variable

It will be moved to a global variable by the next patch, and it
would conflict with the socket function.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

a517e88b 11/11/2011 03:02 pm Paolo Bonzini

qemu-nbd: move client to a thread

This avoids that qemu-nbd uses both forking and threads, which do
not 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,...

c1f8fdc3 11/11/2011 03:02 pm Paolo Bonzini

qemu-nbd: print error messages from the daemon through a pipe

In order to get nice error messages, keep the qemu-nbd process running
until 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...

f1ef5555 11/11/2011 03:02 pm Paolo Bonzini

qemu-nbd: fix socket creation race

Now that the client and server are in the same process, there is
no need to race on the creation of the socket. We can open the
listening socket before starting the client thread.

This avoids that "qemu-nbd -v -c" prints this once before connecting...

802ddc37 11/11/2011 03:02 pm Paolo Bonzini

qemu-nbd: open the block device after starting the client thread

This is cleaner, because we do not need to close the block device when
there is an error opening /dev/nbdX. It was done this way only to
print errors before daemonizing.

At the same time, use atexit to ensure that the block device is closed...

b90fb4b8 09/19/2011 12:34 pm Paolo Bonzini

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 it
in qemu-nbd.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

5a61cb60 09/09/2011 11:56 am Stefan Weil

Fix include statements for qemu-common.h

  • qemu-common.h is not a system include file, so it should be included
    with "" instead of <>. Otherwise incremental builds might fail
    because only local include files are checked for changes.
  • linux-user/syscall.c included the file twice....
7267c094 08/21/2011 07:01 am Anthony Liguori

Use glib memory allocation and free functions

qemu_malloc/qemu_free no longer exist after this commit.

Signed-off-by: Anthony Liguori <>

f97742d0 06/14/2011 04:10 am Alexandre Raymond

Darwin: Fix compilation warning regarding the deprecated daemon() function

Changes since v1: create a wrapper function named qemu_daemon() in oslib-posix.c
instead of putting the OS specific workaround in qemu-nbd.c directly.

On OSX >= 10.5, daemon() is deprecated, resulting in the following warning:...

a6599793 06/08/2011 11:39 am Christoph Hellwig

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 also
specify BDRV_O_CACHE_WB to give them writeback semantics.

Signed-off-by: Christoph Hellwig <>...

ad717139 12/17/2010 05:11 pm Kevin Wolf

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 <>

72aef731 09/21/2010 04:39 pm Christoph Hellwig

use qemu_blockalign consistently

Use qemu_blockalign for all allocations in the block layer. This allows
increasing the required alignment, which is need to support O_DIRECT on
devices with large block sizes.

Signed-off-by: Christoph Hellwig <>...

c2e2872b 09/21/2010 04:39 pm Laurent Vivier

nbd: correctly manage default port

block/nbd.c: use default port number when none is specified
qemu-nbd.c: use IANA-assigned port number: 10809

Signed-off-by: Laurent Vivier <>
Signed-off-by: Kevin Wolf <>

aab2e8f7 09/08/2010 10:26 pm Anthony Liguori

Merge remote branch 'kwolf/for-anthony' into staging

e301b13d 09/04/2010 12:45 pm Jes Sorensen

Respect return value from nbd_client()

Signed-off-by: Jes Sorensen <>
Signed-off-by: Blue Swirl <>

0a4eb864 09/04/2010 12:45 pm Jes Sorensen

Remove unused argument for nbd_client()

Signed-off-by: Jes Sorensen <>
Signed-off-by: Blue Swirl <>

1d45f8b5 08/30/2010 07:29 pm Laurent Vivier

nbd: Introduce NBD named exports.

This patch allows to connect Qemu using NBD protocol to an nbd-server
using 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...

cb7cf0e3 05/17/2010 11:20 am Ryota Ozaki

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...

d6e9098e 04/23/2010 05:08 pm Kevin Wolf

Replace calls of old bdrv_open

What is known today as bdrv_open2 becomes the new bdrv_open. All remaining
callers of the old function are converted to the new one. In some places they
even know the right format, so they should have used bdrv_open2 from the...

b6353bea 03/27/2010 03:02 pm Ryota Ozaki

qemu-nbd: Fix invalid usage of the first argument of errx

errx takes the exit status of a process as the first
argument. Passing errno to it is wrong. Instead the
patch lets errx take EXIT_FAILURE.

Signed-off-by: Ryota Ozaki <>
Signed-off-by: Aurelien Jarno <>

a16c174c 03/27/2010 02:56 pm Ryota Ozaki

qemu-nbd: Fix return value handling of bdrv_open

bdrv_open may return -errno so we have to check
if the return value is '< 0', not '== -1'.

Signed-off-by: Ryota Ozaki <>
Signed-off-by: Aurelien Jarno <>

07108b29 03/17/2010 06:16 pm Naphtali Sprei

read-only: minor cleanup

Really use read-only flags for opening the file when asked for read-only

Signed-off-by: Naphtali Sprei <>
Signed-off-by: Anthony Liguori <>

f8a83245 01/27/2010 12:41 am Herve Poussineau

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 (ie
VirtualAlloc) but frees it with qemu_free (ie free).
Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks....

f5edb014 01/20/2010 04:25 pm Naphtali Sprei

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,...

22ff51ee 12/23/2009 05:45 pm Blue Swirl

qemu-nbd: fix OpenBSD linker warning

Signed-off-by: Blue Swirl <>

2bff4b6f 12/23/2009 05:34 pm Blue Swirl

Compile qemu-nbd also on OpenBSD and Solaris

basename() needs #include <libgen.h>.

No prototype for daemon() is available on Solaris, but link
succeeds.

Signed-off-by: Blue Swirl <>

660f11be 08/01/2009 12:16 am Blue Swirl

Fix Sparse warnings: "Using plain integer as NULL pointer"

Signed-off-by: Blue Swirl <>

8167ee88 07/16/2009 11:47 pm Blue Swirl

Update to a hopefully more future proof FSF address

Signed-off-by: Blue Swirl <>

f5de141b 06/15/2009 08:51 pm Anthony Liguori

Fix warning in qemu-nbd.c

qemu-nbd.c:349: error: ignoring return value of 'daemon', declared with attribute warn_unused_result

Signed-off-by: Anthony Liguori <>

1eec614b 02/06/2009 12:06 am aliguori

toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)

Signed-off-by: Avi Kivity <>
Signed-off-by: Anthony Liguori <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6531 c046a42c-6fe2-441c-8c8c-71466251a162

d6aa671f 01/08/2009 09:34 pm aliguori

qemu-nbd: fix options: -b (--bind) expects an argument (IFACE) (Uri Lublin)

Rebased for qemu tree.

Signed-off-by: Uri Lublin <>
Signed-off-by: Anthony Liguori <>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6246 c046a42c-6fe2-441c-8c8c-71466251a162

fad6cb1a 01/05/2009 12:05 am aurel32

Update FSF address in GPL/LGPL boilerplate

The attached patch updates the FSF address in the GPL/LGPL boilerplate
in most GPL/LGPLed files, and also in COPYING.LIB.

Signed-off-by: Stuart Brady <>
Signed-off-by: Aurelien Jarno <>...

b1d8e52e 10/26/2008 03:43 pm blueswir1

Fix undeclared symbol warnings from sparse

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5539 c046a42c-6fe2-441c-8c8c-71466251a162

9f7965c7 10/14/2008 05:42 pm aliguori

Expand cache= option and use write-through caching by default

This patch changes the cache= option to accept none, writeback, or writethough
to control the host page cache behavior. By default, writethrough caching is
now used which internally is implemented by using O_DSYNC to open the disk...

27982661 09/10/2008 06:23 pm aliguori

qemu-nbd: remove useless parameter from nbd_negotiate() (Laurent Vivier)

This patch removes "BlockDriverState *bs" from nbd_negotiate() because
it is not used.

Signed-off-by: Laurent Vivier <>
Signed-off-by: Anthony Liguori <>...

315bc7aa 07/18/2008 09:06 pm ths

Allow qemu-nbd --version to show the application name dynamically, by
Carlo Marcelo Arenas Belon.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4893 c046a42c-6fe2-441c-8c8c-71466251a162

75818250 07/03/2008 04:41 pm ths

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

3b05a8e9 07/03/2008 03:45 pm ths

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

2f726488 07/03/2008 02:47 pm ths

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

cd831bd7 07/03/2008 01:23 pm ths

Merge NBD client/server, by Laurent Vivier.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4834 c046a42c-6fe2-441c-8c8c-71466251a162

975b092b 07/03/2008 12:18 am ths

Cleanup qemu-nbd related code, by Laurent Vivier.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4829 c046a42c-6fe2-441c-8c8c-71466251a162

7a5ca864 05/28/2008 12:13 am bellard

qemu-nbd tool (Anthony Liguori)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4596 c046a42c-6fe2-441c-8c8c-71466251a162