提交 bc210e7a 编写于 作者: D Daniel Henrique Barboza 提交者: Ján Tomko

qemu: move qemuValidateDomainDeviceDef() to qemu_validate.c

Now that all its helper functions are in qemu_validate.c, we can
move the function itself. The helpers can become static again since
they're all in the same file.
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 a5f488d3
......@@ -5287,132 +5287,6 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
}
static int
qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
const virDomainDef *def,
void *opaque)
{
int ret = 0;
virQEMUDriverPtr driver = opaque;
g_autoptr(virQEMUCaps) qemuCaps = NULL;
g_autoptr(virDomainCaps) domCaps = NULL;
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
def->emulator)))
return -1;
if (!(domCaps = virQEMUDriverGetDomainCapabilities(driver, qemuCaps,
def->os.machine,
def->os.arch,
def->virtType)))
return -1;
if ((ret = qemuValidateDomainDeviceDefAddress(dev, qemuCaps)) < 0)
return ret;
if ((ret = virDomainCapsDeviceDefValidate(domCaps, dev, def)) < 0)
return ret;
switch ((virDomainDeviceType)dev->type) {
case VIR_DOMAIN_DEVICE_NET:
ret = qemuValidateDomainDeviceDefNetwork(dev->data.net, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_CHR:
ret = qemuValidateDomainChrDef(dev->data.chr, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_SMARTCARD:
ret = qemuValidateDomainSmartcardDef(dev->data.smartcard, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_RNG:
ret = qemuValidateDomainRNGDef(dev->data.rng, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_REDIRDEV:
ret = qemuValidateDomainRedirdevDef(dev->data.redirdev, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_WATCHDOG:
ret = qemuValidateDomainWatchdogDef(dev->data.watchdog, def);
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
ret = qemuValidateDomainDeviceDefHostdev(dev->data.hostdev, def,
qemuCaps);
break;
case VIR_DOMAIN_DEVICE_VIDEO:
ret = qemuValidateDomainDeviceDefVideo(dev->data.video, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_DISK:
ret = qemuValidateDomainDeviceDefDisk(dev->data.disk, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_CONTROLLER:
ret = qemuValidateDomainDeviceDefController(dev->data.controller, def,
qemuCaps);
break;
case VIR_DOMAIN_DEVICE_VSOCK:
ret = qemuValidateDomainDeviceDefVsock(dev->data.vsock, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_TPM:
ret = qemuValidateDomainDeviceDefTPM(dev->data.tpm, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_GRAPHICS:
ret = qemuValidateDomainDeviceDefGraphics(dev->data.graphics, def,
driver, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_INPUT:
ret = qemuValidateDomainDeviceDefInput(dev->data.input, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_MEMBALLOON:
ret = qemuValidateDomainDeviceDefMemballoon(dev->data.memballoon, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_IOMMU:
ret = qemuValidateDomainDeviceDefIOMMU(dev->data.iommu, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_FS:
ret = qemuValidateDomainDeviceDefFS(dev->data.fs, def, driver, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_NVRAM:
ret = qemuValidateDomainDeviceDefNVRAM(dev->data.nvram, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_HUB:
ret = qemuValidateDomainDeviceDefHub(dev->data.hub, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_SOUND:
ret = qemuValidateDomainDeviceDefSound(dev->data.sound, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_MEMORY:
ret = qemuValidateDomainDeviceDefMemory(dev->data.memory, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_SHMEM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_LAST:
break;
}
return ret;
}
/**
* qemuDomainDefaultNetModel:
* @def: domain definition
......@@ -6162,7 +6036,7 @@ virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
.domainPostParseCallback = qemuDomainDefPostParse,
.assignAddressesCallback = qemuDomainDefAssignAddresses,
.domainValidateCallback = qemuValidateDomainDef,
.deviceValidateCallback = qemuDomainDeviceDefValidate,
.deviceValidateCallback = qemuValidateDomainDeviceDef,
.features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN |
......
......@@ -964,7 +964,7 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info,
}
int
static int
qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev,
virQEMUCapsPtr qemuCaps)
{
......@@ -1044,7 +1044,7 @@ qemuValidateNetSupportsCoalesce(virDomainNetType type)
}
int
static int
qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
virQEMUCapsPtr qemuCaps)
{
......@@ -1361,7 +1361,7 @@ qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def,
}
int
static int
qemuValidateDomainChrDef(const virDomainChrDef *dev,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -1421,7 +1421,7 @@ qemuValidateDomainChrDef(const virDomainChrDef *dev,
}
int
static int
qemuValidateDomainSmartcardDef(const virDomainSmartcardDef *def,
virQEMUCapsPtr qemuCaps)
{
......@@ -1466,7 +1466,7 @@ qemuValidateDomainSmartcardDef(const virDomainSmartcardDef *def,
}
int
static int
qemuValidateDomainRNGDef(const virDomainRNGDef *def,
virQEMUCapsPtr qemuCaps G_GNUC_UNUSED)
{
......@@ -1478,7 +1478,7 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def,
}
int
static int
qemuValidateDomainRedirdevDef(const virDomainRedirdevDef *def,
virQEMUCapsPtr qemuCaps)
{
......@@ -1489,7 +1489,7 @@ qemuValidateDomainRedirdevDef(const virDomainRedirdevDef *def,
}
int
static int
qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev,
const virDomainDef *def)
{
......@@ -1668,7 +1668,7 @@ qemuValidateDomainMdevDef(const virDomainHostdevDef *hostdev,
}
int
static int
qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -1725,7 +1725,7 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev,
}
int
static int
qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video,
virQEMUCapsPtr qemuCaps)
{
......@@ -2672,7 +2672,7 @@ qemuValidateDomainDeviceDefControllerPCI(const virDomainControllerDef *cont,
#undef virReportControllerMissingOption
int
static int
qemuValidateDomainDeviceDefController(const virDomainControllerDef *controller,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -2796,7 +2796,7 @@ qemuValidateDomainDeviceDefSPICEGraphics(const virDomainGraphicsDef *graphics,
}
int
static int
qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
const virDomainDef *def,
virQEMUDriverPtr driver,
......@@ -2939,7 +2939,7 @@ qemuValidateDomainDefVirtioFSSharedMemory(const virDomainDef *def)
}
int
static int
qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
const virDomainDef *def,
virQEMUDriverPtr driver,
......@@ -3032,7 +3032,7 @@ qemuSoundCodecTypeToCaps(int type)
}
int
static int
qemuValidateDomainDeviceDefSound(virDomainSoundDefPtr sound,
virQEMUCapsPtr qemuCaps)
{
......@@ -3091,7 +3091,7 @@ qemuValidateDomainDeviceDefSound(virDomainSoundDefPtr sound,
}
int
static int
qemuValidateDomainDeviceDefVsock(const virDomainVsockDef *vsock,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -3111,7 +3111,7 @@ qemuValidateDomainDeviceDefVsock(const virDomainVsockDef *vsock,
}
int
static int
qemuValidateDomainDeviceDefTPM(virDomainTPMDef *tpm,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -3191,7 +3191,7 @@ qemuValidateDomainDeviceDefTPM(virDomainTPMDef *tpm,
}
int
static int
qemuValidateDomainDeviceDefInput(const virDomainInputDef *input,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -3284,7 +3284,7 @@ qemuValidateDomainDeviceDefInput(const virDomainInputDef *input,
}
int
static int
qemuValidateDomainDeviceDefMemballoon(const virDomainMemballoonDef *memballoon,
virQEMUCapsPtr qemuCaps)
{
......@@ -3313,7 +3313,7 @@ qemuValidateDomainDeviceDefMemballoon(const virDomainMemballoonDef *memballoon,
}
int
static int
qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -3398,7 +3398,7 @@ qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
}
int
static int
qemuValidateDomainDeviceDefNVRAM(virDomainNVRAMDefPtr nvram,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
......@@ -3431,7 +3431,7 @@ qemuValidateDomainDeviceDefNVRAM(virDomainNVRAMDefPtr nvram,
}
int
static int
qemuValidateDomainDeviceDefHub(virDomainHubDefPtr hub,
virQEMUCapsPtr qemuCaps)
{
......@@ -3452,7 +3452,7 @@ qemuValidateDomainDeviceDefHub(virDomainHubDefPtr hub,
}
int
static int
qemuValidateDomainDeviceDefMemory(virDomainMemoryDefPtr mem,
virQEMUCapsPtr qemuCaps)
{
......@@ -3465,3 +3465,129 @@ qemuValidateDomainDeviceDefMemory(virDomainMemoryDefPtr mem,
return 0;
}
int
qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
const virDomainDef *def,
void *opaque)
{
int ret = 0;
virQEMUDriverPtr driver = opaque;
g_autoptr(virQEMUCaps) qemuCaps = NULL;
g_autoptr(virDomainCaps) domCaps = NULL;
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
def->emulator)))
return -1;
if (!(domCaps = virQEMUDriverGetDomainCapabilities(driver, qemuCaps,
def->os.machine,
def->os.arch,
def->virtType)))
return -1;
if ((ret = qemuValidateDomainDeviceDefAddress(dev, qemuCaps)) < 0)
return ret;
if ((ret = virDomainCapsDeviceDefValidate(domCaps, dev, def)) < 0)
return ret;
switch ((virDomainDeviceType)dev->type) {
case VIR_DOMAIN_DEVICE_NET:
ret = qemuValidateDomainDeviceDefNetwork(dev->data.net, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_CHR:
ret = qemuValidateDomainChrDef(dev->data.chr, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_SMARTCARD:
ret = qemuValidateDomainSmartcardDef(dev->data.smartcard, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_RNG:
ret = qemuValidateDomainRNGDef(dev->data.rng, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_REDIRDEV:
ret = qemuValidateDomainRedirdevDef(dev->data.redirdev, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_WATCHDOG:
ret = qemuValidateDomainWatchdogDef(dev->data.watchdog, def);
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
ret = qemuValidateDomainDeviceDefHostdev(dev->data.hostdev, def,
qemuCaps);
break;
case VIR_DOMAIN_DEVICE_VIDEO:
ret = qemuValidateDomainDeviceDefVideo(dev->data.video, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_DISK:
ret = qemuValidateDomainDeviceDefDisk(dev->data.disk, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_CONTROLLER:
ret = qemuValidateDomainDeviceDefController(dev->data.controller, def,
qemuCaps);
break;
case VIR_DOMAIN_DEVICE_VSOCK:
ret = qemuValidateDomainDeviceDefVsock(dev->data.vsock, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_TPM:
ret = qemuValidateDomainDeviceDefTPM(dev->data.tpm, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_GRAPHICS:
ret = qemuValidateDomainDeviceDefGraphics(dev->data.graphics, def,
driver, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_INPUT:
ret = qemuValidateDomainDeviceDefInput(dev->data.input, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_MEMBALLOON:
ret = qemuValidateDomainDeviceDefMemballoon(dev->data.memballoon, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_IOMMU:
ret = qemuValidateDomainDeviceDefIOMMU(dev->data.iommu, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_FS:
ret = qemuValidateDomainDeviceDefFS(dev->data.fs, def, driver, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_NVRAM:
ret = qemuValidateDomainDeviceDefNVRAM(dev->data.nvram, def, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_HUB:
ret = qemuValidateDomainDeviceDefHub(dev->data.hub, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_SOUND:
ret = qemuValidateDomainDeviceDefSound(dev->data.sound, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_MEMORY:
ret = qemuValidateDomainDeviceDefMemory(dev->data.memory, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_LEASE:
case VIR_DOMAIN_DEVICE_SHMEM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_LAST:
break;
}
return ret;
}
......@@ -29,57 +29,6 @@
int qemuValidateDomainDef(const virDomainDef *def, void *opaque);
int qemuValidateDomainDeviceDefDisk(const virDomainDiskDef *disk,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainChrDef(const virDomainChrDef *dev,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainSmartcardDef(const virDomainSmartcardDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainRNGDef(const virDomainRNGDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainRedirdevDef(const virDomainRedirdevDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev,
const virDomainDef *def);
int qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefController(const virDomainControllerDef *controller,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefGraphics(const virDomainGraphicsDef *graphics,
const virDomainDef *def,
virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
const virDomainDef *def,
virQEMUDriverPtr driver,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefSound(virDomainSoundDefPtr sound,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefVsock(const virDomainVsockDef *vsock,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefTPM(virDomainTPMDef *tpm,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefInput(const virDomainInputDef *input,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefMemballoon(const virDomainMemballoonDef *memballoon,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefIOMMU(const virDomainIOMMUDef *iommu,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefMemory(virDomainMemoryDefPtr mem,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefHub(virDomainHubDefPtr hub,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDefNVRAM(virDomainNVRAMDefPtr nvram,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps);
int qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
const virDomainDef *def,
void *opaque);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册