mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
virDomainDefValidate: Add per-run 'opaque' data
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4e750e932a
commit
18de9dfd77
@ -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 &&
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -5467,7 +5467,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)
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user