mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Use sendmsg() on QEMU monitor socket
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
This commit is contained in:
parent
9de2972c30
commit
7d9576edcb
@ -2213,6 +2213,30 @@ qemuMonitorDiscardPendingData(virDomainObjPtr vm) {
|
||||
} while (ret > 0);
|
||||
}
|
||||
|
||||
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)
|
||||
@ -2226,8 +2250,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:
|
||||
|
Loading…
Reference in New Issue
Block a user