diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 4af75a14589f04df06ccfdccc78c7ee1bdc0f1e6..c3a732154e236c915c271f7832bccb784bef5a75 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8778,6 +8778,10 @@ class LUSetInstanceParams(LogicalUnit):
                                    errors.ECODE_INVAL)
       _CheckInstanceDown(self, instance, "cannot change disk template")
       if self.op.disk_template in constants.DTS_NET_MIRROR:
+        if self.op.remote_node == pnode:
+          raise errors.OpPrereqError("Given new secondary node %s is the same"
+                                     " as the primary node of the instance" %
+                                     self.op.remote_node, errors.ECODE_STATE)
         _CheckNodeOnline(self, self.op.remote_node)
         _CheckNodeNotDrained(self, self.op.remote_node)
         disks = [{"size": d.size} for d in instance.disks]