Add smbios element to schema and configuration to HVM os

the element has a mode attribute allowing only 3 values:
  - emulate: use the smbios emulation from the hypervisor
  - host: try to use the smbios values from the node
  - sysinfo: grab the values from the <sysinfo> fields

* docs/schemas/domain.rng: extend the schemas
* src/conf/domain_conf.h: add the flag to the domain config
* src/conf/domain_conf.h: parse and serialize the smbios if present
This commit is contained in:
Daniel Veillard 2010-11-05 14:10:34 +01:00
parent ebb7a0ddc4
commit d528b52ff9
3 changed files with 59 additions and 0 deletions

View File

@ -135,6 +135,9 @@
</attribute>
</element>
</optional>
<optional>
<ref name="smbios"/>
</optional>
</interleave>
</element>
</define>
@ -1819,6 +1822,19 @@
</data>
</define>
<define name="smbios">
<element name="smbios">
<attribute name="mode">
<choice>
<value>emulate</value>
<value>host</value>
<value>sysinfo</value>
</choice>
</attribute>
<empty/>
</element>
</define>
<define name="address">
<element name="address">
<choice>

View File

@ -230,6 +230,12 @@ VIR_ENUM_IMPL(virDomainMemballoonModel, VIR_DOMAIN_MEMBALLOON_MODEL_LAST,
VIR_ENUM_IMPL(virDomainSysinfo, VIR_DOMAIN_SYSINFO_LAST,
"smbios")
VIR_ENUM_IMPL(virDomainSmbiosMode, VIR_DOMAIN_SMBIOS_LAST,
"none",
"emulate",
"host",
"sysinfo")
VIR_ENUM_IMPL(virDomainWatchdogModel, VIR_DOMAIN_WATCHDOG_MODEL_LAST,
"i6300esb",
"ib700")
@ -5069,6 +5075,20 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
if (def->sysinfo == NULL)
goto error;
}
tmp = virXPathString("string(./os/smbios/@mode)", ctxt);
if (tmp) {
int mode;
if ((mode = virDomainSmbiosModeTypeFromString(tmp)) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown smbios mode '%s'"), tmp);
goto error;
}
def->os.smbios_mode = mode;
VIR_FREE(tmp);
} else {
def->os.smbios_mode = VIR_DOMAIN_SMBIOS_NONE; /* not present */
}
/* we have to make a copy of all of the callback pointers here since
* we won't have the virCaps structure available during free
@ -6748,6 +6768,18 @@ char *virDomainDefFormat(virDomainDefPtr def,
}
}
if (def->os.smbios_mode) {
const char *mode;
mode = virDomainSmbiosModeTypeToString(def->os.smbios_mode);
if (mode == NULL) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected smbios mode %d"), def->os.smbios_mode);
goto cleanup;
}
virBufferVSprintf(&buf, " <smbios mode='%s'/>\n", mode);
}
virBufferAddLit(&buf, " </os>\n");
if (def->features) {

View File

@ -630,6 +630,15 @@ struct _virSysinfoDef {
char *system_sku;
};
enum virDomainSmbiosMode {
VIR_DOMAIN_SMBIOS_NONE,
VIR_DOMAIN_SMBIOS_EMULATE,
VIR_DOMAIN_SMBIOS_HOST,
VIR_DOMAIN_SMBIOS_SYSINFO,
VIR_DOMAIN_SMBIOS_LAST
};
/* Flags for the 'type' field in next struct */
enum virDomainDeviceType {
VIR_DOMAIN_DEVICE_DISK,
@ -728,6 +737,7 @@ struct _virDomainOSDef {
char *loader;
char *bootloader;
char *bootloaderArgs;
int smbios_mode;
};
enum virDomainSeclabelType {
@ -1221,6 +1231,7 @@ VIR_ENUM_DECL(virDomainChrTcpProtocol)
VIR_ENUM_DECL(virDomainSoundModel)
VIR_ENUM_DECL(virDomainMemballoonModel)
VIR_ENUM_DECL(virDomainSysinfo)
VIR_ENUM_DECL(virDomainSmbiosMode)
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
VIR_ENUM_DECL(virDomainVideo)