nbd: convert to using I/O channels for actual socket I/O
Now that all callers are converted to use I/O channels for
initial connection setup, it is possible to switch the core
NBD protocol handling core over to use QIOChannel APIs for
actual sockets I/O.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1455129674-17255-7-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/qemu-nbd.c b/qemu-nbd.c
index bc309e0..5e54290 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -249,7 +249,7 @@
goto out;
}
- ret = nbd_receive_negotiate(sioc->fd, NULL, &nbdflags,
+ ret = nbd_receive_negotiate(QIO_CHANNEL(sioc), NULL, &nbdflags,
&size, &local_error);
if (ret < 0) {
if (local_error) {
@@ -265,7 +265,7 @@
goto out_socket;
}
- ret = nbd_init(fd, sioc->fd, nbdflags, size);
+ ret = nbd_init(fd, sioc, nbdflags, size);
if (ret < 0) {
goto out_fd;
}
@@ -325,7 +325,6 @@
static gboolean nbd_accept(QIOChannel *ioc, GIOCondition cond, gpointer opaque)
{
QIOChannelSocket *cioc;
- int fd;
cioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
NULL);
@@ -340,10 +339,7 @@
nb_fds++;
nbd_update_server_watch();
- fd = dup(cioc->fd);
- if (fd >= 0) {
- nbd_client_new(exp, fd, nbd_client_closed);
- }
+ nbd_client_new(exp, cioc, nbd_client_closed);
object_unref(OBJECT(cioc));
return TRUE;