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

Re: [libvirt] [PATCH 04/15] Move code for low level QEMU monitor interaction into separate file



On Tue, Nov 03, 2009 at 02:49:58PM -0500, Daniel P. Berrange wrote:
> The qemu_driver.c code should not contain any code that interacts
> with the QEMU monitor at a low level. A previous commit moved all
> the command invocations out. This change moves out the code which
> actually opens the monitor device.
[...]
> +static int
> +qemuConnectMonitor(virDomainObjPtr vm, int reconnect)
> +{
> +    int rc;
> +    if ((rc = qemuMonitorOpen(vm, reconnect)) != 0) {
> +        VIR_ERROR(_("Failed to connect monitor for %s: %d\n"),
> +                  vm->def->name, rc);
> +        return -1;
> +    }
>  
> -static int qemudOpenMonitor(virConnectPtr conn,
> -                            virDomainObjPtr vm,
> -                            int reconnect);
> +    if ((vm->monitorWatch = virEventAddHandle(vm->monitor,
> +                                              VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR,
> +                                              qemudDispatchVMEvent,

  Let's try to keep at 80 columns, even if we don't reindent exactly
  under the opening brace

[...]
> +static int
> +qemuMonitorReadOutput(virDomainObjPtr vm,
> +                      int fd,
> +                      char *buf,
> +                      size_t buflen,
> +                      qemuMonitorHandleOutput func,
> +                      const char *what,
> +                      int timeout)
> +{
[...]
> +            if (errno != EAGAIN) {
> +                virReportSystemError(NULL, errno,
> +                                     _("Failure while reading %s startup output"),
> +                                     what);
> +                return -1;
> +            }
> +
> +            ret = poll(&pfd, 1, timeout);
> +            if (ret == 0) {
> +                qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
> +                                 _("Timed out while reading %s startup output"), what);
> +                return -1;
> +            } else if (ret == -1) {
> +                if (errno != EINTR) {
> +                    virReportSystemError(NULL, errno,
> +                                         _("Failure while reading %s startup output"),
> +                                         what);
> +                    return -1;
> +                }
> +            } else {
> +                /* Make sure we continue loop & read any further data
> +                   available before dealing with EOF */
> +                if (pfd.revents & (POLLIN | POLLHUP))
> +                    continue;
> +
> +                qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
> +                                 _("Failure while reading %s startup output"), what);
> +                return -1;

  same even if we might want to preserve the commit as a pure cut and
  paste, then let's resize to keep in 80 column as a second commit.

[...]
> +static int
> +qemuMonitorCheckPrompt(virDomainObjPtr vm,
> +                       const char *output,
> +                       int fd)
> +{
> +    if (strstr(output, "(qemu) ") == NULL)
> +        return 1; /* keep reading */

  just wondering, wouldn't it be safer to try to find the previous end
  of line too ?


  ACK !

Daniel

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


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