Re: [libvirt] [PATCH 05/15] Make use of private data structure for monitor state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 03, 2009 at 02:49:59PM -0500, Daniel P. Berrange wrote:
> Introduce a new qemuDomainObjPrivate object which is used to store
> the private QEMU specific data associated with each virDomainObjPtr
> instance. This contains a single member, an instance of the new
> qemuMonitorPtr object which encapsulates the QEMU monitor state.
> The internals of the latter are private to the qemu_monitor* files,
> not to be shown to qemu_driver.c
> 
> * src/qemu/qemu_conf.h: Definition of qemuDomainObjPrivate.
> * src/qemu/qemu_driver.c: Register a functions for creating
>   and freeing qemuDomainObjPrivate instances with the domain
>   capabilities. Remove the qemudDispatchVMEvent() watch since
>   I/O watches are now handled by the monitor code itself. Pass
>   a new qemuHandleMonitorEOF() callback into qemuMonitorOpen
>   to allow notification when the monitor quits.
> * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Introduce
>   the 'qemuMonitor' object. Temporarily add new APIs
>   qemuMonitorWrite, qemuMonitorRead, qemuMonitorWaitForInput
>   to allow text based monitor impl to perform I/O.
> * src/qemu/qemu_monitor_text.c: Call APIs for reading/writing
>   to monitor instead of accessing the file handle directly.
[...]
> +int qemuMonitorWriteWithFD(qemuMonitorPtr mon,
> +                           const char *data,
> +                           size_t len,
> +                           int fd)
> +{
> +    struct msghdr msg;
> +    struct iovec iov[1];
> +    ssize_t ret;
> +    char control[CMSG_SPACE(sizeof(int))];
> +    struct cmsghdr *cmsg;
> +
> +    if (!mon->hasSendFD) {
> +        errno = EINVAL;
>          return -1;
>      }
> +
> +    memset(&msg, 0, sizeof(msg));
> +
> +    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);
> +
> +    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 == len ? 0 : -1;
> +}

  I must admit I'm a bit puzzled by this function, we are sending both
data and a file descriptor ? But it's an in-process exchange, why would
that be needed, I'm at loss ...

[...]
> -static int
> -qemuMonitorSendUnix(const virDomainObjPtr vm,
> -                    const char *cmd,
> -                    size_t cmdlen,
> -                    int scm_fd)
> -{
> -    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;
> -
> -    if (scm_fd != -1) {
> -        char control[CMSG_SPACE(sizeof(int))];
> -        struct cmsghdr *cmsg;
> -
> -        msg.msg_control = control;
> -        msg.msg_controllen = sizeof(control);
> -
> -        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), &scm_fd, sizeof(int));
> -    }
> -
> -    do {
> -        ret = sendmsg(vm->monitor, &msg, 0);
> -    } while (ret < 0 && errno == EINTR);
> -
> -    return ret == cmdlen ? 0 : -1;
> -}

  okay that's the source function, nothing new but still wondering...

Other than that I didn't found anything strange, so ACK, but if you
have time to explain :-)

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]