virDomainDefPostParse infrastructure has apart from the global opaque
data also per-run data, but this was not duplicated into the validation
callbacks.
This is important when drivers want to use correct run-state for the
validation.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/bhyve/bhyve_domain.c | 3 ++-
src/conf/domain_conf.c | 21 +++++++++++++--------
src/conf/domain_conf.h | 9 ++++++---
src/qemu/qemu_process.c | 2 +-
src/qemu/qemu_validate.c | 6 ++++--
src/qemu/qemu_validate.h | 7 +++++--
src/vz/vz_driver.c | 6 ++++--
7 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 6935609b96..f0e553113f 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -199,7 +199,8 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver)
static int
bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def G_GNUC_UNUSED,
- void *opaque G_GNUC_UNUSED)
+ void *opaque G_GNUC_UNUSED,
+ void *parseOpaque G_GNUC_UNUSED)
{
if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER &&
dev->data.controller->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA &&
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 66ee658e7b..fa19563a35 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6974,14 +6974,15 @@ static int
virDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def,
unsigned int parseFlags,
- virDomainXMLOptionPtr xmlopt)
+ virDomainXMLOptionPtr xmlopt,
+ void *parseOpaque)
{
/* validate configuration only in certain places */
if (parseFlags & VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE)
return 0;
if (xmlopt->config.deviceValidateCallback &&
- xmlopt->config.deviceValidateCallback(dev, def, xmlopt->config.priv))
+ xmlopt->config.deviceValidateCallback(dev, def, xmlopt->config.priv,
parseOpaque))
return -1;
if (virDomainDeviceDefValidateInternal(dev, def) < 0)
@@ -6999,7 +7000,8 @@ virDomainDefValidateDeviceIterator(virDomainDefPtr def,
{
struct virDomainDefPostParseDeviceIteratorData *data = opaque;
return virDomainDeviceDefValidate(dev, def,
- data->parseFlags, data->xmlopt);
+ data->parseFlags, data->xmlopt,
+ data->parseOpaque);
}
@@ -7357,6 +7359,7 @@ virDomainDefValidateInternal(const virDomainDef *def,
* @caps: driver capabilities object
* @parseFlags: virDomainDefParseFlags
* @xmlopt: XML parser option object
+ * @parseOpaque: hypervisor driver specific data for this validation run
*
* This validation function is designed to take checks of globally invalid
* configurations that the parser needs to accept so that VMs don't vanish upon
@@ -7369,11 +7372,13 @@ virDomainDefValidateInternal(const virDomainDef *def,
int
virDomainDefValidate(virDomainDefPtr def,
unsigned int parseFlags,
- virDomainXMLOptionPtr xmlopt)
+ virDomainXMLOptionPtr xmlopt,
+ void *parseOpaque)
{
struct virDomainDefPostParseDeviceIteratorData data = {
.xmlopt = xmlopt,
.parseFlags = parseFlags,
+ .parseOpaque = parseOpaque,
};
/* validate configuration only in certain places */
@@ -7382,7 +7387,7 @@ virDomainDefValidate(virDomainDefPtr def,
/* call the domain config callback */
if (xmlopt->config.domainValidateCallback &&
- xmlopt->config.domainValidateCallback(def, xmlopt->config.priv) < 0)
+ xmlopt->config.domainValidateCallback(def, xmlopt->config.priv,
parseOpaque) < 0)
return -1;
/* iterate the devices */
@@ -17220,7 +17225,7 @@ virDomainDeviceDefParse(const char *xmlStr,
return NULL;
/* validate the configuration */
- if (virDomainDeviceDefValidate(dev, def, flags, xmlopt) < 0)
+ if (virDomainDeviceDefValidate(dev, def, flags, xmlopt, parseOpaque) < 0)
return NULL;
return g_steal_pointer(&dev);
@@ -22617,7 +22622,7 @@ virDomainObjParseXML(xmlDocPtr xml,
goto error;
/* validate configuration */
- if (virDomainDefValidate(obj->def, flags, xmlopt) < 0)
+ if (virDomainDefValidate(obj->def, flags, xmlopt, parseOpaque) < 0)
goto error;
return obj;
@@ -22701,7 +22706,7 @@ virDomainDefParseNode(xmlDocPtr xml,
return NULL;
/* validate configuration */
- if (virDomainDefValidate(def, flags, xmlopt) < 0)
+ if (virDomainDefValidate(def, flags, xmlopt, parseOpaque) < 0)
return NULL;
return g_steal_pointer(&def);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cdf08de60a..72771c46b9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2867,13 +2867,15 @@ typedef void (*virDomainDefPostParseDataFree)(void *parseOpaque);
* for configurations that were previously accepted. This shall not modify the
* config. */
typedef int (*virDomainDefValidateCallback)(const virDomainDef *def,
- void *opaque);
+ void *opaque,
+ void *parseOpaque);
/* Called once per device, for adjusting per-device settings while
* leaving the overall domain otherwise unchanged. */
typedef int (*virDomainDeviceDefValidateCallback)(const virDomainDeviceDef *dev,
const virDomainDef *def,
- void *opaque);
+ void *opaque,
+ void *parseOpaque);
struct _virDomainDefParserConfig {
/* driver domain definition callbacks */
@@ -2993,7 +2995,8 @@ bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);
int virDomainDefValidate(virDomainDefPtr def,
unsigned int parseFlags,
- virDomainXMLOptionPtr xmlopt);
+ virDomainXMLOptionPtr xmlopt,
+ void *parseOpaque);
int
virDomainActualNetDefValidate(const virDomainNetDef *net);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index e0b42ee2c9..474cb93bad 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5464,7 +5464,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
* VM that was running before (migration, snapshots, save). It's more
* important to start such VM than keep the configuration clean */
if ((flags & VIR_QEMU_PROCESS_START_NEW) &&
- virDomainDefValidate(vm->def, 0, driver->xmlopt) < 0)
+ virDomainDefValidate(vm->def, 0, driver->xmlopt, qemuCaps) < 0)
return -1;
if (qemuProcessStartValidateGraphics(vm) < 0)
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 52d15defed..62d7243e21 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1066,7 +1066,8 @@ qemuValidateDomainDefPanic(const virDomainDef *def,
int
qemuValidateDomainDef(const virDomainDef *def,
- void *opaque)
+ void *opaque,
+ void *parseOpaque G_GNUC_UNUSED)
{
virQEMUDriverPtr driver = opaque;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
@@ -4670,7 +4671,8 @@ qemuValidateDomainDeviceDefShmem(virDomainShmemDefPtr shmem,
int
qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
const virDomainDef *def,
- void *opaque)
+ void *opaque,
+ void *parseOpaque G_GNUC_UNUSED)
{
int ret = 0;
virQEMUDriverPtr driver = opaque;
diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h
index acf7d26ce0..b6c5441f90 100644
--- a/src/qemu/qemu_validate.h
+++ b/src/qemu/qemu_validate.h
@@ -26,10 +26,13 @@
#include "qemu_capabilities.h"
#include "qemu_conf.h"
-int qemuValidateDomainDef(const virDomainDef *def, void *opaque);
+int qemuValidateDomainDef(const virDomainDef *def,
+ void *opaque,
+ void *parseOpaque);
int qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
const virDomainDef *def,
- void *opaque);
+ void *opaque,
+ void *parseOpaque);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 8d47b90bdb..b60e99d4f5 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -259,7 +259,8 @@ vzDomainDefPostParse(virDomainDefPtr def,
static int
vzDomainDefValidate(const virDomainDef *def,
- void *opaque)
+ void *opaque,
+ void *parseOpaque G_GNUC_UNUSED)
{
if (vzCheckUnsupportedControllers(def, opaque) < 0)
return -1;
@@ -295,7 +296,8 @@ vzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
static int
vzDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def,
- void *opaque)
+ void *opaque,
+ void *parseOpaque G_GNUC_UNUSED)
{
vzDriverPtr driver = opaque;
--
2.28.0