On Wed, Jul 22, 2009 at 10:57:34PM +0100, Mark McLoughlin wrote: > 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; > + } Oooooh, of course this is why you added the allocation instead of doing two safewrite() calls. In which case, ACK to this & previous patch Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list