ConfigWriter.AddInstance check instance mac
authorGuido Trotter <ultrotter@google.com>
Thu, 12 Feb 2009 17:35:28 +0000 (17:35 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 12 Feb 2009 17:35:28 +0000 (17:35 +0000)
commite46402147df5702872534f3c312f8f60c05fc175
treec89382ca919929abcf481e121ca32213f7acf8f8
parent295728dfc13797a99ed6aaea7fb4557928e623d4
ConfigWriter.AddInstance check instance mac

There is a race condition in CreateInstance, since the mac address is
generated early and only added to the config (and thus really assured to
be unique) only at this point. Since it's possible that another instance
gets the same mac address in the meantime with this check we'll make the
instance creation fail before modifying the config data and thus having
a wrong in-memory config (which is bad!!).

Note that the same race condition exists, for example, in
SetInstanceParams, and should be fully addressed by a way to revert
config changes if writing them fails!

Reviewed-by: iustin
lib/config.py