Signed-off-by: Praveen K Paladugu <prapal@xxxxxxxxxxxxxxxxxxx> --- src/ch/ch_domain.c | 130 ++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index dd4de9e1ea..44f7d26ca4 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -30,16 +30,12 @@ VIR_ENUM_IMPL(virCHDomainJob, CH_JOB_LAST, - "none", - "query", - "destroy", - "modify", -); + "none", "query", "destroy", "modify",); VIR_LOG_INIT("ch.ch_domain"); static int -virCHDomainObjInitJob(virCHDomainObjPrivate *priv) +virCHDomainObjInitJob(virCHDomainObjPrivate * priv) { memset(&priv->job, 0, sizeof(priv->job)); @@ -50,7 +46,7 @@ virCHDomainObjInitJob(virCHDomainObjPrivate *priv) } static void -virCHDomainObjResetJob(virCHDomainObjPrivate *priv) +virCHDomainObjResetJob(virCHDomainObjPrivate * priv) { struct virCHDomainJobObj *job = &priv->job; @@ -59,7 +55,7 @@ virCHDomainObjResetJob(virCHDomainObjPrivate *priv) } static void -virCHDomainObjFreeJob(virCHDomainObjPrivate *priv) +virCHDomainObjFreeJob(virCHDomainObjPrivate * priv) { ignore_value(virCondDestroy(&priv->job.cond)); } @@ -74,7 +70,7 @@ virCHDomainObjFreeJob(virCHDomainObjPrivate *priv) * Successful calls must be followed by EndJob eventually. */ int -virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job) +virCHDomainObjBeginJob(virDomainObj * obj, enum virCHDomainJob job) { virCHDomainObjPrivate *priv = obj->privateData; unsigned long long now; @@ -121,13 +117,12 @@ virCHDomainObjBeginJob(virDomainObj *obj, enum virCHDomainJob job) * earlier virCHDomainBeginJob() call */ void -virCHDomainObjEndJob(virDomainObj *obj) +virCHDomainObjEndJob(virDomainObj * obj) { virCHDomainObjPrivate *priv = obj->privateData; enum virCHDomainJob job = priv->job.active; - VIR_DEBUG("Stopping job: %s", - virCHDomainJobTypeToString(job)); + VIR_DEBUG("Stopping job: %s", virCHDomainJobTypeToString(job)); virCHDomainObjResetJob(priv); virCondSignal(&priv->job.cond); @@ -170,8 +165,7 @@ virDomainXMLPrivateDataCallbacks virCHDriverPrivateDataCallbacks = { }; static int -virCHDomainDefPostParseBasic(virDomainDef *def, - void *opaque G_GNUC_UNUSED) +virCHDomainDefPostParseBasic(virDomainDef * def, void *opaque G_GNUC_UNUSED) { /* check for emulator and create a default one if needed */ if (!def->emulator) { @@ -186,71 +180,70 @@ virCHDomainDefPostParseBasic(virDomainDef *def, } static int -virCHDomainDefPostParse(virDomainDef *def, +virCHDomainDefPostParse(virDomainDef * def, unsigned int parseFlags G_GNUC_UNUSED, - void *opaque, - void *parseOpaque G_GNUC_UNUSED) + void *opaque, void *parseOpaque G_GNUC_UNUSED) { virCHDriver *driver = opaque; + g_autoptr(virCaps) caps = virCHDriverGetCapabilities(driver, false); if (!caps) return -1; if (!virCapabilitiesDomainSupported(caps, def->os.type, - def->os.arch, - def->virtType)) + def->os.arch, def->virtType)) return -1; return 0; } static int -chValidateDomainDeviceDef(const virDomainDeviceDef *dev, - const virDomainDef *def G_GNUC_UNUSED, +chValidateDomainDeviceDef(const virDomainDeviceDef * dev, + const virDomainDef * def G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { - switch ((virDomainDeviceType)dev->type) { - case VIR_DOMAIN_DEVICE_DISK: - case VIR_DOMAIN_DEVICE_NET: - case VIR_DOMAIN_DEVICE_MEMORY: - case VIR_DOMAIN_DEVICE_VSOCK: - case VIR_DOMAIN_DEVICE_CONTROLLER: - case VIR_DOMAIN_DEVICE_CHR: - break; - - case VIR_DOMAIN_DEVICE_LEASE: - case VIR_DOMAIN_DEVICE_FS: - case VIR_DOMAIN_DEVICE_INPUT: - case VIR_DOMAIN_DEVICE_SOUND: - case VIR_DOMAIN_DEVICE_VIDEO: - case VIR_DOMAIN_DEVICE_HOSTDEV: - case VIR_DOMAIN_DEVICE_WATCHDOG: - case VIR_DOMAIN_DEVICE_GRAPHICS: - case VIR_DOMAIN_DEVICE_HUB: - case VIR_DOMAIN_DEVICE_REDIRDEV: - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: - case VIR_DOMAIN_DEVICE_RNG: - case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_AUDIO: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Cloud-Hypervisor doesn't support '%s' device"), - virDomainDeviceTypeToString(dev->type)); - return -1; + switch ((virDomainDeviceType) dev->type) { + case VIR_DOMAIN_DEVICE_DISK: + case VIR_DOMAIN_DEVICE_NET: + case VIR_DOMAIN_DEVICE_MEMORY: + case VIR_DOMAIN_DEVICE_VSOCK: + case VIR_DOMAIN_DEVICE_CONTROLLER: + case VIR_DOMAIN_DEVICE_CHR: + break; + + case VIR_DOMAIN_DEVICE_LEASE: + case VIR_DOMAIN_DEVICE_FS: + case VIR_DOMAIN_DEVICE_INPUT: + case VIR_DOMAIN_DEVICE_SOUND: + case VIR_DOMAIN_DEVICE_VIDEO: + case VIR_DOMAIN_DEVICE_HOSTDEV: + case VIR_DOMAIN_DEVICE_WATCHDOG: + case VIR_DOMAIN_DEVICE_GRAPHICS: + case VIR_DOMAIN_DEVICE_HUB: + case VIR_DOMAIN_DEVICE_REDIRDEV: + case VIR_DOMAIN_DEVICE_SMARTCARD: + case VIR_DOMAIN_DEVICE_MEMBALLOON: + case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_RNG: + case VIR_DOMAIN_DEVICE_SHMEM: + case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: + case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_AUDIO: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Cloud-Hypervisor doesn't support '%s' device"), + virDomainDeviceTypeToString(dev->type)); + return -1; - case VIR_DOMAIN_DEVICE_NONE: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("unexpected VIR_DOMAIN_DEVICE_NONE")); - return -1; + case VIR_DOMAIN_DEVICE_NONE: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unexpected VIR_DOMAIN_DEVICE_NONE")); + return -1; - case VIR_DOMAIN_DEVICE_LAST: - default: - virReportEnumRangeError(virDomainDeviceType, dev->type); - return -1; + case VIR_DOMAIN_DEVICE_LAST: + default: + virReportEnumRangeError(virDomainDeviceType, dev->type); + return -1; } if ((def->nconsoles && @@ -258,25 +251,30 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev, && (def->nserials && def->serials[0]->source->type == VIR_DOMAIN_CHR_TYPE_PTY)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Only a single console or serial can be configured for this domain")); + _ + ("Only a single console or serial can be configured for this domain")); return -1; } else if (def->nconsoles > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Only a single console can be configured for this domain")); + _ + ("Only a single console can be configured for this domain")); return -1; } else if (def->nserials > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Only a single serial can be configured for this domain")); + _ + ("Only a single serial can be configured for this domain")); return -1; } - if (def->nconsoles && def->consoles[0]->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (def->nconsoles + && def->consoles[0]->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Console can only be enabled for a PTY")); return -1; } - if (def->nserials && def->serials[0]->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { + if (def->nserials + && def->serials[0]->source->type != VIR_DOMAIN_CHR_TYPE_PTY) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Serial can only be enabled for a PTY")); return -1; -- 2.27.0