Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/libvirt-connection.c | 2 ++ src/libvirt-php.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libvirt-connection.c b/src/libvirt-connection.c index 086cd57..9e70031 100644 --- a/src/libvirt-connection.c +++ b/src/libvirt-connection.c @@ -404,6 +404,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) char cmd[4096] = { 0 }; char tmp2[16] = { 0 }; snprintf(cmd, sizeof(cmd), "%s -net nic,model=? 2>&1", tmp); + VIR_FREE(tmp); FILE *fp = popen(cmd, "r"); if (fp == NULL) @@ -475,6 +476,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) char cmd[4096] = { 0 }; snprintf(cmd, sizeof(cmd), "%s -soundhw help 2>&1", tmp); + VIR_FREE(tmp); FILE *fp = popen(cmd, "r"); if (fp == NULL) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 5ec6e60..cf8fd7f 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2277,6 +2277,7 @@ char *installation_get_xml(virConnectPtr conn, char *name, int memMB, { int i; char *xml = NULL; + char *emulator = NULL; char disks_xml[16384] = { 0 }; char networks_xml[16384] = { 0 }; char features[128] = { 0 }; @@ -2304,6 +2305,11 @@ char *installation_get_xml(virConnectPtr conn, char *name, int memMB, DPRINTF("%s: No architecture defined, got host arch of '%s'\n", __FUNCTION__, arch); } + if (!(emulator = connection_get_emulator(conn, arch TSRMLS_CC))) { + DPRINTF("%s: Cannot get emulator\n", __FUNCTION__); + return NULL; + } + if (iso_image && access(iso_image, R_OK) != 0) { DPRINTF("%s: Installation image %s doesn't exist\n", __FUNCTION__, iso_image); return NULL; @@ -2370,7 +2376,7 @@ char *installation_get_xml(virConnectPtr conn, char *name, int memMB, "</domain>", type, name, memMB * 1024, maxmemMB * 1024, uuid, arch, features, (domain_flags & DOMAIN_FLAG_CLOCK_LOCALTIME ? "localtime" : "utc"), - vCpus, connection_get_emulator(conn, arch TSRMLS_CC), disks_xml, + vCpus, emulator, disks_xml, iso_image, networks_xml, (domain_flags & DOMAIN_FLAG_SOUND_AC97 ? "<sound model='ac97'/>\n" : "")); } else { @@ -2409,11 +2415,12 @@ char *installation_get_xml(virConnectPtr conn, char *name, int memMB, "</domain>", type, name, memMB * 1024, maxmemMB * 1024, uuid, arch, features, (domain_flags & DOMAIN_FLAG_CLOCK_LOCALTIME ? "localtime" : "utc"), - vCpus, connection_get_emulator(conn, arch TSRMLS_CC), disks_xml, + vCpus, emulator, disks_xml, networks_xml, (domain_flags & DOMAIN_FLAG_SOUND_AC97 ? "<sound model='ac97'/>\n" : "")); } + VIR_FREE(emulator); VIR_FREE(tmp); VIR_FREE(arch); if (rv < 0) -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list