sockets: move qapi_copy_SocketAddress into qemu-sockets.c
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. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
17c55decec
commit
2a8e21c7c8
@ -118,4 +118,8 @@ SocketAddress *socket_local_address(int fd, Error **errp);
|
|||||||
*/
|
*/
|
||||||
SocketAddress *socket_remote_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 */
|
#endif /* QEMU_SOCKET_H */
|
||||||
|
25
qemu-char.c
25
qemu-char.c
@ -92,31 +92,6 @@
|
|||||||
|
|
||||||
/***********************************************************/
|
/***********************************************************/
|
||||||
/* Socket address helpers */
|
/* 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,
|
static int SocketAddress_to_str(char *dest, int max_len,
|
||||||
const char *prefix, SocketAddress *addr,
|
const char *prefix, SocketAddress *addr,
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#include "monitor/monitor.h"
|
#include "monitor/monitor.h"
|
||||||
#include "qemu/sockets.h"
|
#include "qemu/sockets.h"
|
||||||
#include "qemu/main-loop.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
|
#ifndef AI_ADDRCONFIG
|
||||||
# define AI_ADDRCONFIG 0
|
# define AI_ADDRCONFIG 0
|
||||||
@ -1128,3 +1131,30 @@ SocketAddress *socket_remote_address(int fd, Error **errp)
|
|||||||
|
|
||||||
return socket_sockaddr_to_address(&ss, sslen, 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);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user