]> git.ipfire.org Git - thirdparty/libvirt.git/commit
tools: fix libvirt-guests.sh text assignments
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>
Wed, 19 Aug 2020 10:04:58 +0000 (12:04 +0200)
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>
Fri, 21 Aug 2020 06:31:18 +0000 (08:31 +0200)
commitab5b5f22b9d9d32177ea57f4300497e5022059fe
tree56843039dd21883a439272b696d980571e427790
parentf34642d17cdf45096c35b2b87243c983157a6280
tools: fix libvirt-guests.sh text assignments

In libvirt 6.6 stopping guests with libvirt-guests.sh is broken.
As soon as there is more than one guest one can see
`systemctl stop libvirt-guests` failing and in the log we see:
  libvirt-guests.sh[2455]: Running guests on default URI:
  libvirt-guests.sh[2457]: /usr/lib/libvirt/libvirt-guests.sh: 120:
      local: 2a49cb0f-1ff8-44b5-a61d-806b9e52dae2: bad variable name
  libvirt-guests.sh[2462]: no running guests.

That is due do mutliple guests becoming a list of UUIDs. Without
recognizing this as one single string the assignment breaks when using 'local'
(which was recently added in 6.3.0). This is because local is defined as
  local [option] [name[=value] ... | - ]
which makes the shell trying handle the further part of the string as
variable names. In the error above that string isn't a valid variable
name triggering the issue that is seen.

This depends on the shell being used. POSIX shells don't have 'local'
specified yet and for the common shells it depends. It worked in bash and
bash-in-POSIX-mode, but for example dash in POSIX mode triggers the issue.

To resolve that 'textify' all assignments that are strings or potentially
can become such lists (even if they are not using the local qualifier).

Fixes: 08071ec0 "tools: variables clean-up in libvirt-guests script"
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
tools/libvirt-guests.sh.in