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

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