1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 08:26:03 +00:00

fix(vrtManager): a new VM's disk path, network and filter names are XML text

create_instance put an existing volume's path and the network and
filter names into the domain XML unescaped, so a quote or ampersand,
which libvirt allows in them, broke the VM's XML. They are escaped as
attach_disk does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-08 14:42:47 +03:00
parent 0ac078b9cc
commit 2dfc393f05
2 changed files with 24 additions and 3 deletions

View file

@ -227,7 +227,7 @@ class wvmCreate(wvmConnect):
else:
xml += f"""<disk type='file' device='{volume["device"]}'>"""
xml += f""" <driver name='qemu' type='{volume["type"]}' {disk_opts}/>"""
xml += f""" <source file='{volume["path"]}'/>"""
xml += f""" <source file='{util.xml_escape(volume["path"])}'/>"""
if volume.get("bus") in dom_caps["disk_bus"]:
dev_prefix = util.vol_dev_type(volume.get("bus"))
@ -255,9 +255,9 @@ class wvmCreate(wvmConnect):
xml += """<interface type='network'>"""
if idx < len(macs):
xml += f"""<mac address='{macs[idx].strip()}'/>"""
xml += f"""<source network='{net}'/>"""
xml += f"""<source network='{util.xml_escape(net)}'/>"""
if nwfilter:
xml += f"""<filterref filter='{nwfilter}'/>"""
xml += f"""<filterref filter='{util.xml_escape(nwfilter)}'/>"""
if virtio:
xml += f"""<model type='{net_model}'/>"""
xml += """</interface>"""