- qemu: Generate shorter channel target paths
- qemu: Move channelTargetDir into stateDir - qemu_domain: Drop unused variables from qemuDomainChrDefDropDefaultPath()
This commit is contained in:
parent
c10bd8cbd9
commit
0a1fe0c265
232
SOURCES/qemu-generate-shorter-channel-target-paths.patch
Normal file
232
SOURCES/qemu-generate-shorter-channel-target-paths.patch
Normal file
@ -0,0 +1,232 @@
|
|||||||
|
From d3759d3674ab9453e5fb5a27ab6c28b8ff8d5569 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Tue, 18 Apr 2023 17:34:12 +0200
|
||||||
|
Subject: [PATCH] qemu: Generate shorter channel target paths
|
||||||
|
|
||||||
|
A <channel/> device is basically an UNIX socket into guest.
|
||||||
|
Whatever is sent from the host, appears in the guest and vice
|
||||||
|
versa. But because of that, the length of the path to the socket
|
||||||
|
is important (underscored by fact that we derive the path from
|
||||||
|
domain short name). But there are still cases where we might not
|
||||||
|
fit into UNIX_PATH_MAX limit (usually 108 characters), because
|
||||||
|
the path is derived also from other variables, e.g.
|
||||||
|
XDG_CONFIG_HOME for session domains.
|
||||||
|
|
||||||
|
There are two components though, that are needless: "/target/"
|
||||||
|
and "domain-" prefix. Drop them. This is safe to do, because
|
||||||
|
running domains have their path saved in status XML and even
|
||||||
|
though paths are dropped on migration, they are not part of guest
|
||||||
|
ABI and thus we are free to change them.
|
||||||
|
|
||||||
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
||||||
|
---
|
||||||
|
libvirt.spec.in | 1 -
|
||||||
|
src/qemu/qemu_conf.c | 6 +++---
|
||||||
|
src/qemu/qemu_domain.c | 15 +++++++++------
|
||||||
|
.../qemuhotplug-qemu-agent-detach.xml | 2 +-
|
||||||
|
.../qemuhotplug-base+qemu-agent-detach.xml | 2 +-
|
||||||
|
.../qemuhotplug-base+qemu-agent.xml | 2 +-
|
||||||
|
.../qemuhotplug-base-live+qemu-agent-detach.xml | 2 +-
|
||||||
|
.../qemuhotplug-base-live+qemu-agent.xml | 2 +-
|
||||||
|
.../qemuxml2argvdata/channel-unix-source-path.xml | 4 ++++
|
||||||
|
.../channel-unix-source-path-active.xml | 5 +++++
|
||||||
|
.../channel-unix-source-path-inactive.xml | 4 ++++
|
||||||
|
tests/testutilsqemu.c | 2 +-
|
||||||
|
12 files changed, 31 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libvirt.spec.in b/libvirt.spec.in
|
||||||
|
index 17d5f5ff4a0..3b179d1fd98 100644
|
||||||
|
--- a/libvirt.spec.in
|
||||||
|
+++ b/libvirt.spec.in
|
||||||
|
@@ -2136,7 +2136,6 @@ exit 0
|
||||||
|
%ghost %dir %{_rundir}/libvirt/qemu/swtpm/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/
|
||||||
|
-%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/target/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/checkpoint/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/dump/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/
|
||||||
|
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
||||||
|
index bd984448a39..532fe36be36 100644
|
||||||
|
--- a/src/qemu/qemu_conf.c
|
||||||
|
+++ b/src/qemu/qemu_conf.c
|
||||||
|
@@ -146,7 +146,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->snapshotDir = g_strdup_printf("%s/snapshot", cfg->libDir);
|
||||||
|
cfg->checkpointDir = g_strdup_printf("%s/checkpoint", cfg->libDir);
|
||||||
|
cfg->autoDumpPath = g_strdup_printf("%s/dump", cfg->libDir);
|
||||||
|
- cfg->channelTargetDir = g_strdup_printf("%s/channel/target", cfg->libDir);
|
||||||
|
+ cfg->channelTargetDir = g_strdup_printf("%s/channel", cfg->libDir);
|
||||||
|
cfg->nvramDir = g_strdup_printf("%s/nvram", cfg->libDir);
|
||||||
|
cfg->memoryBackingDir = g_strdup_printf("%s/ram", cfg->libDir);
|
||||||
|
} else if (privileged) {
|
||||||
|
@@ -168,7 +168,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->snapshotDir = g_strdup_printf("%s/snapshot", cfg->libDir);
|
||||||
|
cfg->checkpointDir = g_strdup_printf("%s/checkpoint", cfg->libDir);
|
||||||
|
cfg->autoDumpPath = g_strdup_printf("%s/dump", cfg->libDir);
|
||||||
|
- cfg->channelTargetDir = g_strdup_printf("%s/channel/target", cfg->libDir);
|
||||||
|
+ cfg->channelTargetDir = g_strdup_printf("%s/channel", cfg->libDir);
|
||||||
|
cfg->nvramDir = g_strdup_printf("%s/nvram", cfg->libDir);
|
||||||
|
cfg->memoryBackingDir = g_strdup_printf("%s/ram", cfg->libDir);
|
||||||
|
cfg->swtpmStorageDir = g_strdup_printf("%s/lib/libvirt/swtpm",
|
||||||
|
@@ -202,7 +202,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->checkpointDir = g_strdup_printf("%s/qemu/checkpoint",
|
||||||
|
cfg->configBaseDir);
|
||||||
|
cfg->autoDumpPath = g_strdup_printf("%s/qemu/dump", cfg->configBaseDir);
|
||||||
|
- cfg->channelTargetDir = g_strdup_printf("%s/qemu/channel/target",
|
||||||
|
+ cfg->channelTargetDir = g_strdup_printf("%s/qemu/channel",
|
||||||
|
cfg->configBaseDir);
|
||||||
|
cfg->nvramDir = g_strdup_printf("%s/qemu/nvram", cfg->configBaseDir);
|
||||||
|
cfg->memoryBackingDir = g_strdup_printf("%s/qemu/ram", cfg->configBaseDir);
|
||||||
|
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||||||
|
index 029238a9d73..224350dabc3 100644
|
||||||
|
--- a/src/qemu/qemu_domain.c
|
||||||
|
+++ b/src/qemu/qemu_domain.c
|
||||||
|
@@ -1733,7 +1733,7 @@ qemuDomainSetPrivatePaths(virQEMUDriver *driver,
|
||||||
|
priv->libDir = g_strdup_printf("%s/domain-%s", cfg->libDir, domname);
|
||||||
|
|
||||||
|
if (!priv->channelTargetDir)
|
||||||
|
- priv->channelTargetDir = g_strdup_printf("%s/domain-%s",
|
||||||
|
+ priv->channelTargetDir = g_strdup_printf("%s/%s",
|
||||||
|
cfg->channelTargetDir, domname);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
@@ -5157,13 +5157,16 @@ qemuDomainDefaultNetModel(const virDomainDef *def,
|
||||||
|
* Clear auto generated unix socket paths:
|
||||||
|
*
|
||||||
|
* libvirt 1.2.18 and older:
|
||||||
|
- * {cfg->channelTargetDir}/{dom-name}.{target-name}
|
||||||
|
+ * {cfg->channelTargetDir}/target/{dom-name}.{target-name}
|
||||||
|
*
|
||||||
|
* libvirt 1.2.19 - 1.3.2:
|
||||||
|
- * {cfg->channelTargetDir}/domain-{dom-name}/{target-name}
|
||||||
|
+ * {cfg->channelTargetDir}/target/domain-{dom-name}/{target-name}
|
||||||
|
+ *
|
||||||
|
+ * libvirt 1.3.3 - 9.7.0:
|
||||||
|
+ * {cfg->channelTargetDir}/target/domain-{dom-id}-{short-dom-name}/{target-name}
|
||||||
|
*
|
||||||
|
- * libvirt 1.3.3 and newer:
|
||||||
|
- * {cfg->channelTargetDir}/domain-{dom-id}-{short-dom-name}/{target-name}
|
||||||
|
+ * libvirt 9.7.0 and newer:
|
||||||
|
+ * {cfg->channelTargetDir}/{dom-id}-{short-dom-name}/{target-name}
|
||||||
|
*
|
||||||
|
* The unix socket path was stored in config XML until libvirt 1.3.0.
|
||||||
|
* If someone specifies the same path as we generate, they shouldn't do it.
|
||||||
|
@@ -5189,7 +5192,7 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDef *chr,
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
|
virBufferEscapeRegex(&buf, "^%s", cfg->channelTargetDir);
|
||||||
|
- virBufferAddLit(&buf, "/([^/]+\\.)|(domain-[^/]+/)");
|
||||||
|
+ virBufferAddLit(&buf, "/(target/)?([^/]+\\.)|(domain-[^/]+/)|([0-9]+-[^/]+/)");
|
||||||
|
virBufferEscapeRegex(&buf, "%s$", chr->target.name);
|
||||||
|
|
||||||
|
regexp = virBufferContentAndReset(&buf);
|
||||||
|
diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-qemu-agent-detach.xml b/tests/qemuhotplugtestdevices/qemuhotplug-qemu-agent-detach.xml
|
||||||
|
index 0c3c70a78e8..7871de59c40 100644
|
||||||
|
--- a/tests/qemuhotplugtestdevices/qemuhotplug-qemu-agent-detach.xml
|
||||||
|
+++ b/tests/qemuhotplugtestdevices/qemuhotplug-qemu-agent-detach.xml
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
<channel type='unix'>
|
||||||
|
- <source mode='bind' path='/tmp/channel/domain-7-hotplug/org.qemu.guest_agent.0'/>
|
||||||
|
+ <source mode='bind' path='/tmp/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>
|
||||||
|
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent-detach.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent-detach.xml
|
||||||
|
index 728af3391e3..bf2afb67d9c 100644
|
||||||
|
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent-detach.xml
|
||||||
|
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent-detach.xml
|
||||||
|
@@ -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/target/domain-7-hotplug/org.qemu.guest_agent.0'/>
|
||||||
|
+ <source mode='bind' path='/tmp/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'/>
|
||||||
|
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent.xml
|
||||||
|
index 728af3391e3..31917cee92c 100644
|
||||||
|
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent.xml
|
||||||
|
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent.xml
|
||||||
|
@@ -39,7 +39,7 @@
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<channel type='unix'>
|
||||||
|
- <source mode='bind' path='/tmp/channel/domain-7-hotplug/org.qemu.guest_agent.0'/>
|
||||||
|
+ <source mode='bind' path='/var/lib/libvirt/qemu/channel/domain-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'/>
|
||||||
|
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent-detach.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent-detach.xml
|
||||||
|
index 728af3391e3..bf2afb67d9c 100644
|
||||||
|
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent-detach.xml
|
||||||
|
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent-detach.xml
|
||||||
|
@@ -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/target/domain-7-hotplug/org.qemu.guest_agent.0'/>
|
||||||
|
+ <source mode='bind' path='/tmp/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'/>
|
||||||
|
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml
|
||||||
|
index 0e4c3907bfb..00191a9cb8b 100644
|
||||||
|
--- a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml
|
||||||
|
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml
|
||||||
|
@@ -39,7 +39,7 @@
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<channel type='unix'>
|
||||||
|
- <source mode='bind' path='/tmp/channel/domain-7-hotplug/org.qemu.guest_agent.0'/>
|
||||||
|
+ <source mode='bind' path='/tmp/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'/>
|
||||||
|
diff --git a/tests/qemuxml2argvdata/channel-unix-source-path.xml b/tests/qemuxml2argvdata/channel-unix-source-path.xml
|
||||||
|
index f24c636147e..db0e99c3d12 100644
|
||||||
|
--- a/tests/qemuxml2argvdata/channel-unix-source-path.xml
|
||||||
|
+++ b/tests/qemuxml2argvdata/channel-unix-source-path.xml
|
||||||
|
@@ -24,6 +24,10 @@
|
||||||
|
<source mode='bind' path='/tmp/channel/QEMUGuest1/org.qemu.guest_agent.3'/>
|
||||||
|
<target type='virtio' name='org.qemu.guest_agent.3'/>
|
||||||
|
</channel>
|
||||||
|
+ <channel type='unix'>
|
||||||
|
+ <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>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
||||||
|
diff --git a/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml b/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml
|
||||||
|
index 0d6a0295f82..68835ceb151 100644
|
||||||
|
--- a/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml
|
||||||
|
+++ b/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml
|
||||||
|
@@ -41,6 +41,11 @@
|
||||||
|
<target type='virtio' name='org.qemu.guest_agent.3'/>
|
||||||
|
<address type='virtio-serial' controller='0' bus='0' port='4'/>
|
||||||
|
</channel>
|
||||||
|
+ <channel type='unix'>
|
||||||
|
+ <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'/>
|
||||||
|
+ <address type='virtio-serial' controller='0' bus='0' port='5'/>
|
||||||
|
+ </channel>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<audio id='1' type='none'/>
|
||||||
|
diff --git a/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml b/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml
|
||||||
|
index d02ea52408d..738c1184c0e 100644
|
||||||
|
--- a/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml
|
||||||
|
+++ b/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml
|
||||||
|
@@ -38,6 +38,10 @@
|
||||||
|
<target type='virtio' name='org.qemu.guest_agent.3'/>
|
||||||
|
<address type='virtio-serial' controller='0' bus='0' port='4'/>
|
||||||
|
</channel>
|
||||||
|
+ <channel type='unix'>
|
||||||
|
+ <target type='virtio' name='org.qemu.guest_agent.4'/>
|
||||||
|
+ <address type='virtio-serial' controller='0' bus='0' port='5'/>
|
||||||
|
+ </channel>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<audio id='1' type='none'/>
|
229
SOURCES/qemu-move-channelTargetDir-into-stateDir.patch
Normal file
229
SOURCES/qemu-move-channelTargetDir-into-stateDir.patch
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
From 8abc979bb09ca4b93123e8f75f3d28cc421a0bb6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Thu, 20 Apr 2023 10:16:43 +0200
|
||||||
|
Subject: [PATCH] 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>
|
||||||
|
---
|
||||||
|
libvirt.spec.in | 1 -
|
||||||
|
src/qemu/qemu_conf.c | 9 ++--
|
||||||
|
src/qemu/qemu_domain.c | 52 +++++++++++++++++--
|
||||||
|
.../qemuhotplug-qemu-agent-detach.xml | 2 +-
|
||||||
|
...emuhotplug-base-live+qemu-agent-detach.xml | 2 +-
|
||||||
|
.../qemuhotplug-base-live+qemu-agent.xml | 2 +-
|
||||||
|
.../channel-unix-source-path.xml | 4 ++
|
||||||
|
.../channel-unix-source-path-active.xml | 5 ++
|
||||||
|
.../channel-unix-source-path-inactive.xml | 4 ++
|
||||||
|
tests/testutilsqemu.c | 2 +-
|
||||||
|
10 files changed, 67 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libvirt.spec.in b/libvirt.spec.in
|
||||||
|
index 3b179d1fd98..7157cfe3b4f 100644
|
||||||
|
--- a/libvirt.spec.in
|
||||||
|
+++ b/libvirt.spec.in
|
||||||
|
@@ -2135,7 +2135,6 @@ exit 0
|
||||||
|
%ghost %dir %{_rundir}/libvirt/qemu/slirp/
|
||||||
|
%ghost %dir %{_rundir}/libvirt/qemu/swtpm/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/
|
||||||
|
-%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/checkpoint/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/dump/
|
||||||
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/
|
||||||
|
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
||||||
|
index 532fe36be36..3f811d064fe 100644
|
||||||
|
--- a/src/qemu/qemu_conf.c
|
||||||
|
+++ b/src/qemu/qemu_conf.c
|
||||||
|
@@ -138,6 +138,7 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->configBaseDir = g_strdup_printf("%s/etc", root);
|
||||||
|
cfg->stateDir = g_strdup_printf("%s/run/qemu", root);
|
||||||
|
cfg->swtpmStateDir = g_strdup_printf("%s/run/swtpm", root);
|
||||||
|
+ cfg->channelTargetDir = g_strdup_printf("%s/channel", cfg->stateDir);
|
||||||
|
cfg->cacheDir = g_strdup_printf("%s/cache/qemu", root);
|
||||||
|
cfg->libDir = g_strdup_printf("%s/lib/qemu", root);
|
||||||
|
cfg->swtpmStorageDir = g_strdup_printf("%s/lib/swtpm", root);
|
||||||
|
@@ -146,7 +147,6 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->snapshotDir = g_strdup_printf("%s/snapshot", cfg->libDir);
|
||||||
|
cfg->checkpointDir = g_strdup_printf("%s/checkpoint", cfg->libDir);
|
||||||
|
cfg->autoDumpPath = g_strdup_printf("%s/dump", cfg->libDir);
|
||||||
|
- cfg->channelTargetDir = g_strdup_printf("%s/channel", cfg->libDir);
|
||||||
|
cfg->nvramDir = g_strdup_printf("%s/nvram", cfg->libDir);
|
||||||
|
cfg->memoryBackingDir = g_strdup_printf("%s/ram", cfg->libDir);
|
||||||
|
} else if (privileged) {
|
||||||
|
@@ -158,8 +158,8 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->configBaseDir = g_strdup(SYSCONFDIR "/libvirt");
|
||||||
|
|
||||||
|
cfg->stateDir = g_strdup_printf("%s/libvirt/qemu", RUNSTATEDIR);
|
||||||
|
-
|
||||||
|
cfg->swtpmStateDir = g_strdup_printf("%s/libvirt/qemu/swtpm", RUNSTATEDIR);
|
||||||
|
+ cfg->channelTargetDir = g_strdup_printf("%s/channel", cfg->stateDir);
|
||||||
|
|
||||||
|
cfg->cacheDir = g_strdup_printf("%s/cache/libvirt/qemu", LOCALSTATEDIR);
|
||||||
|
|
||||||
|
@@ -168,7 +168,6 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->snapshotDir = g_strdup_printf("%s/snapshot", cfg->libDir);
|
||||||
|
cfg->checkpointDir = g_strdup_printf("%s/checkpoint", cfg->libDir);
|
||||||
|
cfg->autoDumpPath = g_strdup_printf("%s/dump", cfg->libDir);
|
||||||
|
- cfg->channelTargetDir = g_strdup_printf("%s/channel", cfg->libDir);
|
||||||
|
cfg->nvramDir = g_strdup_printf("%s/nvram", cfg->libDir);
|
||||||
|
cfg->memoryBackingDir = g_strdup_printf("%s/ram", cfg->libDir);
|
||||||
|
cfg->swtpmStorageDir = g_strdup_printf("%s/lib/libvirt/swtpm",
|
||||||
|
@@ -191,8 +190,8 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
|
||||||
|
rundir = virGetUserRuntimeDirectory();
|
||||||
|
cfg->stateDir = g_strdup_printf("%s/qemu/run", rundir);
|
||||||
|
-
|
||||||
|
cfg->swtpmStateDir = g_strdup_printf("%s/swtpm", cfg->stateDir);
|
||||||
|
+ cfg->channelTargetDir = g_strdup_printf("%s/channel", cfg->stateDir);
|
||||||
|
|
||||||
|
cfg->configBaseDir = virGetUserConfigDirectory();
|
||||||
|
|
||||||
|
@@ -202,8 +201,6 @@ virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged,
|
||||||
|
cfg->checkpointDir = g_strdup_printf("%s/qemu/checkpoint",
|
||||||
|
cfg->configBaseDir);
|
||||||
|
cfg->autoDumpPath = g_strdup_printf("%s/qemu/dump", cfg->configBaseDir);
|
||||||
|
- cfg->channelTargetDir = g_strdup_printf("%s/qemu/channel",
|
||||||
|
- cfg->configBaseDir);
|
||||||
|
cfg->nvramDir = g_strdup_printf("%s/qemu/nvram", cfg->configBaseDir);
|
||||||
|
cfg->memoryBackingDir = g_strdup_printf("%s/qemu/ram", cfg->configBaseDir);
|
||||||
|
cfg->swtpmStorageDir = g_strdup_printf("%s/qemu/swtpm",
|
||||||
|
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||||||
|
index 224350dabc3..d46516856eb 100644
|
||||||
|
--- a/src/qemu/qemu_domain.c
|
||||||
|
+++ b/src/qemu/qemu_domain.c
|
||||||
|
@@ -5153,6 +5153,28 @@ qemuDomainDefaultNetModel(const virDomainDef *def,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+
|
||||||
|
+static bool
|
||||||
|
+qemuDomainChrMatchDefaultPath(const char *prefix,
|
||||||
|
+ const char *infix,
|
||||||
|
+ const char *target,
|
||||||
|
+ const char *path)
|
||||||
|
+{
|
||||||
|
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
+ g_autofree char *regexp = NULL;
|
||||||
|
+
|
||||||
|
+ virBufferEscapeRegex(&buf, "^%s", prefix);
|
||||||
|
+ if (infix)
|
||||||
|
+ virBufferEscapeRegex(&buf, "%s", infix);
|
||||||
|
+ virBufferAddLit(&buf, "/(target/)?([^/]+\\.)|(domain-[^/]+/)|([0-9]+-[^/]+/)");
|
||||||
|
+ virBufferEscapeRegex(&buf, "%s$", target);
|
||||||
|
+
|
||||||
|
+ regexp = virBufferContentAndReset(&buf);
|
||||||
|
+
|
||||||
|
+ return virStringMatch(path, regexp);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Clear auto generated unix socket paths:
|
||||||
|
*
|
||||||
|
@@ -5173,6 +5195,9 @@ qemuDomainDefaultNetModel(const virDomainDef *def,
|
||||||
|
*
|
||||||
|
* This function clears the path for migration as well, so we need to clear
|
||||||
|
* the path even if we are not storing it in the XML.
|
||||||
|
+ *
|
||||||
|
+ * Please note, as of libvirt 9.7.0 the channelTargetDir is no longer derived
|
||||||
|
+ * from cfg->libDir but rather cfg->stateDir.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
qemuDomainChrDefDropDefaultPath(virDomainChrDef *chr,
|
||||||
|
@@ -5191,14 +5216,31 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDef *chr,
|
||||||
|
|
||||||
|
cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
|
- virBufferEscapeRegex(&buf, "^%s", cfg->channelTargetDir);
|
||||||
|
- virBufferAddLit(&buf, "/(target/)?([^/]+\\.)|(domain-[^/]+/)|([0-9]+-[^/]+/)");
|
||||||
|
- virBufferEscapeRegex(&buf, "%s$", chr->target.name);
|
||||||
|
+ if (qemuDomainChrMatchDefaultPath(cfg->channelTargetDir,
|
||||||
|
+ NULL,
|
||||||
|
+ chr->target.name,
|
||||||
|
+ chr->source->data.nix.path)) {
|
||||||
|
+ VIR_FREE(chr->source->data.nix.path);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- regexp = virBufferContentAndReset(&buf);
|
||||||
|
+ /* Previously, channelTargetDir was derived from cfg->libdir, or
|
||||||
|
+ * cfg->configBaseDir even. Try them too. */
|
||||||
|
+ if (qemuDomainChrMatchDefaultPath(cfg->libDir,
|
||||||
|
+ "/channel",
|
||||||
|
+ chr->target.name,
|
||||||
|
+ chr->source->data.nix.path)) {
|
||||||
|
+ VIR_FREE(chr->source->data.nix.path);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- if (virStringMatch(chr->source->data.nix.path, regexp))
|
||||||
|
+ if (qemuDomainChrMatchDefaultPath(cfg->configBaseDir,
|
||||||
|
+ "/qemu/channel",
|
||||||
|
+ chr->target.name,
|
||||||
|
+ chr->source->data.nix.path)) {
|
||||||
|
VIR_FREE(chr->source->data.nix.path);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/tests/qemuxml2argvdata/channel-unix-source-path.xml b/tests/qemuxml2argvdata/channel-unix-source-path.xml
|
||||||
|
index db0e99c3d12..df548d88e72 100644
|
||||||
|
--- a/tests/qemuxml2argvdata/channel-unix-source-path.xml
|
||||||
|
+++ b/tests/qemuxml2argvdata/channel-unix-source-path.xml
|
||||||
|
@@ -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>
|
||||||
|
diff --git a/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml b/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml
|
||||||
|
index 68835ceb151..ec927d37c68 100644
|
||||||
|
--- a/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml
|
||||||
|
+++ b/tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml
|
||||||
|
@@ -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'/>
|
||||||
|
diff --git a/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml b/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml
|
||||||
|
index 738c1184c0e..c979bedb392 100644
|
||||||
|
--- a/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml
|
||||||
|
+++ b/tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml
|
||||||
|
@@ -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'/>
|
29
SOURCES/qemu_domain-drop-unused-variables-from.patch
Normal file
29
SOURCES/qemu_domain-drop-unused-variables-from.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From b07640bb438d21e592d66ca8367904d82838602f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
Date: Thu, 17 Aug 2023 17:43:54 +0200
|
||||||
|
Subject: [PATCH] qemu_domain: Drop unused variables from
|
||||||
|
qemuDomainChrDefDropDefaultPath()
|
||||||
|
|
||||||
|
In mu previous commits I've moved internals of
|
||||||
|
qemuDomainChrDefDropDefaultPath() into a separate function
|
||||||
|
(qemuDomainChrMatchDefaultPath()) but forgot to remove @buf and
|
||||||
|
@regexp variables which are now unused.
|
||||||
|
|
||||||
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
||||||
|
---
|
||||||
|
src/qemu/qemu_domain.c | 2 --
|
||||||
|
1 file changed, 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||||||
|
index d46516856eb..f64836fbb17 100644
|
||||||
|
--- a/src/qemu/qemu_domain.c
|
||||||
|
+++ b/src/qemu/qemu_domain.c
|
||||||
|
@@ -5204,8 +5204,6 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDef *chr,
|
||||||
|
virQEMUDriver *driver)
|
||||||
|
{
|
||||||
|
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||||
|
- g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
- g_autofree char *regexp = NULL;
|
||||||
|
|
||||||
|
if (chr->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL ||
|
||||||
|
chr->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO ||
|
@ -229,7 +229,7 @@
|
|||||||
Summary: Library providing a simple virtualization API
|
Summary: Library providing a simple virtualization API
|
||||||
Name: libvirt
|
Name: libvirt
|
||||||
Version: 9.0.0
|
Version: 9.0.0
|
||||||
Release: 10.2%{?dist}%{?extra_release}
|
Release: 10.3%{?dist}%{?extra_release}.alma.1
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: https://libvirt.org/
|
URL: https://libvirt.org/
|
||||||
|
|
||||||
@ -307,6 +307,13 @@ Patch66: libvirt-docs-Document-memory-allocation-and-emulator-pinning-limitation
|
|||||||
Patch67: libvirt-conf-Fix-migration-in-some-firmware-autoselection-scenarios.patch
|
Patch67: libvirt-conf-Fix-migration-in-some-firmware-autoselection-scenarios.patch
|
||||||
Patch68: libvirt-virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch
|
Patch68: libvirt-virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch
|
||||||
|
|
||||||
|
# Patches were taken from and backported to apply cleanly:
|
||||||
|
# https://github.com/libvirt/libvirt/commit/d3759d3674ab9453e5fb5a27ab6c28b8ff8d5569
|
||||||
|
Patch69: qemu-generate-shorter-channel-target-paths.patch
|
||||||
|
# https://github.com/libvirt/libvirt/commit/8abc979bb09ca4b93123e8f75f3d28cc421a0bb6
|
||||||
|
Patch70: qemu-move-channelTargetDir-into-stateDir.patch
|
||||||
|
# https://github.com/libvirt/libvirt/commit/b07640bb438d21e592d66ca8367904d82838602f
|
||||||
|
Patch71: qemu_domain-drop-unused-variables-from.patch
|
||||||
|
|
||||||
Requires: libvirt-daemon = %{version}-%{release}
|
Requires: libvirt-daemon = %{version}-%{release}
|
||||||
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
||||||
@ -2069,8 +2076,6 @@ exit 0
|
|||||||
%ghost %dir %{_rundir}/libvirt/qemu/slirp/
|
%ghost %dir %{_rundir}/libvirt/qemu/slirp/
|
||||||
%ghost %dir %{_rundir}/libvirt/qemu/swtpm/
|
%ghost %dir %{_rundir}/libvirt/qemu/swtpm/
|
||||||
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/
|
||||||
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/
|
|
||||||
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/channel/target/
|
|
||||||
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/checkpoint/
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/checkpoint/
|
||||||
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/dump/
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/dump/
|
||||||
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/
|
%dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/nvram/
|
||||||
@ -2399,6 +2404,11 @@ exit 0
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Sep 13 2023 Eduard Abdullin <eabdullin@almalinux.org> - 9.0.0-10.3.el9_2.alma.1
|
||||||
|
- qemu: Generate shorter channel target paths
|
||||||
|
- qemu: Move channelTargetDir into stateDir
|
||||||
|
- qemu_domain: Drop unused variables from qemuDomainChrDefDropDefaultPath()
|
||||||
|
|
||||||
* Mon May 29 2023 Jiri Denemark <jdenemar@redhat.com> - 9.0.0-10.2.el9_2
|
* Mon May 29 2023 Jiri Denemark <jdenemar@redhat.com> - 9.0.0-10.2.el9_2
|
||||||
- virpci: Resolve leak in virPCIVirtualFunctionList cleanup (CVE-2023-2700, rhbz#2208596)
|
- virpci: Resolve leak in virPCIVirtualFunctionList cleanup (CVE-2023-2700, rhbz#2208596)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user