mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
virQEMUDriverGetConfig: Fix memleak
==19015== 968 (416 direct, 552 indirect) bytes in 1 blocks are definitely lost in loss record 999 of 1,049 ==19015== at 0x4C2C070: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==19015== by 0x52ADF14: virAllocVar (viralloc.c:560) ==19015== by 0x5302FD1: virObjectNew (virobject.c:193) ==19015== by 0x1DD9401E: virQEMUDriverConfigNew (qemu_conf.c:164) ==19015== by 0x1DDDF65D: qemuStateInitialize (qemu_driver.c:666) ==19015== by 0x53E0823: virStateInitialize (libvirt.c:777) ==19015== by 0x11E067: daemonRunStateInit (libvirtd.c:905) ==19015== by 0x53201AD: virThreadHelper (virthread.c:206) ==19015== by 0xA1EE1F2: start_thread (in /lib64/libpthread-2.19.so) ==19015== by 0xA4EFC8C: clone (in /lib64/libc-2.19.so) Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
8d971cecc6
commit
225aa80246
@ -1246,11 +1246,13 @@ qemuRemoveCgroup(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virQEMUDriverConfigPtr cfg;
|
||||
|
||||
if (priv->cgroup == NULL)
|
||||
return 0; /* Not supported, so claim success */
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
|
||||
if (virCgroupTerminateMachine(vm->def->name,
|
||||
"qemu",
|
||||
cfg->privileged) < 0) {
|
||||
|
@ -8051,7 +8051,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
|
||||
char **tapfdName = NULL;
|
||||
char **vhostfdName = NULL;
|
||||
int actualType = virDomainNetGetActualType(net);
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
virNetDevBandwidthPtr actualBandwidth;
|
||||
size_t i;
|
||||
|
||||
@ -8088,6 +8088,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
|
||||
return -1;
|
||||
}
|
||||
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
|
||||
if (actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
|
||||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
||||
tapfdSize = net->driver.virtio.queues;
|
||||
@ -8269,6 +8271,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
|
||||
VIR_FREE(host);
|
||||
VIR_FREE(tapfdName);
|
||||
VIR_FREE(vhostfdName);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1095,6 +1095,9 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
virQEMUDriverPtr driver = opaque;
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
|
||||
if (driver)
|
||||
cfg = virQEMUDriverGetConfig(driver);
|
||||
|
||||
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
|
||||
dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV &&
|
||||
!dev->data.net->model) {
|
||||
@ -1108,7 +1111,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
virDomainDiskDefPtr disk = dev->data.disk;
|
||||
|
||||
/* both of these require data from the driver config */
|
||||
if (driver && (cfg = virQEMUDriverGetConfig(driver))) {
|
||||
if (cfg) {
|
||||
/* assign default storage format and driver according to config */
|
||||
if (cfg->allowDiskFormatProbing) {
|
||||
/* default disk format for drives */
|
||||
@ -1117,7 +1120,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_BLOCK))
|
||||
virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_AUTO);
|
||||
|
||||
/* default disk format for mirrored drive */
|
||||
/* default disk format for mirrored drive */
|
||||
if (disk->mirror &&
|
||||
disk->mirror->format == VIR_STORAGE_FILE_NONE)
|
||||
disk->mirror->format = VIR_STORAGE_FILE_AUTO;
|
||||
@ -1125,7 +1128,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
/* default driver if probing is forbidden */
|
||||
if (!virDomainDiskGetDriver(disk) &&
|
||||
virDomainDiskSetDriver(disk, "qemu") < 0)
|
||||
goto cleanup;
|
||||
goto cleanup;
|
||||
|
||||
/* default disk format for drives */
|
||||
if (virDomainDiskGetFormat(disk) == VIR_STORAGE_FILE_NONE &&
|
||||
@ -1133,7 +1136,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
virDomainDiskGetType(disk) == VIR_STORAGE_TYPE_BLOCK))
|
||||
virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW);
|
||||
|
||||
/* default disk format for mirrored drive */
|
||||
/* default disk format for mirrored drive */
|
||||
if (disk->mirror &&
|
||||
disk->mirror->format == VIR_STORAGE_FILE_NONE)
|
||||
disk->mirror->format = VIR_STORAGE_FILE_RAW;
|
||||
@ -1168,8 +1171,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
|
||||
dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
|
||||
dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
|
||||
!dev->data.chr->source.data.nix.path &&
|
||||
(driver && (cfg = virQEMUDriverGetConfig(driver)))) {
|
||||
!dev->data.chr->source.data.nix.path && cfg) {
|
||||
|
||||
if (virAsprintf(&dev->data.chr->source.data.nix.path,
|
||||
"%s/channel/target/%s.%s",
|
||||
|
Loading…
Reference in New Issue
Block a user