mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
qemuMigrationCookieGraphicsSpiceAlloc: Refactor memory handling
Use modern memory handling approach to simplify the code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
85d6d515ed
commit
f3e087ac9c
@ -192,13 +192,10 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver,
|
|||||||
virDomainGraphicsDefPtr def,
|
virDomainGraphicsDefPtr def,
|
||||||
virDomainGraphicsListenDefPtr glisten)
|
virDomainGraphicsListenDefPtr glisten)
|
||||||
{
|
{
|
||||||
qemuMigrationCookieGraphicsPtr mig = NULL;
|
g_autoptr(qemuMigrationCookieGraphics) mig = g_new0(qemuMigrationCookieGraphics, 1);
|
||||||
const char *listenAddr;
|
const char *listenAddr;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
if (VIR_ALLOC(mig) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
mig->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
|
mig->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
|
||||||
mig->port = def->data.spice.port;
|
mig->port = def->data.spice.port;
|
||||||
if (cfg->spiceTLS)
|
if (cfg->spiceTLS)
|
||||||
@ -211,15 +208,11 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if (cfg->spiceTLS &&
|
if (cfg->spiceTLS &&
|
||||||
!(mig->tlsSubject = qemuDomainExtractTLSSubject(cfg->spiceTLSx509certdir)))
|
!(mig->tlsSubject = qemuDomainExtractTLSSubject(cfg->spiceTLSx509certdir)))
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
mig->listen = g_strdup(listenAddr);
|
mig->listen = g_strdup(listenAddr);
|
||||||
|
|
||||||
return mig;
|
return g_steal_pointer(&mig);
|
||||||
|
|
||||||
error:
|
|
||||||
qemuMigrationCookieGraphicsFree(mig);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user