Switch from using write() to using sendmsg() on QEMU's monitor socket so that we can add support for SCM_RIGHTS. * src/qemu_driver.c: add sendmsg() based qemudMonitorSendUnix() and use it when the monitor fd is a unix socket --- src/qemu_driver.c | 37 +++++++++++++++++++++++++++++++++++-- 1 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index 7d4de9e..e6e6786 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -2013,6 +2013,30 @@ qemuMonitorDiscardPendingData(virDomainObjPtr vm) { } static int +qemudMonitorSendUnix(const virDomainObjPtr vm, + const char *cmd, + size_t cmdlen) +{ + struct msghdr msg; + struct iovec iov[1]; + ssize_t ret; + + memset(&msg, 0, sizeof(msg)); + + iov[0].iov_base = (void *)cmd; + iov[0].iov_len = cmdlen; + + msg.msg_iov = iov; + msg.msg_iovlen = 1; + + do { + ret = sendmsg(vm->monitor, &msg, 0); + } while (ret < 0 && errno == EINTR); + + return ret == cmdlen ? 0 : -1; +} + +static int qemudMonitorSend(const virDomainObjPtr vm, const char *cmd) { @@ -2025,8 +2049,17 @@ qemudMonitorSend(const virDomainObjPtr vm, len = strlen(full); - if (safewrite(vm->monitor, full, len) != len) - goto out; + switch (vm->monitor_chr->type) { + case VIR_DOMAIN_CHR_TYPE_UNIX: + if (qemudMonitorSendUnix(vm, full, len) < 0) + goto out; + break; + default: + case VIR_DOMAIN_CHR_TYPE_PTY: + if (safewrite(vm->monitor, full, len) != len) + goto out; + break; + } ret = 0; out: -- 1.6.2.5 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list