libvirt: Fix setmaxmem from changing mem size

The test setmaxmem backup the vm's max memory and restore it by calling
`virsh setmaxmem` after test.

This will cause problem when test shinking the max memory. The current
memory will also shrink to adapt the max memory. After restore the max
memory, this shrinked current memory will remain.

* To ensure the fully restoration of guest, we change back to
  backup by new_from_inactive_dumpxml and sync after test.

* Use `try ... finally ...` to make sure restoration even bad thing
  happens.

* Fix some pylint complaints.

Signed-off-by: Hao Liu <hliu@redhat.com>