Skip to content

Commit e20da06

Browse files
authored
Properly manage libvirt services (#1603)
With newer CS9 and RHEL-9, libvirtd has moved to a modular, socket activated layout. This new layout conflicts with the single, monolithic "libvirtd.service" that was restarted until now, creating issues with other projects that may wrap this metal3-dev-env. There is a related PR against metal3-env-dev[1]. [1] metal3-io/metal3-dev-env#1313
1 parent d96ef53 commit e20da06

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

02_configure_host.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ source oc_mirror.sh
1010

1111
early_deploy_validation
1212

13+
#
14+
# Manage libvirtd services based on OS
15+
# Get a dedicated method, making it easier to duplicate
16+
# or move in order to expose it to some other parts if needed.
17+
# This is the same method as defined in metal3-dev-env via that
18+
# commit:
19+
# https://github.com/metal3-io/metal3-dev-env/pull/1313/commits/a6a79685986f9d7cb18c4eb680ee4d2a759e99dc
20+
#
21+
manage_libvirtd() {
22+
case ${DISTRO} in
23+
centos9|rhel9)
24+
for i in qemu network nodedev nwfilter secret storage interface; do
25+
sudo systemctl enable --now virt${i}d.socket
26+
sudo systemctl enable --now virt${i}d-ro.socket
27+
sudo systemctl enable --now virt${i}d-admin.socket
28+
done
29+
;;
30+
*)
31+
sudo systemctl restart libvirtd.service
32+
;;
33+
esac
34+
}
35+
1336
# Generate user ssh key
1437
if [ ! -f $HOME/.ssh/id_rsa.pub ]; then
1538
ssh-keygen -f ~/.ssh/id_rsa -P ""
@@ -141,14 +164,14 @@ fi
141164
ZONE="\nZONE=libvirt"
142165

143166
# Allow local non-root-user access to libvirt
144-
# Restart libvirtd service to get the new group membership loaded
145167
if ! id $USER | grep -q libvirt; then
146168
sudo usermod -a -G "libvirt" $USER
169+
gpasswd -a "${USER}" libvirt
147170
fi
148171

149-
# Restart to see we are using firewalld and the new
150-
# usergroup from above
151-
sudo systemctl restart libvirtd
172+
# This method, defined in common.sh, will either ensure sockets are up'n'running
173+
# for CS9 and RHEL9, or restart the libvirtd.service for other DISTRO
174+
manage_libvirtd
152175

153176
# As per https://github.com/openshift/installer/blob/master/docs/dev/libvirt-howto.md#configure-default-libvirt-storage-pool
154177
# Usually virt-manager/virt-install creates this: https://www.redhat.com/archives/libvir-list/2008-August/msg00179.html

0 commit comments

Comments
 (0)