[libvirt] [PATCH 5/5] read saved vm status on libvirtd startup

Guido Günther agx at sigxcpu.org
Mon Jan 12 15:37:50 UTC 2009


On Mon, Jan 12, 2009 at 11:30:19AM +0000, Daniel P. Berrange wrote:
> There's different needs for each file descriptor
> 
>  - stdin_fd  - this is only ever used for incoming migration data
>    all other times it is hooked up to /dev/null. So we don't need
>    to keep this FD around at all
Agreed.

>  - stdout_fd - AFAIK, the only time we get any data on stdout is
>    when we run qemu -help to check support args. Current code will
>    read & log all data on stdout, but I believe this is effectively
>    nothing and so we could just hook it to /dev/null & ignore it
We can just dup that one too while at it in case qemu/kvm should dump
anything else there.

>  - stderr_fd - libvirtd reads this FD & logs the data to the domain
>    logfile in /var/log/libvirt/qemu/$NAME.log. Instead of having
>    the daemon process this logging, we can just dup() the file straight
>    onto the logfile FD, so data will be logged even when libvirtd is
>    not running. The only minor complication is that we need to parse
>    the logfile to get the monitor TTY path.
There's one more thing (which was my intial reason for asking): we also use
this fd in qemudDispatchVMEvent() to detect vm shutdown:

      if (events & VIR_EVENT_HANDLE_READABLE) {
            if (qemudVMData(driver, vm, fd) < 0)
                failed = 1;
        } else {
            quit = 1;
        }
    }

    if (failed || quit) {
        event = virDomainEventNewFromObj(vm,
                                         VIR_DOMAIN_EVENT_STOPPED,
                                         quit ?
                                         VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN
:
                                         VIR_DOMAIN_EVENT_STOPPED_FAILED);
        qemudShutdownVMDaemon(NULL, driver, vm);
        if (!vm->persistent) {
            virDomainRemoveInactive(&driver->domains,
                                    vm);
            vm = NULL;
        }

Using the monitor fd for this instead should work. Would that be o.k.?
 -- Guido




More information about the libvir-list mailing list