[systemd-devel] systemd-detect-virt API
Mantas Mikulėnas
grawity at gmail.com
Tue Jan 21 11:45:34 UTC 2020
On Tue, Jan 21, 2020 at 1:34 PM Pavla Kratochvilova <pkratoch at redhat.com>
wrote:
> Hi,
>
> Is there any API for systemd-detect-virt that would provide a way to call
> it from a c++ code?
>
> I need to detect if running in container and "systemd-detect-virt -c" gets
> the job done, but I don't want to call the shell command. I haven't found
> any good way, but maybe I am missing something.
>
I think the only other option is to make a DBus call to systemd – read the
"org.freedesktop.systemd1.Manager.Virtualization" property at
/org/freedesktop/systemd1.
(This would also avoid permission problems in case any detection methods
require root.)
--
Mantas Mikulėnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20200121/fa4c85a3/attachment.htm>
More information about the systemd-devel
mailing list