[libvirt] [PATCH] util: swap After/Before clauses in virSystemdCreateMachine

An unexpected behavior in systemd has been introduced between the versions 225 and 229: when non-existing units are specified in After/Before clauses, systemd fails if the After clause is listed first. What is expected is that systemd simply ignores these clauses. Because the After clause is specified before the Before clause in virSystemdCreateMachine and because libvirt does not tolerate missing the systemd-machined registration, it leads to fatal boot failures, whereas instances could start properly without these units - only the shutdown workflow could be affected. This fixes the following error in some particular cases: `libvirtError: Cannot set property Before, or unknown property.`. If accepted, this bug fix should be backported. https://bugzilla.redhat.com/show_bug.cgi?id=1350909 --- src/util/virsystemd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 871db7e..3a146f8 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -365,8 +365,8 @@ int virSystemdCreateMachine(const char *name, nnicindexes, nicindexes, 3, "Slice", "s", slicename, - "After", "as", 1, "libvirtd.service", - "Before", "as", 1, "libvirt-guests.service") < 0) + "Before", "as", 1, "libvirt-guests.service", + "After", "as", 1, "libvirtd.service") < 0) goto cleanup; if (error.level == VIR_ERR_ERROR) { @@ -406,8 +406,8 @@ int virSystemdCreateMachine(const char *name, rootdir ? rootdir : "", 3, "Slice", "s", slicename, - "After", "as", 1, "libvirtd.service", - "Before", "as", 1, "libvirt-guests.service") < 0) + "Before", "as", 1, "libvirt-guests.service", + "After", "as", 1, "libvirtd.service") < 0) goto cleanup; } -- 1.8.3.1

On Wed, Jun 29, 2016 at 03:15:44AM -0700, Quentin Machu wrote:
An unexpected behavior in systemd has been introduced between the versions 225 and 229: when non-existing units are specified in After/Before clauses, systemd fails if the After clause is listed first. What is expected is that systemd simply ignores these clauses. Because the After clause is specified before the Before clause in virSystemdCreateMachine and because libvirt does not tolerate missing the systemd-machined registration, it leads to fatal boot failures, whereas instances could start properly without these units - only the shutdown workflow could be affected.
IMHO the real bug here is the fact that you are missing the libvirtd.service unit file referenced by the After clause. That missing unit file is what should be fixed. The order of properties should have no effect at all - any functional difference in After/Before and Before/After is likely a bug in systemd that should be fixed there, as there is no defined requirement from systemd to set properties in any particular order. If this change in ordering has an effect for you, I think it is likely just blind luck. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Quentin Machu