]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Fix domain ID allocation
authorJán Tomko <jtomko@redhat.com>
Fri, 31 Jan 2020 14:27:37 +0000 (15:27 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 31 Jan 2020 15:11:50 +0000 (16:11 +0100)
commite8d5eb0cdec4c4c2e7aea2ebf66dfe6f5b4cb526
tree356e586c82c02f53a3bd22f59f3c7799d5e420f7
parent5b63cb5abff09882feda8e333285259aecc8e9e8
qemu: Fix domain ID allocation

The rewrite to use GLib's atomic ops functions changed the behavior
of virAtomicIntInc - before it returned the pre-increment value.

Most of the callers using its value were adjusted, but the one
in qemuDriverAllocateID was not. If libvirtd would reconnect to
a running domain during startup, the next started domain would get
the same ID:

$ virsh list
 Id   Name       State
--------------------------
 1    f28live    running
 1    f28live1   running

Use the g_atomic_add function directly (as recommended in viratomic.h)
and add 1 to the result.

This also restores the usual numbering from 1 instead of 0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 7b9645a7d127a374b8d1c83fdf9789706dbab2c9
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_conf.c