static int
bhyveDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps G_GNUC_UNUSED,
+ virCapsPtr caps,
unsigned int parseFlags G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
/* Add an implicit PCI root controller */
if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) < 0)
}
+bool
+virCapabilitiesDomainSupported(virCapsPtr caps,
+ int ostype,
+ virArch arch,
+ int virttype)
+{
+ g_autofree virCapsDomainDataPtr capsdata = NULL;
+
+ capsdata = virCapabilitiesDomainDataLookup(caps, ostype,
+ arch,
+ virttype,
+ NULL, NULL);
+
+ return capsdata != NULL;
+}
+
+
int
virCapabilitiesAddStoragePool(virCapsPtr caps,
int poolType)
const char *emulator,
const char *machinetype);
+bool
+virCapabilitiesDomainSupported(virCapsPtr caps,
+ int ostype,
+ virArch arch,
+ int domaintype);
+
+
void
virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu,
size_t ncpus);
static int
virDomainDefParseCaps(virDomainDefPtr def,
xmlXPathContextPtr ctxt,
- virDomainXMLOptionPtr xmlopt,
- virCapsPtr caps,
- unsigned int flags)
+ virDomainXMLOptionPtr xmlopt)
{
g_autofree char *virttype = NULL;
g_autofree char *arch = NULL;
g_autofree char *ostype = NULL;
- g_autofree virCapsDomainDataPtr capsdata = NULL;
virttype = virXPathString("string(./@type)", ctxt);
ostype = virXPathString("string(./os/type[1])", ctxt);
def->os.arch = virArchFromHost();
}
- if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
- def->os.arch,
- def->virtType,
- NULL, NULL))) {
- if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))
- return -1;
- virResetLastError();
- } else {
- if (!def->os.machine)
- def->os.machine = g_strdup(capsdata->machinetype);
- }
-
return 0;
}
id = -1;
def->id = (int)id;
- if (virDomainDefParseCaps(def, ctxt, xmlopt, caps, flags) < 0)
+ if (virDomainDefParseCaps(def, ctxt, xmlopt) < 0)
goto error;
/* Extract domain name */
virCapabilitiesAllocMachines;
virCapabilitiesClearHostNUMACellCPUTopology;
virCapabilitiesDomainDataLookup;
+virCapabilitiesDomainSupported;
virCapabilitiesFormatXML;
virCapabilitiesFreeGuest;
virCapabilitiesFreeMachines;
static int
libxlDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps G_GNUC_UNUSED,
+ virCapsPtr caps,
unsigned int parseFlags G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
/* Xen PV domains always have a PV console, so add one to the domain config
* via post-parse callback if not explicitly specified in the XML. */
if (def->os.type != VIR_DOMAIN_OSTYPE_HVM && def->nconsoles == 0) {
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
/* check for emulator and create a default one if needed */
if (!def->emulator &&
!(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
static int
openvzDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps G_GNUC_UNUSED,
+ virCapsPtr caps,
unsigned int parseFlags G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
/* fill the init path */
if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init)
def->os.init = g_strdup("/sbin/init");
static int
-phypDomainDefPostParse(virDomainDefPtr def G_GNUC_UNUSED,
- virCapsPtr caps G_GNUC_UNUSED,
+phypDomainDefPostParse(virDomainDefPtr def,
+ virCapsPtr caps,
unsigned int parseFlags G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
return 0;
}
static int
qemuDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps G_GNUC_UNUSED,
+ virCapsPtr caps,
unsigned int parseFlags,
void *opaque,
void *parseOpaque)
* with the capabilities populated. */
virQEMUCapsPtr qemuCaps = parseOpaque;
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
if (def->os.bootloader || def->os.bootloaderArgs) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("bootloader is not supported by QEMU"));
}
if (!def->os.machine) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("missing machine type"));
- return -1;
+ g_autofree virCapsDomainDataPtr capsdata = NULL;
+
+ if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
+ def->os.arch,
+ def->virtType,
+ NULL, NULL))) {
+ return -1;
+ }
+ def->os.machine = g_strdup(capsdata->machinetype);
}
qemuDomainNVRAMPathGenerate(cfg, def);
}
static int
-vmwareDomainDefPostParse(virDomainDefPtr def G_GNUC_UNUSED,
- virCapsPtr caps G_GNUC_UNUSED,
+vmwareDomainDefPostParse(virDomainDefPtr def,
+ virCapsPtr caps,
unsigned int parseFlags G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
return 0;
}
*/
static int
-virVMXDomainDefPostParse(virDomainDefPtr def G_GNUC_UNUSED,
- virCapsPtr caps G_GNUC_UNUSED,
+virVMXDomainDefPostParse(virDomainDefPtr def,
+ virCapsPtr caps,
unsigned int parseFlags G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
return 0;
}
static int
vzDomainDefPostParse(virDomainDefPtr def,
- virCapsPtr caps G_GNUC_UNUSED,
+ virCapsPtr caps,
unsigned int parseFlags G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED,
void *parseOpaque G_GNUC_UNUSED)
{
+ if (!virCapabilitiesDomainSupported(caps, def->os.type,
+ def->os.arch,
+ def->virtType))
+ return -1;
+
if (vzDomainDefAddDefaultInputDevices(def) < 0)
return -1;