Convert capabilities / domain_conf to use virArch

Convert the host capabilities and domain config structs to
use the virArch datatype. Update the parsers and all drivers
to take account of datatype change

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2012-12-10 22:28:09 +00:00
parent 2f4a139a4c
commit c25c18f71b
29 changed files with 287 additions and 377 deletions

View File

@ -42,14 +42,14 @@ VIR_ENUM_IMPL(virCapsHostPMTarget, VIR_NODE_SUSPEND_TARGET_LAST,
/** /**
* virCapabilitiesNew: * virCapabilitiesNew:
* @arch: host machine architecture * @hostarch: host machine architecture
* @offlineMigrate: non-zero if offline migration is available * @offlineMigrate: non-zero if offline migration is available
* @liveMigrate: non-zero if live migration is available * @liveMigrate: non-zero if live migration is available
* *
* Allocate a new capabilities object * Allocate a new capabilities object
*/ */
virCapsPtr virCapsPtr
virCapabilitiesNew(const char *arch, virCapabilitiesNew(virArch hostarch,
int offlineMigrate, int offlineMigrate,
int liveMigrate) int liveMigrate)
{ {
@ -58,16 +58,11 @@ virCapabilitiesNew(const char *arch,
if (VIR_ALLOC(caps) < 0) if (VIR_ALLOC(caps) < 0)
return NULL; return NULL;
if ((caps->host.arch = strdup(arch)) == NULL) caps->host.arch = hostarch;
goto no_memory;
caps->host.offlineMigrate = offlineMigrate; caps->host.offlineMigrate = offlineMigrate;
caps->host.liveMigrate = liveMigrate; caps->host.liveMigrate = liveMigrate;
return caps; return caps;
no_memory:
virCapabilitiesFree(caps);
return NULL;
} }
static void static void
@ -125,7 +120,6 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest)
VIR_FREE(guest->ostype); VIR_FREE(guest->ostype);
VIR_FREE(guest->arch.name);
VIR_FREE(guest->arch.defaultInfo.emulator); VIR_FREE(guest->arch.defaultInfo.emulator);
VIR_FREE(guest->arch.defaultInfo.loader); VIR_FREE(guest->arch.defaultInfo.loader);
for (i = 0 ; i < guest->arch.defaultInfo.nmachines ; i++) for (i = 0 ; i < guest->arch.defaultInfo.nmachines ; i++)
@ -180,8 +174,6 @@ virCapabilitiesFree(virCapsPtr caps) {
VIR_FREE(caps->host.migrateTrans[i]); VIR_FREE(caps->host.migrateTrans[i]);
VIR_FREE(caps->host.migrateTrans); VIR_FREE(caps->host.migrateTrans);
VIR_FREE(caps->host.arch);
for (i = 0; i < caps->host.nsecModels; i++) { for (i = 0; i < caps->host.nsecModels; i++) {
VIR_FREE(caps->host.secModels[i].model); VIR_FREE(caps->host.secModels[i].model);
VIR_FREE(caps->host.secModels[i].doi); VIR_FREE(caps->host.secModels[i].doi);
@ -353,7 +345,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
* virCapabilitiesAddGuest: * virCapabilitiesAddGuest:
* @caps: capabilities to extend * @caps: capabilities to extend
* @ostype: guest operating system type ('hvm' or 'xen') * @ostype: guest operating system type ('hvm' or 'xen')
* @arch: guest CPU architecture ('i686', or 'x86_64', etc) * @arch: guest CPU architecture
* @wordsize: number of bits in CPU word * @wordsize: number of bits in CPU word
* @emulator: path to default device emulator for arch/ostype * @emulator: path to default device emulator for arch/ostype
* @loader: path to default BIOS loader for arch/ostype * @loader: path to default BIOS loader for arch/ostype
@ -367,8 +359,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
virCapsGuestPtr virCapsGuestPtr
virCapabilitiesAddGuest(virCapsPtr caps, virCapabilitiesAddGuest(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch, virArch arch,
int wordsize,
const char *emulator, const char *emulator,
const char *loader, const char *loader,
int nmachines, int nmachines,
@ -382,9 +373,8 @@ virCapabilitiesAddGuest(virCapsPtr caps,
if ((guest->ostype = strdup(ostype)) == NULL) if ((guest->ostype = strdup(ostype)) == NULL)
goto no_memory; goto no_memory;
if ((guest->arch.name = strdup(arch)) == NULL) guest->arch.id = arch;
goto no_memory; guest->arch.wordsize = virArchGetWordSize(arch);
guest->arch.wordsize = wordsize;
if (emulator && if (emulator &&
(guest->arch.defaultInfo.emulator = strdup(emulator)) == NULL) (guest->arch.defaultInfo.emulator = strdup(emulator)) == NULL)
@ -505,18 +495,18 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
/** /**
* virCapabilitiesSupportsGuestArch: * virCapabilitiesSupportsGuestArch:
* @caps: capabilities to query * @caps: capabilities to query
* @arch: Architecture to search for (eg, 'i686', 'x86_64') * @arch: Architecture to search for
* *
* Returns non-zero if the capabilities support the * Returns non-zero if the capabilities support the
* requested architecture * requested architecture
*/ */
extern int extern int
virCapabilitiesSupportsGuestArch(virCapsPtr caps, virCapabilitiesSupportsGuestArch(virCapsPtr caps,
const char *arch) virArch arch)
{ {
int i; int i;
for (i = 0 ; i < caps->nguests ; i++) { for (i = 0 ; i < caps->nguests ; i++) {
if (STREQ(caps->guests[i]->arch.name, arch)) if (caps->guests[i]->arch.id == arch)
return 1; return 1;
} }
return 0; return 0;
@ -548,7 +538,7 @@ virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
* virCapabilitiesSupportsGuestOSTypeArch: * virCapabilitiesSupportsGuestOSTypeArch:
* @caps: capabilities to query * @caps: capabilities to query
* @ostype: OS type to search for (eg 'hvm', 'xen') * @ostype: OS type to search for (eg 'hvm', 'xen')
* @arch: Architecture to search for (eg, 'i686', 'x86_64') * @arch: Architecture to search for
* *
* Returns non-zero if the capabilities support the * Returns non-zero if the capabilities support the
* requested operating system type * requested operating system type
@ -556,12 +546,12 @@ virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
extern int extern int
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch) virArch arch)
{ {
int i; int i;
for (i = 0 ; i < caps->nguests ; i++) { for (i = 0 ; i < caps->nguests ; i++) {
if (STREQ(caps->guests[i]->ostype, ostype) && if (STREQ(caps->guests[i]->ostype, ostype) &&
STREQ(caps->guests[i]->arch.name, arch)) caps->guests[i]->arch.id == arch)
return 1; return 1;
} }
return 0; return 0;
@ -576,28 +566,35 @@ virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
* Returns the first architecture able to run the * Returns the first architecture able to run the
* requested operating system type * requested operating system type
*/ */
extern const char * extern virArch
virCapabilitiesDefaultGuestArch(virCapsPtr caps, virCapabilitiesDefaultGuestArch(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *domain) const char *domain)
{ {
int i, j; int i, j;
const char *arch = NULL;
/* First try to find one matching host arch */
for (i = 0 ; i < caps->nguests ; i++) { for (i = 0 ; i < caps->nguests ; i++) {
if (STREQ(caps->guests[i]->ostype, ostype)) { if (STREQ(caps->guests[i]->ostype, ostype)) {
for (j = 0 ; j < caps->guests[i]->arch.ndomains ; j++) { for (j = 0 ; j < caps->guests[i]->arch.ndomains ; j++) {
if (STREQ(caps->guests[i]->arch.domains[j]->type, domain)) { if (STREQ(caps->guests[i]->arch.domains[j]->type, domain) &&
/* Use the first match... */ caps->guests[i]->arch.id == caps->host.arch)
if (!arch) return caps->guests[i]->arch.id;
arch = caps->guests[i]->arch.name;
/* ...unless we can match the host's architecture. */
if (STREQ(caps->guests[i]->arch.name, caps->host.arch))
return caps->guests[i]->arch.name;
}
} }
} }
} }
return arch;
/* Otherwise find the first match */
for (i = 0 ; i < caps->nguests ; i++) {
if (STREQ(caps->guests[i]->ostype, ostype)) {
for (j = 0 ; j < caps->guests[i]->arch.ndomains ; j++) {
if (STREQ(caps->guests[i]->arch.domains[j]->type, domain))
return caps->guests[i]->arch.id;
}
}
}
return VIR_ARCH_NONE;
} }
/** /**
@ -614,7 +611,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps,
extern const char * extern const char *
virCapabilitiesDefaultGuestMachine(virCapsPtr caps, virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch, virArch arch,
const char *domain) const char *domain)
{ {
int i; int i;
@ -623,11 +620,12 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
virCapsGuestPtr guest = caps->guests[i]; virCapsGuestPtr guest = caps->guests[i];
int j; int j;
if (!STREQ(guest->ostype, ostype) || !STREQ(guest->arch.name, arch)) if (!STREQ(guest->ostype, ostype) ||
guest->arch.id != arch)
continue; continue;
for (j = 0; j < guest->arch.ndomains; j++) { for (j = 0; j < guest->arch.ndomains; j++) {
virCapsGuestDomainPtr dom= guest->arch.domains[j]; virCapsGuestDomainPtr dom = guest->arch.domains[j];
if (!STREQ(dom->type, domain)) if (!STREQ(dom->type, domain))
continue; continue;
@ -659,14 +657,14 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
extern const char * extern const char *
virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch, virArch arch,
const char *domain) const char *domain)
{ {
int i, j; int i, j;
for (i = 0 ; i < caps->nguests ; i++) { for (i = 0 ; i < caps->nguests ; i++) {
char *emulator; char *emulator;
if (STREQ(caps->guests[i]->ostype, ostype) && if (STREQ(caps->guests[i]->ostype, ostype) &&
STREQ(caps->guests[i]->arch.name, arch)) { caps->guests[i]->arch.id == arch) {
emulator = caps->guests[i]->arch.defaultInfo.emulator; emulator = caps->guests[i]->arch.defaultInfo.emulator;
for (j = 0 ; j < caps->guests[i]->arch.ndomains ; j++) { for (j = 0 ; j < caps->guests[i]->arch.ndomains ; j++) {
if (STREQ(caps->guests[i]->arch.domains[j]->type, domain)) { if (STREQ(caps->guests[i]->arch.domains[j]->type, domain)) {
@ -703,8 +701,9 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAsprintf(&xml," <uuid>%s</uuid>\n", host_uuid); virBufferAsprintf(&xml," <uuid>%s</uuid>\n", host_uuid);
} }
virBufferAddLit(&xml, " <cpu>\n"); virBufferAddLit(&xml, " <cpu>\n");
virBufferAsprintf(&xml, " <arch>%s</arch>\n", if (caps->host.arch)
caps->host.arch); virBufferAsprintf(&xml, " <arch>%s</arch>\n",
virArchToString(caps->host.arch));
if (caps->host.nfeatures) { if (caps->host.nfeatures) {
virBufferAddLit(&xml, " <features>\n"); virBufferAddLit(&xml, " <features>\n");
@ -788,8 +787,9 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAddLit(&xml, " <guest>\n"); virBufferAddLit(&xml, " <guest>\n");
virBufferAsprintf(&xml, " <os_type>%s</os_type>\n", virBufferAsprintf(&xml, " <os_type>%s</os_type>\n",
caps->guests[i]->ostype); caps->guests[i]->ostype);
virBufferAsprintf(&xml, " <arch name='%s'>\n", if (caps->guests[i]->arch.id)
caps->guests[i]->arch.name); virBufferAsprintf(&xml, " <arch name='%s'>\n",
virArchToString(caps->guests[i]->arch.id));
virBufferAsprintf(&xml, " <wordsize>%d</wordsize>\n", virBufferAsprintf(&xml, " <wordsize>%d</wordsize>\n",
caps->guests[i]->arch.wordsize); caps->guests[i]->arch.wordsize);
if (caps->guests[i]->arch.defaultInfo.emulator) if (caps->guests[i]->arch.defaultInfo.emulator)

View File

@ -27,6 +27,7 @@
# include "internal.h" # include "internal.h"
# include "buf.h" # include "buf.h"
# include "cpu_conf.h" # include "cpu_conf.h"
# include "virarch.h"
# include "virmacaddr.h" # include "virmacaddr.h"
# include <libxml/xpath.h> # include <libxml/xpath.h>
@ -65,8 +66,8 @@ struct _virCapsGuestDomain {
typedef struct _virCapsGuestArch virCapsGuestArch; typedef struct _virCapsGuestArch virCapsGuestArch;
typedef virCapsGuestArch *virCapsGuestArchptr; typedef virCapsGuestArch *virCapsGuestArchptr;
struct _virCapsGuestArch { struct _virCapsGuestArch {
char *name; virArch id;
int wordsize; unsigned int wordsize;
virCapsGuestDomainInfo defaultInfo; virCapsGuestDomainInfo defaultInfo;
size_t ndomains; size_t ndomains;
size_t ndomains_max; size_t ndomains_max;
@ -101,7 +102,7 @@ struct _virCapsHostSecModel {
typedef struct _virCapsHost virCapsHost; typedef struct _virCapsHost virCapsHost;
typedef virCapsHost *virCapsHostPtr; typedef virCapsHost *virCapsHostPtr;
struct _virCapsHost { struct _virCapsHost {
char *arch; virArch arch;
size_t nfeatures; size_t nfeatures;
size_t nfeatures_max; size_t nfeatures_max;
char **features; char **features;
@ -150,7 +151,7 @@ struct _virCaps {
unsigned int emulatorRequired : 1; unsigned int emulatorRequired : 1;
const char *defaultDiskDriverName; const char *defaultDiskDriverName;
int defaultDiskDriverType; /* enum virStorageFileFormat */ int defaultDiskDriverType; /* enum virStorageFileFormat */
int (*defaultConsoleTargetType)(const char *ostype, const char *arch); int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
void *(*privateDataAllocFunc)(void); void *(*privateDataAllocFunc)(void);
void (*privateDataFreeFunc)(void *); void (*privateDataFreeFunc)(void *);
int (*privateDataXMLFormat)(virBufferPtr, void *); int (*privateDataXMLFormat)(virBufferPtr, void *);
@ -163,7 +164,7 @@ struct _virCaps {
extern virCapsPtr extern virCapsPtr
virCapabilitiesNew(const char *arch, virCapabilitiesNew(virArch hostarch,
int offlineMigrate, int offlineMigrate,
int liveMigrate); int liveMigrate);
@ -218,8 +219,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
extern virCapsGuestPtr extern virCapsGuestPtr
virCapabilitiesAddGuest(virCapsPtr caps, virCapabilitiesAddGuest(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch, virArch arch,
int wordsize,
const char *emulator, const char *emulator,
const char *loader, const char *loader,
int nmachines, int nmachines,
@ -241,29 +241,29 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
extern int extern int
virCapabilitiesSupportsGuestArch(virCapsPtr caps, virCapabilitiesSupportsGuestArch(virCapsPtr caps,
const char *arch); virArch arch);
extern int extern int
virCapabilitiesSupportsGuestOSType(virCapsPtr caps, virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
const char *ostype); const char *ostype);
extern int extern int
virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch); virArch arch);
extern const char * extern virArch
virCapabilitiesDefaultGuestArch(virCapsPtr caps, virCapabilitiesDefaultGuestArch(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *domain); const char *domain);
extern const char * extern const char *
virCapabilitiesDefaultGuestMachine(virCapsPtr caps, virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch, virArch arch,
const char *domain); const char *domain);
extern const char * extern const char *
virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
const char *ostype, const char *ostype,
const char *arch, virArch arch,
const char *domain); const char *domain);
extern char * extern char *

View File

@ -1709,7 +1709,6 @@ void virDomainDefFree(virDomainDefPtr def)
VIR_FREE(def->redirdevs); VIR_FREE(def->redirdevs);
VIR_FREE(def->os.type); VIR_FREE(def->os.type);
VIR_FREE(def->os.arch);
VIR_FREE(def->os.machine); VIR_FREE(def->os.machine);
VIR_FREE(def->os.init); VIR_FREE(def->os.init);
for (i = 0 ; def->os.initargv && def->os.initargv[i] ; i++) for (i = 0 ; def->os.initargv && def->os.initargv[i] ; i++)
@ -8525,7 +8524,7 @@ static char *virDomainDefDefaultEmulator(virDomainDefPtr def,
if (!emulator) { if (!emulator) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("no emulator for domain %s os type %s on architecture %s"), _("no emulator for domain %s os type %s on architecture %s"),
type, def->os.type, def->os.arch); type, def->os.type, virArchToString(def->os.arch));
return NULL; return NULL;
} }
@ -9581,12 +9580,21 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
goto error; goto error;
} }
def->os.arch = virXPathString("string(./os/type[1]/@arch)", ctxt); tmp = virXPathString("string(./os/type[1]/@arch)", ctxt);
if (def->os.arch) { if (tmp) {
virArch arch = virArchFromString(tmp);
if (!arch) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown architecture %s"),
tmp);
goto error;
}
VIR_FREE(tmp);
if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) { if (!virCapabilitiesSupportsGuestArch(caps, def->os.arch)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("No guest options available for arch '%s'"), _("No guest options available for arch '%s'"),
def->os.arch); virArchToString(def->os.arch));
goto error; goto error;
} }
@ -9595,20 +9603,20 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
def->os.arch)) { def->os.arch)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("No os type '%s' available for arch '%s'"), _("No os type '%s' available for arch '%s'"),
def->os.type, def->os.arch); def->os.type, virArchToString(def->os.arch));
goto error; goto error;
} }
} else { } else {
const char *defaultArch = virCapabilitiesDefaultGuestArch(caps, def->os.type, virDomainVirtTypeToString(def->virtType)); def->os.arch =
if (defaultArch == NULL) { virCapabilitiesDefaultGuestArch(caps,
def->os.type,
virDomainVirtTypeToString(def->virtType));
if (!def->os.arch) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("no supported architecture for os type '%s'"), _("no supported architecture for os type '%s'"),
def->os.type); def->os.type);
goto error; goto error;
} }
if (!(def->os.arch = strdup(defaultArch))) {
goto no_memory;
}
} }
def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt); def->os.machine = virXPathString("string(./os/type[1]/@machine)", ctxt);
@ -10235,7 +10243,8 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
def->memballoon = memballoon; def->memballoon = memballoon;
VIR_FREE(nodes); VIR_FREE(nodes);
} else if (!STREQ(def->os.arch,"s390x")) { } else if (def->os.arch != VIR_ARCH_S390 &&
def->os.arch != VIR_ARCH_S390X) {
/* TODO: currently no balloon support on s390 -> no default balloon */ /* TODO: currently no balloon support on s390 -> no default balloon */
if (def->virtType == VIR_DOMAIN_VIRT_XEN || if (def->virtType == VIR_DOMAIN_VIRT_XEN ||
def->virtType == VIR_DOMAIN_VIRT_QEMU || def->virtType == VIR_DOMAIN_VIRT_QEMU ||
@ -11407,10 +11416,11 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src,
dst->os.type, src->os.type); dst->os.type, src->os.type);
goto cleanup; goto cleanup;
} }
if (STRNEQ(src->os.arch, dst->os.arch)) { if (src->os.arch != dst->os.arch){
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain architecture %s does not match source %s"), _("Target domain architecture %s does not match source %s"),
dst->os.arch, src->os.arch); virArchToString(dst->os.arch),
virArchToString(src->os.arch));
goto cleanup; goto cleanup;
} }
if (STRNEQ(src->os.machine, dst->os.machine)) { if (STRNEQ(src->os.machine, dst->os.machine)) {
@ -14181,7 +14191,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAddLit(buf, " <type"); virBufferAddLit(buf, " <type");
if (def->os.arch) if (def->os.arch)
virBufferAsprintf(buf, " arch='%s'", def->os.arch); virBufferAsprintf(buf, " arch='%s'", virArchToString(def->os.arch));
if (def->os.machine) if (def->os.machine)
virBufferAsprintf(buf, " machine='%s'", def->os.machine); virBufferAsprintf(buf, " machine='%s'", def->os.machine);
/* /*

View File

@ -1499,7 +1499,7 @@ typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr; typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef { struct _virDomainOSDef {
char *type; char *type;
char *arch; virArch arch;
char *machine; char *machine;
size_t nBootDevs; size_t nBootDevs;
int bootDevs[VIR_DOMAIN_BOOT_LAST]; int bootDevs[VIR_DOMAIN_BOOT_LAST];

View File

@ -569,7 +569,7 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid)
static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} }
@ -587,9 +587,9 @@ esxCapsInit(esxPrivate *priv)
} }
if (supportsLongMode == esxVI_Boolean_True) { if (supportsLongMode == esxVI_Boolean_True) {
caps = virCapabilitiesNew("x86_64", 1, 1); caps = virCapabilitiesNew(VIR_ARCH_X86_64, 1, 1);
} else { } else {
caps = virCapabilitiesNew("i686", 1, 1); caps = virCapabilitiesNew(VIR_ARCH_I686, 1, 1);
} }
if (caps == NULL) { if (caps == NULL) {
@ -608,7 +608,9 @@ esxCapsInit(esxPrivate *priv)
} }
/* i686 */ /* i686 */
guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32, NULL, NULL, 0, guest = virCapabilitiesAddGuest(caps, "hvm",
VIR_ARCH_I686,
NULL, NULL, 0,
NULL); NULL);
if (guest == NULL) { if (guest == NULL) {
@ -622,7 +624,9 @@ esxCapsInit(esxPrivate *priv)
/* x86_64 */ /* x86_64 */
if (supportsLongMode == esxVI_Boolean_True) { if (supportsLongMode == esxVI_Boolean_True) {
guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64, NULL, NULL, guest = virCapabilitiesAddGuest(caps, "hvm",
VIR_ARCH_X86_64,
NULL, NULL,
0, NULL); 0, NULL);
if (guest == NULL) { if (guest == NULL) {

View File

@ -29,7 +29,6 @@
#include <libxl.h> #include <libxl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/utsname.h>
#include "internal.h" #include "internal.h"
#include "logging.h" #include "logging.h"
@ -53,7 +52,7 @@
struct guest_arch { struct guest_arch {
const char *model; virArch arch;
int bits; int bits;
int hvm; int hvm;
int pae; int pae;
@ -156,9 +155,8 @@ libxlBuildCapabilities(const char *hostmachine,
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
guest_archs[i].hvm ? "hvm" : "xen", guest_archs[i].hvm ? "hvm" : "xen",
guest_archs[i].model, guest_archs[i].arch,
guest_archs[i].bits, ((hostarch == VIR_ARCH_X86_64) ?
(STREQ(hostmachine, "x86_64") ?
"/usr/lib64/xen/bin/qemu-dm" : "/usr/lib64/xen/bin/qemu-dm" :
"/usr/lib/xen/bin/qemu-dm"), "/usr/lib/xen/bin/qemu-dm"),
(guest_archs[i].hvm ? (guest_archs[i].hvm ?
@ -230,7 +228,7 @@ libxlBuildCapabilities(const char *hostmachine,
} }
static virCapsPtr static virCapsPtr
libxlMakeCapabilitiesInternal(const char *hostmachine, libxlMakeCapabilitiesInternal(virArch hostarch,
libxl_physinfo *phy_info, libxl_physinfo *phy_info,
char *capabilities) char *capabilities)
{ {
@ -285,12 +283,11 @@ libxlMakeCapabilitiesInternal(const char *hostmachine,
if (regexec(&xen_cap_rec, token, sizeof(subs) / sizeof(subs[0]), if (regexec(&xen_cap_rec, token, sizeof(subs) / sizeof(subs[0]),
subs, 0) == 0) { subs, 0) == 0) {
int hvm = STRPREFIX(&token[subs[1].rm_so], "hvm"); int hvm = STRPREFIX(&token[subs[1].rm_so], "hvm");
const char *model; virArch arch;
int bits, pae = 0, nonpae = 0, ia64_be = 0; int pae = 0, nonpae = 0, ia64_be = 0;
if (STRPREFIX(&token[subs[2].rm_so], "x86_32")) { if (STRPREFIX(&token[subs[2].rm_so], "x86_32")) {
model = "i686"; arch = VIR_ARCH_I686;
bits = 32;
if (subs[3].rm_so != -1 && if (subs[3].rm_so != -1 &&
STRPREFIX(&token[subs[3].rm_so], "p")) STRPREFIX(&token[subs[3].rm_so], "p"))
pae = 1; pae = 1;
@ -298,26 +295,24 @@ libxlMakeCapabilitiesInternal(const char *hostmachine,
nonpae = 1; nonpae = 1;
} }
else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) { else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) {
model = "x86_64"; arch = VIR_ARCH_X86_64;
bits = 64;
} }
else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) { else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) {
model = "ia64"; arch = VIR_ARCH_ITANIUM;
bits = 64;
if (subs[3].rm_so != -1 && if (subs[3].rm_so != -1 &&
STRPREFIX(&token[subs[3].rm_so], "be")) STRPREFIX(&token[subs[3].rm_so], "be"))
ia64_be = 1; ia64_be = 1;
} }
else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64")) { else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64")) {
model = "ppc64"; arch = VIR_ARCH_PPC64;
bits = 64;
} else { } else {
/* XXX arm ? */
continue; continue;
} }
/* Search for existing matching (model,hvm) tuple */ /* Search for existing matching (model,hvm) tuple */
for (i = 0 ; i < nr_guest_archs ; i++) { for (i = 0 ; i < nr_guest_archs ; i++) {
if (STREQ(guest_archs[i].model, model) && if ((guest_archs[i].arch == arch) &&
guest_archs[i].hvm == hvm) { guest_archs[i].hvm == hvm) {
break; break;
} }
@ -330,7 +325,7 @@ libxlMakeCapabilitiesInternal(const char *hostmachine,
if (i == nr_guest_archs) if (i == nr_guest_archs)
nr_guest_archs++; nr_guest_archs++;
guest_archs[i].model = model; guest_archs[i].arch = arch;
guest_archs[i].bits = bits; guest_archs[i].bits = bits;
guest_archs[i].hvm = hvm; guest_archs[i].hvm = hvm;
@ -347,7 +342,7 @@ libxlMakeCapabilitiesInternal(const char *hostmachine,
} }
} }
if ((caps = libxlBuildCapabilities(hostmachine, if ((caps = libxlBuildCapabilities(hostarch,
host_pae, host_pae,
guest_archs, guest_archs,
nr_guest_archs)) == NULL) nr_guest_archs)) == NULL)
@ -825,7 +820,6 @@ libxlMakeCapabilities(libxl_ctx *ctx)
{ {
libxl_physinfo phy_info; libxl_physinfo phy_info;
const libxl_version_info *ver_info; const libxl_version_info *ver_info;
struct utsname utsname;
regcomp(&xen_cap_rec, xen_cap_re, REG_EXTENDED); regcomp(&xen_cap_rec, xen_cap_re, REG_EXTENDED);
@ -841,9 +835,7 @@ libxlMakeCapabilities(libxl_ctx *ctx)
return NULL; return NULL;
} }
uname(&utsname); return libxlMakeCapabilitiesInternal(virArchFromHost(),
return libxlMakeCapabilitiesInternal(utsname.machine,
&phy_info, &phy_info,
ver_info->capabilities); ver_info->capabilities);
} }

View File

@ -26,7 +26,6 @@
#include <config.h> #include <config.h>
#include <sys/utsname.h>
#include <math.h> #include <math.h>
#include <libxl.h> #include <libxl.h>
#include <fcntl.h> #include <fcntl.h>
@ -320,7 +319,7 @@ libxlDoNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
{ {
libxl_physinfo phy_info; libxl_physinfo phy_info;
const libxl_version_info* ver_info; const libxl_version_info* ver_info;
struct utsname utsname; virArch hostarch = virArchFromHost();
if (libxl_get_physinfo(driver->ctx, &phy_info)) { if (libxl_get_physinfo(driver->ctx, &phy_info)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -334,14 +333,10 @@ libxlDoNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr info)
return -1; return -1;
} }
uname(&utsname); if (virStrcpyStatic(info->model, virArchToString(hostarch)) == NULL) {
if (virStrncpy(info->model,
utsname.machine,
strlen(utsname.machine),
sizeof(info->model)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("machine type %s too big for destination"), _("machine type %s too big for destination"),
utsname.machine); virArchToString(hostarch));
return -1; return -1;
} }

View File

@ -26,8 +26,6 @@
/* includes */ /* includes */
#include <config.h> #include <config.h>
#include <sys/utsname.h>
#include "lxc_conf.h" #include "lxc_conf.h"
#include "nodeinfo.h" #include "nodeinfo.h"
#include "virterror_internal.h" #include "virterror_internal.h"
@ -43,7 +41,7 @@
#define VIR_FROM_THIS VIR_FROM_LXC #define VIR_FROM_THIS VIR_FROM_LXC
static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
} }
@ -52,14 +50,11 @@ static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
/* Functions */ /* Functions */
virCapsPtr lxcCapsInit(virLXCDriverPtr driver) virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
{ {
struct utsname utsname;
virCapsPtr caps; virCapsPtr caps;
virCapsGuestPtr guest; virCapsGuestPtr guest;
const char *altArch; virArch altArch;
uname(&utsname); if ((caps = virCapabilitiesNew(virArchFromHost(),
if ((caps = virCapabilitiesNew(utsname.machine,
0, 0)) == NULL) 0, 0)) == NULL)
goto error; goto error;
@ -88,8 +83,7 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"exe", "exe",
utsname.machine, caps->host.arch,
sizeof(void*) == 4 ? 32 : 64,
LIBEXECDIR "/libvirt_lxc", LIBEXECDIR "/libvirt_lxc",
NULL, NULL,
0, 0,
@ -105,11 +99,10 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
goto error; goto error;
/* On 64-bit hosts, we can use personality() to request a 32bit process */ /* On 64-bit hosts, we can use personality() to request a 32bit process */
if ((altArch = lxcContainerGetAlt32bitArch(utsname.machine)) != NULL) { if ((altArch = lxcContainerGetAlt32bitArch(caps->host.arch)) != VIR_ARCH_NONE) {
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"exe", "exe",
altArch, altArch,
32,
LIBEXECDIR "/libvirt_lxc", LIBEXECDIR "/libvirt_lxc",
NULL, NULL,
0, 0,

View File

@ -2299,24 +2299,26 @@ static int userns_supported(void)
#endif #endif
} }
const char *lxcContainerGetAlt32bitArch(const char *arch) virArch lxcContainerGetAlt32bitArch(virArch arch)
{ {
/* Any Linux 64bit arch which has a 32bit /* Any Linux 64bit arch which has a 32bit
* personality available should be listed here */ * personality available should be listed here */
if (STREQ(arch, "x86_64")) if (arch == VIR_ARCH_X86_64)
return "i686"; return VIR_ARCH_I686;
if (STREQ(arch, "s390x")) if (arch == VIR_ARCH_S390X)
return "s390"; return VIR_ARCH_S390;
if (STREQ(arch, "ppc64")) if (arch == VIR_ARCH_PPC64)
return "ppc"; return VIR_ARCH_PPC;
if (STREQ(arch, "parisc64")) if (arch == VIR_ARCH_PARISC64)
return "parisc"; return VIR_ARCH_PARISC;
if (STREQ(arch, "sparc64")) if (arch == VIR_ARCH_SPARC64)
return "sparc"; return VIR_ARCH_SPARC;
if (STREQ(arch, "mips64")) if (arch == VIR_ARCH_MIPS64)
return "mips"; return VIR_ARCH_MIPS;
if (arch == VIR_ARCH_MIPS64EL)
return VIR_ARCH_MIPSEL;
return NULL; return VIR_ARCH_NONE;
} }

View File

@ -63,6 +63,6 @@ int lxcContainerStart(virDomainDefPtr def,
int lxcContainerAvailable(int features); int lxcContainerAvailable(int features);
const char *lxcContainerGetAlt32bitArch(const char *arch); virArch lxcContainerGetAlt32bitArch(virArch arch);
#endif /* LXC_CONTAINER_H */ #endif /* LXC_CONTAINER_H */

View File

@ -29,7 +29,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/un.h> #include <sys/un.h>
#include <sys/utsname.h>
#include <sys/personality.h> #include <sys/personality.h>
#include <unistd.h> #include <unistd.h>
#include <paths.h> #include <paths.h>
@ -1077,17 +1076,15 @@ static int virLXCControllerDeleteInterfaces(virLXCControllerPtr ctrl)
static int lxcSetPersonality(virDomainDefPtr def) static int lxcSetPersonality(virDomainDefPtr def)
{ {
struct utsname utsname; virArch altArch;
const char *altArch;
uname(&utsname); altArch = lxcContainerGetAlt32bitArch(virArchFromHost());
altArch = lxcContainerGetAlt32bitArch(utsname.machine);
if (altArch && if (altArch &&
STREQ(def->os.arch, altArch)) { (def->os.arch == altArch)) {
if (personality(PER_LINUX32) < 0) { if (personality(PER_LINUX32) < 0) {
virReportSystemError(errno, _("Unable to request personality for %s on %s"), virReportSystemError(errno, _("Unable to request personality for %s on %s"),
altArch, utsname.machine); virArchToString(altArch),
virArchToString(virArchFromHost()));
return -1; return -1;
} }
} }

View File

@ -40,7 +40,6 @@
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <sys/utsname.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "virterror_internal.h" #include "virterror_internal.h"
@ -170,20 +169,17 @@ error:
static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ;
} }
virCapsPtr openvzCapsInit(void) virCapsPtr openvzCapsInit(void)
{ {
struct utsname utsname;
virCapsPtr caps; virCapsPtr caps;
virCapsGuestPtr guest; virCapsGuestPtr guest;
uname(&utsname); if ((caps = virCapabilitiesNew(virArchFromHost(),
if ((caps = virCapabilitiesNew(utsname.machine,
0, 0)) == NULL) 0, 0)) == NULL)
goto no_memory; goto no_memory;
@ -194,8 +190,7 @@ virCapsPtr openvzCapsInit(void)
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"exe", "exe",
utsname.machine, caps->host.arch,
sizeof(void*) == 4 ? 32 : 64,
NULL, NULL,
NULL, NULL,
0, 0,

View File

@ -37,7 +37,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/utsname.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <paths.h> #include <paths.h>

View File

@ -31,7 +31,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/utsname.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <paths.h> #include <paths.h>
@ -59,7 +58,6 @@
#define PRLCTL "prlctl" #define PRLCTL "prlctl"
#define PRLSRVCTL "prlsrvctl" #define PRLSRVCTL "prlsrvctl"
#define PARALLELS_DEFAULT_ARCH "x86_64"
#define parallelsDomNotFoundError(domain) \ #define parallelsDomNotFoundError(domain) \
do { \ do { \
@ -100,7 +98,7 @@ parallelsDriverUnlock(parallelsConnPtr driver)
static int static int
parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} }
@ -123,10 +121,9 @@ parallelsBuildCapabilities(void)
{ {
virCapsPtr caps; virCapsPtr caps;
virCapsGuestPtr guest; virCapsGuestPtr guest;
struct utsname utsname;
uname(&utsname);
if ((caps = virCapabilitiesNew(utsname.machine, 0, 0)) == NULL) if ((caps = virCapabilitiesNew(virArchFromHost(),
0, 0)) == NULL)
goto no_memory; goto no_memory;
if (nodeCapsInitNUMA(caps) < 0) if (nodeCapsInitNUMA(caps) < 0)
@ -135,8 +132,9 @@ parallelsBuildCapabilities(void)
virCapabilitiesSetMacPrefix(caps, (unsigned char[]) { virCapabilitiesSetMacPrefix(caps, (unsigned char[]) {
0x42, 0x1C, 0x00}); 0x42, 0x1C, 0x00});
if ((guest = virCapabilitiesAddGuest(caps, "hvm", PARALLELS_DEFAULT_ARCH, if ((guest = virCapabilitiesAddGuest(caps, "hvm",
64, "parallels", VIR_ARCH_X86_64,
"parallels",
NULL, 0, NULL)) == NULL) NULL, 0, NULL)) == NULL)
goto no_memory; goto no_memory;
@ -144,8 +142,9 @@ parallelsBuildCapabilities(void)
"parallels", NULL, NULL, 0, NULL) == NULL) "parallels", NULL, NULL, 0, NULL) == NULL)
goto no_memory; goto no_memory;
if ((guest = virCapabilitiesAddGuest(caps, "exe", PARALLELS_DEFAULT_ARCH, if ((guest = virCapabilitiesAddGuest(caps, "exe",
64, "parallels", VIR_ARCH_X86_64,
"parallels",
NULL, 0, NULL)) == NULL) NULL, 0, NULL)) == NULL)
goto no_memory; goto no_memory;
@ -792,8 +791,7 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj)
goto no_memory; goto no_memory;
} }
if (!(def->os.arch = strdup(PARALLELS_DEFAULT_ARCH))) def->os.arch = VIR_ARCH_X86_64;
goto no_memory;
if (VIR_ALLOC(pdom) < 0) if (VIR_ALLOC(pdom) < 0)
goto no_memory; goto no_memory;
@ -2103,7 +2101,7 @@ parallelsApplyChanges(virConnectPtr conn, virDomainObjPtr dom, virDomainDefPtr n
* other paramenters are null and boot devices config is default */ * other paramenters are null and boot devices config is default */
if (!STREQ_NULLABLE(old->os.type, new->os.type) || if (!STREQ_NULLABLE(old->os.type, new->os.type) ||
!STREQ_NULLABLE(old->os.arch, new->os.arch) || old->os.arch != new->os.arch ||
new->os.machine != NULL || new->os.bootmenu != 0 || new->os.machine != NULL || new->os.bootmenu != 0 ||
new->os.kernel != NULL || new->os.initrd != NULL || new->os.kernel != NULL || new->os.initrd != NULL ||
new->os.cmdline != NULL || new->os.root != NULL || new->os.cmdline != NULL || new->os.root != NULL ||

View File

@ -40,7 +40,6 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/utsname.h>
#include <domain_event.h> #include <domain_event.h>
#include "internal.h" #include "internal.h"
@ -289,7 +288,7 @@ phypGetVIOSPartitionID(virConnectPtr conn)
static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} }
@ -298,13 +297,11 @@ static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
static virCapsPtr static virCapsPtr
phypCapsInit(void) phypCapsInit(void)
{ {
struct utsname utsname;
virCapsPtr caps; virCapsPtr caps;
virCapsGuestPtr guest; virCapsGuestPtr guest;
uname(&utsname); if ((caps = virCapabilitiesNew(virArchFromHost(),
0, 0)) == NULL)
if ((caps = virCapabilitiesNew(utsname.machine, 0, 0)) == NULL)
goto no_memory; goto no_memory;
/* Some machines have problematic NUMA toplogy causing /* Some machines have problematic NUMA toplogy causing
@ -323,8 +320,7 @@ phypCapsInit(void)
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"linux", "linux",
utsname.machine, caps->host.arch,
sizeof(int) == 4 ? 32 : 8,
NULL, NULL, 0, NULL)) == NULL) NULL, NULL, 0, NULL)) == NULL)
goto no_memory; goto no_memory;

View File

@ -582,17 +582,20 @@ cleanup:
static char * static char *
qemuCapsFindBinaryForArch(const char *hostarch, qemuCapsFindBinaryForArch(virArch hostarch,
const char *guestarch) virArch guestarch)
{ {
char *ret; char *ret;
if (STREQ(guestarch, "i686")) { /* Some special cases where libvirt's canonical
* guestarch string form can't match qemu's binary
*/
if (guestarch == VIR_ARCH_I686) {
ret = virFindFileInPath("qemu-system-i386"); ret = virFindFileInPath("qemu-system-i386");
if (ret && !virFileIsExecutable(ret)) if (ret && !virFileIsExecutable(ret))
VIR_FREE(ret); VIR_FREE(ret);
if (!ret && STREQ(hostarch, "x86_64")) { if (!ret && hostarch == VIR_ARCH_X86_64) {
ret = virFindFileInPath("qemu-system-x86_64"); ret = virFindFileInPath("qemu-system-x86_64");
if (ret && !virFileIsExecutable(ret)) if (ret && !virFileIsExecutable(ret))
VIR_FREE(ret); VIR_FREE(ret);
@ -600,11 +603,12 @@ qemuCapsFindBinaryForArch(const char *hostarch,
if (!ret) if (!ret)
ret = virFindFileInPath("qemu"); ret = virFindFileInPath("qemu");
} else if (STREQ(guestarch, "itanium")) { } else if (guestarch == VIR_ARCH_ITANIUM) {
ret = virFindFileInPath("qemu-system-ia64"); ret = virFindFileInPath("qemu-system-ia64");
} else { } else {
/* Default case we have matching arch strings */
char *bin; char *bin;
if (virAsprintf(&bin, "qemu-system-%s", guestarch) < 0) { if (virAsprintf(&bin, "qemu-system-%s", virArchToString(guestarch)) < 0) {
virReportOOMError(); virReportOOMError();
return NULL; return NULL;
} }
@ -616,26 +620,15 @@ qemuCapsFindBinaryForArch(const char *hostarch,
return ret; return ret;
} }
static int
qemuCapsGetArchWordSize(const char *guestarch)
{
if (STREQ(guestarch, "i686") ||
STREQ(guestarch, "ppc") ||
STREQ(guestarch, "sparc") ||
STREQ(guestarch, "mips") ||
STREQ(guestarch, "mipsel"))
return 32;
return 64;
}
static bool static bool
qemuCapsIsValidForKVM(const char *hostarch, qemuCapsIsValidForKVM(virArch hostarch,
const char *guestarch) virArch guestarch)
{ {
if (STREQ(hostarch, guestarch)) if (hostarch == guestarch)
return true; return true;
if (STREQ(hostarch, "x86_64") && if (hostarch == VIR_ARCH_X86_64 &&
STREQ(guestarch, "i686")) guestarch == VIR_ARCH_I686)
return true; return true;
return false; return false;
} }
@ -643,8 +636,8 @@ qemuCapsIsValidForKVM(const char *hostarch,
static int static int
qemuCapsInitGuest(virCapsPtr caps, qemuCapsInitGuest(virCapsPtr caps,
qemuCapsCachePtr cache, qemuCapsCachePtr cache,
const char *hostarch, virArch hostarch,
const char *guestarch) virArch guestarch)
{ {
virCapsGuestPtr guest; virCapsGuestPtr guest;
int i; int i;
@ -725,7 +718,6 @@ qemuCapsInitGuest(virCapsPtr caps,
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"hvm", "hvm",
guestarch, guestarch,
qemuCapsGetArchWordSize(guestarch),
binary, binary,
NULL, NULL,
nmachines, nmachines,
@ -783,13 +775,13 @@ qemuCapsInitGuest(virCapsPtr caps,
} }
if ((STREQ(guestarch, "i686") || if (((guestarch == VIR_ARCH_I686) ||
STREQ(guestarch, "x86_64")) && (guestarch == VIR_ARCH_X86_64)) &&
(virCapabilitiesAddGuestFeature(guest, "acpi", 1, 1) == NULL || (virCapabilitiesAddGuestFeature(guest, "acpi", 1, 1) == NULL ||
virCapabilitiesAddGuestFeature(guest, "apic", 1, 0) == NULL)) virCapabilitiesAddGuestFeature(guest, "apic", 1, 0) == NULL))
goto error; goto error;
if (STREQ(guestarch, "i686") && if ((guestarch == VIR_ARCH_I686) &&
(virCapabilitiesAddGuestFeature(guest, "pae", 1, 0) == NULL || (virCapabilitiesAddGuestFeature(guest, "pae", 1, 0) == NULL ||
virCapabilitiesAddGuestFeature(guest, "nonpae", 1, 0) == NULL)) virCapabilitiesAddGuestFeature(guest, "nonpae", 1, 0) == NULL))
goto error; goto error;
@ -813,15 +805,16 @@ error:
static int static int
qemuCapsInitCPU(virCapsPtr caps, qemuCapsInitCPU(virCapsPtr caps,
const char *arch) virArch arch)
{ {
virCPUDefPtr cpu = NULL; virCPUDefPtr cpu = NULL;
union cpuData *data = NULL; union cpuData *data = NULL;
virNodeInfo nodeinfo; virNodeInfo nodeinfo;
int ret = -1; int ret = -1;
const char *archstr = virArchToString(arch);
if (VIR_ALLOC(cpu) < 0 if (VIR_ALLOC(cpu) < 0
|| !(cpu->arch = strdup(arch))) { || !(cpu->arch = strdup(archstr))) {
virReportOOMError(); virReportOOMError();
goto error; goto error;
} }
@ -835,14 +828,14 @@ qemuCapsInitCPU(virCapsPtr caps,
cpu->threads = nodeinfo.threads; cpu->threads = nodeinfo.threads;
caps->host.cpu = cpu; caps->host.cpu = cpu;
if (!(data = cpuNodeData(arch)) if (!(data = cpuNodeData(archstr))
|| cpuDecode(cpu, data, NULL, 0, NULL) < 0) || cpuDecode(cpu, data, NULL, 0, NULL) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
cleanup: cleanup:
cpuDataFree(arch, data); cpuDataFree(archstr, data);
return ret; return ret;
@ -853,9 +846,10 @@ error:
static int qemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int qemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch) virArch arch)
{ {
if (STRPREFIX(arch, "s390")) if (arch == VIR_ARCH_S390 ||
arch == VIR_ARCH_S390X)
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
else else
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
@ -864,21 +858,10 @@ static int qemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virCapsPtr qemuCapsInit(qemuCapsCachePtr cache) virCapsPtr qemuCapsInit(qemuCapsCachePtr cache)
{ {
struct utsname utsname;
virCapsPtr caps; virCapsPtr caps;
int i; int i;
const char *const arches[] = {
"i686", "x86_64", "arm",
"microblaze", "microblazeel",
"mips", "mipsel", "sparc",
"ppc", "ppc64", "itanium",
"s390x"
};
/* Really, this never fails - look at the man-page. */ if ((caps = virCapabilitiesNew(virArchFromHost(),
uname(&utsname);
if ((caps = virCapabilitiesNew(utsname.machine,
1, 1)) == NULL) 1, 1)) == NULL)
goto error; goto error;
@ -894,7 +877,7 @@ virCapsPtr qemuCapsInit(qemuCapsCachePtr cache)
VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities"); VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
} }
if (qemuCapsInitCPU(caps, utsname.machine) < 0) if (qemuCapsInitCPU(caps, virArchFromHost()) < 0)
VIR_WARN("Failed to get host CPU"); VIR_WARN("Failed to get host CPU");
/* Add the power management features of the host */ /* Add the power management features of the host */
@ -905,11 +888,14 @@ virCapsPtr qemuCapsInit(qemuCapsCachePtr cache)
virCapabilitiesAddHostMigrateTransport(caps, virCapabilitiesAddHostMigrateTransport(caps,
"tcp"); "tcp");
/* First the pure HVM guests */ /* QEMU can support pretty much every arch that exists,
for (i = 0 ; i < ARRAY_CARDINALITY(arches) ; i++) * so just probe for them all - we gracefully fail
* if a qemu-system-$ARCH binary can't be found
*/
for (i = 0 ; i < VIR_ARCH_LAST ; i++)
if (qemuCapsInitGuest(caps, cache, if (qemuCapsInitGuest(caps, cache,
utsname.machine, virArchFromHost(),
arches[i]) < 0) i) < 0)
goto error; goto error;
/* QEMU Requires an emulator in the XML */ /* QEMU Requires an emulator in the XML */
@ -1622,7 +1608,6 @@ cleanup:
return ret; return ret;
} }
static void static void
uname_normalize(struct utsname *ut) uname_normalize(struct utsname *ut)
{ {
@ -1637,24 +1622,24 @@ uname_normalize(struct utsname *ut)
ut->machine[1] = '6'; ut->machine[1] = '6';
} }
int qemuCapsGetDefaultVersion(virCapsPtr caps, int qemuCapsGetDefaultVersion(virCapsPtr caps,
qemuCapsCachePtr capsCache, qemuCapsCachePtr capsCache,
unsigned int *version) unsigned int *version)
{ {
const char *binary; const char *binary;
struct utsname ut;
qemuCapsPtr qemucaps; qemuCapsPtr qemucaps;
if (*version > 0) if (*version > 0)
return 0; return 0;
uname_normalize(&ut);
if ((binary = virCapabilitiesDefaultGuestEmulator(caps, if ((binary = virCapabilitiesDefaultGuestEmulator(caps,
"hvm", "hvm",
ut.machine, virArchFromHost(),
"qemu")) == NULL) { "qemu")) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot find suitable emulator for %s"), ut.machine); _("Cannot find suitable emulator for %s"),
virArchToString(virArchFromHost()));
return -1; return -1;
} }

View File

@ -46,7 +46,6 @@
#include "device_conf.h" #include "device_conf.h"
#include "storage_file.h" #include "storage_file.h"
#include <sys/utsname.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
@ -517,7 +516,7 @@ qemuSetScsiControllerModel(virDomainDefPtr def,
return -1; return -1;
} }
} else { } else {
if (STREQ(def->os.arch, "ppc64") && if ((def->os.arch == VIR_ARCH_PPC64) &&
STREQ(def->os.machine, "pseries")) { STREQ(def->os.machine, "pseries")) {
*model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; *model = VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
} else if (qemuCapsGet(caps, QEMU_CAPS_SCSI_LSI)) { } else if (qemuCapsGet(caps, QEMU_CAPS_SCSI_LSI)) {
@ -807,7 +806,8 @@ qemuDomainPrimeS390VirtioDevices(virDomainDefPtr def,
} }
for (i = 0; i < def->nnets ; i++) { for (i = 0; i < def->nnets ; i++) {
if (STRPREFIX(def->os.arch, "s390") && if ((def->os.arch == VIR_ARCH_S390 ||
def->os.arch == VIR_ARCH_S390X) &&
def->nets[i]->model == NULL) { def->nets[i]->model == NULL) {
def->nets[i]->model = strdup("virtio"); def->nets[i]->model = strdup("virtio");
} }
@ -924,7 +924,7 @@ int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
for (i = 0 ; i < def->nserials; i++) { for (i = 0 ; i < def->nserials; i++) {
if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && if (def->serials[i]->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY && def->serials[i]->source.type == VIR_DOMAIN_CHR_TYPE_PTY &&
STREQ(def->os.arch, "ppc64") && (def->os.arch == VIR_ARCH_PPC64) &&
STREQ(def->os.machine, "pseries")) STREQ(def->os.machine, "pseries"))
def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; def->serials[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
if (qemuAssignSpaprVIOAddress(def, &def->serials[i]->info, if (qemuAssignSpaprVIOAddress(def, &def->serials[i]->info,
@ -3011,7 +3011,7 @@ qemuBuildUSBControllerDevStr(virDomainDefPtr domainDef,
model = def->model; model = def->model;
if (model == -1) { if (model == -1) {
if (STREQ(domainDef->os.arch, "ppc64")) if (domainDef->os.arch == VIR_ARCH_PPC64)
model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI; model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI;
else else
model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI; model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
@ -4338,7 +4338,7 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
*hasHwVirt = false; *hasHwVirt = false;
if (STREQ(def->os.arch, "i686")) if (def->os.arch == VIR_ARCH_I686)
default_model = "qemu32"; default_model = "qemu32";
else else
default_model = "qemu64"; default_model = "qemu64";
@ -4450,7 +4450,7 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
* 1. guest OS is i686 * 1. guest OS is i686
* 2. emulator is qemu-system-x86_64 * 2. emulator is qemu-system-x86_64
*/ */
if (STREQ(def->os.arch, "i686") && if (def->os.arch == VIR_ARCH_I686 &&
((hostarch == VIR_ARCH_X86_64 && ((hostarch == VIR_ARCH_X86_64 &&
strstr(emulator, "kvm")) || strstr(emulator, "kvm")) ||
strstr(emulator, "x86_64"))) { strstr(emulator, "x86_64"))) {
@ -6962,13 +6962,13 @@ qemuBuildCommandLine(virConnectPtr conn,
*/ */
char * char *
qemuBuildChrDeviceStr(virDomainChrDefPtr serial, qemuBuildChrDeviceStr(virDomainChrDefPtr serial,
qemuCapsPtr caps, qemuCapsPtr caps,
char *os_arch, virArch arch,
char *machine) char *machine)
{ {
virBuffer cmd = VIR_BUFFER_INITIALIZER; virBuffer cmd = VIR_BUFFER_INITIALIZER;
if (STREQ(os_arch, "ppc64") && STREQ(machine, "pseries")) { if ((arch == VIR_ARCH_PPC64) && STREQ(machine, "pseries")) {
if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && if (serial->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
serial->source.type == VIR_DOMAIN_CHR_TYPE_PTY && serial->source.type == VIR_DOMAIN_CHR_TYPE_PTY &&
serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { serial->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) {
@ -8198,7 +8198,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
} }
} while ((p = next)); } while ((p = next));
if (STREQ(dom->os.arch, "x86_64")) { if (dom->os.arch == VIR_ARCH_X86_64) {
bool is_32bit = false; bool is_32bit = false;
if (cpu) { if (cpu) {
union cpuData *cpuData = NULL; union cpuData *cpuData = NULL;
@ -8216,8 +8216,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
} }
if (is_32bit) { if (is_32bit) {
VIR_FREE(dom->os.arch); dom->os.arch = VIR_ARCH_I686;
dom->os.arch = strdup("i686");
} }
} }
VIR_FREE(model); VIR_FREE(model);
@ -8415,16 +8414,15 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
else else
path = strstr(def->emulator, "qemu"); path = strstr(def->emulator, "qemu");
if (def->virtType == VIR_DOMAIN_VIRT_KVM) if (def->virtType == VIR_DOMAIN_VIRT_KVM)
def->os.arch = strdup(caps->host.cpu->arch); def->os.arch = caps->host.arch;
else if (path && else if (path &&
STRPREFIX(path, "qemu-system-")) STRPREFIX(path, "qemu-system-"))
def->os.arch = strdup(path + strlen("qemu-system-")); def->os.arch = virArchFromString(path + strlen("qemu-system-"));
else else
def->os.arch = strdup("i686"); def->os.arch = VIR_ARCH_I686;
if (!def->os.arch)
goto no_memory;
if (STREQ(def->os.arch, "i686")||STREQ(def->os.arch, "x86_64")) if ((def->os.arch == VIR_ARCH_I686) ||
(def->os.arch == VIR_ARCH_X86_64))
def->features |= (1 << VIR_DOMAIN_FEATURE_ACPI) def->features |= (1 << VIR_DOMAIN_FEATURE_ACPI)
/*| (1 << VIR_DOMAIN_FEATURE_APIC)*/; /*| (1 << VIR_DOMAIN_FEATURE_APIC)*/;
#define WANT_VALUE() \ #define WANT_VALUE() \

View File

@ -65,7 +65,7 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
char * char *
qemuBuildChrDeviceStr (virDomainChrDefPtr serial, qemuBuildChrDeviceStr (virDomainChrDefPtr serial,
qemuCapsPtr caps, qemuCapsPtr caps,
char *os_arch, virArch arch,
char *machine); char *machine);
/* With vlan == -1, use netdev syntax, else old hostnet */ /* With vlan == -1, use netdev syntax, else old hostnet */

View File

@ -33,7 +33,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/utsname.h>
#include "virterror_internal.h" #include "virterror_internal.h"
#include "qemu_conf.h" #include "qemu_conf.h"

View File

@ -34,7 +34,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/utsname.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>

View File

@ -73,7 +73,6 @@ typedef struct {
virCapsPtr caps; /* VM capabilities */ virCapsPtr caps; /* VM capabilities */
char *hvm; /* type of hypervisor (eg hvm, xen) */ char *hvm; /* type of hypervisor (eg hvm, xen) */
char *arch; /* machine architecture */ char *arch; /* machine architecture */
int bits; /* bits in the guest */
char *newfile; /* newly added file */ char *newfile; /* newly added file */
bool append; /* append to .files instead of rewrite */ bool append; /* append to .files instead of rewrite */
} vahControl; } vahControl;
@ -640,7 +639,6 @@ verify_xpath_context(xmlXPathContextPtr ctxt)
* Parse the xml we received to fill in the following: * Parse the xml we received to fill in the following:
* ctl->hvm * ctl->hvm
* ctl->arch * ctl->arch
* ctl->bits
* *
* These are suitable for setting up a virCapsPtr * These are suitable for setting up a virCapsPtr
*/ */
@ -650,6 +648,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
int rc = -1; int rc = -1;
xmlDocPtr xml = NULL; xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
char *arch;
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(domain_definition)"), if (!(xml = virXMLParseStringCtxt(xmlStr, _("(domain_definition)"),
&ctxt))) { &ctxt))) {
@ -670,24 +669,13 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
vah_error(ctl, 0, _("os.type is not 'hvm'")); vah_error(ctl, 0, _("os.type is not 'hvm'"));
goto cleanup; goto cleanup;
} }
ctl->arch = virXPathString("string(./os/type[1]/@arch)", ctxt); arch = virXPathString("string(./os/type[1]/@arch)", ctxt);
if (!ctl->arch) { if (!arch) {
/* The XML we are given should have an arch, but in case it doesn't, ctl->arch = virArchFromHost();
* just use the host's arch. } else {
*/ ctl->arch = virArchFromString(arch);
struct utsname utsname; VIR_FREE(arch);
/* Really, this never fails - look at the man-page. */
uname(&utsname);
if ((ctl->arch = strdup(utsname.machine)) == NULL) {
vah_error(ctl, 0, _("could not allocate memory"));
goto cleanup;
}
} }
if (STREQ(ctl->arch, "x86_64"))
ctl->bits = 64;
else
ctl->bits = 32;
rc = 0; rc = 0;
@ -699,7 +687,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
} }
static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} }
@ -727,7 +715,6 @@ get_definition(vahControl * ctl, const char *xmlStr)
if ((guest = virCapabilitiesAddGuest(ctl->caps, if ((guest = virCapabilitiesAddGuest(ctl->caps,
ctl->hvm, ctl->hvm,
ctl->arch, ctl->arch,
ctl->bits,
NULL, NULL,
NULL, NULL,
0, 0,

View File

@ -150,7 +150,7 @@ static void testDomainObjPrivateFree(void *data)
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} }
@ -163,7 +163,7 @@ testBuildCapabilities(virConnectPtr conn) {
const char *const guest_types[] = { "hvm", "xen" }; const char *const guest_types[] = { "hvm", "xen" };
int i; int i;
if ((caps = virCapabilitiesNew(TEST_MODEL, 0, 0)) == NULL) if ((caps = virCapabilitiesNew(VIR_ARCH_I686, 0, 0)) == NULL)
goto no_memory; goto no_memory;
caps->defaultConsoleTargetType = testDefaultConsoleType; caps->defaultConsoleTargetType = testDefaultConsoleType;
@ -182,8 +182,7 @@ testBuildCapabilities(virConnectPtr conn) {
for (i = 0; i < ARRAY_CARDINALITY(guest_types) ; i++) { for (i = 0; i < ARRAY_CARDINALITY(guest_types) ; i++) {
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
guest_types[i], guest_types[i],
TEST_MODEL, VIR_ARCH_I686,
TEST_MODEL_WORDSIZE,
TEST_EMULATOR, TEST_EMULATOR,
NULL, NULL,
0, 0,

View File

@ -33,7 +33,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/utsname.h>
#include "uml_conf.h" #include "uml_conf.h"
#include "uuid.h" #include "uuid.h"
@ -54,21 +53,17 @@
static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML;
} }
virCapsPtr umlCapsInit(void) { virCapsPtr umlCapsInit(void) {
struct utsname utsname;
virCapsPtr caps; virCapsPtr caps;
virCapsGuestPtr guest; virCapsGuestPtr guest;
/* Really, this never fails - look at the man-page. */ if ((caps = virCapabilitiesNew(virArchFromHost(),
uname(&utsname);
if ((caps = virCapabilitiesNew(utsname.machine,
0, 0)) == NULL) 0, 0)) == NULL)
goto error; goto error;
@ -92,8 +87,7 @@ virCapsPtr umlCapsInit(void) {
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"uml", "uml",
utsname.machine, caps->host.arch,
STREQ(utsname.machine, "x86_64") ? 64 : 32,
NULL, NULL,
NULL, NULL,
0, 0,
@ -412,11 +406,8 @@ virCommandPtr umlBuildCommandLine(virConnectPtr conn,
virDomainObjPtr vm) virDomainObjPtr vm)
{ {
int i, j; int i, j;
struct utsname ut;
virCommandPtr cmd; virCommandPtr cmd;
uname(&ut);
cmd = virCommandNew(vm->def->os.kernel); cmd = virCommandNew(vm->def->os.kernel);
virCommandAddEnvPassCommon(cmd); virCommandAddEnvPassCommon(cmd);

View File

@ -34,7 +34,6 @@
#include <config.h> #include <config.h>
#include <sys/utsname.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -823,20 +822,18 @@ cleanup:
static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} }
static virCapsPtr vboxCapsInit(void) { static virCapsPtr vboxCapsInit(void)
struct utsname utsname; {
virCapsPtr caps; virCapsPtr caps;
virCapsGuestPtr guest; virCapsGuestPtr guest;
uname(&utsname); if ((caps = virCapabilitiesNew(virArchFromHost(),
if ((caps = virCapabilitiesNew(utsname.machine,
0, 0)) == NULL) 0, 0)) == NULL)
goto no_memory; goto no_memory;
@ -847,8 +844,7 @@ static virCapsPtr vboxCapsInit(void) {
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"hvm", "hvm",
utsname.machine, caps->host.arch,
sizeof(void *) * CHAR_BIT,
NULL, NULL,
NULL, NULL,
0, 0,
@ -2230,7 +2226,6 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
machine->vtbl->GetAccessible(machine, &accessible); machine->vtbl->GetAccessible(machine, &accessible);
if (accessible) { if (accessible) {
int i = 0; int i = 0;
struct utsname utsname;
PRBool PAEEnabled = PR_FALSE; PRBool PAEEnabled = PR_FALSE;
PRBool ACPIEnabled = PR_FALSE; PRBool ACPIEnabled = PR_FALSE;
PRBool IOAPICEnabled = PR_FALSE; PRBool IOAPICEnabled = PR_FALSE;
@ -2312,8 +2307,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
def->os.type = strdup("hvm"); def->os.type = strdup("hvm");
uname(&utsname); def->os.arch = virArchFromHost();
def->os.arch = strdup(utsname.machine);
def->os.nBootDevs = 0; def->os.nBootDevs = 0;
for (i = 0; (i < VIR_DOMAIN_BOOT_LAST) && (i < maxBootPosition); i++) { for (i = 0; (i < VIR_DOMAIN_BOOT_LAST) && (i < maxBootPosition); i++) {
@ -3785,7 +3779,7 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data,
int i = 0; int i = 0;
VIR_DEBUG("def->os.type %s", def->os.type); VIR_DEBUG("def->os.type %s", def->os.type);
VIR_DEBUG("def->os.arch %s", def->os.arch); VIR_DEBUG("def->os.arch %s", virArchToString(def->os.arch));
VIR_DEBUG("def->os.machine %s", def->os.machine); VIR_DEBUG("def->os.machine %s", def->os.machine);
VIR_DEBUG("def->os.nBootDevs %zu", def->os.nBootDevs); VIR_DEBUG("def->os.nBootDevs %zu", def->os.nBootDevs);
VIR_DEBUG("def->os.bootDevs[0] %d", def->os.bootDevs[0]); VIR_DEBUG("def->os.bootDevs[0] %d", def->os.bootDevs[0]);

View File

@ -22,7 +22,6 @@
#include <config.h> #include <config.h>
#include <string.h> #include <string.h>
#include <sys/utsname.h>
#include "command.h" #include "command.h"
#include "cpu/cpu.h" #include "cpu/cpu.h"
@ -51,7 +50,7 @@ vmwareFreeDriver(struct vmware_driver *driver)
static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
} }
@ -60,15 +59,14 @@ static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
virCapsPtr virCapsPtr
vmwareCapsInit(void) vmwareCapsInit(void)
{ {
struct utsname utsname;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
virCapsGuestPtr guest = NULL; virCapsGuestPtr guest = NULL;
virCPUDefPtr cpu = NULL; virCPUDefPtr cpu = NULL;
union cpuData *data = NULL; union cpuData *data = NULL;
const char *hostarch = NULL;
uname(&utsname); if ((caps = virCapabilitiesNew(virArchFromHost(),
0, 0)) == NULL)
if ((caps = virCapabilitiesNew(utsname.machine, 0, 0)) == NULL)
goto error; goto error;
if (nodeCapsInitNUMA(caps) < 0) if (nodeCapsInitNUMA(caps) < 0)
@ -79,8 +77,7 @@ vmwareCapsInit(void)
/* i686 guests are always supported */ /* i686 guests are always supported */
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"hvm", "hvm",
"i686", VIR_ARCH_I686,
32,
NULL, NULL, 0, NULL)) == NULL) NULL, NULL, 0, NULL)) == NULL)
goto error; goto error;
@ -89,12 +86,16 @@ vmwareCapsInit(void)
NULL, NULL, 0, NULL) == NULL) NULL, NULL, 0, NULL) == NULL)
goto error; goto error;
if (VIR_ALLOC(cpu) < 0 if (VIR_ALLOC(cpu) < 0) {
|| !(cpu->arch = strdup(utsname.machine))) {
virReportOOMError(); virReportOOMError();
goto error; goto error;
} }
hostarch = virArchToString(caps->host.arch);
if (!(cpu->arch = strdup(hostarch))) {
virReportOOMError();
goto error;
}
cpu->type = VIR_CPU_TYPE_HOST; cpu->type = VIR_CPU_TYPE_HOST;
if (!(data = cpuNodeData(cpu->arch)) if (!(data = cpuNodeData(cpu->arch))
@ -107,15 +108,14 @@ vmwareCapsInit(void)
* Or * Or
* - Host CPU is x86_64 with virtualization extensions * - Host CPU is x86_64 with virtualization extensions
*/ */
if (STREQ(utsname.machine, "x86_64") || if (caps->host.arch == VIR_ARCH_X86_64 ||
(cpuHasFeature(utsname.machine, data, "lm") && (cpuHasFeature(hostarch, data, "lm") &&
(cpuHasFeature(utsname.machine, data, "vmx") || (cpuHasFeature(hostarch, data, "vmx") ||
cpuHasFeature(utsname.machine, data, "svm")))) { cpuHasFeature(hostarch, data, "svm")))) {
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
"hvm", "hvm",
"x86_64", VIR_ARCH_X86_64,
64,
NULL, NULL, 0, NULL)) == NULL) NULL, NULL, 0, NULL)) == NULL)
goto error; goto error;
@ -129,7 +129,7 @@ vmwareCapsInit(void)
cleanup: cleanup:
virCPUDefFree(cpu); virCPUDefFree(cpu);
cpuDataFree(utsname.machine, data); cpuDataFree(hostarch, data);
return caps; return caps;

View File

@ -1522,14 +1522,9 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
} }
if (guestOS != NULL && virFileHasSuffix(guestOS, "-64")) { if (guestOS != NULL && virFileHasSuffix(guestOS, "-64")) {
def->os.arch = strdup("x86_64"); def->os.arch = VIR_ARCH_X86_64;
} else { } else {
def->os.arch = strdup("i686"); def->os.arch = VIR_ARCH_I686;
}
if (def->os.arch == NULL) {
virReportOOMError();
goto cleanup;
} }
/* vmx:smbios.reflecthost -> def:os.smbios_mode */ /* vmx:smbios.reflecthost -> def:os.smbios_mode */
@ -3069,14 +3064,15 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
virtualHW_version); virtualHW_version);
/* def:os.arch -> vmx:guestOS */ /* def:os.arch -> vmx:guestOS */
if (def->os.arch == NULL || STRCASEEQ(def->os.arch, "i686")) { if (def->os.arch == VIR_ARCH_I686) {
virBufferAddLit(&buffer, "guestOS = \"other\"\n"); virBufferAddLit(&buffer, "guestOS = \"other\"\n");
} else if (STRCASEEQ(def->os.arch, "x86_64")) { } else if (def->os.arch == VIR_ARCH_X86_64) {
virBufferAddLit(&buffer, "guestOS = \"other-64\"\n"); virBufferAddLit(&buffer, "guestOS = \"other-64\"\n");
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML attribute 'arch' of entry 'os/type' " _("Expecting domain XML attribute 'arch' of entry 'os/type' "
"to be 'i686' or 'x86_64' but found '%s'"), def->os.arch); "to be 'i686' or 'x86_64' but found '%s'"),
virArchToString(def->os.arch));
goto cleanup; goto cleanup;
} }

View File

@ -36,7 +36,6 @@
#include <stdint.h> #include <stdint.h>
#include <regex.h> #include <regex.h>
#include <errno.h> #include <errno.h>
#include <sys/utsname.h>
#ifdef __sun #ifdef __sun
# include <sys/systeminfo.h> # include <sys/systeminfo.h>
@ -2292,8 +2291,7 @@ xenHypervisorGetVersion(virConnectPtr conn, unsigned long *hvVer)
} }
struct guest_arch { struct guest_arch {
const char *model; virArch arch;
int bits;
int hvm; int hvm;
int pae; int pae;
int nonpae; int nonpae;
@ -2302,7 +2300,7 @@ struct guest_arch {
static int xenDefaultConsoleType(const char *ostype, static int xenDefaultConsoleType(const char *ostype,
const char *arch ATTRIBUTE_UNUSED) virArch arch ATTRIBUTE_UNUSED)
{ {
if (STREQ(ostype, "hvm")) if (STREQ(ostype, "hvm"))
return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
@ -2312,7 +2310,7 @@ static int xenDefaultConsoleType(const char *ostype,
static virCapsPtr static virCapsPtr
xenHypervisorBuildCapabilities(virConnectPtr conn, xenHypervisorBuildCapabilities(virConnectPtr conn,
const char *hostmachine, virArch hostarch,
int host_pae, int host_pae,
const char *hvm_type, const char *hvm_type,
struct guest_arch *guest_archs, struct guest_arch *guest_archs,
@ -2322,7 +2320,7 @@ xenHypervisorBuildCapabilities(virConnectPtr conn,
int hv_major = hv_versions.hv >> 16; int hv_major = hv_versions.hv >> 16;
int hv_minor = hv_versions.hv & 0xFFFF; int hv_minor = hv_versions.hv & 0xFFFF;
if ((caps = virCapabilitiesNew(hostmachine, 1, 1)) == NULL) if ((caps = virCapabilitiesNew(hostarch, 1, 1)) == NULL)
goto no_memory; goto no_memory;
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x16, 0x3e }); virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x16, 0x3e });
@ -2357,9 +2355,8 @@ xenHypervisorBuildCapabilities(virConnectPtr conn,
if ((guest = virCapabilitiesAddGuest(caps, if ((guest = virCapabilitiesAddGuest(caps,
guest_archs[i].hvm ? "hvm" : "xen", guest_archs[i].hvm ? "hvm" : "xen",
guest_archs[i].model, guest_archs[i].arch,
guest_archs[i].bits, (hostarch == VIR_ARCH_X86_64 ?
(STREQ(hostmachine, "x86_64") ?
"/usr/lib64/xen/bin/qemu-dm" : "/usr/lib64/xen/bin/qemu-dm" :
"/usr/lib/xen/bin/qemu-dm"), "/usr/lib/xen/bin/qemu-dm"),
(guest_archs[i].hvm ? (guest_archs[i].hvm ?
@ -2505,18 +2502,13 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
struct guest_arch guest_arches[32]; struct guest_arch guest_arches[32];
int i = 0; int i = 0;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
struct utsname utsname;
int pae, longmode; int pae, longmode;
const char *hvm; const char *hvm;
if (!get_cpu_flags(conn, &hvm, &pae, &longmode)) if (!get_cpu_flags(conn, &hvm, &pae, &longmode))
return NULL; return NULL;
/* Really, this never fails - look at the man-page. */ guest_arches[i].arch = VIR_ARCH_I686;
uname(&utsname);
guest_arches[i].model = "i686";
guest_arches[i].bits = 32;
guest_arches[i].hvm = 0; guest_arches[i].hvm = 0;
guest_arches[i].pae = pae; guest_arches[i].pae = pae;
guest_arches[i].nonpae = !pae; guest_arches[i].nonpae = !pae;
@ -2524,8 +2516,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
i++; i++;
if (longmode) { if (longmode) {
guest_arches[i].model = "x86_64"; guest_arches[i].arch = VIR_ARCH_X86_64;
guest_arches[i].bits = 64;
guest_arches[i].hvm = 0; guest_arches[i].hvm = 0;
guest_arches[i].pae = 0; guest_arches[i].pae = 0;
guest_arches[i].nonpae = 0; guest_arches[i].nonpae = 0;
@ -2534,8 +2525,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
} }
if (hvm[0] != '\0') { if (hvm[0] != '\0') {
guest_arches[i].model = "i686"; guest_arches[i].arch = VIR_ARCH_I686;
guest_arches[i].bits = 32;
guest_arches[i].hvm = 1; guest_arches[i].hvm = 1;
guest_arches[i].pae = pae; guest_arches[i].pae = pae;
guest_arches[i].nonpae = 1; guest_arches[i].nonpae = 1;
@ -2543,8 +2533,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
i++; i++;
if (longmode) { if (longmode) {
guest_arches[i].model = "x86_64"; guest_arches[i].arch = VIR_ARCH_X86_64;
guest_arches[i].bits = 64;
guest_arches[i].hvm = 1; guest_arches[i].hvm = 1;
guest_arches[i].pae = 0; guest_arches[i].pae = 0;
guest_arches[i].nonpae = 0; guest_arches[i].nonpae = 0;
@ -2554,7 +2543,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
} }
if ((caps = xenHypervisorBuildCapabilities(conn, if ((caps = xenHypervisorBuildCapabilities(conn,
utsname.machine, virArchFromHost(),
pae, hvm, pae, hvm,
guest_arches, i)) == NULL) guest_arches, i)) == NULL)
virReportOOMError(); virReportOOMError();
@ -2574,7 +2563,7 @@ xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
*/ */
virCapsPtr virCapsPtr
xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn, xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
const char *hostmachine, virArch hostarch,
FILE *cpuinfo, FILE *capabilities) FILE *cpuinfo, FILE *capabilities)
{ {
char line[1024], *str, *token; char line[1024], *str, *token;
@ -2645,12 +2634,11 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
if (regexec(&xen_cap_rec, token, sizeof(subs) / sizeof(subs[0]), if (regexec(&xen_cap_rec, token, sizeof(subs) / sizeof(subs[0]),
subs, 0) == 0) { subs, 0) == 0) {
int hvm = STRPREFIX(&token[subs[1].rm_so], "hvm"); int hvm = STRPREFIX(&token[subs[1].rm_so], "hvm");
const char *model; int pae = 0, nonpae = 0, ia64_be = 0;
int bits, pae = 0, nonpae = 0, ia64_be = 0; virArch arch;
if (STRPREFIX(&token[subs[2].rm_so], "x86_32")) { if (STRPREFIX(&token[subs[2].rm_so], "x86_32")) {
model = "i686"; arch = VIR_ARCH_I686;
bits = 32;
if (subs[3].rm_so != -1 && if (subs[3].rm_so != -1 &&
STRPREFIX(&token[subs[3].rm_so], "p")) STRPREFIX(&token[subs[3].rm_so], "p"))
pae = 1; pae = 1;
@ -2658,27 +2646,24 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
nonpae = 1; nonpae = 1;
} }
else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) { else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) {
model = "x86_64"; arch = VIR_ARCH_X86_64;
bits = 64;
} }
else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) { else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) {
model = "ia64"; arch = VIR_ARCH_ITANIUM;
bits = 64;
if (subs[3].rm_so != -1 && if (subs[3].rm_so != -1 &&
STRPREFIX(&token[subs[3].rm_so], "be")) STRPREFIX(&token[subs[3].rm_so], "be"))
ia64_be = 1; ia64_be = 1;
} }
else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64")) { else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64")) {
model = "ppc64"; arch = VIR_ARCH_PPC64;
bits = 64;
} else { } else {
/* XXX surely no other Xen archs exist */ /* XXX surely no other Xen archs exist. Arrrrrrrrrm */
continue; continue;
} }
/* Search for existing matching (model,hvm) tuple */ /* Search for existing matching (model,hvm) tuple */
for (i = 0 ; i < nr_guest_archs ; i++) { for (i = 0 ; i < nr_guest_archs ; i++) {
if (STREQ(guest_archs[i].model, model) && if (guest_archs[i].arch == arch &&
guest_archs[i].hvm == hvm) { guest_archs[i].hvm == hvm) {
break; break;
} }
@ -2691,8 +2676,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
if (i == nr_guest_archs) if (i == nr_guest_archs)
nr_guest_archs++; nr_guest_archs++;
guest_archs[i].model = model; guest_archs[i].arch = arch;
guest_archs[i].bits = bits;
guest_archs[i].hvm = hvm; guest_archs[i].hvm = hvm;
/* Careful not to overwrite a previous positive /* Careful not to overwrite a previous positive
@ -2710,7 +2694,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
} }
if ((caps = xenHypervisorBuildCapabilities(conn, if ((caps = xenHypervisorBuildCapabilities(conn,
hostmachine, hostarch,
host_pae, host_pae,
hvm_type, hvm_type,
guest_archs, guest_archs,
@ -2738,10 +2722,6 @@ xenHypervisorMakeCapabilities(virConnectPtr conn)
#else #else
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
FILE *cpuinfo, *capabilities; FILE *cpuinfo, *capabilities;
struct utsname utsname;
/* Really, this never fails - look at the man-page. */
uname(&utsname);
cpuinfo = fopen("/proc/cpuinfo", "r"); cpuinfo = fopen("/proc/cpuinfo", "r");
if (cpuinfo == NULL) { if (cpuinfo == NULL) {
@ -2765,7 +2745,7 @@ xenHypervisorMakeCapabilities(virConnectPtr conn)
} }
caps = xenHypervisorMakeCapabilitiesInternal(conn, caps = xenHypervisorMakeCapabilitiesInternal(conn,
utsname.machine, virArchFromHost(),
cpuinfo, cpuinfo,
capabilities); capabilities);
if (caps == NULL) if (caps == NULL)

View File

@ -62,7 +62,7 @@ int xenHypervisorGetVersion (virConnectPtr conn,
unsigned long *hvVer); unsigned long *hvVer);
virCapsPtr virCapsPtr
xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn, xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
const char *hostmachine, virArch hostarch,
FILE *cpuinfo, FILE *cpuinfo,
FILE *capabilities); FILE *capabilities);
char * char *

View File

@ -263,7 +263,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virDomainGraphicsDefPtr graphics = NULL; virDomainGraphicsDefPtr graphics = NULL;
virDomainHostdevDefPtr hostdev = NULL; virDomainHostdevDefPtr hostdev = NULL;
int i; int i;
const char *defaultArch, *defaultMachine; const char *defaultMachine;
int vmlocaltime = 0; int vmlocaltime = 0;
unsigned long count; unsigned long count;
char *script = NULL; char *script = NULL;
@ -290,15 +290,16 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (!(def->os.type = strdup(hvm ? "hvm" : "xen"))) if (!(def->os.type = strdup(hvm ? "hvm" : "xen")))
goto no_memory; goto no_memory;
defaultArch = virCapabilitiesDefaultGuestArch(caps, def->os.type, virDomainVirtTypeToString(def->virtType)); def->os.arch =
if (defaultArch == NULL) { virCapabilitiesDefaultGuestArch(caps,
def->os.type,
virDomainVirtTypeToString(def->virtType));
if (!def->os.arch) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("no supported architecture for os type '%s'"), _("no supported architecture for os type '%s'"),
def->os.type); def->os.type);
goto cleanup; goto cleanup;
} }
if (!(def->os.arch = strdup(defaultArch)))
goto no_memory;
defaultMachine = virCapabilitiesDefaultGuestMachine(caps, defaultMachine = virCapabilitiesDefaultGuestMachine(caps,
def->os.type, def->os.type,