From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58565) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcwJc-0000Er-Lm for qemu-devel@nongnu.org; Fri, 18 Sep 2015 10:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcvZP-0007hH-7e for qemu-devel@nongnu.org; Fri, 18 Sep 2015 09:20:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcvZO-0007gI-QY for qemu-devel@nongnu.org; Fri, 18 Sep 2015 09:19:19 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 56D23C06428C for ; Fri, 18 Sep 2015 13:19:18 +0000 (UTC) From: "Daniel P. Berrange" Date: Fri, 18 Sep 2015 14:18:56 +0100 Message-Id: <1442582350-9179-3-git-send-email-berrange@redhat.com> In-Reply-To: <1442582350-9179-1-git-send-email-berrange@redhat.com> References: <1442582350-9179-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH v1 02/16] sockets: move qapi_copy_SocketAddress into qemu-sockets.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Dr. David Alan Gilbert" , Gerd Hoffmann The qapi_copy_SocketAddress method is going to be useful in more places than just qemu-char.c, so move it into the qemu-sockets.c file to allow its reuse. Signed-off-by: Daniel P. Berrange --- include/qemu/sockets.h | 4 ++++ qemu-char.c | 25 ------------------------- util/qemu-sockets.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 3ea7cc9..5a183c5 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -118,4 +118,8 @@ SocketAddress *socket_local_address(int fd, Error **errp); */ SocketAddress *socket_remote_address(int fd, Error **errp); + +void qapi_copy_SocketAddress(SocketAddress **p_dest, + SocketAddress *src); + #endif /* QEMU_SOCKET_H */ diff --git a/qemu-char.c b/qemu-char.c index 653ea10..50ea4f7 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -92,31 +92,6 @@ /***********************************************************/ /* Socket address helpers */ -static void qapi_copy_SocketAddress(SocketAddress **p_dest, - SocketAddress *src) -{ - QmpOutputVisitor *qov; - QmpInputVisitor *qiv; - Visitor *ov, *iv; - QObject *obj; - - *p_dest = NULL; - - qov = qmp_output_visitor_new(); - ov = qmp_output_get_visitor(qov); - visit_type_SocketAddress(ov, &src, NULL, &error_abort); - obj = qmp_output_get_qobject(qov); - qmp_output_visitor_cleanup(qov); - if (!obj) { - return; - } - - qiv = qmp_input_visitor_new(obj); - iv = qmp_input_get_visitor(qiv); - visit_type_SocketAddress(iv, p_dest, NULL, &error_abort); - qmp_input_visitor_cleanup(qiv); - qobject_decref(obj); -} static int SocketAddress_to_str(char *dest, int max_len, const char *prefix, SocketAddress *addr, diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 2bdfacf..9cc5bee 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -25,6 +25,9 @@ #include "monitor/monitor.h" #include "qemu/sockets.h" #include "qemu/main-loop.h" +#include "qapi/qmp-input-visitor.h" +#include "qapi/qmp-output-visitor.h" +#include "qapi-visit.h" #ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 @@ -1125,3 +1128,30 @@ SocketAddress *socket_remote_address(int fd, Error **errp) return socket_sockaddr_to_address(&ss, sslen, errp); } + + +void qapi_copy_SocketAddress(SocketAddress **p_dest, + SocketAddress *src) +{ + QmpOutputVisitor *qov; + QmpInputVisitor *qiv; + Visitor *ov, *iv; + QObject *obj; + + *p_dest = NULL; + + qov = qmp_output_visitor_new(); + ov = qmp_output_get_visitor(qov); + visit_type_SocketAddress(ov, &src, NULL, &error_abort); + obj = qmp_output_get_qobject(qov); + qmp_output_visitor_cleanup(qov); + if (!obj) { + return; + } + + qiv = qmp_input_visitor_new(obj); + iv = qmp_input_get_visitor(qiv); + visit_type_SocketAddress(iv, p_dest, NULL, &error_abort); + qmp_input_visitor_cleanup(qiv); + qobject_decref(obj); +} -- 2.4.3