From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
---
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 9e1c8babf8..e99e52dc5e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2820,13 +2820,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;
}
@@ -2858,6 +2864,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
return;
virDomainVideoDefClear(def);
+ virObjectUnref(def->privateData);
VIR_FREE(def);
}
@@ -5681,7 +5688,8 @@ virDomainDefPostParseVideo(virDomainDefPtr def,
static int
virDomainDefPostParseCommon(virDomainDefPtr def,
- struct virDomainDefPostParseDeviceIteratorData *data)
+ struct virDomainDefPostParseDeviceIteratorData *data,
+ virDomainXMLOptionPtr xmlopt)
{
size_t i;
@@ -5716,7 +5724,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)
@@ -5842,7 +5850,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) {
@@ -15450,7 +15458,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;
@@ -23771,7 +23779,7 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def)
}
static int
-virDomainDefAddImplicitVideo(virDomainDefPtr def)
+virDomainDefAddImplicitVideo(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt)
{
int ret = -1;
virDomainVideoDefPtr video = NULL;
@@ -23781,7 +23789,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)
@@ -23794,7 +23802,7 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def)
}
int
-virDomainDefAddImplicitDevices(virDomainDefPtr def)
+virDomainDefAddImplicitDevices(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt)
{
if (virDomainDefAddConsoleCompat(def) < 0)
return -1;
@@ -23802,7 +23810,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 cec945de54..78aa1e83f2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1427,6 +1427,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) */
@@ -2729,6 +2731,7 @@ struct _virDomainXMLPrivateDataCallbacks {
virDomainXMLPrivateDataNewFunc vsockNew;
virDomainXMLPrivateDataNewFunc graphicsNew;
virDomainXMLPrivateDataNewFunc networkNew;
+ virDomainXMLPrivateDataNewFunc videoNew;
virDomainXMLPrivateDataFormatFunc format;
virDomainXMLPrivateDataParseFunc parse;
/* following function shall return a pointer which will be used as the
@@ -2870,7 +2873,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);
@@ -3062,7 +3065,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