[Kimchi-devel] [PATCH] [Kimchi] Always update snapshot XML with new name and UUID
Aline Manera
alinefm at linux.vnet.ibm.com
Mon May 30 21:58:35 UTC 2016
Hi Lucio,
I am getting the following errors while running the tests. Could you
fix it and resend? I tested on Fedora 23.
***** Running unit test: test_model... FAILED
======================================================================
ERROR: test_vm_edit (test_model.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_model.py", line 1080, in test_vm_edit
inst.vm_update('kimchi-vm1', params)
File "/home/alinefm/wok/src/wok/plugins/kimchi/model/vms.py", line
290, in update
vm_name, dom = self._static_vm_update(name, dom, params)
File "/home/alinefm/wok/src/wok/plugins/kimchi/model/vms.py", line
816, in _static_vm_update
self._redefine_snapshots(dom, snapshots_info)
File "/home/alinefm/wok/src/wok/plugins/kimchi/model/vms.py", line
737, in _redefine_snapshots
xml = xml_item_update(xml, XPATH_SNAP_VM_NAME, dom.name(), None)
File "/home/alinefm/wok/src/wok/xmlutils/utils.py", line 52, in
xml_item_update
item.text = value
File "lxml.etree.pyx", line 951, in lxml.etree._Element.text.__set__
(src/lxml/lxml.etree.c:46377)
File "apihelpers.pxi", line 695, in lxml.etree._setNodeText
(src/lxml/lxml.etree.c:20989)
File "apihelpers.pxi", line 683, in lxml.etree._createTextNode
(src/lxml/lxml.etree.c:20865)
File "apihelpers.pxi", line 1393, in lxml.etree._utf8
(src/lxml/lxml.etree.c:27155)
ValueError: All strings must be XML compatible: Unicode or ASCII, no
NULL bytes or control characters
======================================================================
FAIL: test_vm_lifecycle (test_model.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_model.py", line 230, in test_vm_lifecycle
self.assertEquals(result, [u'kimchi-vm', snap['name']])
AssertionError: Lists differ: ['kimchi-vm-new', u'mysnap'] !=
[u'kimchi-vm', u'mysnap']
First differing element 0:
kimchi-vm-new
kimchi-vm
- ['kimchi-vm-new', u'mysnap']
? ----
+ [u'kimchi-vm', u'mysnap']
? +
----------------------------------------------------------------------
Ran 25 tests in 96.215s
FAILED (failures=1, errors=1, skipped=1)
On 05/30/2016 05:32 PM, Lucio Correia wrote:
> When a guest with snapshots is renamed, and afterwards
> guest is reverted to a snapshot created before the name
> change, the guest is also renamed back. This patch fixes
> this issue by updating snapshot XML when guest is renamed.
>
> Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
> ---
> model/vms.py | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/model/vms.py b/model/vms.py
> index 5c1b4e6..f5fbd16 100644
> --- a/model/vms.py
> +++ b/model/vms.py
> @@ -97,6 +97,8 @@ XPATH_DOMAIN_DEV_CPU_ID = '/domain/devices/spapr-cpu-socket/@id'
> XPATH_CPU = './cpu'
> XPATH_NAME = './name'
> XPATH_NUMA_CELL = './cpu/numa/cell'
> +XPATH_SNAP_VM_NAME = './domain/name'
> +XPATH_SNAP_VM_UUID = './domain/uuid'
> XPATH_TOPOLOGY = './cpu/topology'
> XPATH_VCPU = './vcpu'
> XPATH_MAX_MEMORY = './maxMemory'
> @@ -728,7 +730,15 @@ class VMModel(object):
> if info['current']:
> flags |= libvirt.VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT
>
> - dom.snapshotCreateXML(info['xml'], flags)
> + # Snapshot XML contains the VM xml from the time it was created.
> + # Thus VM name and uuid must be updated to current ones. Otherwise,
> + # when reverted, the vm name will be inconsistent.
> + xml = info['xml']
> + xml = xml_item_update(xml, XPATH_SNAP_VM_NAME, dom.name(), None)
> + xml = xml_item_update(xml, XPATH_SNAP_VM_UUID, dom.UUIDString(),
> + None)
> +
> + dom.snapshotCreateXML(xml, flags)
>
> def _update_metadata_name(self, dom, nonascii_name):
> if nonascii_name is not None:
More information about the Kimchi-devel
mailing list