[libvirt PATCH 09/15] systemd: check org.freedesktop.machine1 registration

marcandre.lureau@redhat.com posted 15 patches 5 years, 10 months ago
[libvirt PATCH 09/15] systemd: check org.freedesktop.machine1 registration
Posted by marcandre.lureau@redhat.com 5 years, 10 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Since commit f10bd740e178c89f24d0b0298d0b5413537d0699 ("Cache the
presence of machine1 service"), the code checks for systemd1
registration. Not totally unreasonable, but that seems odd since we
actually check machined presence in this function.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 src/util/virsystemd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
index 9a659dad84..74d0d15ca7 100644
--- a/src/util/virsystemd.c
+++ b/src/util/virsystemd.c
@@ -163,7 +163,7 @@ virSystemdHasMachined(void)
         return ret;
     }
 
-    if ((ret = virDBusSystemIsServiceRegistered("org.freedesktop.systemd1")) == -1)
+    if ((ret = virDBusSystemIsServiceRegistered("org.freedesktop.machine1")) == -1)
         return ret;
     g_atomic_int_set(&virSystemdHasMachinedCachedValue, ret);
     return ret;
-- 
2.26.0.rc2.42.g98cedd0233

Re: [libvirt PATCH 09/15] systemd: check org.freedesktop.machine1 registration
Posted by Ján Tomko 5 years, 10 months ago
On a Monday in 2020, marcandre.lureau@redhat.com wrote:
>From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
>Since commit f10bd740e178c89f24d0b0298d0b5413537d0699 ("Cache the
>presence of machine1 service"), the code checks for systemd1
>registration. Not totally unreasonable, but that seems odd since we
>actually check machined presence in this function.

That is intentional.

We only count the systemd-based services as really activatable
if systemd1 is already registered.

On some Frankenstein'd Gentoo systems with systemd installed
but not started, the services were showing up as activatable
but failed with obscure errors.

Some history:
commit 12ee0b98d3ddcb2c71cdb2352512153791ebcb7e
     Check if systemd is running before creating machines
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=12ee0b98
https://bugs.gentoo.org/show_bug.cgi?id=493246#c22

Jano
Re: [libvirt PATCH 09/15] systemd: check org.freedesktop.machine1 registration
Posted by Daniel P. Berrangé 5 years, 10 months ago
On Tue, Apr 07, 2020 at 11:50:31AM +0200, Ján Tomko wrote:
> On a Monday in 2020, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > 
> > Since commit f10bd740e178c89f24d0b0298d0b5413537d0699 ("Cache the
> > presence of machine1 service"), the code checks for systemd1
> > registration. Not totally unreasonable, but that seems odd since we
> > actually check machined presence in this function.
> 
> That is intentional.
> 
> We only count the systemd-based services as really activatable
> if systemd1 is already registered.
> 
> On some Frankenstein'd Gentoo systems with systemd installed
> but not started, the services were showing up as activatable
> but failed with obscure errors.

We could benefit from a comment to this effect being added to
the code, as one of my own local changes makes much the same
fix as Marc-Andre's

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [libvirt PATCH 09/15] systemd: check org.freedesktop.machine1 registration
Posted by Marc-André Lureau 5 years, 10 months ago
Hi

On Tue, Apr 7, 2020 at 11:50 AM Ján Tomko <jtomko@redhat.com> wrote:
>
> On a Monday in 2020, marcandre.lureau@redhat.com wrote:
> >From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> >Since commit f10bd740e178c89f24d0b0298d0b5413537d0699 ("Cache the
> >presence of machine1 service"), the code checks for systemd1
> >registration. Not totally unreasonable, but that seems odd since we
> >actually check machined presence in this function.
>
> That is intentional.
>
> We only count the systemd-based services as really activatable
> if systemd1 is already registered.
>
> On some Frankenstein'd Gentoo systems with systemd installed
> but not started, the services were showing up as activatable
> but failed with obscure errors.
>
> Some history:
> commit 12ee0b98d3ddcb2c71cdb2352512153791ebcb7e
>      Check if systemd is running before creating machines
> https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=12ee0b98
> https://bugs.gentoo.org/show_bug.cgi?id=493246#c22

Ok, I imagined something like that. However, making systemd a
hard-dependency for machine1 is not a good solution. In theory,
machine1 could have a different implementation that doesn't rely on
systemd.


Re: [libvirt PATCH 09/15] systemd: check org.freedesktop.machine1 registration
Posted by Daniel P. Berrangé 5 years, 10 months ago
On Tue, Apr 07, 2020 at 12:29:29PM +0200, Marc-André Lureau wrote:
> Hi
> 
> On Tue, Apr 7, 2020 at 11:50 AM Ján Tomko <jtomko@redhat.com> wrote:
> >
> > On a Monday in 2020, marcandre.lureau@redhat.com wrote:
> > >From: Marc-André Lureau <marcandre.lureau@redhat.com>
> > >
> > >Since commit f10bd740e178c89f24d0b0298d0b5413537d0699 ("Cache the
> > >presence of machine1 service"), the code checks for systemd1
> > >registration. Not totally unreasonable, but that seems odd since we
> > >actually check machined presence in this function.
> >
> > That is intentional.
> >
> > We only count the systemd-based services as really activatable
> > if systemd1 is already registered.
> >
> > On some Frankenstein'd Gentoo systems with systemd installed
> > but not started, the services were showing up as activatable
> > but failed with obscure errors.
> >
> > Some history:
> > commit 12ee0b98d3ddcb2c71cdb2352512153791ebcb7e
> >      Check if systemd is running before creating machines
> > https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=12ee0b98
> > https://bugs.gentoo.org/show_bug.cgi?id=493246#c22
> 
> Ok, I imagined something like that. However, making systemd a
> hard-dependency for machine1 is not a good solution. In theory,
> machine1 could have a different implementation that doesn't rely on
> systemd.

I don't think we need to worry about that possibilty, since AFAIK
no such alternate impl exists. Such a replacement would be a
major piece of work needing to implement a lot of system logic
around the cgroups/service setup, so I'd be sceptical that libvirt
would "just work" regardless. 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|