提交 3f9868a5 编写于 作者: C Cole Robinson

domain: conf: Use CapabilitiesDomainDataLookup for caps validation

The strange logic here is just to duplicate the previous behavior,
which parts of the test suite are currently relying on.
上级 4c96e682
...@@ -729,74 +729,6 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, ...@@ -729,74 +729,6 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps,
return ret; return ret;
} }
/**
* virCapabilitiesSupportsGuestArch:
* @caps: capabilities to query
* @arch: Architecture to search for
*
* Returns non-zero if the capabilities support the
* requested architecture
*/
extern int
virCapabilitiesSupportsGuestArch(virCapsPtr caps,
virArch arch)
{
size_t i;
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->arch.id == arch)
return 1;
}
return 0;
}
/**
* virCapabilitiesSupportsGuestOSType:
* @caps: capabilities to query
* @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
*
* Returns non-zero if the capabilities support the
* requested operating system type
*/
extern int
virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
int ostype)
{
size_t i;
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->ostype == ostype)
return 1;
}
return 0;
}
/**
* virCapabilitiesSupportsGuestOSTypeArch:
* @caps: capabilities to query
* @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
* @arch: Architecture to search for
*
* Returns non-zero if the capabilities support the
* requested operating system type
*/
extern int
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
int ostype,
virArch arch)
{
size_t i;
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->ostype == ostype &&
caps->guests[i]->arch.id == arch)
return 1;
}
return 0;
}
/** /**
* virCapabilitiesDefaultGuestArch: * virCapabilitiesDefaultGuestArch:
* @caps: capabilities to query * @caps: capabilities to query
......
...@@ -280,17 +280,6 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps, ...@@ -280,17 +280,6 @@ virCapabilitiesDomainDataLookup(virCapsPtr caps,
const char *emulator, const char *emulator,
const char *machinetype); const char *machinetype);
extern int
virCapabilitiesSupportsGuestArch(virCapsPtr caps,
virArch arch);
extern int
virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
int ostype);
extern int
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
int ostype,
virArch arch);
void void
virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu, virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu,
size_t ncpus); size_t ncpus);
......
...@@ -13729,51 +13729,28 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -13729,51 +13729,28 @@ virDomainDefParseXML(xmlDocPtr xml,
def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); def->emulator = virXPathString("string(./devices/emulator[1])", ctxt);
if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) { if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS)) {
if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) { /* If the logic here seems fairly arbitrary, that's because it is :)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, * This is duplicating how the code worked before
_("no support found for os <type> '%s'"), * CapabilitiesDomainDataLookup was added. We can simplify this,
virDomainOSTypeToString(def->os.type)); * but it would take a bit of work because the test suite fails
goto error; * in numerous minor ways. */
} bool use_virttype = ((def->os.arch == VIR_ARCH_NONE) ||
!def->os.machine);
virCapsDomainDataPtr capsdata = NULL;
if (def->os.arch) { if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { def->os.arch, use_virttype ? def->virtType : -1,
virReportError(VIR_ERR_INTERNAL_ERROR, NULL, NULL)))
_("No guest options available for arch '%s'"), goto error;
virArchToString(def->os.arch));
goto error;
}
if (!virCapabilitiesSupportsGuestOSTypeArch(caps,
def->os.type,
def->os.arch)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No os type '%s' available for arch '%s'"),
virDomainOSTypeToString(def->os.type),
virArchToString(def->os.arch));
goto error;
}
} else {
def->os.arch =
virCapabilitiesDefaultGuestArch(caps,
def->os.type,
def->virtType);
if (!def->os.arch) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no supported architecture for os type '%s'"),
virDomainOSTypeToString(def->os.type));
goto error;
}
}
if (!def->os.machine) { if (!def->os.arch)
const char *defaultMachine = virCapabilitiesDefaultGuestMachine(caps, def->os.arch = capsdata->arch;
def->os.type, if ((!def->os.machine &&
def->os.arch, VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0)) {
def->virtType); VIR_FREE(capsdata);
if (VIR_STRDUP(def->os.machine, defaultMachine) < 0) goto error;
goto error;
} }
VIR_FREE(capsdata);
} }
/* Extract domain name */ /* Extract domain name */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册