Am Tue, 25 May 2021 23:40:59 +0200 schrieb Olaf Hering <olaf@xxxxxxxxx>: > In case of error the objects are disposed by libxl_domain_config_dispose. I just realized this is not always true, unless this change is applied on top. If libxlMakeNic fails, libxl_domain_config_dispose can not release anything. With this additional change each successfully initialized object can be fully disposed. Olaf --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1523,13 +1523,14 @@ libxlMakeNicList(virDomainDef *def, libxl_domain_config *d_config) libxl_device_nic *x_nics; size_t i, nvnics = 0; - x_nics = g_new0(libxl_device_nic, nnics); + d_config->nics = x_nics = g_new0(libxl_device_nic, nnics); for (i = 0; i < nnics; i++) { if (virDomainNetGetActualType(l_nics[i]) == VIR_DOMAIN_NET_TYPE_HOSTDEV) continue; libxl_device_nic_init(&x_nics[nvnics]); + d_config->num_nics = nvnics + 1; if (libxlMakeNic(def, l_nics[i], &x_nics[nvnics], false)) return -1; /* @@ -1544,8 +1545,6 @@ libxlMakeNicList(virDomainDef *def, libxl_domain_config *d_config) } VIR_SHRINK_N(x_nics, nnics, nnics - nvnics); - d_config->nics = x_nics; - d_config->num_nics = nvnics; return 0; }
Attachment:
pgpHS7KuqLAHr.pgp
Description: Digitale Signatur von OpenPGP