]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Generate shorter channel target paths
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 18 Apr 2023 15:34:12 +0000 (17:34 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 17 Aug 2023 15:19:01 +0000 (17:19 +0200)
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>
12 files changed:
libvirt.spec.in
src/qemu/qemu_conf.c
src/qemu/qemu_domain.c
tests/qemuhotplugtestdevices/qemuhotplug-qemu-agent-detach.xml
tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent-detach.xml
tests/qemuhotplugtestdomains/qemuhotplug-base+qemu-agent.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent-detach.xml
tests/qemuhotplugtestdomains/qemuhotplug-base-live+qemu-agent.xml
tests/qemuxml2argvdata/channel-unix-source-path.xml
tests/qemuxml2xmloutdata/channel-unix-source-path-active.xml
tests/qemuxml2xmloutdata/channel-unix-source-path-inactive.xml
tests/testutilsqemu.c

index 17d5f5ff4a023be54064307cbfa92d4c059ed747..3b179d1fd989b977f37ccb5450c43273213c141a 100644 (file)
@@ -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/
index bd984448a3980e6c14176b8198403b7cf1d6a53c..532fe36be36ebb0d1674a714681ee44b7df2f717 100644 (file)
@@ -151,7 +151,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) {
@@ -173,7 +173,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",
@@ -201,7 +201,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);
index 029238a9d7372e5e5ac8f474a2ba22ad1022021b..224350dabc32c602ed8e9a9b19d9ef558f140da1 100644 (file)
@@ -1780,7 +1780,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;
@@ -5405,13 +5405,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.
@@ -5437,7 +5440,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);
index 0c3c70a78e89f4d6838ac599ae8b9690e05f1520..7871de59c4044eb84b5011b31f01f97affebbd9e 100644 (file)
@@ -1,5 +1,5 @@
     <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='/var/lib/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>
index 728af3391e3476b9e52d3226faca30b926c92669..bf2afb67d9c8238063e26780bf27f5711296d57a 100644 (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/target/domain-7-hotplug/org.qemu.guest_agent.0'/>
+      <source mode='bind' path='/var/lib/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'/>
index 728af3391e3476b9e52d3226faca30b926c92669..31917cee92cbbf79b0a56b03958cf02c2f66a6b9 100644 (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/target/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'/>
index 728af3391e3476b9e52d3226faca30b926c92669..bf2afb67d9c8238063e26780bf27f5711296d57a 100644 (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/target/domain-7-hotplug/org.qemu.guest_agent.0'/>
+      <source mode='bind' path='/var/lib/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'/>
index 0e4c3907bfbc7de27fe8f43f3f376db203dbf843..00191a9cb8ba4e862454dbfba5d831333271339b 100644 (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/target/domain-7-hotplug/org.qemu.guest_agent.0'/>
+      <source mode='bind' path='/var/lib/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'/>
index f24c636147e840189fc35a0e2e6e4e64f4d4cf7b..db0e99c3d12f5d3d738c03afca8051166bee1051 100644 (file)
       <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/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>
index 0d6a0295f821d4d6044da19a4143705037f69b4e..68835ceb151c4f9c11c781727e6d02534bd6ddd5 100644 (file)
       <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'/>
index d02ea52408dd0a3dcb514f54c5036fb1d467aa5a..738c1184c0ed511df51ea92d95b4e4a7a0612819 100644 (file)
       <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'/>
index 16b773a768c344b271a1e6d24b487d2838b91083..2d3e04de73840c52e01eeb1f79d724764e1e8291 100644 (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/target");
+    cfg->channelTargetDir = g_strdup("/var/lib/libvirt/qemu/channel");
     VIR_FREE(cfg->memoryBackingDir);
     cfg->memoryBackingDir = g_strdup("/var/lib/libvirt/qemu/ram");
     VIR_FREE(cfg->nvramDir);