Blame SOURCES/virt-manager-virtinst-Remove-only-auto-generated-channel-source-path.patch

3d61c0
From 3e7e10ffe0d761c92fc2065e0030229845bd5322 Mon Sep 17 00:00:00 2001
3d61c0
Message-Id: <3e7e10ffe0d761c92fc2065e0030229845bd5322@dist-git>
3d61c0
From: Pavel Hrdina <phrdina@redhat.com>
3d61c0
Date: Thu, 28 Jun 2018 16:18:43 +0200
3d61c0
Subject: [PATCH] virtinst: Remove only auto-generated channel source path
3d61c0
3d61c0
In attempt to fix https://bugzilla.redhat.com/show_bug.cgi?id=1270696
3d61c0
this code was introduced but it removes the path for all channel
3d61c0
devices.  We need to limit it only to the devices that have
3d61c0
auto-generated source path.
3d61c0
3d61c0
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1591670
3d61c0
3d61c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3d61c0
(cherry picked from commit 931936a328d22413bb663e0e21d2f7bb111dbd7c)
3d61c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3d61c0
---
3d61c0
 tests/clone-xml/channel-source-in.xml  | 35 ++++++++++++++++++++++++++
3d61c0
 tests/clone-xml/channel-source-out.xml | 35 ++++++++++++++++++++++++++
3d61c0
 tests/clonetest.py                     |  3 +++
3d61c0
 virtinst/cloner.py                     |  4 ++-
3d61c0
 4 files changed, 76 insertions(+), 1 deletion(-)
3d61c0
 create mode 100644 tests/clone-xml/channel-source-in.xml
3d61c0
 create mode 100644 tests/clone-xml/channel-source-out.xml
3d61c0
3d61c0
diff --git a/tests/clone-xml/channel-source-in.xml b/tests/clone-xml/channel-source-in.xml
3d61c0
new file mode 100644
3d61c0
index 00000000..f69054c4
3d61c0
--- /dev/null
3d61c0
+++ b/tests/clone-xml/channel-source-in.xml
3d61c0
@@ -0,0 +1,35 @@
3d61c0
+<domain type='kvm'>
3d61c0
+  <name>clone-orig</name>
3d61c0
+  <uuid>aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82</uuid>
3d61c0
+  <memory>262144</memory>
3d61c0
+  <currentMemory>262144</currentMemory>
3d61c0
+  <vcpu>1</vcpu>
3d61c0
+  <os>
3d61c0
+    <type arch='i686' machine='pc'>hvm</type>
3d61c0
+    <boot dev='cdrom'/>
3d61c0
+  </os>
3d61c0
+  <features>
3d61c0
+    <acpi/>
3d61c0
+  </features>
3d61c0
+  <clock offset='utc'/>
3d61c0
+  <on_poweroff>destroy</on_poweroff>
3d61c0
+  <on_reboot>restart</on_reboot>
3d61c0
+  <on_crash>destroy</on_crash>
3d61c0
+  <devices>
3d61c0
+    <emulator>/usr/bin/qemu-kvm</emulator>
3d61c0
+    <channel type='unix'>
3d61c0
+      <source mode='bind' path='/tmp/guestfwd'/>
3d61c0
+      <target type='guestfwd' address='10.0.0.1' port='1234'/>
3d61c0
+    </channel>
3d61c0
+    <channel type='unix'>
3d61c0
+      <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-2-generic/org.qemu.guest_agent.0'/>
3d61c0
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
3d61c0
+    </channel>
3d61c0
+    <channel type='unix'>
3d61c0
+      <target type='virtio' name='org.qemu.guest_agent.0'/>
3d61c0
+    </channel>
3d61c0
+    <channel type='unix'>
3d61c0
+      <target type='virtio'/>
3d61c0
+    </channel>
3d61c0
+  </devices>
3d61c0
+</domain>
3d61c0
diff --git a/tests/clone-xml/channel-source-out.xml b/tests/clone-xml/channel-source-out.xml
3d61c0
new file mode 100644
3d61c0
index 00000000..210e7a7b
3d61c0
--- /dev/null
3d61c0
+++ b/tests/clone-xml/channel-source-out.xml
3d61c0
@@ -0,0 +1,35 @@
3d61c0
+<domain type="kvm">
3d61c0
+  <name>clone-new</name>
3d61c0
+  <uuid>12345678-1234-1234-1234-123456789012</uuid>
3d61c0
+  <memory>262144</memory>
3d61c0
+  <currentMemory>262144</currentMemory>
3d61c0
+  <vcpu>1</vcpu>
3d61c0
+  <os>
3d61c0
+    <type arch="i686" machine="pc">hvm</type>
3d61c0
+    <boot dev="cdrom"/>
3d61c0
+  </os>
3d61c0
+  <features>
3d61c0
+    <acpi/>
3d61c0
+  </features>
3d61c0
+  <clock offset="utc"/>
3d61c0
+  <on_poweroff>destroy</on_poweroff>
3d61c0
+  <on_reboot>restart</on_reboot>
3d61c0
+  <on_crash>destroy</on_crash>
3d61c0
+  <devices>
3d61c0
+    <emulator>/usr/bin/qemu-kvm</emulator>
3d61c0
+    <channel type="unix">
3d61c0
+      <source mode="bind" path="/tmp/guestfwd"/>
3d61c0
+      <target type="guestfwd" address="10.0.0.1" port="1234"/>
3d61c0
+    </channel>
3d61c0
+    <channel type="unix">
3d61c0
+      <source mode="bind"/>
3d61c0
+      <target type="virtio" name="org.qemu.guest_agent.0"/>
3d61c0
+    </channel>
3d61c0
+    <channel type="unix">
3d61c0
+      <target type="virtio" name="org.qemu.guest_agent.0"/>
3d61c0
+    </channel>
3d61c0
+    <channel type="unix">
3d61c0
+      <target type="virtio"/>
3d61c0
+    </channel>
3d61c0
+  </devices>
3d61c0
+</domain>
3d61c0
diff --git a/tests/clonetest.py b/tests/clonetest.py
3d61c0
index 3546be01..5fd51e73 100644
3d61c0
--- a/tests/clonetest.py
3d61c0
+++ b/tests/clonetest.py
3d61c0
@@ -191,3 +191,6 @@ class TestClone(unittest.TestCase):
3d61c0
     def testCloneGraphicsPassword(self):
3d61c0
         base = "graphics-password"
3d61c0
         self._clone_helper(base)
3d61c0
+
3d61c0
+    def testCloneChannelSource(self):
3d61c0
+        self._clone_helper("channel-source")
3d61c0
diff --git a/virtinst/cloner.py b/virtinst/cloner.py
3d61c0
index c4030ddf..632c3cbf 100644
3d61c0
--- a/virtinst/cloner.py
3d61c0
+++ b/virtinst/cloner.py
3d61c0
@@ -441,7 +441,9 @@ class Cloner(object):
3d61c0
         # For guest agent channel, remove a path to generate a new one with
3d61c0
         # new guest name
3d61c0
         for channel in self._guest.get_devices("channel"):
3d61c0
-            if channel.type == VirtualChannelDevice.TYPE_UNIX:
3d61c0
+            if (channel.type == VirtualChannelDevice.TYPE_UNIX and
3d61c0
+                channel.target_name and channel.source_path and
3d61c0
+                channel.target_name in channel.source_path):
3d61c0
                 channel.source_path = None
3d61c0
 
3d61c0
         if self._guest.os.nvram:
3d61c0
-- 
3d61c0
2.20.1
3d61c0