diff --git a/include/io/task.h b/include/io/task.h
index a993212..df9499a 100644
--- a/include/io/task.h
+++ b/include/io/task.h
@@ -159,7 +159,7 @@ typedef int (*QIOTaskWorker)(QIOTask *task,
  *      QIOTask *task;
  *      SocketAddress *addrCopy;
  *
- *      qapi_copy_SocketAddress(&addrCopy, addr);
+ *      addrCopy = QAPI_CLONE(SocketAddress, addr);
  *      task = qio_task_new(OBJECT(obj), func, opaque, notify);
  *
  *      qio_task_run_in_thread(task, myobject_listen_worker,
diff --git a/include/qapi/clone-visitor.h b/include/qapi/clone-visitor.h
index 16ceff5..b16177e 100644
--- a/include/qapi/clone-visitor.h
+++ b/include/qapi/clone-visitor.h
@@ -11,7 +11,9 @@
 #ifndef QAPI_CLONE_VISITOR_H
 #define QAPI_CLONE_VISITOR_H

+#include "qemu/typedefs.h"
 #include "qapi/visitor.h"
+#include "qapi-visit.h"

 /*
  * The clone visitor is for direct use only by the QAPI_CLONE() macro;
diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
index 1bd9218..3e3445f 100644
--- a/include/qemu/sockets.h
+++ b/include/qemu/sockets.h
@@ -106,8 +106,4 @@ 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/io/channel-socket.c b/io/channel-socket.c
index ca8bc20..27eee07 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -23,6 +23,7 @@
 #include "io/channel-socket.h"
 #include "io/channel-watch.h"
 #include "trace.h"
+#include "qapi/clone-visitor.h"

 #define SOCKET_MAX_FDS 16

@@ -182,7 +183,7 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
         OBJECT(ioc), callback, opaque, destroy);
     SocketAddress *addrCopy;

-    qapi_copy_SocketAddress(&addrCopy, addr);
+    addrCopy = QAPI_CLONE(SocketAddress, addr);

     /* socket_connect() does a non-blocking connect(), but it
      * still blocks in DNS lookups, so we must use a thread */
@@ -244,7 +245,7 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
         OBJECT(ioc), callback, opaque, destroy);
     SocketAddress *addrCopy;

-    qapi_copy_SocketAddress(&addrCopy, addr);
+    addrCopy = QAPI_CLONE(SocketAddress, addr);

     /* socket_listen() blocks in DNS lookups, so we must use a thread */
     trace_qio_channel_socket_listen_async(ioc, addr);
@@ -324,8 +325,8 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
     struct QIOChannelSocketDGramWorkerData *data = g_new0(
         struct QIOChannelSocketDGramWorkerData, 1);

-    qapi_copy_SocketAddress(&data->localAddr, localAddr);
-    qapi_copy_SocketAddress(&data->remoteAddr, remoteAddr);
+    data->localAddr = QAPI_CLONE(SocketAddress, localAddr);
+    data->remoteAddr = QAPI_CLONE(SocketAddress, remoteAddr);

     trace_qio_channel_socket_dgram_async(ioc, localAddr, remoteAddr);
     qio_task_run_in_thread(task,
diff --git a/qemu-char.c b/qemu-char.c
index b13ecbb..0ceb545 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -32,8 +32,7 @@
 #include "sysemu/char.h"
 #include "hw/usb.h"
 #include "qmp-commands.h"
-#include "qapi/qmp-input-visitor.h"
-#include "qapi/qmp-output-visitor.h"
+#include "qapi/clone-visitor.h"
 #include "qapi-visit.h"
 #include "qemu/base64.h"
 #include "io/channel-socket.h"
@@ -4383,7 +4382,7 @@ static CharDriverState *qmp_chardev_open_socket(const char *id,
         }
     }

-    qapi_copy_SocketAddress(&s->addr, sock->addr);
+    s->addr = QAPI_CLONE(SocketAddress, sock->addr);

     chr->opaque = s;
     chr->chr_write = tcp_chr_write;
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index dcf86ec..09203fe 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -1124,26 +1124,3 @@ 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)
-{
-    Visitor *ov, *iv;
-    QObject *obj;
-
-    *p_dest = NULL;
-
-    ov = qmp_output_visitor_new(&obj);
-    visit_type_SocketAddress(ov, NULL, &src, &error_abort);
-    visit_complete(ov, &obj);
-    visit_free(ov);
-    if (!obj) {
-        return;
-    }
-
-    iv = qmp_input_visitor_new(obj, true);
-    visit_type_SocketAddress(iv, NULL, p_dest, &error_abort);
-    visit_free(iv);
-    qobject_decref(obj);
-}
