From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> --- src/conf/domain_conf.c | 26 +++++++++++++++++--------- src/conf/domain_conf.h | 7 +++++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 270f597e3b..a482e2f88f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2819,13 +2819,19 @@ void virDomainShmemDefFree(virDomainShmemDefPtr def) virDomainVideoDefPtr -virDomainVideoDefNew(void) +virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt) { virDomainVideoDefPtr def; if (VIR_ALLOC(def) < 0) return NULL; + if (xmlopt && xmlopt->privateData.videoNew && + !(def->privateData = xmlopt->privateData.videoNew())) { + VIR_FREE(def); + return NULL; + } + def->heads = 1; return def; } @@ -2857,6 +2863,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def) return; virDomainVideoDefClear(def); + virObjectUnref(def->privateData); VIR_FREE(def); } @@ -5676,7 +5683,8 @@ virDomainDefPostParseVideo(virDomainDefPtr def, static int virDomainDefPostParseCommon(virDomainDefPtr def, - struct virDomainDefPostParseDeviceIteratorData *data) + struct virDomainDefPostParseDeviceIteratorData *data, + virDomainXMLOptionPtr xmlopt) { size_t i; @@ -5711,7 +5719,7 @@ virDomainDefPostParseCommon(virDomainDefPtr def, if (virDomainDefPostParseTimer(def) < 0) return -1; - if (virDomainDefAddImplicitDevices(def) < 0) + if (virDomainDefAddImplicitDevices(def, xmlopt) < 0) return -1; if (virDomainDefPostParseVideo(def, data) < 0) @@ -5837,7 +5845,7 @@ virDomainDefPostParse(virDomainDefPtr def, if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0) goto cleanup; - if ((ret = virDomainDefPostParseCommon(def, &data)) < 0) + if ((ret = virDomainDefPostParseCommon(def, &data, xmlopt)) < 0) goto cleanup; if (xmlopt->config.assignAddressesCallback) { @@ -15403,7 +15411,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt, VIR_AUTOFREE(char *) vgamem = NULL; VIR_AUTOFREE(char *) primary = NULL; - if (!(def = virDomainVideoDefNew())) + if (!(def = virDomainVideoDefNew(xmlopt))) return NULL; ctxt->node = node; @@ -23721,7 +23729,7 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def) } static int -virDomainDefAddImplicitVideo(virDomainDefPtr def) +virDomainDefAddImplicitVideo(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt) { int ret = -1; virDomainVideoDefPtr video = NULL; @@ -23731,7 +23739,7 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def) if (def->ngraphics == 0 || def->nvideos > 0) return 0; - if (!(video = virDomainVideoDefNew())) + if (!(video = virDomainVideoDefNew(xmlopt))) goto cleanup; video->type = virDomainVideoDefaultType(def); if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) @@ -23744,7 +23752,7 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def) } int -virDomainDefAddImplicitDevices(virDomainDefPtr def) +virDomainDefAddImplicitDevices(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt) { if (virDomainDefAddConsoleCompat(def) < 0) return -1; @@ -23752,7 +23760,7 @@ virDomainDefAddImplicitDevices(virDomainDefPtr def) if (virDomainDefAddImplicitControllers(def) < 0) return -1; - if (virDomainDefAddImplicitVideo(def) < 0) + if (virDomainDefAddImplicitVideo(def, xmlopt) < 0) return -1; return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index faeb060c04..d8d60f8ca1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1425,6 +1425,8 @@ struct _virDomainVideoDriverDef { }; struct _virDomainVideoDef { + virObjectPtr privateData; + int type; /* enum virDomainVideoType */ unsigned int ram; /* kibibytes (multiples of 1024) */ unsigned int vram; /* kibibytes (multiples of 1024) */ @@ -2726,6 +2728,7 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataNewFunc chrSourceNew; virDomainXMLPrivateDataNewFunc vsockNew; virDomainXMLPrivateDataNewFunc graphicsNew; + virDomainXMLPrivateDataNewFunc videoNew; virDomainXMLPrivateDataFormatFunc format; virDomainXMLPrivateDataParseFunc parse; /* following function shall return a pointer which will be used as the @@ -2867,7 +2870,7 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def); void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def); void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def); void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def); -virDomainVideoDefPtr virDomainVideoDefNew(void); +virDomainVideoDefPtr virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt); void virDomainVideoDefFree(virDomainVideoDefPtr def); void virDomainVideoDefClear(virDomainVideoDefPtr def); virDomainHostdevDefPtr virDomainHostdevDefNew(void); @@ -3055,7 +3058,7 @@ bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, virDomainXMLOptionPtr xmlopt, unsigned int flags); -int virDomainDefAddImplicitDevices(virDomainDefPtr def); +int virDomainDefAddImplicitDevices(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt); virDomainIOThreadIDDefPtr virDomainIOThreadIDFind(const virDomainDef *def, unsigned int iothread_id); -- 2.23.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list