From c3912912447353d0b3e744bac949d2ffd1e2c2a8 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Thu, 17 Jun 2010 16:39:50 +0200 Subject: [PATCH] Add optional model attribute to the controller element This is a step towards controller support for the ESX driver. --- docs/schemas/domain.rng | 9 +++++++++ src/conf/domain_conf.c | 34 ++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 11 +++++++++++ src/qemu/qemu_driver.c | 1 + 4 files changed, 55 insertions(+) diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng index 99a37f2912..fd57917be7 100644 --- a/docs/schemas/domain.rng +++ b/docs/schemas/domain.rng @@ -670,6 +670,15 @@ + + + + buslogic + lsilogic + lsisas1068 + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cac4042c84..182d8abec6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -139,6 +139,11 @@ VIR_ENUM_IMPL(virDomainController, VIR_DOMAIN_CONTROLLER_TYPE_LAST, "sata", "virtio-serial") +VIR_ENUM_IMPL(virDomainControllerModel, VIR_DOMAIN_CONTROLLER_MODEL_LAST, + "buslogic", + "lsilogic", + "lsisas1068") + VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST, "mount", "block", @@ -1670,6 +1675,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, virDomainControllerDefPtr def; char *type = NULL; char *idx = NULL; + char *model = NULL; if (VIR_ALLOC(def) < 0) { virReportOOMError(); @@ -1694,6 +1700,17 @@ virDomainControllerDefParseXML(xmlNodePtr node, } } + model = virXMLPropString(node, "model"); + if (model) { + if ((def->model = virDomainControllerModelTypeFromString(model)) < 0) { + virDomainReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown model type '%s'"), model); + goto error; + } + } else { + def->model = -1; + } + if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0) goto error; @@ -1745,6 +1762,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, cleanup: VIR_FREE(type); VIR_FREE(idx); + VIR_FREE(model); return def; @@ -4819,6 +4837,7 @@ static int virDomainDefMaybeAddController(virDomainDefPtr def, cont->type = type; cont->idx = idx; + cont->model = -1; if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) { cont->opts.vioserial.ports = -1; @@ -5232,6 +5251,7 @@ virDomainControllerDefFormat(virBufferPtr buf, int flags) { const char *type = virDomainControllerTypeToString(def->type); + const char *model = NULL; if (!type) { virDomainReportError(VIR_ERR_INTERNAL_ERROR, @@ -5239,10 +5259,24 @@ virDomainControllerDefFormat(virBufferPtr buf, return -1; } + if (def->model != -1) { + model = virDomainControllerModelTypeToString(def->model); + + if (!model) { + virDomainReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected model type %d"), def->model); + return -1; + } + } + virBufferVSprintf(buf, " idx); + if (model) { + virBufferEscapeString(buf, " model='%s'", model); + } + switch (def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: if (def->opts.vioserial.ports != -1) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 701849f0bf..55893d6914 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -194,6 +194,15 @@ enum virDomainControllerType { VIR_DOMAIN_CONTROLLER_TYPE_LAST }; + +enum virDomainControllerModel { + VIR_DOMAIN_CONTROLLER_MODEL_BUSLOGIC, + VIR_DOMAIN_CONTROLLER_MODEL_LSILOGIC, + VIR_DOMAIN_CONTROLLER_MODEL_LSISAS1068, + + VIR_DOMAIN_CONTROLLER_MODEL_LAST +}; + typedef struct _virDomainVirtioSerialOpts virDomainVirtioSerialOpts; typedef virDomainVirtioSerialOpts *virDomainVirtioSerialOptsPtr; struct _virDomainVirtioSerialOpts { @@ -207,6 +216,7 @@ typedef virDomainControllerDef *virDomainControllerDefPtr; struct _virDomainControllerDef { int type; int idx; + int model; /* -1 == undef */ union { virDomainVirtioSerialOpts vioserial; } opts; @@ -1073,6 +1083,7 @@ VIR_ENUM_DECL(virDomainDiskBus) VIR_ENUM_DECL(virDomainDiskCache) VIR_ENUM_DECL(virDomainDiskErrorPolicy) VIR_ENUM_DECL(virDomainController) +VIR_ENUM_DECL(virDomainControllerModel) VIR_ENUM_DECL(virDomainFS) VIR_ENUM_DECL(virDomainNet) VIR_ENUM_DECL(virDomainChrTarget) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a7b3f2558b..9f4e08228a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7270,6 +7270,7 @@ qemuDomainFindOrCreateSCSIDiskController(struct qemud_driver *driver, } cont->type = VIR_DOMAIN_CONTROLLER_TYPE_SCSI; cont->idx = 0; + cont->model = -1; VIR_INFO0("No SCSI controller present, hotplugging one"); if (qemudDomainAttachPciControllerDevice(driver, -- GitLab