@@ -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;
@@ -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);
@@ -528,6 +528,7 @@ virDomainUSBDeviceDefForeach;
virDomainVideoDefaultRAM;
virDomainVideoDefaultType;
virDomainVideoDefFree;
+virDomainVideoDefNew;
virDomainVideoTypeFromString;
virDomainVideoTypeToString;
virDomainVideoVGAConfTypeFromString;
@@ -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);
@@ -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;
To handle setting a default heads value. Convert callers that were doing it by hand Signed-off-by: Cole Robinson <crobinso@redhat.com> --- 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(-) -- 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list