@@ -330,9 +330,9 @@ def update(self, name, params):
330
330
331
331
# You can only change <maxMemory> offline, updating guest XML
332
332
if (
333
- ('memory' in params ) and
334
- ('maxmemory' in params ['memory' ]) and
335
- (DOM_STATE_MAP [dom .info ()[0 ]] != 'shutoff' )
333
+ ('memory' in params )
334
+ and ('maxmemory' in params ['memory' ])
335
+ and (DOM_STATE_MAP [dom .info ()[0 ]] != 'shutoff' )
336
336
):
337
337
raise InvalidParameter ('KCHVM0080E' )
338
338
@@ -722,8 +722,8 @@ def _get_access_info(self, dom):
722
722
access_info = dictize (access_xml )
723
723
auth = config .get ('authentication' , 'method' )
724
724
if 'auth' in access_info ['access' ] and (
725
- 'type' in access_info ['access' ]['auth' ] or
726
- len (access_info ['access' ]['auth' ]) > 1
725
+ 'type' in access_info ['access' ]['auth' ]
726
+ or len (access_info ['access' ]['auth' ]) > 1
727
727
):
728
728
users = xpath_get_text (
729
729
access_xml , f"/access/auth[@type='{ auth } ']/user" )
@@ -772,7 +772,7 @@ def _update_graphics(self, dom, params):
772
772
773
773
conn = self .conn .get ()
774
774
if not dom .isActive ():
775
- return conn .defineXML (ET .tostring (root , encoding = 'utf-8' ). decode ( 'utf-8 ' ))
775
+ return conn .defineXML (ET .tostring (root , encoding = 'unicode ' ))
776
776
777
777
xml = dom .XMLDesc (libvirt .VIR_DOMAIN_XML_SECURE )
778
778
dom .updateDeviceFlags (
@@ -851,7 +851,7 @@ def _update_bootorder(self, xml, params):
851
851
os .append (get_bootmenu_node ())
852
852
853
853
# update <os>
854
- return ET .tostring (et )
854
+ return ET .tostring (et , encoding = 'unicode' )
855
855
856
856
def _update_s390x_console (self , xml , params ):
857
857
if xpath_get_text (xml , XPATH_DOMAIN_CONSOLE_TARGET ):
@@ -865,7 +865,7 @@ def _update_s390x_console(self, xml, params):
865
865
et = ET .fromstring (xml )
866
866
devices = et .find ('devices' )
867
867
devices .append (console )
868
- return ET .tostring (et )
868
+ return ET .tostring (et , encoding = 'unicode' )
869
869
870
870
def _update_title (self , new_xml , title ):
871
871
if len (xpath_get_text (new_xml , XPATH_TITLE )) > 0 :
@@ -874,7 +874,7 @@ def _update_title(self, new_xml, title):
874
874
else :
875
875
et = ET .fromstring (new_xml )
876
876
et .append (E .title (title ))
877
- new_xml = ET .tostring (et )
877
+ new_xml = ET .tostring (et , encoding = 'unicode' )
878
878
879
879
return new_xml
880
880
@@ -886,7 +886,7 @@ def _update_description(self, new_xml, description):
886
886
else :
887
887
et = ET .fromstring (new_xml )
888
888
et .append (E .description (description ))
889
- new_xml = ET .tostring (et )
889
+ new_xml = ET .tostring (et , encoding = 'unicode' )
890
890
891
891
return new_xml
892
892
@@ -960,8 +960,8 @@ def _static_vm_update(self, vm_name, dom, params):
960
960
if 'name' in params :
961
961
lflags = libvirt .VIR_DOMAIN_SNAPSHOT_LIST_ROOTS
962
962
dflags = (
963
- libvirt .VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
964
- libvirt .VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY
963
+ libvirt .VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN
964
+ | libvirt .VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY
965
965
)
966
966
967
967
for virt_snap in dom .listAllSnapshots (lflags ):
@@ -997,7 +997,8 @@ def _static_vm_update(self, vm_name, dom, params):
997
997
return nonascii_name if nonascii_name is not None else vm_name , dom
998
998
999
999
def _get_new_memory (self , root , newMem , oldMem , memDevs ):
1000
- memDevsAmount = self ._get_mem_dev_total_size (ET .tostring (root ))
1000
+ memDevsAmount = self ._get_mem_dev_total_size (
1001
+ ET .tostring (root , encoding = 'unicode' ))
1001
1002
1002
1003
if newMem > (oldMem << 10 ):
1003
1004
return newMem - memDevsAmount
@@ -1013,7 +1014,7 @@ def _get_new_memory(self, root, newMem, oldMem, memDevs):
1013
1014
root .find ('./devices' ).remove (dev )
1014
1015
if ((oldMem << 10 ) - totRemoved ) <= newMem :
1015
1016
return newMem - self ._get_mem_dev_total_size (
1016
- ET .tostring (root )
1017
+ ET .tostring (root , encoding = 'unicode' )
1017
1018
)
1018
1019
1019
1020
if newMem == (oldMem << 10 ):
@@ -1034,7 +1035,7 @@ def _set_max_memory(self, root, newMem, newMaxMem, maxMemTag):
1034
1035
# Just update value in max memory tag
1035
1036
maxMemTag .text = str (newMaxMem )
1036
1037
elif (maxMemTag is not None ) and (newMem == newMaxMem ):
1037
- if self ._get_mem_dev_total_size (ET .tostring (root )) == 0 :
1038
+ if self ._get_mem_dev_total_size (ET .tostring (root , encoding = 'unicode' )) == 0 :
1038
1039
# Remove the tag
1039
1040
root .remove (maxMemTag )
1040
1041
else :
@@ -1104,7 +1105,8 @@ def _update_memory_config(self, xml, params, dom):
1104
1105
1105
1106
if (maxMemTag is not None ) and (not hasMaxMem ):
1106
1107
if newMem == newMaxMem and (
1107
- self ._get_mem_dev_total_size (ET .tostring (root )) == 0
1108
+ self ._get_mem_dev_total_size (
1109
+ ET .tostring (root , encoding = 'unicode' )) == 0
1108
1110
):
1109
1111
root .remove (maxMemTag )
1110
1112
@@ -1116,7 +1118,7 @@ def _update_memory_config(self, xml, params, dom):
1116
1118
memtune .remove (hl )
1117
1119
memtune .insert (0 , E .hard_limit (
1118
1120
str (newMaxMem + 1048576 ), unit = 'Kib' ))
1119
- return ET .tostring (root , encoding = 'utf-8 ' )
1121
+ return ET .tostring (root , encoding = 'unicode ' )
1120
1122
1121
1123
def get_vm_cpu_cores (self , vm_xml ):
1122
1124
return xpath_get_text (vm_xml , XPATH_TOPOLOGY + '/@cores' )[0 ]
@@ -1224,8 +1226,8 @@ def _update_memory_live(self, dom, params):
1224
1226
)
1225
1227
# Check number of slots supported
1226
1228
if (
1227
- len (xpath_get_text (xml , './devices/memory' )) ==
1228
- MEM_DEV_SLOTS [os .uname ()[4 ]]
1229
+ len (xpath_get_text (xml , './devices/memory' ))
1230
+ == MEM_DEV_SLOTS [os .uname ()[4 ]]
1229
1231
):
1230
1232
raise InvalidOperation ('KCHVM0045E' )
1231
1233
@@ -1728,8 +1730,8 @@ def serial(self, name):
1728
1730
)
1729
1731
1730
1732
websocket .add_proxy_token (
1731
- name
1732
- + '-console' , os .path .join (serialconsole .BASE_DIRECTORY , name ), True
1733
+ name +
1734
+ '-console' , os .path .join (serialconsole .BASE_DIRECTORY , name ), True
1733
1735
)
1734
1736
1735
1737
try :
0 commit comments