9c6c51
From f60ad6c8636b58d8559963aaf2e445bb4dd3db63 Mon Sep 17 00:00:00 2001
9c6c51
Message-Id: <f60ad6c8636b58d8559963aaf2e445bb4dd3db63@dist-git>
9c6c51
From: Erik Skultety <eskultet@redhat.com>
9c6c51
Date: Thu, 19 Jul 2018 15:03:51 +0200
9c6c51
Subject: [PATCH] conf: Introduce virDomainVideoDefClear helper
9c6c51
MIME-Version: 1.0
9c6c51
Content-Type: text/plain; charset=UTF-8
9c6c51
Content-Transfer-Encoding: 8bit
9c6c51
9c6c51
Future patches rely on the ability to reset the contents of the
9c6c51
virDomainVideoDef structure rather than re-allocating it.
9c6c51
9c6c51
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9c6c51
Reviewed-by: John Ferlan <jferlan@redhat.com>
9c6c51
(cherry picked from commit f317b1e5c57291644c841cb620eda86dac8642a1)
9c6c51
9c6c51
https://bugzilla.redhat.com/show_bug.cgi?id=1475770
9c6c51
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9c6c51
Reviewed-by: Ján Tomko <jtomko@redhat.com>
9c6c51
---
9c6c51
 src/conf/domain_conf.c   | 14 +++++++++++++-
9c6c51
 src/conf/domain_conf.h   |  1 +
9c6c51
 src/libvirt_private.syms |  1 +
9c6c51
 3 files changed, 15 insertions(+), 1 deletion(-)
9c6c51
9c6c51
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
9c6c51
index 70eb45f03a..d23b2861ef 100644
9c6c51
--- a/src/conf/domain_conf.c
9c6c51
+++ b/src/conf/domain_conf.c
9c6c51
@@ -2538,7 +2538,8 @@ virDomainVideoDefNew(void)
9c6c51
 }
9c6c51
 
9c6c51
 
9c6c51
-void virDomainVideoDefFree(virDomainVideoDefPtr def)
9c6c51
+void
9c6c51
+virDomainVideoDefClear(virDomainVideoDefPtr def)
9c6c51
 {
9c6c51
     if (!def)
9c6c51
         return;
9c6c51
@@ -2548,6 +2549,17 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
9c6c51
     VIR_FREE(def->accel);
9c6c51
     VIR_FREE(def->virtio);
9c6c51
     VIR_FREE(def->driver);
9c6c51
+
9c6c51
+    memset(def, 0, sizeof(*def));
9c6c51
+}
9c6c51
+
9c6c51
+
9c6c51
+void virDomainVideoDefFree(virDomainVideoDefPtr def)
9c6c51
+{
9c6c51
+    if (!def)
9c6c51
+        return;
9c6c51
+
9c6c51
+    virDomainVideoDefClear(def);
9c6c51
     VIR_FREE(def);
9c6c51
 }
9c6c51
 
9c6c51
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
9c6c51
index 41d27482fb..1fc1734bcc 100644
9c6c51
--- a/src/conf/domain_conf.h
9c6c51
+++ b/src/conf/domain_conf.h
9c6c51
@@ -2884,6 +2884,7 @@ void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
9c6c51
 void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
9c6c51
 virDomainVideoDefPtr virDomainVideoDefNew(void);
9c6c51
 void virDomainVideoDefFree(virDomainVideoDefPtr def);
9c6c51
+void virDomainVideoDefClear(virDomainVideoDefPtr def);
9c6c51
 virDomainHostdevDefPtr virDomainHostdevDefNew(void);
9c6c51
 void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
9c6c51
 void virDomainHostdevDefFree(virDomainHostdevDefPtr def);
9c6c51
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
9c6c51
index 5499a368c0..5bd08d3f67 100644
9c6c51
--- a/src/libvirt_private.syms
9c6c51
+++ b/src/libvirt_private.syms
9c6c51
@@ -567,6 +567,7 @@ virDomainTPMModelTypeToString;
9c6c51
 virDomainUSBDeviceDefForeach;
9c6c51
 virDomainVideoDefaultRAM;
9c6c51
 virDomainVideoDefaultType;
9c6c51
+virDomainVideoDefClear;
9c6c51
 virDomainVideoDefFree;
9c6c51
 virDomainVideoDefNew;
9c6c51
 virDomainVideoTypeFromString;
9c6c51
-- 
9c6c51
2.18.0
9c6c51