mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 20:26:48 +00:00
fix(vrtManager): a volume upload aborts its stream when the volume cannot be made
upload_volume opens the libvirt stream before it creates the volume, but created the volume outside the block that aborts the stream: a pool that refused the volume (full, a name taken) left an unfinished stream to be freed. The creation is now inside that block.
This commit is contained in:
parent
297f9a8a53
commit
d4b9edc3e5
2 changed files with 18 additions and 6 deletions
|
|
@ -1040,12 +1040,13 @@ class wvmConnect(object):
|
|||
stream, which every connection type carries. A failed write leaves
|
||||
no volume."""
|
||||
stream = self.wvm.newStream(0)
|
||||
vol = pool.createXML(
|
||||
f"<volume><name>{util.xml_escape(name)}</name><capacity>{len(data)}</capacity>"
|
||||
"<target><format type='raw'/></target></volume>",
|
||||
0,
|
||||
)
|
||||
vol = None
|
||||
try:
|
||||
vol = pool.createXML(
|
||||
f"<volume><name>{util.xml_escape(name)}</name><capacity>{len(data)}</capacity>"
|
||||
"<target><format type='raw'/></target></volume>",
|
||||
0,
|
||||
)
|
||||
vol.upload(stream, 0, len(data), 0)
|
||||
stream.sendAll(lambda _stream, size, buffer: buffer.read(size), io.BytesIO(data))
|
||||
stream.finish()
|
||||
|
|
@ -1053,7 +1054,8 @@ class wvmConnect(object):
|
|||
# libvirt: a stream that did not finish is aborted before it is freed
|
||||
with contextlib.suppress(libvirtError):
|
||||
stream.abort()
|
||||
vol.delete(0)
|
||||
if vol is not None:
|
||||
vol.delete(0)
|
||||
raise
|
||||
return vol
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue