[libvirt] [PATCH v2] libxl: define a per-domain logger.

Jim Fehlig jfehlig at suse.com
Fri Jan 6 15:52:40 UTC 2017


On 01/06/2017 08:25 AM, Daniel P. Berrange wrote:
> On Fri, Jan 06, 2017 at 08:15:58AM -0700, Jim Fehlig wrote:
>> On 01/06/2017 01:04 AM, Cedric Bosdonnat wrote:
>>> On Thu, 2017-01-05 at 15:45 -0700, Jim Fehlig wrote:
>>>> Cédric Bosdonnat wrote:
>>>>> libxl doesn't provide a way to write one log for each domain. Thus
>>>>> we need to demux the messages. If our logger doesn't know to which
>>>>> domain to attribute a message, then it will write it to the default
>>>>> log file.
>>>>>
>>>>> Starting with Xen 4.9 (commit f9858025 and following), libxl will
>>>>> write the domain ID in an easy to grab manner. The logger introduced
>>>>> by this commit will use it to demux the libxl log messages.
>>>>
>>>> One thing I noticed when testing this on a Xen installation prior to that commit
>>>> is log files are created that will never be written to. E.g. after starting
>>>> libvirtd and one domain
>>>>
>>>> # ll /var/log/libvirt/libxl/
>>>> -rw-r--r-- 1 root root     0 Jan  5 15:48 Domain-0.log
>>>> -rw-r--r-- 1 root root 17512 Jan  5 15:49 libxl-driver.log
>>>> -rw-r--r-- 1 root root     0 Jan  5 15:49 sles12sp2-hvm.log
>>>>
>>>> IMO these empty, never-to-be-written-to log files might be a bit confusing to
>>>> users. AFAIK there is no way to detect up front that the underlying Xen supports
>>>> this capability right?
>>>
>>> No there is no way to know it since there is no public API change
>>> in libxl. The only thing we can do is delaying the creation of the file
>>> to the first message write.
>>
>> I think that is a wise thing to do, otherwise I envision bug reports such as
>> "my domain log files are 0 bytes" :-).
>
> Or put some content in them :-)
>
> With the QEMU driver, every single /var/log/libvirt/qemu/$GUEST.log will
> at least have the QEMU command line arguments, followed by a timestamp
> showing when it started.
>
> The idea of the CLI args is that it gives an accurate record of the config
> of the guest from QEMU's POV, which is helpful to support people as you
> can't be sure the XML you see is the same as the XML when the guest first
> started. You don't have CLI args for libxl, but perhaps there's some  confg
> you can easily serialize into there.

That's a good idea! libxl_domain_config_to_json() could be used to convert the 
libxl_domain_config object used at domain creation to json and write it to the 
domain log file.

Regards,
Jim




More information about the libvir-list mailing list