vzctl create: fix race vs init.d/vz

If one runs vzctl create and then /etc/init.d/vz stop, a race can occur
since vzctl create turns on quota for new container and init.d/vz drops it.
The result is half-created VE which can not even be started.

The problem is absense of checking return values from quota functions.
This patch adds the missing checks, now the race is detected and the result
is container creation error (which is better than a silent fail):

Creating container private area (suse-10.3-x86)
vzquota : (error) can't lock quota file, some quota operations are performing for id 109
vzquota off failed [7]
vzquota : (error) can't lock quota file, some quota operations are performing for id 109
vzquota off failed [7]
vzquota : (error) can't lock quota file, some quota operations are performing for id 109
vzquota off failed [7]
vzquota : (error) can't lock quota file, some quota operations are performing for id 109
vzquota off failed [7]
Creation of container private area failed
dionysos ~ # vzctl status 109
CTID 109 deleted unmounted down
dionysos ~ # ls -l /etc/vz/conf/109.conf
ls: cannot access /etc/vz/conf/109.conf: No such file or directory
dionysos ~ # ls -l /vz/root/109
ls: cannot access /vz/root/109: No such file or directory
dionysos ~ # ls -l /vz/private/109
ls: cannot access /vz/private/109: No such file or directory

http://bugzilla.openvz.org/495

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
1 file changed