[PATCH 4/8] conf: add virDomainVideoDefNew

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To handle setting a default heads value. Convert callers that were
doing it by hand

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 src/conf/domain_conf.c        | 21 ++++++++++++++++-----
 src/conf/domain_conf.h        |  1 +
 src/libvirt_private.syms      |  1 +
 src/qemu/qemu_parse_command.c |  3 +--
 src/vz/vz_sdk.c               |  3 +--
 5 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c3149f976..47b668dc1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2351,6 +2351,20 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def)
     VIR_FREE(def);
 }
 
+
+virDomainVideoDefPtr
+virDomainVideoDefNew(void)
+{
+    virDomainVideoDefPtr def;
+
+    if (VIR_ALLOC(def) < 0)
+        return NULL;
+
+    def->heads = 1;
+    return def;
+}
+
+
 void virDomainVideoDefFree(virDomainVideoDefPtr def)
 {
     if (!def)
@@ -13660,7 +13674,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
 
     ctxt->node = node;
 
-    if (VIR_ALLOC(def) < 0)
+    if (!(def = virDomainVideoDefNew()))
         return NULL;
 
     cur = node->children;
@@ -13754,8 +13768,6 @@ virDomainVideoDefParseXML(xmlNodePtr node,
                            _("cannot parse video heads '%s'"), heads);
             goto error;
         }
-    } else {
-        def->heads = 1;
     }
 
     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
@@ -20944,7 +20956,7 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def)
     if (def->ngraphics == 0 || def->nvideos > 0)
         return 0;
 
-    if (VIR_ALLOC(video) < 0)
+    if (!(video = virDomainVideoDefNew()))
         goto cleanup;
     video->type = virDomainVideoDefaultType(def);
     if (video->type < 0) {
@@ -20952,7 +20964,6 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def)
                        _("cannot determine default video type"));
         goto cleanup;
     }
-    video->heads = 1;
     if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0)
         goto cleanup;
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 964bc02f9..db89ffa97 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2683,6 +2683,7 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def);
 void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
 void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
 void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
+virDomainVideoDefPtr virDomainVideoDefNew(void);
 void virDomainVideoDefFree(virDomainVideoDefPtr def);
 virDomainHostdevDefPtr virDomainHostdevDefAlloc(virDomainXMLOptionPtr xmlopt);
 void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 888412ac7..248237c4a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -528,6 +528,7 @@ virDomainUSBDeviceDefForeach;
 virDomainVideoDefaultRAM;
 virDomainVideoDefaultType;
 virDomainVideoDefFree;
+virDomainVideoDefNew;
 virDomainVideoTypeFromString;
 virDomainVideoTypeToString;
 virDomainVideoVGAConfTypeFromString;
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 60c81f0ca..6751868a6 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -2606,10 +2606,9 @@ qemuParseCommandLine(virCapsPtr caps,
 
     if (def->ngraphics) {
         virDomainVideoDefPtr vid;
-        if (VIR_ALLOC(vid) < 0)
+        if (!(vid = virDomainVideoDefNew()))
             goto error;
         vid->type = video;
-        vid->heads = 1;
 
         if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, vid) < 0) {
             virDomainVideoDefFree(vid);
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index a62b31079..950eeaa34 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -552,12 +552,11 @@ prlsdkAddDomainVideoInfoCt(virDomainDefPtr def)
     if (def->ngraphics == 0)
         return 0;
 
-    if (VIR_ALLOC(video) < 0)
+    if (!(video = virDomainVideoDefNew()))
         goto cleanup;
 
     video->type = VIR_DOMAIN_VIDEO_TYPE_PARALLELS;
     video->vram = 0;
-    video->heads = 1;
 
     if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0)
         goto cleanup;
-- 
2.13.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux