Hi Chris:

Thanks very much.These functions can work well with normal rename.

But I found a bug when I use a symbol name such as "#".:-(
It needs to be escaped, then operation with this symbol directly are failed.

I can use an especial parameter to avoid it in testcases,
but I have not found how to avoid in function vm_rename().:-)

Just like follow(an idea, I have tested it, and it is ok.^^):

+import logging
+from autotest.client.shared import utils, error
+from autotest.client.virt import libvirt_vm, libvirt_xml
+
+def run_virsh_rename_domain(test, params, env):
+    """
+    Rename a domain to different type.
+    """
+    vm_name = params.get("main_vm")
+    vm = env.get_vm(params["main_vm"])
+    new_name = params.get("new_name", "test")
+    logging.info("Test rename %s to %s.", vm_name, new_name)
+
+    libvirt_xml.vm_rename(vm_name, new_name)
+    vm.name = new_name
_+    if params.get("escape_name", "no"):
+        new_name = "\" + new_name
+        vm.name = new_name_
+    logging.info(vm.get_xml())
+    if vm.start():
+        logging.info("Start new guest %s succeed.", new_name)
+    vm.destroy()
+
+    libvirt_xml.vm_rename(new_name, vm_name)
+    vm.name = vm_name
+    logging.info(vm.get_xml())
+    if vm.start():
+        logging.info("Back up to old guest %s succeed.", vm_name)
diff --git a/client/virt/subtests.cfg.sample b/client/virt/subtests.cfg.sample
index 534529f..13c22e6 100644
--- a/client/virt/subtests.cfg.sample
+++ b/client/virt/subtests.cfg.sample
@@ -310,6 +310,11 @@ variants:
                 libvirtd = "off"
                 status_error = "yes"

+    - virsh_rename_domain:
+        type = virsh_rename_domain
+        new_name = "#"
+        start_vm = "no"
_+        escape_name = yes_
+
     - virsh_domname:
         type = virsh_domname
         kill_vm = yes
-- 1.7.4.1

--
Best Regards
Yu Mingfei

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to