qemu: Move channelTargetDir into stateDir

For historical reasons (i.e. unknown reason) we put channel
sockets into a path derived from cfg->libDir which is a path that
survives host reboots (e.g. /var/lib/libvirt/...). This is not
necessary and in fact for session daemon creates a longer prefix:

  XDG_CONFIG_HOME -> /home/user/.config
  XDG_RUNTIME_DIR -> /run/user/1000

Worse, if host is rebooted suddenly (e.g. due to power loss) then
we leave files behind and nobody will ever remove them.

Therefore, place the channel target dir into state dir.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2173980
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Michal Privoznik
2023-04-20 10:16:43 +02:00
parent d3759d3674
commit 8abc979bb0
10 changed files with 69 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/7-hotplug/org.qemu.guest_agent.0'/>
<source mode='bind' path='/var/run/libvirt/qemu/channel/7-hotplug/org.qemu.guest_agent.0'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>

View File

@@ -39,7 +39,7 @@
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/7-hotplug/org.qemu.guest_agent.0'/>
<source mode='bind' path='/var/run/libvirt/qemu/channel/7-hotplug/org.qemu.guest_agent.0'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>

View File

@@ -42,7 +42,7 @@
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</controller>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/7-hotplug/org.qemu.guest_agent.0'/>
<source mode='bind' path='/var/run/libvirt/qemu/channel/7-hotplug/org.qemu.guest_agent.0'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<alias name='channel0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>

View File

@@ -28,6 +28,10 @@
<source mode='bind' path='/var/lib/libvirt/qemu/channel/1-QEMUGuest1/org.qemu.guest_agent.4'/>
<target type='virtio' name='org.qemu.guest_agent.4'/>
</channel>
<channel type='unix'>
<source mode='bind' path='/var/run/libvirt/qemu/channel/1-QEMUGuest1/org.qemu.guest_agent.5'/>
<target type='virtio' name='org.qemu.guest_agent.5'/>
</channel>
<memballoon model='none'/>
</devices>
</domain>

View File

@@ -46,6 +46,11 @@
<target type='virtio' name='org.qemu.guest_agent.4'/>
<address type='virtio-serial' controller='0' bus='0' port='5'/>
</channel>
<channel type='unix'>
<source mode='bind' path='/var/run/libvirt/qemu/channel/1-QEMUGuest1/org.qemu.guest_agent.5'/>
<target type='virtio' name='org.qemu.guest_agent.5'/>
<address type='virtio-serial' controller='0' bus='0' port='6'/>
</channel>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<audio id='1' type='none'/>

View File

@@ -42,6 +42,10 @@
<target type='virtio' name='org.qemu.guest_agent.4'/>
<address type='virtio-serial' controller='0' bus='0' port='5'/>
</channel>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.5'/>
<address type='virtio-serial' controller='0' bus='0' port='6'/>
</channel>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<audio id='1' type='none'/>

View File

@@ -460,7 +460,7 @@ int qemuTestDriverInit(virQEMUDriver *driver)
VIR_FREE(cfg->libDir);
cfg->libDir = g_strdup("/var/lib/libvirt/qemu");
VIR_FREE(cfg->channelTargetDir);
cfg->channelTargetDir = g_strdup("/var/lib/libvirt/qemu/channel");
cfg->channelTargetDir = g_strdup("/var/run/libvirt/qemu/channel");
VIR_FREE(cfg->memoryBackingDir);
cfg->memoryBackingDir = g_strdup("/var/lib/libvirt/qemu/ram");
VIR_FREE(cfg->nvramDir);