We don't allow to define domain with same name and different UUID,
or with same UUID, so it's reasonable to not load the domain config
if there is domain with same name already exists.
Otherwise it can cause problem like:
1) % cp /etc/libvirt/qemu/dom.xml /etc/libvirt/qemu/dom_diffuuid.xml
2) remove the line with "uuid" in the "dom_diffuuid.xml"
3) % for i in {1..10}; do kill -SIGHUP $(pidof libvirtd); done
4) % virsh list --all
There will be 11 domains listed with the same name, as if there is
no UUID specified in domain XML, libvirt will generate one for it,
which will be definitely different with the original one.
---
src/conf/domain_conf.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ce1f3c5..0bed929 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10535,7 +10535,8 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps,
/* if the domain is already in our hashtable, we only need to
* update the autostart flag
*/
- if ((dom = virDomainFindByUUID(doms, def->uuid))) {
+ if ((dom = virDomainFindByUUID(doms, def->uuid)) ||
+ (dom = virDomainFindByName(doms, def->name))) {
dom->autostart = autostart;
VIR_FREE(configFile);
--
1.7.6