render / rpms / libvirt

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