[libvirt] [PATCH 4/5] Retry veth device creation on failure
Eric Blake
eblake at redhat.com
Wed Oct 2 20:51:54 UTC 2013
On 10/02/2013 05:31 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> The veth device creation code run in two steps, first it looks
> for two free veth device names, then it runs ip link to create
> the veth pair. There is an obvious race between finding free
> names and creating them, when guests are started in parallel.
>
> Rewrite the code to loop and re-try creation if it fails, to
> deal with the race condition.
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> src/util/virnetdevveth.c | 151 +++++++++++++++++++++++++++++------------------
> 1 file changed, 92 insertions(+), 59 deletions(-)
>
> /* Functions */
> +
> +static int virNetDevVethExists(int devNum)
> +{
> + int ret;
> + char *path = NULL;
> + if (virAsprintf(&path, "/sys/class/net/veth%d/", devNum) < 0)
> + return -1;
> + ret = virFileExists(path) ? 1 : 0;
Looks a bit funny for converting a bool to int. I probably would have
skipped the ternary; but what you did is not wrong.
>
> - if (virAsprintf(veth, "veth%d", devNum) < 0)
> - return -1;
> + for (devNum = startDev ; devNum < MAX_DEV_NUM ; devNum++) {
How did this get past 'make syntax-check'? We cleaned up the code base
to avoid space before ';'.
ACK with the syntax cleaned up.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131002/5d3a83a1/attachment-0001.sig>
More information about the libvir-list
mailing list