From f2a5494fbdc929736d7368595db55987b77fe75e Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 2 Feb 2024 13:08:58 +0100 Subject: [PATCH] qemu_monitor: Simplify qemuMonitorIOWriteWithFD() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit After previous cleanups, qemuMonitorIOWriteWithFD() is but a thin wrapper over virSocketSendMsgWithFDs(). Replace the body of the former with a call to the latter. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/qemu/qemu_monitor.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7f3e4de329..0f29fb02b4 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -308,32 +308,9 @@ qemuMonitorIOWriteWithFD(qemuMonitor *mon, size_t len, int fd) { - struct msghdr msg = { 0 }; - struct iovec iov[1]; - int ret; - char control[CMSG_SPACE(sizeof(int))] = { 0 }; - struct cmsghdr *cmsg; - - iov[0].iov_base = (void *)data; - iov[0].iov_len = len; - - msg.msg_iov = iov; - msg.msg_iovlen = 1; - - msg.msg_control = control; - msg.msg_controllen = sizeof(control); + int fds[] = { fd }; - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - memcpy(CMSG_DATA(cmsg), &fd, sizeof(int)); - - do { - ret = sendmsg(mon->fd, &msg, 0); - } while (ret < 0 && errno == EINTR); - - return ret; + return virSocketSendMsgWithFDs(mon->fd, data, len, fds, G_N_ELEMENTS(fds)); } -- 2.47.2