Re: Question about qemuDomainLogContextNew

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

 



On Mon, Mar 27, 2017 at 11:39:09AM +0800, Liu Feng wrote:
> Hi, Dear all
>     I have a question, and need your help.
>     I want to output some log message to
> "/var/log/libvirt/qemu/instance-xxxxxx" when guest kernel crashed, so I add
> following the code:
>     >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
>     static int
>     qemuProcessHandleGuestPanic(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
>                                         virDomainObjPtr vm,
>                                                                     void
> *opaque) { ......
>     +    qemuDomainLogContextPtr logCtxt = NULL;
> 
>     +    if (!(logCtxt = qemuDomainLogContextNew(driver, vm,
> QEMU_DOMAIN_LOG_CONTEXT_MODE_START))){
>     +        VIR_WARN("Unable to open domainlog");
>     +        goto cleanup;
>     +    }
> 
>         ......
>     }
> 
>     <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> 
>     But this code cannot get the logCtxt,
>     logCtxt = qemuDomainLogContextNew(driver, vm,
> QEMU_DOMAIN_LOG_CONTEXT_MODE_START)  always return NULL, so I CANNOT write
> message to log file.
> 

Far from being an expert in this area, but you might want to use
QEMU_DOMAIN_LOG_CONTEXT_MODE_ATTACH, since one domain log file most probably
exists already. Other than that, generally it's very hard to tell why a function
returns NULL, I'd suggest using GDB and see what causes the function to fail.
One more thing, looking at qemuDomainLogContextNew, if it's about to fail, it
will log an error, you might want to check the daemon log as well which will
give you an idea what exactly inside the function failed, but as I said,
nothing can serve you better than the good old GDB in this case.

Erik

>     Really Need your help, Thanks!
> 
>     Thanks
>     Feng

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

--
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]
  Powered by Linux