On Wed, Feb 23, 2022 at 12:25:38PM +0000, Daniel P. Berrangé wrote:
On Wed, Feb 23, 2022 at 10:56:11AM +0100, Martin Kletzander wrote:
> Commit 4e42686adef8 wrongly assumed how g_variant_new_parsed() works and broke
> starting of domains on systems with systemd (machined).
so IIUC, it isn't a arbitrary printf format, but rather the format
substitutions only get performed on full values/fields.
>
> Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
> ---
> src/util/virsystemd.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
> index 0554884811a7..18bf2932a426 100644
> --- a/src/util/virsystemd.c
> +++ b/src/util/virsystemd.c
> @@ -360,6 +360,7 @@ int virSystemdCreateMachine(const char *name,
> g_autofree char *creatorname = NULL;
> g_autofree char *slicename = NULL;
> g_autofree char *scopename = NULL;
> + g_autofree char *servicename = NULL;
> static int hasCreateWithNetwork = 1;
>
> if ((rc = virSystemdHasMachined()) < 0)
> @@ -369,6 +370,7 @@ int virSystemdCreateMachine(const char *name,
> return -1;
>
> creatorname = g_strdup_printf("libvirt-%s", drivername);
> + servicename = g_strdup_printf("virt%sd.service", drivername);
>
> if (partition) {
> if (!(slicename = virSystemdMakeSliceName(partition)))
> @@ -440,11 +442,10 @@ int virSystemdCreateMachine(const char *name,
> gnicindexes = g_variant_new_fixed_array(G_VARIANT_TYPE("i"),
> nicindexes, nnicindexes,
sizeof(int));
> gprops = g_variant_new_parsed("[('Slice', <%s>),"
> - " ('After',
<['libvirtd.service']>),"
> - " ('After',
<['virt%sd.service']>),"
> + " ('After',
<['libvirtd.service', %s]>),"
> " ('Before',
<['virt-guest-shutdown.target']>)]",
> slicename,
> - drivername);
> + servicename);
> message = g_variant_new("(s@ayssus@ai@a(sv))",
> name,
> guuid,
> @@ -490,11 +491,10 @@ int virSystemdCreateMachine(const char *name,
> guuid = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
> uuid, 16, sizeof(unsigned char));
> gprops = g_variant_new_parsed("[('Slice', <%s>),"
> - " ('After',
<['libvirtd.service']>),"
> - " ('After',
<['virt%sd.service']>),"
> + " ('After',
<['libvirtd.service', %s]>),"
> " ('Before',
<['virt-guest-shutdown.target']>)]",
> slicename,
> - drivername);
> + servicename);
> message = g_variant_new("(s@ayssus@a(sv))",
> name,
> guuid,
> --
> 2.35.1
>
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 :|