tools/xenstore: fix node accounting after failed node creation
authorJuergen Gross <jgross@suse.com>
Tue, 15 Dec 2020 12:34:40 +0000 (13:34 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 15 Dec 2020 12:34:40 +0000 (13:34 +0100)
commit0bfb2101f243b27611ffec2087559d816d591e63
tree0d4707e19c22bf309df00c72c98409137f0c3adb
parent09a4146bdcf8eea804dd90fee4b9132bdbf69bae
tools/xenstore: fix node accounting after failed node creation

When a node creation fails the number of nodes of the domain should be
the same as before the failed node creation. In case of failure when
trying to create a node requiring to create one or more intermediate
nodes as well (e.g. when /a/b/c/d is to be created, but /a/b isn't
existing yet) it might happen that the number of nodes of the creating
domain is not reset to the value it had before.

So move the quota accounting out of construct_node() and into the node
write loop in create_node() in order to be able to undo the accounting
in case of an error in the intermediate node destructor.

This is part of XSA-115.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Acked-by: Julien Grall <jgrall@amazon.com>
tools/xenstore/xenstored_core.c