Remove virConnectPtr from CPU XML APIs

The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in cpu_conf.{h,c} and update all callers to
match
This commit is contained in:
Daniel P. Berrange 2010-02-10 12:22:36 +00:00
parent 031366383a
commit f430ddb624
10 changed files with 91 additions and 114 deletions

View File

@ -678,7 +678,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
virBufferAddLit(&xml, " </features>\n"); virBufferAddLit(&xml, " </features>\n");
} }
virCPUDefFormatBuf(NULL, &xml, caps->host.cpu, " ", virCPUDefFormatBuf(&xml, caps->host.cpu, " ",
VIR_CPU_FORMAT_EMBEDED); VIR_CPU_FORMAT_EMBEDED);
virBufferAddLit(&xml, " </cpu>\n"); virBufferAddLit(&xml, " </cpu>\n");

View File

@ -31,9 +31,9 @@
#define VIR_FROM_THIS VIR_FROM_CPU #define VIR_FROM_THIS VIR_FROM_CPU
#define virCPUReportError(conn, code, fmt...) \ #define virCPUReportError(code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_CPU, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_CPU, code, __FILE__, \
__FUNCTION__, __LINE__, fmt) __FUNCTION__, __LINE__, fmt)
VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST, VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST,
"minimum", "minimum",
@ -69,8 +69,7 @@ virCPUDefFree(virCPUDefPtr def)
#ifndef PROXY #ifndef PROXY
virCPUDefPtr virCPUDefPtr
virCPUDefParseXML(virConnectPtr conn, virCPUDefParseXML(const xmlNodePtr node,
const xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
enum virCPUType mode) enum virCPUType mode)
{ {
@ -97,7 +96,7 @@ virCPUDefParseXML(virConnectPtr conn,
if (!match) { if (!match) {
if (virXPathBoolean("boolean(./model)", ctxt)) { if (virXPathBoolean("boolean(./model)", ctxt)) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing match attribute for CPU specification")); "%s", _("Missing match attribute for CPU specification"));
goto error; goto error;
} }
@ -107,7 +106,7 @@ virCPUDefParseXML(virConnectPtr conn,
VIR_FREE(match); VIR_FREE(match);
if (def->match < 0) { if (def->match < 0) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid match attribute for CPU specification")); "%s", _("Invalid match attribute for CPU specification"));
goto error; goto error;
} }
@ -117,7 +116,7 @@ virCPUDefParseXML(virConnectPtr conn,
if (def->type == VIR_CPU_TYPE_HOST) { if (def->type == VIR_CPU_TYPE_HOST) {
def->arch = virXPathString("string(./arch[1])", ctxt); def->arch = virXPathString("string(./arch[1])", ctxt);
if (!def->arch) { if (!def->arch) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU architecture")); "%s", _("Missing CPU architecture"));
goto error; goto error;
} }
@ -125,7 +124,7 @@ virCPUDefParseXML(virConnectPtr conn,
if (!(def->model = virXPathString("string(./model[1])", ctxt)) && if (!(def->model = virXPathString("string(./model[1])", ctxt)) &&
def->type == VIR_CPU_TYPE_HOST) { def->type == VIR_CPU_TYPE_HOST) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU model name")); "%s", _("Missing CPU model name"));
goto error; goto error;
} }
@ -137,7 +136,7 @@ virCPUDefParseXML(virConnectPtr conn,
ret = virXPathULong("string(./topology[1]/@sockets)", ret = virXPathULong("string(./topology[1]/@sockets)",
ctxt, &ul); ctxt, &ul);
if (ret < 0) { if (ret < 0) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing 'sockets' attribute in CPU topology")); "%s", _("Missing 'sockets' attribute in CPU topology"));
goto error; goto error;
} }
@ -146,7 +145,7 @@ virCPUDefParseXML(virConnectPtr conn,
ret = virXPathULong("string(./topology[1]/@cores)", ret = virXPathULong("string(./topology[1]/@cores)",
ctxt, &ul); ctxt, &ul);
if (ret < 0) { if (ret < 0) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing 'cores' attribute in CPU topology")); "%s", _("Missing 'cores' attribute in CPU topology"));
goto error; goto error;
} }
@ -155,14 +154,14 @@ virCPUDefParseXML(virConnectPtr conn,
ret = virXPathULong("string(./topology[1]/@threads)", ret = virXPathULong("string(./topology[1]/@threads)",
ctxt, &ul); ctxt, &ul);
if (ret < 0) { if (ret < 0) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing 'threads' attribute in CPU topology")); "%s", _("Missing 'threads' attribute in CPU topology"));
goto error; goto error;
} }
def->threads = (unsigned int) ul; def->threads = (unsigned int) ul;
if (!def->sockets || !def->cores || !def->threads) { if (!def->sockets || !def->cores || !def->threads) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid CPU topology")); "%s", _("Invalid CPU topology"));
goto error; goto error;
} }
@ -174,7 +173,7 @@ virCPUDefParseXML(virConnectPtr conn,
if (n > 0) { if (n > 0) {
if (!def->model) { if (!def->model) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Non-empty feature list specified without CPU model")); "%s", _("Non-empty feature list specified without CPU model"));
goto error; goto error;
} }
@ -197,7 +196,7 @@ virCPUDefParseXML(virConnectPtr conn,
VIR_FREE(strpolicy); VIR_FREE(strpolicy);
if (policy < 0) { if (policy < 0) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid CPU feature policy")); "%s", _("Invalid CPU feature policy"));
goto error; goto error;
} }
@ -207,14 +206,14 @@ virCPUDefParseXML(virConnectPtr conn,
if (!(name = virXMLPropString(nodes[i], "name")) || *name == 0) { if (!(name = virXMLPropString(nodes[i], "name")) || *name == 0) {
VIR_FREE(name); VIR_FREE(name);
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid CPU feature name")); "%s", _("Invalid CPU feature name"));
goto error; goto error;
} }
for (j = 0 ; j < i ; j++) { for (j = 0 ; j < i ; j++) {
if (STREQ(name, def->features[j].name)) { if (STREQ(name, def->features[j].name)) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU feature `%s' specified more than once"), _("CPU feature `%s' specified more than once"),
name); name);
VIR_FREE(name); VIR_FREE(name);
@ -243,14 +242,13 @@ error:
char * char *
virCPUDefFormat(virConnectPtr conn, virCPUDefFormat(virCPUDefPtr def,
virCPUDefPtr def,
const char *indent, const char *indent,
int flags) int flags)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
if (virCPUDefFormatBuf(conn, &buf, def, indent, flags) < 0) if (virCPUDefFormatBuf(&buf, def, indent, flags) < 0)
goto cleanup; goto cleanup;
if (virBufferError(&buf)) if (virBufferError(&buf))
@ -267,8 +265,7 @@ cleanup:
int int
virCPUDefFormatBuf(virConnectPtr conn, virCPUDefFormatBuf(virBufferPtr buf,
virBufferPtr buf,
virCPUDefPtr def, virCPUDefPtr def,
const char *indent, const char *indent,
int flags) int flags)
@ -282,7 +279,7 @@ virCPUDefFormatBuf(virConnectPtr conn,
indent = ""; indent = "";
if (!def->model && def->nfeatures) { if (!def->model && def->nfeatures) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Non-empty feature list specified without CPU model")); "%s", _("Non-empty feature list specified without CPU model"));
return -1; return -1;
} }
@ -291,7 +288,7 @@ virCPUDefFormatBuf(virConnectPtr conn,
if (def->type == VIR_CPU_TYPE_GUEST && def->model) { if (def->type == VIR_CPU_TYPE_GUEST && def->model) {
const char *match; const char *match;
if (!(match = virCPUMatchTypeToString(def->match))) { if (!(match = virCPUMatchTypeToString(def->match))) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected CPU match policy %d"), def->match); _("Unexpected CPU match policy %d"), def->match);
return -1; return -1;
} }
@ -320,7 +317,7 @@ virCPUDefFormatBuf(virConnectPtr conn,
virCPUFeatureDefPtr feature = def->features + i; virCPUFeatureDefPtr feature = def->features + i;
if (!feature->name) { if (!feature->name) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU feature name")); "%s", _("Missing CPU feature name"));
return -1; return -1;
} }
@ -330,7 +327,7 @@ virCPUDefFormatBuf(virConnectPtr conn,
policy = virCPUFeaturePolicyTypeToString(feature->policy); policy = virCPUFeaturePolicyTypeToString(feature->policy);
if (!policy) { if (!policy) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected CPU feature policy %d"), feature->policy); _("Unexpected CPU feature policy %d"), feature->policy);
return -1; return -1;
} }
@ -351,8 +348,7 @@ virCPUDefFormatBuf(virConnectPtr conn,
int int
virCPUDefAddFeature(virConnectPtr conn, virCPUDefAddFeature(virCPUDefPtr def,
virCPUDefPtr def,
const char *name, const char *name,
int policy) int policy)
{ {
@ -360,7 +356,7 @@ virCPUDefAddFeature(virConnectPtr conn,
for (i = 0 ; i < def->nfeatures ; i++) { for (i = 0 ; i < def->nfeatures ; i++) {
if (STREQ(name, def->features[i].name)) { if (STREQ(name, def->features[i].name)) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU feature `%s' specified more than once"), name); _("CPU feature `%s' specified more than once"), name);
return -1; return -1;
} }

View File

@ -85,8 +85,7 @@ virCPUDefFree(virCPUDefPtr def);
#ifndef PROXY #ifndef PROXY
virCPUDefPtr virCPUDefPtr
virCPUDefParseXML(virConnectPtr conn, virCPUDefParseXML(const xmlNodePtr node,
const xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
enum virCPUType mode); enum virCPUType mode);
#endif #endif
@ -98,21 +97,18 @@ enum virCPUFormatFlags {
char * char *
virCPUDefFormat(virConnectPtr conn, virCPUDefFormat(virCPUDefPtr def,
virCPUDefPtr def,
const char *indent, const char *indent,
int flags); int flags);
int int
virCPUDefFormatBuf(virConnectPtr conn, virCPUDefFormatBuf(virBufferPtr buf,
virBufferPtr buf,
virCPUDefPtr def, virCPUDefPtr def,
const char *indent, const char *indent,
int flags); int flags);
int int
virCPUDefAddFeature(virConnectPtr conn, virCPUDefAddFeature(virCPUDefPtr cpu,
virCPUDefPtr cpu,
const char *name, const char *name,
int policy); int policy);

View File

@ -3928,7 +3928,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
if ((node = virXPathNode("./cpu[1]", ctxt)) != NULL) { if ((node = virXPathNode("./cpu[1]", ctxt)) != NULL) {
xmlNodePtr oldnode = ctxt->node; xmlNodePtr oldnode = ctxt->node;
ctxt->node = node; ctxt->node = node;
def->cpu = virCPUDefParseXML(NULL, node, ctxt, VIR_CPU_TYPE_GUEST); def->cpu = virCPUDefParseXML(node, ctxt, VIR_CPU_TYPE_GUEST);
ctxt->node = oldnode; ctxt->node = oldnode;
if (def->cpu == NULL) if (def->cpu == NULL)
@ -5341,7 +5341,7 @@ char *virDomainDefFormat(virDomainDefPtr def,
virBufferAddLit(&buf, " </features>\n"); virBufferAddLit(&buf, " </features>\n");
} }
if (virCPUDefFormatBuf(NULL, &buf, def->cpu, " ", 0) < 0) if (virCPUDefFormatBuf(&buf, def->cpu, " ", 0) < 0)
goto cleanup; goto cleanup;
virBufferVSprintf(&buf, " <clock offset='%s'/>\n", virBufferVSprintf(&buf, " <clock offset='%s'/>\n",

View File

@ -40,14 +40,13 @@ static struct cpuArchDriver *drivers[] = {
static struct cpuArchDriver * static struct cpuArchDriver *
cpuGetSubDriver(virConnectPtr conn, cpuGetSubDriver(const char *arch)
const char *arch)
{ {
unsigned int i; unsigned int i;
unsigned int j; unsigned int j;
if (arch == NULL) { if (arch == NULL) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("undefined hardware architecture")); "%s", _("undefined hardware architecture"));
return NULL; return NULL;
} }
@ -65,8 +64,7 @@ cpuGetSubDriver(virConnectPtr conn,
virCPUCompareResult virCPUCompareResult
cpuCompareXML(virConnectPtr conn, cpuCompareXML(virCPUDefPtr host,
virCPUDefPtr host,
const char *xml) const char *xml)
{ {
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
@ -83,11 +81,11 @@ cpuCompareXML(virConnectPtr conn,
ctxt->node = xmlDocGetRootElement(doc); ctxt->node = xmlDocGetRootElement(doc);
cpu = virCPUDefParseXML(conn, ctxt->node, ctxt, VIR_CPU_TYPE_AUTO); cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO);
if (cpu == NULL) if (cpu == NULL)
goto cleanup; goto cleanup;
ret = cpuCompare(conn, host, cpu); ret = cpuCompare(host, cpu);
cleanup: cleanup:
virCPUDefFree(cpu); virCPUDefFree(cpu);
@ -99,17 +97,16 @@ cleanup:
virCPUCompareResult virCPUCompareResult
cpuCompare(virConnectPtr conn, cpuCompare(virCPUDefPtr host,
virCPUDefPtr host,
virCPUDefPtr cpu) virCPUDefPtr cpu)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
if ((driver = cpuGetSubDriver(conn, host->arch)) == NULL) if ((driver = cpuGetSubDriver(host->arch)) == NULL)
return VIR_CPU_COMPARE_ERROR; return VIR_CPU_COMPARE_ERROR;
if (driver->compare == NULL) { if (driver->compare == NULL) {
virCPUReportError(conn, VIR_ERR_NO_SUPPORT, virCPUReportError(VIR_ERR_NO_SUPPORT,
_("cannot compare CPUs of %s architecture"), _("cannot compare CPUs of %s architecture"),
host->arch); host->arch);
return VIR_CPU_COMPARE_ERROR; return VIR_CPU_COMPARE_ERROR;
@ -120,8 +117,7 @@ cpuCompare(virConnectPtr conn,
int int
cpuDecode(virConnectPtr conn, cpuDecode(virCPUDefPtr cpu,
virCPUDefPtr cpu,
const union cpuData *data, const union cpuData *data,
unsigned int nmodels, unsigned int nmodels,
const char **models) const char **models)
@ -129,22 +125,22 @@ cpuDecode(virConnectPtr conn,
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
if (models == NULL && nmodels != 0) { if (models == NULL && nmodels != 0) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("nonzero nmodels doesn't match with NULL models")); "%s", _("nonzero nmodels doesn't match with NULL models"));
return -1; return -1;
} }
if (cpu == NULL) { if (cpu == NULL) {
virCPUReportError(conn, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("invalid CPU definition")); "%s", _("invalid CPU definition"));
return -1; return -1;
} }
if ((driver = cpuGetSubDriver(conn, cpu->arch)) == NULL) if ((driver = cpuGetSubDriver(cpu->arch)) == NULL)
return -1; return -1;
if (driver->decode == NULL) { if (driver->decode == NULL) {
virCPUReportError(conn, VIR_ERR_NO_SUPPORT, virCPUReportError(VIR_ERR_NO_SUPPORT,
_("cannot decode CPU data for %s architecture"), _("cannot decode CPU data for %s architecture"),
cpu->arch); cpu->arch);
return -1; return -1;
@ -155,8 +151,7 @@ cpuDecode(virConnectPtr conn,
int int
cpuEncode(virConnectPtr conn, cpuEncode(const char *arch,
const char *arch,
const virCPUDefPtr cpu, const virCPUDefPtr cpu,
union cpuData **forced, union cpuData **forced,
union cpuData **required, union cpuData **required,
@ -166,11 +161,11 @@ cpuEncode(virConnectPtr conn,
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
if ((driver = cpuGetSubDriver(conn, arch)) == NULL) if ((driver = cpuGetSubDriver(arch)) == NULL)
return -1; return -1;
if (driver->encode == NULL) { if (driver->encode == NULL) {
virCPUReportError(conn, VIR_ERR_NO_SUPPORT, virCPUReportError(VIR_ERR_NO_SUPPORT,
_("cannot encode CPU data for %s architecture"), _("cannot encode CPU data for %s architecture"),
arch); arch);
return -1; return -1;
@ -182,8 +177,7 @@ cpuEncode(virConnectPtr conn,
void void
cpuDataFree(virConnectPtr conn, cpuDataFree(const char *arch,
const char *arch,
union cpuData *data) union cpuData *data)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
@ -191,11 +185,11 @@ cpuDataFree(virConnectPtr conn,
if (data == NULL) if (data == NULL)
return; return;
if ((driver = cpuGetSubDriver(conn, arch)) == NULL) if ((driver = cpuGetSubDriver(arch)) == NULL)
return; return;
if (driver->free == NULL) { if (driver->free == NULL) {
virCPUReportError(conn, VIR_ERR_NO_SUPPORT, virCPUReportError(VIR_ERR_NO_SUPPORT,
_("cannot free CPU data for %s architecture"), _("cannot free CPU data for %s architecture"),
arch); arch);
return; return;
@ -206,16 +200,15 @@ cpuDataFree(virConnectPtr conn,
union cpuData * union cpuData *
cpuNodeData(virConnectPtr conn, cpuNodeData(const char *arch)
const char *arch)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
if ((driver = cpuGetSubDriver(conn, arch)) == NULL) if ((driver = cpuGetSubDriver(arch)) == NULL)
return NULL; return NULL;
if (driver->nodeData == NULL) { if (driver->nodeData == NULL) {
virCPUReportError(conn, VIR_ERR_NO_SUPPORT, virCPUReportError(VIR_ERR_NO_SUPPORT,
_("cannot get node CPU data for %s architecture"), _("cannot get node CPU data for %s architecture"),
arch); arch);
return NULL; return NULL;
@ -226,18 +219,17 @@ cpuNodeData(virConnectPtr conn,
virCPUCompareResult virCPUCompareResult
cpuGuestData(virConnectPtr conn, cpuGuestData(virCPUDefPtr host,
virCPUDefPtr host,
virCPUDefPtr guest, virCPUDefPtr guest,
union cpuData **data) union cpuData **data)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
if ((driver = cpuGetSubDriver(conn, host->arch)) == NULL) if ((driver = cpuGetSubDriver(host->arch)) == NULL)
return VIR_CPU_COMPARE_ERROR; return VIR_CPU_COMPARE_ERROR;
if (driver->guestData == NULL) { if (driver->guestData == NULL) {
virCPUReportError(conn, VIR_ERR_NO_SUPPORT, virCPUReportError(VIR_ERR_NO_SUPPORT,
_("cannot compute guest CPU data for %s architecture"), _("cannot compute guest CPU data for %s architecture"),
host->arch); host->arch);
return VIR_CPU_COMPARE_ERROR; return VIR_CPU_COMPARE_ERROR;

View File

@ -30,9 +30,9 @@
#include "cpu_x86_data.h" #include "cpu_x86_data.h"
#define virCPUReportError(conn, code, fmt...) \ #define virCPUReportError(code, fmt...) \
virReportErrorHelper(conn, VIR_FROM_CPU, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_CPU, code, __FILE__, \
__FUNCTION__, __LINE__, fmt) __FUNCTION__, __LINE__, fmt)
union cpuData { union cpuData {
@ -85,25 +85,21 @@ struct cpuArchDriver {
extern virCPUCompareResult extern virCPUCompareResult
cpuCompareXML(virConnectPtr conn, cpuCompareXML(virCPUDefPtr host,
virCPUDefPtr host,
const char *xml); const char *xml);
extern virCPUCompareResult extern virCPUCompareResult
cpuCompare (virConnectPtr conn, cpuCompare (virCPUDefPtr host,
virCPUDefPtr host,
virCPUDefPtr cpu); virCPUDefPtr cpu);
extern int extern int
cpuDecode (virConnectPtr conn, cpuDecode (virCPUDefPtr cpu,
virCPUDefPtr cpu,
const union cpuData *data, const union cpuData *data,
unsigned int nmodels, unsigned int nmodels,
const char **models); const char **models);
extern int extern int
cpuEncode (virConnectPtr conn, cpuEncode (const char *arch,
const char *arch,
const virCPUDefPtr cpu, const virCPUDefPtr cpu,
union cpuData **forced, union cpuData **forced,
union cpuData **required, union cpuData **required,
@ -112,17 +108,14 @@ cpuEncode (virConnectPtr conn,
union cpuData **forbidden); union cpuData **forbidden);
extern void extern void
cpuDataFree (virConnectPtr conn, cpuDataFree (const char *arch,
const char *arch,
union cpuData *data); union cpuData *data);
extern union cpuData * extern union cpuData *
cpuNodeData (virConnectPtr conn, cpuNodeData (const char *arch);
const char *arch);
extern virCPUCompareResult extern virCPUCompareResult
cpuGuestData(virConnectPtr conn, cpuGuestData(virCPUDefPtr host,
virCPUDefPtr host,
virCPUDefPtr guest, virCPUDefPtr guest,
union cpuData **data); union cpuData **data);

View File

@ -78,13 +78,13 @@ int cpuMapLoad(const char *arch,
int ret = -1; int ret = -1;
if (arch == NULL) { if (arch == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("undefined hardware architecture")); "%s", _("undefined hardware architecture"));
return -1; return -1;
} }
if ((xml = xmlParseFile(CPUMAPFILE)) == NULL) { if ((xml = xmlParseFile(CPUMAPFILE)) == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse CPU map file: %s"), _("cannot parse CPU map file: %s"),
CPUMAPFILE); CPUMAPFILE);
goto cleanup; goto cleanup;
@ -102,14 +102,14 @@ int cpuMapLoad(const char *arch,
ctxt->node = xmlDocGetRootElement(xml); ctxt->node = xmlDocGetRootElement(xml);
if ((ctxt->node = virXPathNode(xpath, ctxt)) == NULL) { if ((ctxt->node = virXPathNode(xpath, ctxt)) == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find CPU map for %s architecture"), arch); _("cannot find CPU map for %s architecture"), arch);
goto cleanup; goto cleanup;
} }
if ((feature_cb && load(ctxt, "feature", feature_cb, feature_data) < 0) || if ((feature_cb && load(ctxt, "feature", feature_cb, feature_data) < 0) ||
(model_cb && load(ctxt, "model", model_cb, model_data) < 0)) { (model_cb && load(ctxt, "model", model_cb, model_data) < 0)) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse CPU map for %s architecture"), arch); _("cannot parse CPU map for %s architecture"), arch);
goto cleanup; goto cleanup;
} }

View File

@ -265,7 +265,7 @@ x86DataToCPU(const union cpuData *data,
if ((cpuid = x86DataCpuid(tmp, feature->cpuid[i].function)) if ((cpuid = x86DataCpuid(tmp, feature->cpuid[i].function))
&& x86cpuidMatchMasked(cpuid, feature->cpuid + i)) { && x86cpuidMatchMasked(cpuid, feature->cpuid + i)) {
x86cpuidClearBits(cpuid, feature->cpuid + i); x86cpuidClearBits(cpuid, feature->cpuid + i);
if (virCPUDefAddFeature(NULL, cpu, feature->name, if (virCPUDefAddFeature(cpu, feature->name,
VIR_CPU_FEATURE_REQUIRE) < 0) VIR_CPU_FEATURE_REQUIRE) < 0)
goto error; goto error;
} }
@ -334,13 +334,13 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
feature->name = virXPathString("string(@name)", ctxt); feature->name = virXPathString("string(@name)", ctxt);
if (feature->name == NULL) { if (feature->name == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU feature name")); "%s", _("Missing CPU feature name"));
goto ignore; goto ignore;
} }
if (x86FeatureFind(map, feature->name)) { if (x86FeatureFind(map, feature->name)) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU feature %s already defined"), feature->name); _("CPU feature %s already defined"), feature->name);
goto ignore; goto ignore;
} }
@ -370,7 +370,7 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
if (ret_fun < 0 || ret_eax == -2 || ret_ebx == -2 if (ret_fun < 0 || ret_eax == -2 || ret_ebx == -2
|| ret_ecx == -2 || ret_edx == -2) { || ret_ecx == -2 || ret_edx == -2) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid cpuid[%d] in %s feature"), i, feature->name); _("Invalid cpuid[%d] in %s feature"), i, feature->name);
goto ignore; goto ignore;
} }
@ -539,7 +539,7 @@ x86ModelFromCPU(const virCPUDefPtr cpu,
if (cpu->type == VIR_CPU_TYPE_HOST if (cpu->type == VIR_CPU_TYPE_HOST
|| policy == VIR_CPU_FEATURE_REQUIRE) { || policy == VIR_CPU_FEATURE_REQUIRE) {
if ((model = x86ModelFind(map, cpu->model)) == NULL) { if ((model = x86ModelFind(map, cpu->model)) == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown CPU model %s"), cpu->model); _("Unknown CPU model %s"), cpu->model);
goto error; goto error;
} }
@ -558,7 +558,7 @@ x86ModelFromCPU(const virCPUDefPtr cpu,
continue; continue;
if ((feature = x86FeatureFind(map, cpu->features[i].name)) == NULL) { if ((feature = x86FeatureFind(map, cpu->features[i].name)) == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown CPU feature %s"), cpu->features[i].name); _("Unknown CPU feature %s"), cpu->features[i].name);
goto error; goto error;
} }
@ -647,7 +647,7 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
model->name = virXPathString("string(@name)", ctxt); model->name = virXPathString("string(@name)", ctxt);
if (model->name == NULL) { if (model->name == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing CPU model name")); "%s", _("Missing CPU model name"));
goto ignore; goto ignore;
} }
@ -658,14 +658,14 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
name = virXPathString("string(./model/@name)", ctxt); name = virXPathString("string(./model/@name)", ctxt);
if (name == NULL) { if (name == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing ancestor's name in CPU model %s"), _("Missing ancestor's name in CPU model %s"),
model->name); model->name);
goto ignore; goto ignore;
} }
if ((ancestor = x86ModelFind(map, name)) == NULL) { if ((ancestor = x86ModelFind(map, name)) == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Ancestor model %s not found for CPU model %s"), _("Ancestor model %s not found for CPU model %s"),
name, model->name); name, model->name);
VIR_FREE(name); VIR_FREE(name);
@ -691,13 +691,13 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
char *name; char *name;
if ((name = virXMLPropString(nodes[i], "name")) == NULL) { if ((name = virXMLPropString(nodes[i], "name")) == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing feature name for CPU model %s"), model->name); _("Missing feature name for CPU model %s"), model->name);
goto ignore; goto ignore;
} }
if ((feature = x86FeatureFind(map, name)) == NULL) { if ((feature = x86FeatureFind(map, name)) == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
_("Feature %s required by CPU model %s not found"), _("Feature %s required by CPU model %s not found"),
name, model->name); name, model->name);
VIR_FREE(name); VIR_FREE(name);
@ -993,7 +993,7 @@ x86Decode(virCPUDefPtr cpu,
} }
if (cpuModel == NULL) { if (cpuModel == NULL) {
virCPUReportError(NULL, VIR_ERR_INTERNAL_ERROR, virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Cannot find suitable CPU model for given data")); "%s", _("Cannot find suitable CPU model for given data"));
goto out; goto out;
} }

View File

@ -1015,8 +1015,8 @@ qemudCapsInitCPU(virCapsPtr caps,
cpu->cores = nodeinfo.cores; cpu->cores = nodeinfo.cores;
cpu->threads = nodeinfo.threads; cpu->threads = nodeinfo.threads;
if (!(data = cpuNodeData(NULL, arch)) if (!(data = cpuNodeData(arch))
|| cpuDecode(NULL, cpu, data, 0, NULL) < 0) || cpuDecode(cpu, data, 0, NULL) < 0)
goto error; goto error;
caps->host.cpu = cpu; caps->host.cpu = cpu;
@ -1024,7 +1024,7 @@ qemudCapsInitCPU(virCapsPtr caps,
ret = 0; ret = 0;
cleanup: cleanup:
cpuDataFree(NULL, arch, data); cpuDataFree(arch, data);
return ret; return ret;
@ -2943,7 +2943,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
if (ncpus > 0 && host) { if (ncpus > 0 && host) {
virCPUCompareResult cmp; virCPUCompareResult cmp;
cmp = cpuGuestData(NULL, host, def->cpu, &data); cmp = cpuGuestData(host, def->cpu, &data);
switch (cmp) { switch (cmp) {
case VIR_CPU_COMPARE_INCOMPATIBLE: case VIR_CPU_COMPARE_INCOMPATIBLE:
qemuReportError(VIR_ERR_INTERNAL_ERROR, qemuReportError(VIR_ERR_INTERNAL_ERROR,
@ -2959,7 +2959,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(ut->machine))) if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(ut->machine)))
goto no_memory; goto no_memory;
if (cpuDecode(NULL, guest, data, ncpus, cpus) < 0) if (cpuDecode(guest, data, ncpus, cpus) < 0)
goto cleanup; goto cleanup;
virBufferVSprintf(&buf, "%s", guest->model); virBufferVSprintf(&buf, "%s", guest->model);
@ -2995,7 +2995,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
cleanup: cleanup:
virCPUDefFree(guest); virCPUDefFree(guest);
cpuDataFree(NULL, ut->machine, data); cpuDataFree(ut->machine, data);
if (cpus) { if (cpus) {
for (i = 0; i < ncpus; i++) for (i = 0; i < ncpus; i++)
@ -5026,7 +5026,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
else else
feature = strdup(p); feature = strdup(p);
ret = virCPUDefAddFeature(NULL, cpu, feature, policy); ret = virCPUDefAddFeature(cpu, feature, policy);
VIR_FREE(feature); VIR_FREE(feature);
if (ret < 0) if (ret < 0)
goto error; goto error;

View File

@ -8495,7 +8495,7 @@ qemuCPUCompare(virConnectPtr conn,
"%s", _("cannot get host CPU capabilities")); "%s", _("cannot get host CPU capabilities"));
} }
else else
ret = cpuCompareXML(conn, driver->caps->host.cpu, xmlDesc); ret = cpuCompareXML(driver->caps->host.cpu, xmlDesc);
qemuDriverUnlock(driver); qemuDriverUnlock(driver);