On 04/06/2018 12:53 PM, John Ferlan wrote:
Rather than VIR_ALLOC, use the New function for allocation. We
already use the Free function anyway.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/conf/domain_conf.c | 2 +-
src/conf/domain_conf.h | 3 +++
src/libvirt_private.syms | 1 +
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_process.c | 2 +-
5 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index caf3f47c63..fd57364cd4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12211,7 +12211,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
}
-static virDomainChrSourceDefPtr
+virDomainChrSourceDefPtr
virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt)
{
virDomainChrSourceDefPtr def = NULL;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 68473c309e..89a7131fdb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2827,6 +2827,9 @@ bool virDomainDefHasDeviceAddress(virDomainDefPtr def,
void virDomainDefFree(virDomainDefPtr vm);
+virDomainChrSourceDefPtr
+virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt);
+
virDomainChrDefPtr virDomainChrDefNew(virDomainXMLOptionPtr xmlopt);
virDomainDefPtr virDomainDefNew(void);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c550310cc0..cab324c4d7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -218,6 +218,7 @@ virDomainChrSourceDefClear;
virDomainChrSourceDefCopy;
virDomainChrSourceDefFree;
virDomainChrSourceDefGetPath;
+virDomainChrSourceDefNew;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
virDomainChrTcpProtocolTypeFromString;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f03aa03e8a..bdc6e58d6e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2422,7 +2422,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
xmlNodePtr node = NULL;
virQEMUCapsPtr qemuCaps = NULL;
- if (VIR_ALLOC(priv->monConfig) < 0)
+ if (!(priv->monConfig = virDomainChrSourceDefNew(NULL)))
goto error;
if (!(monitorpath =
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c0105c8b84..a8dab92dd6 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5717,7 +5717,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
goto cleanup;
}
- if (VIR_ALLOC(priv->monConfig) < 0)
+ if (!(priv->monConfig = virDomainChrSourceDefNew(NULL)))
goto cleanup;
VIR_DEBUG("Preparing monitor state");
It's a bit obscure to get to, but qemu_parse_command.c:2487 has a
VIR_ALLOC(chr) that ends up being put into a monConfig - you'll need to
change that one to use virDomainChrSourceDefNew() to be complete. If you
do that, then:
Reviewed-by: Laine Stump <laine(a)laine.org>