From 97230f6a351a73b4d330f917e344a613117e7fdf Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 24 Mar 2009 11:16:29 +0000 Subject: [PATCH] Default to native arch, and check domain type when auto-filling guest arch (Soren Hansen) --- ChangeLog | 7 +++++++ src/capabilities.c | 22 +++++++++++++++++----- src/capabilities.h | 3 ++- src/domain_conf.c | 2 +- src/xm_internal.c | 2 +- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28516954ef..f1a420cfe0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Mar 24 11:14:22 GMT 2009 Daniel P. Berrange + + * src/capabilities.c, file src/capabilities.h, + src/domain_conf.c, src/xm_internal.c: Prefer native arch + when auto-filling guest architecture. Match on domain type + when auto-filling architecture (Soren Hansen) + Tue Mar 24 10:51:22 GMT 2009 Daniel P. Berrange * src/Makefile.maint: Include 'CHECK: ' prefix when printing diff --git a/src/capabilities.c b/src/capabilities.c index fb21d875ae..d6e3478f93 100644 --- a/src/capabilities.c +++ b/src/capabilities.c @@ -468,14 +468,26 @@ virCapabilitiesSupportsGuestArch(virCapsPtr caps, */ extern const char * virCapabilitiesDefaultGuestArch(virCapsPtr caps, - const char *ostype) + const char *ostype, + const char *domain) { - int i; + int i, j; + const char *arch = NULL; for (i = 0 ; i < caps->nguests ; i++) { - if (STREQ(caps->guests[i]->ostype, ostype)) - return caps->guests[i]->arch.name; + 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)) { + /* Use the first match... */ + if (!arch) + 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 NULL; + return arch; } /** diff --git a/src/capabilities.h b/src/capabilities.h index db3229129b..5b0bbabbbf 100644 --- a/src/capabilities.h +++ b/src/capabilities.h @@ -177,7 +177,8 @@ virCapabilitiesSupportsGuestArch(virCapsPtr caps, extern const char * virCapabilitiesDefaultGuestArch(virCapsPtr caps, - const char *ostype); + const char *ostype, + const char *domain); extern const char * virCapabilitiesDefaultGuestMachine(virCapsPtr caps, const char *ostype, diff --git a/src/domain_conf.c b/src/domain_conf.c index 5bf34837f4..269644983f 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -2146,7 +2146,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn, goto error; } } else { - const char *defaultArch = virCapabilitiesDefaultGuestArch(caps, def->os.type); + const char *defaultArch = virCapabilitiesDefaultGuestArch(caps, def->os.type, virDomainVirtTypeToString(def->virtType)); if (defaultArch == NULL) { virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"), diff --git a/src/xm_internal.c b/src/xm_internal.c index 3a96058d72..8519391966 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -695,7 +695,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) { if (!(def->os.type = strdup(hvm ? "hvm" : "xen"))) goto no_memory; - defaultArch = virCapabilitiesDefaultGuestArch(priv->caps, def->os.type); + defaultArch = virCapabilitiesDefaultGuestArch(priv->caps, def->os.type, virDomainVirtTypeToString(def->virtType)); if (defaultArch == NULL) { xenXMError(conn, VIR_ERR_INTERNAL_ERROR, _("no supported architecture for os type '%s'"),