From: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau(a)redhat.com>
Reviewed-by: Cole Robinson <crobinso(a)redhat.com>
---
src/conf/domain_conf.c | 26 +++++++++++++++++---------
src/conf/domain_conf.h | 8 ++++++--
src/vz/vz_sdk.c | 2 +-
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e7ec9e972d..6dea670257 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) {
@@ -15451,7 +15459,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;
@@ -23743,7 +23751,7 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def)
}
static int
-virDomainDefAddImplicitVideo(virDomainDefPtr def)
+virDomainDefAddImplicitVideo(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt)
{
int ret = -1;
virDomainVideoDefPtr video = NULL;
@@ -23753,7 +23761,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)
@@ -23766,7 +23774,7 @@ virDomainDefAddImplicitVideo(virDomainDefPtr def)
}
int
-virDomainDefAddImplicitDevices(virDomainDefPtr def)
+virDomainDefAddImplicitDevices(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt)
{
if (virDomainDefAddConsoleCompat(def) < 0)
return -1;
@@ -23774,7 +23782,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 0143efddbe..cff33f6682 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);
@@ -3063,7 +3066,8 @@ 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);
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index c6e3398620..7ac4888ecb 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1928,7 +1928,7 @@ prlsdkLoadDomain(vzDriverPtr driver,
if (prlsdkGetDomainState(dom, sdkdom, &domainState) < 0)
goto error;
- if (!IS_CT(def) && virDomainDefAddImplicitDevices(def) < 0)
+ if (!IS_CT(def) && virDomainDefAddImplicitDevices(def, driver->xmlopt)
< 0)
goto error;
if (def->ngraphics > 0) {
--
2.23.0