/**
* virCapabilitiesSupportsGuestOSType:
* @caps: capabilities to query
- * @ostype: OS type to search for (eg 'hvm', 'xen')
+ * @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,
- const char *ostypestr)
+ int ostype)
{
size_t i;
- int ostype;
-
- if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown OS type '%s'"), ostypestr);
- return 0;
- }
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->ostype == ostype)
/**
* virCapabilitiesSupportsGuestOSTypeArch:
* @caps: capabilities to query
- * @ostype: OS type to search for (eg 'hvm', 'xen')
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
* @arch: Architecture to search for
*
* Returns non-zero if the capabilities support the
*/
extern int
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
- const char *ostypestr,
+ int ostype,
virArch arch)
{
size_t i;
- int ostype;
-
- if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown OS type '%s'"), ostypestr);
- return 0;
- }
for (i = 0; i < caps->nguests; i++) {
if (caps->guests[i]->ostype == ostype &&
/**
* virCapabilitiesDefaultGuestArch:
* @caps: capabilities to query
- * @ostype: OS type to search for
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
*
* Returns the first architecture able to run the
* requested operating system type
*/
extern virArch
virCapabilitiesDefaultGuestArch(virCapsPtr caps,
- const char *ostypestr,
+ int ostype,
const char *domain)
{
size_t i, j;
- int ostype;
-
- if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown OS type '%s'"), ostypestr);
- return VIR_ARCH_NONE;
- }
/* First try to find one matching host arch */
for (i = 0; i < caps->nguests; i++) {
/**
* virCapabilitiesDefaultGuestMachine:
* @caps: capabilities to query
- * @ostype: OS type to search for
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
* @arch: architecture to search for
* @domain: domain type to search for
*
*/
extern const char *
virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
- const char *ostypestr,
+ int ostype,
virArch arch,
const char *domain)
{
size_t i;
- int ostype;
-
- if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown OS type '%s'"), ostypestr);
- return NULL;
- }
for (i = 0; i < caps->nguests; i++) {
virCapsGuestPtr guest = caps->guests[i];
/**
* virCapabilitiesDefaultGuestEmulator:
* @caps: capabilities to query
- * @ostype: OS type to search for ('xen', 'hvm')
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
* @arch: architecture to search for
* @domain: domain type ('xen', 'qemu', 'kvm')
*
*/
extern const char *
virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
- const char *ostypestr,
+ int ostype,
virArch arch,
const char *domain)
{
size_t i, j;
- int ostype;
-
- if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown OS type '%s'"), ostypestr);
- return NULL;
- }
for (i = 0; i < caps->nguests; i++) {
char *emulator;
virArch arch);
extern int
virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
- const char *ostype);
+ int ostype);
extern int
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
- const char *ostype,
+ int ostype,
virArch arch);
void
extern virArch
virCapabilitiesDefaultGuestArch(virCapsPtr caps,
- const char *ostype,
+ int ostype,
const char *domain);
extern const char *
virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
- const char *ostype,
+ int ostype,
virArch arch,
const char *domain);
extern const char *
virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
- const char *ostype,
+ int ostype,
virArch arch,
const char *domain);
if (i == 0 &&
(vm->def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
vm->def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
- STREQ_NULLABLE(vm->def->os.type, "hvm"))
+ vm->def->os.type == VIR_DOMAIN_OSTYPE_HVM)
continue;
virDomainAuditChardev(vm, NULL, vm->def->consoles[i], "start", true);
VIR_FREE(def->idmap.uidmap);
VIR_FREE(def->idmap.gidmap);
- VIR_FREE(def->os.type);
VIR_FREE(def->os.machine);
VIR_FREE(def->os.init);
for (i = 0; def->os.initargv && def->os.initargv[i]; i++)
i == 0 &&
(def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
- STREQ_NULLABLE(def->os.type, "hvm"))
+ def->os.type == VIR_DOMAIN_OSTYPE_HVM)
continue;
device.data.chr = def->consoles[i];
if (cb(def, &device, &def->consoles[i]->info, opaque) < 0)
{
size_t i;
- if (!def->os.type) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("hypervisor type must be specified"));
- return -1;
- }
-
/* verify init path for container based domains */
- if (STREQ(def->os.type, "exe") && !def->os.init) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("init binary must be specified"));
return -1;
return -1;
}
}
- if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") &&
+ if (def->nconsoles > 0 && def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
(def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) {
goto error;
}
- if (STREQ(dom->os.type, "hvm")) {
+ if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 &&
def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
def->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
bus);
goto error;
}
- } else if (STREQ(dom->os.type, "xen")) {
+ } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN) {
if (def->bus != VIR_DOMAIN_INPUT_BUS_XEN) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unsupported input bus %s"),
}
}
} else {
- if (STREQ(dom->os.type, "hvm")) {
+ if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
def->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
(ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) {
} else {
def->bus = VIR_DOMAIN_INPUT_BUS_USB;
}
- } else if (STREQ(dom->os.type, "xen")) {
+ } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN) {
def->bus = VIR_DOMAIN_INPUT_BUS_XEN;
} else {
if ((dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
case VIR_DOMAIN_VIRT_KQEMU:
case VIR_DOMAIN_VIRT_KVM:
case VIR_DOMAIN_VIRT_XEN:
- if (def->os.type &&
- (STREQ(def->os.type, "xen") ||
- STREQ(def->os.type, "linux")))
+ if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+ def->os.type == VIR_DOMAIN_OSTYPE_LINUX)
return VIR_DOMAIN_VIDEO_TYPE_XEN;
else if ARCH_IS_PPC64(def->os.arch)
return VIR_DOMAIN_VIDEO_TYPE_VGA;
return VIR_DOMAIN_VIDEO_TYPE_VMVGA;
case VIR_DOMAIN_VIRT_PARALLELS:
- if (def->os.type) {
- if (STREQ(def->os.type, "hvm"))
- return VIR_DOMAIN_VIDEO_TYPE_VGA;
- else
- return VIR_DOMAIN_VIDEO_TYPE_PARALLELS;
- } else {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
return VIR_DOMAIN_VIDEO_TYPE_VGA;
- }
-
+ else
+ return VIR_DOMAIN_VIDEO_TYPE_PARALLELS;
default:
return -1;
}
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no emulator for domain %s os type %s "
"on architecture %s"),
- type, def->os.type, virArchToString(def->os.arch));
+ type, virDomainOSTypeToString(def->os.type),
+ virArchToString(def->os.arch));
return NULL;
}
def->os.bootloader = virXPathString("string(./bootloader)", ctxt);
def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt);
- def->os.type = virXPathString("string(./os/type[1])", ctxt);
- if (!def->os.type) {
+ tmp = virXPathString("string(./os/type[1])", ctxt);
+ if (!tmp) {
if (def->os.bootloader) {
- if (VIR_STRDUP(def->os.type, "xen") < 0)
- goto error;
+ def->os.type = VIR_DOMAIN_OSTYPE_XEN;
} else {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("an os <type> must be specified"));
goto error;
}
+ } else {
+ if ((def->os.type = virDomainOSTypeFromString(tmp)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown OS type '%s'"), tmp);
+ goto error;
+ }
+ VIR_FREE(tmp);
}
+
/*
* HACK: For xen driver we previously used bogus 'linux' as the
* os type for paravirt, whereas capabilities declare it to
* be 'xen'. So we accept the former and convert
*/
- if (STREQ(def->os.type, "linux") &&
+ if (def->os.type == VIR_DOMAIN_OSTYPE_LINUX &&
def->virtType == VIR_DOMAIN_VIRT_XEN) {
- VIR_FREE(def->os.type);
- if (VIR_STRDUP(def->os.type, "xen") < 0)
- goto error;
+ def->os.type = VIR_DOMAIN_OSTYPE_XEN;
}
tmp = virXPathString("string(./os/type[1]/@arch)", ctxt);
if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("no support found for os <type> '%s'"),
- def->os.type);
+ virDomainOSTypeToString(def->os.type));
goto error;
}
def->os.arch)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("No os type '%s' available for arch '%s'"),
- def->os.type, virArchToString(def->os.arch));
+ virDomainOSTypeToString(def->os.type),
+ virArchToString(def->os.arch));
goto error;
}
} else {
if (!def->os.arch) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no supported architecture for os type '%s'"),
- def->os.type);
+ virDomainOSTypeToString(def->os.type));
goto error;
}
}
* - An init script (exe)
*/
- if (STREQ(def->os.type, "exe")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
def->os.init = virXPathString("string(./os/init[1])", ctxt);
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
VIR_FREE(nodes);
}
- if (STREQ(def->os.type, "xen") ||
- STREQ(def->os.type, "hvm") ||
- STREQ(def->os.type, "uml")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+ def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
+ def->os.type == VIR_DOMAIN_OSTYPE_UML) {
xmlNodePtr loader_node;
def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt);
}
}
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (virDomainDefParseBootXML(ctxt, def) < 0)
goto error;
if (!(bootHash = virHashCreate(5, NULL)))
/* With QEMU / KVM / Xen graphics, mouse + PS/2 is implicit
* with graphics, so don't store it.
* XXX will this be true for other virt types ? */
- if ((STREQ(def->os.type, "hvm") &&
+ if ((def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
input->bus == VIR_DOMAIN_INPUT_BUS_PS2 &&
(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) ||
- (STREQ(def->os.type, "xen") &&
+ (def->os.type == VIR_DOMAIN_OSTYPE_XEN &&
input->bus == VIR_DOMAIN_INPUT_BUS_XEN &&
(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) ||
- (STREQ(def->os.type, "exe") &&
+ (def->os.type == VIR_DOMAIN_OSTYPE_EXE &&
def->virtType == VIR_DOMAIN_VIRT_PARALLELS &&
input->bus == VIR_DOMAIN_INPUT_BUS_PARALLELS &&
(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
(ARCH_IS_X86(def->os.arch) || def->os.arch == VIR_ARCH_NONE)) {
int input_bus = VIR_DOMAIN_INPUT_BUS_XEN;
- if (STREQ(def->os.type, "hvm"))
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
input_bus = VIR_DOMAIN_INPUT_BUS_PS2;
- if (STREQ(def->os.type, "exe") &&
+ if (def->os.type == VIR_DOMAIN_OSTYPE_EXE &&
def->virtType == VIR_DOMAIN_VIRT_PARALLELS)
input_bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
goto error;
}
- if (STRNEQ(src->os.type, dst->os.type)) {
+ if (src->os.type != dst->os.type) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain OS type %s does not match source %s"),
- dst->os.type, src->os.type);
+ virDomainOSTypeToString(dst->os.type),
+ virDomainOSTypeToString(src->os.type));
goto error;
}
if (src->os.arch != dst->os.arch) {
}
if (STRNEQ_NULLABLE(src->os.machine, dst->os.machine)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain OS type %s does not match source %s"),
- dst->os.machine, src->os.machine);
+ _("Target domain machine type %s does not match source %s"),
+ dst->os.machine, src->os.machine);
goto error;
}
* be 'xen'. So we convert to the former for backcompat
*/
if (def->virtType == VIR_DOMAIN_VIRT_XEN &&
- STREQ(def->os.type, "xen"))
- virBufferAsprintf(buf, ">%s</type>\n", "linux");
+ def->os.type == VIR_DOMAIN_OSTYPE_XEN)
+ virBufferAsprintf(buf, ">%s</type>\n",
+ virDomainOSTypeToString(VIR_DOMAIN_OSTYPE_LINUX));
else
- virBufferAsprintf(buf, ">%s</type>\n", def->os.type);
+ virBufferAsprintf(buf, ">%s</type>\n",
+ virDomainOSTypeToString(def->os.type));
virBufferEscapeString(buf, "<init>%s</init>\n",
def->os.init);
/* Back compat, ignore the console element for hvm guests
* if it is type == serial
*/
- if (STREQ(def->os.type, "hvm") &&
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
(def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
(n < def->nserials)) {
if (virDomainChrDefFormat(buf, &console, flags) < 0)
goto error;
}
- if (STREQ(def->os.type, "hvm") &&
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
def->nconsoles == 0 &&
def->nserials > 0) {
virDomainChrDef console;
.info = { .alias = NULL },
};
- if (STREQ(def->os.type, "hvm"))
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
autoInput.bus = VIR_DOMAIN_INPUT_BUS_PS2;
- else if (STREQ(def->os.type, "exe") &&
+ else if (def->os.type == VIR_DOMAIN_OSTYPE_EXE &&
def->virtType == VIR_DOMAIN_VIRT_PARALLELS)
autoInput.bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
else
return 0;
if (!virDomainDefHasUSB(def) &&
- STRNEQ(def->os.type, "exe") &&
+ def->os.type != VIR_DOMAIN_OSTYPE_EXE &&
virDomainDeviceIsUSB(dev)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Device configuration is not compatible: "
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
- char *type;
+ int type;
virArch arch;
char *machine;
size_t nBootDevs;
def->vcpus = processorSettingData->data->VirtualQuantity;
def->maxvcpus = processorSettingData->data->VirtualQuantity;
-
- if (VIR_STRDUP(def->os.type, "hvm") < 0)
- goto cleanup;
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
/* FIXME: devices section is totally missing */
libxl_domain_create_info_init(c_info);
- if (STREQ(def->os.type, "hvm"))
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
c_info->type = LIBXL_DOMAIN_TYPE_HVM;
else
c_info->type = LIBXL_DOMAIN_TYPE_PV;
libxl_domain_config *d_config)
{
libxl_domain_build_info *b_info = &d_config->b_info;
- int hvm = STREQ(def->os.type, "hvm");
+ int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
size_t i;
libxl_domain_build_info_init(b_info);
virCommandPtr cmd = NULL;
char *output = NULL;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (def->emulator) {
cmd = virCommandNew(def->emulator);
virDomainNetDefPtr l_nic,
libxl_device_nic *x_nic)
{
- bool ioemu_nic = STREQ(def->os.type, "hvm");
+ bool ioemu_nic = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
virDomainNetType actual_type = virDomainNetGetActualType(l_nic);
/* TODO: Where is mtu stored?
* VNC or SDL info must also be set in libxl_domain_build_info
* for HVM domains. Use the first vfb device.
*/
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
libxl_domain_build_info *b_info = &d_config->b_info;
libxl_device_vfb vfb = d_config->vfbs[0];
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
- STRNEQ(def->os.type, "hvm"))
+ def->os.type != VIR_DOMAIN_OSTYPE_HVM)
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
if (dev->type == VIR_DOMAIN_DEVICE_NET &&
pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
}
- if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && STREQ(def->os.type, "hvm")) {
+ if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
int dm_type = libxlDomainGetEmulatorType(def);
switch (dev->data.video->type) {
{
/* 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 (STRNEQ(def->os.type, "hvm") && def->nconsoles == 0) {
+ if (def->os.type != VIR_DOMAIN_OSTYPE_HVM && def->nconsoles == 0) {
virDomainChrDefPtr chrdef;
if (!(chrdef = virDomainChrDefNew()))
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (VIR_STRDUP(type, vm->def->os.type) < 0)
+ if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0)
goto cleanup;
cleanup:
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (VIR_STRDUP(ret, vm->def->os.type) < 0)
+ if (VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)) < 0)
goto cleanup;
cleanup:
vmdef->vcpus = 1;
vmdef->nfss = 0;
-
- if (VIR_STRDUP(vmdef->os.type, "exe") < 0)
- goto error;
+ vmdef->os.type = VIR_DOMAIN_OSTYPE_EXE;
if ((value = virConfGetValue(properties, "lxc.arch")) && value->str) {
virArch arch = virArchFromString(value->str);
goto cleanup;
}
- if (VIR_STRDUP(def->os.type, "exe") < 0)
- goto cleanup;
+ def->os.type = VIR_DOMAIN_OSTYPE_EXE;
if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
goto cleanup;
void *opaque ATTRIBUTE_UNUSED)
{
/* fill the init path */
- if (STREQ(def->os.type, "exe") && !def->os.init) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
return -1;
}
goto cleanup;
}
- ignore_value(VIR_STRDUP(ret, vm->def->os.type));
+ ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)));
cleanup:
if (vm)
(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
!dev->data.net->model &&
- STREQ(def->os.type, "hvm") &&
+ def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
VIR_STRDUP(dev->data.net->model, "e1000") < 0)
goto cleanup;
goto cleanup;
}
- ignore_value(VIR_STRDUP(ret, privdom->def->os.type));
+ ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(privdom->def->os.type)));
cleanup:
if (privdom)
olddom = virDomainObjListFindByUUID(privconn->domains, def->uuid);
if (olddom == NULL) {
virResetLastError();
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (prlsdkCreateVm(conn, def))
goto cleanup;
- } else if (STREQ(def->os.type, "exe")) {
+ } else if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
if (prlsdkCreateCt(conn, def))
goto cleanup;
} else {
virReportError(VIR_ERR_INVALID_ARG,
- _("Unsupported OS type: %s"), def->os.type);
+ _("Unsupported OS type: %s"),
+ virDomainOSTypeToString(def->os.type));
goto cleanup;
}
switch (domainType) {
case PVT_VM:
- if (VIR_STRDUP(def->os.type, "hvm") < 0)
- return -1;
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
break;
case PVT_CT:
- if (VIR_STRDUP(def->os.type, "exe") < 0)
- return -1;
+ def->os.type = VIR_DOMAIN_OSTYPE_EXE;
if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
return -1;
break;
virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__, \
__FUNCTION__, __LINE__, _("Can't parse prlctl output"))
-# define IS_CT(def) (STREQ_NULLABLE(def->os.type, "exe"))
+# define IS_CT(def) (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
# define parallelsDomNotFoundError(domain) \
do { \
if (domain_name == NULL)
goto cleanup;
- if (VIR_STRDUP(def->os.type, "aix") < 0)
- goto cleanup;
+ def->os.type = VIR_DOMAIN_OSTYPE_AIX;
dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE);
hostarch = virArchFromHost();
if ((binary = virCapabilitiesDefaultGuestEmulator(caps,
- "hvm",
+ VIR_DOMAIN_OSTYPE_HVM,
hostarch,
"qemu")) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_UUID))
virCommandAddArgList(cmd, "-uuid", uuid, NULL);
if (def->virtType == VIR_DOMAIN_VIRT_XEN ||
- STREQ(def->os.type, "xen") ||
- STREQ(def->os.type, "linux")) {
+ def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+ def->os.type == VIR_DOMAIN_OSTYPE_LINUX) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_XEN_DOMID)) {
virCommandAddArg(cmd, "-xen-attach");
virCommandAddArg(cmd, "-xen-domid");
if (strstr(path, "xenner")) {
def->virtType = VIR_DOMAIN_VIRT_KVM;
- if (VIR_STRDUP(def->os.type, "xen") < 0)
- goto error;
+ def->os.type = VIR_DOMAIN_OSTYPE_XEN;
} else {
- if (VIR_STRDUP(def->os.type, "hvm") < 0)
- goto error;
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
if (strstr(path, "kvm")) {
def->virtType = VIR_DOMAIN_VIRT_KVM;
def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON;
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- ignore_value(VIR_STRDUP(type, vm->def->os.type));
+ ignore_value(VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)));
cleanup:
qemuDomObjEndAPI(&vm);
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (VIR_STRDUP(type, vm->def->os.type) < 0)
+ if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0)
goto cleanup;
cleanup:
PRUint32 maxBootPosition = 0;
size_t i = 0;
- VIR_DEBUG("def->os.type %s", def->os.type);
+ VIR_DEBUG("def->os.type %s", virDomainOSTypeToString(def->os.type));
VIR_DEBUG("def->os.arch %s", virArchToString(def->os.arch));
VIR_DEBUG("def->os.machine %s", def->os.machine);
VIR_DEBUG("def->os.nBootDevs %zu", def->os.nBootDevs);
/* Skip cpumasklen, cpumask, onReboot, onPoweroff, onCrash */
- if (VIR_STRDUP(def->os.type, "hvm") < 0)
- goto cleanup;
-
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
def->os.arch = virArchFromHost();
def->os.nBootDevs = 0;
if (!(def = virDomainDefNew()))
return ret;
- if (VIR_STRDUP(def->os.type, "hvm") < 0)
- goto cleanup;
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE);
if (!(def = virDomainDefNew()))
return ret;
- if (VIR_STRDUP(def->os.type, "hvm") < 0)
- goto cleanup;
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt,
VIR_DOMAIN_DEF_PARSE_INACTIVE);
* reading and while dumping xml
*/
virDomainDefSetMemoryInitial(def->dom, memorySize * 1024);
- if (VIR_STRDUP(def->dom->os.type, "hvm") < 0)
- goto cleanup;
+ def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM;
def->dom->os.arch = virArchFromHost();
gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
def->dom->maxvcpus = def->dom->vcpus = CPUCount;
goto cleanup;
}
- ignore_value(VIR_STRDUP(ret, vm->def->os.type));
+ ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)));
cleanup:
if (vm)
def->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
/* def:os */
- if (VIR_STRDUP(def->os.type, "hvm") < 0)
- goto cleanup;
+ def->os.type = VIR_DOMAIN_OSTYPE_HVM;
/* vmx:guestOS -> def:os.arch */
if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0)
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
- STRNEQ(def->os.type, "hvm"))
+ def->os.type != VIR_DOMAIN_OSTYPE_HVM)
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
/* forbid capabilities mode hostdev in this kind of hypervisor */
case VIR_DOMAIN_DEVICE_DISK:
if (xenFormatSxprDisk(dev->data.disk,
&buf,
- STREQ(def->os.type, "hvm") ? 1 : 0,
+ def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
priv->xendConfigVersion, 1) < 0)
goto cleanup;
if (xenFormatSxprNet(conn,
dev->data.net,
&buf,
- STREQ(def->os.type, "hvm") ? 1 : 0,
+ def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
priv->xendConfigVersion, 1) < 0)
goto cleanup;
case VIR_DOMAIN_DEVICE_DISK:
if (xenFormatSxprDisk(dev->data.disk,
&buf,
- STREQ(def->os.type, "hvm") ? 1 : 0,
+ def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
priv->xendConfigVersion, 1) < 0)
goto cleanup;
break;
if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
- STRNEQ(def->os.type, "hvm"))
+ def->os.type != VIR_DOMAIN_OSTYPE_HVM)
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
/* forbid capabilities mode hostdev in this kind of hypervisor */
goto error;
xen_vm_get_hvm_boot_policy(session, &boot_policy, vm);
if (STREQ(boot_policy, "BIOS order")) {
- if (VIR_STRDUP(defPtr->os.type, "hvm") < 0) {
- VIR_FREE(boot_policy);
- goto error;
- }
+ defPtr->os.type = VIR_DOMAIN_OSTYPE_HVM;
xen_vm_get_hvm_boot_params(session, &result, vm);
if (result != NULL) {
size_t i;
VIR_FREE(boot_policy);
} else {
char *value = NULL;
- if (VIR_STRDUP(defPtr->os.type, "xen") < 0) {
- VIR_FREE(boot_policy);
- goto error;
- }
+ defPtr->os.type = VIR_DOMAIN_OSTYPE_XEN;
if (VIR_ALLOC(defPtr->os.loader) < 0 ||
VIR_STRDUP(defPtr->os.loader->path, "pygrub") < 0) {
VIR_FREE(boot_policy);
virUUIDFormat(def->uuid, uuidStr);
if (VIR_STRDUP((*record)->uuid, uuidStr) < 0)
goto error;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
char *boot_order = NULL;
if (VIR_STRDUP((*record)->hvm_boot_policy, "BIOS order") < 0)
goto error;
(*record)->hvm_boot_params = hvm_boot_params;
VIR_FREE(boot_order);
}
- } else if (STREQ(def->os.type, "xen")) {
+ } else if (def->os.type == VIR_DOMAIN_OSTYPE_XEN) {
if (VIR_STRDUP((*record)->pv_bootloader, "pygrub") < 0)
goto error;
if (def->os.kernel) {
if (xenConfigGetBool(conf, "localtime", &vmlocaltime, 0) < 0)
return -1;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
/* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset */
if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
if (vmlocaltime)
if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
return -1;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigGetBool(conf, "pae", &val, 1) < 0)
return -1;
{
int val;
char *listenAddr = NULL;
- int hvm = STREQ(def->os.type, "hvm");
+ int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
virConfValuePtr list;
virDomainGraphicsDefPtr graphics = NULL;
virConfValuePtr value = NULL;
virDomainChrDefPtr chr = NULL;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigGetString(conf, "parallel", &str, NULL) < 0)
goto cleanup;
if (str && STRNEQ(str, "none") &&
{
const char *str;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigGetString(conf, "soundhw", &str, NULL) < 0)
return -1;
STREQ(str, "hvm"))
hvm = 1;
- if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0)
- return -1;
+ def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN);
def->os.arch =
virCapabilitiesDefaultGuestArch(caps,
if (!def->os.arch) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no supported architecture for os type '%s'"),
- def->os.type);
+ virDomainOSTypeToString(def->os.type));
return -1;
}
}
} else {
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
/* >=3.1 HV: VARIABLE */
int rtc_timeoffset;
{
size_t i;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (def->nparallels) {
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *str;
{
size_t i;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigSetInt(conf, "pae",
(def->features[VIR_DOMAIN_FEATURE_PAE] ==
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
{
size_t i;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
static int
xenFormatVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
{
- int hvm = STREQ(def->os.type, "hvm") ? 1 : 0;
+ int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0;
if (def->ngraphics == 1 &&
def->graphics[0]->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
static int
xenFormatSound(virConfPtr conf, virDomainDefPtr def)
{
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (def->sounds) {
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *str = NULL;
{
virConfValuePtr netVal = NULL;
size_t i;
- int hvm = STREQ(def->os.type, "hvm");
+ int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
if (VIR_ALLOC(netVal) < 0)
goto cleanup;
goto error;
}
- if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "linux") < 0)
- goto error;
+ def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_LINUX);
if (def->id != 0) {
if (sexpr_lookup(root, "domain/image")) {
}
virBufferAsprintf(&buf, "(on_crash '%s')", tmp);
- if (STREQ(def->os.type, "hvm"))
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
hvm = 1;
if (!def->os.bootloader) {
size_t i;
const char *extra, *root;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
const char *boot;
for (i = 0; i < caps->nguests; i++) {
char *listenAddr = NULL;
int val;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigGetBool(conf, "spice", &val, 0) < 0)
return -1;
}
}
- if (STRPREFIX(libxldisk->vdev, "xvd") || !STREQ(def->os.type, "hvm"))
+ if (STRPREFIX(libxldisk->vdev, "xvd") ||
+ def->os.type != VIR_DOMAIN_OSTYPE_HVM)
disk->bus = VIR_DOMAIN_DISK_BUS_XEN;
else if (STRPREFIX(libxldisk->vdev, "sd"))
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
const char *str;
virConfValuePtr val;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
val = virConfGetValue(conf, "usbdevice");
/* usbdevice can be defined as either a single string or a list */
if (val && val->type == VIR_CONF_LIST) {
{
size_t i;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
char boot[VIR_DOMAIN_BOOT_LAST+1];
if (xenConfigSetString(conf, "builder", "hvm") < 0)
return -1;
{
const char *listenAddr = NULL;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
/* set others to false but may not be necessary */
if (xenConfigSetInt(conf, "sdl", 0) < 0)
const char *devtype;
virConfValuePtr usbdevices = NULL, lastdev;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (VIR_ALLOC(usbdevices) < 0)
goto error;
{
size_t i;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
const char *boot;
if (VIR_ALLOC(def->os.loader) < 0 ||
{
const char *str = NULL;
virDomainDiskDefPtr disk = NULL;
- int hvm = STREQ(def->os.type, "hvm");
+ int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
virConfValuePtr list = virConfGetValue(conf, "disk");
if (list && list->type == VIR_CONF_LIST) {
{
virConfValuePtr diskVal = NULL;
size_t i = 0;
- int hvm = STREQ(def->os.type, "hvm");
+ int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
if (VIR_ALLOC(diskVal) < 0)
goto cleanup;
{
const char *str;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0)
return -1;
if (str &&
{
size_t i;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
char boot[VIR_DOMAIN_BOOT_LAST+1];
if (xenConfigSetString(conf, "builder", "hvm") < 0)
return -1;
size_t i;
const char *devtype;
- if (STREQ(def->os.type, "hvm")) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
for (i = 0; i < def->ninputs; i++) {
if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
if (xenConfigSetInt(conf, "usb", 1) < 0)
"</domain>\n";
if (!(def = virDomainDefNew()) ||
- VIR_STRDUP(def->os.type, "exe") < 0 ||
VIR_STRDUP(def->os.init, "/sbin/init") < 0)
goto cleanup;
def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
+ def->os.type = VIR_DOMAIN_OSTYPE_EXE;
if (openvzReadNetworkConf(def, 1) < 0) {
err = virGetLastError();