mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-09 12:38:27 -05:00
Misc fixes uncovered by OOM testing
This commit is contained in:
+4
-20
@@ -28,31 +28,15 @@
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
#define virLibConnError(conn, code, fmt...) \
|
||||
virReportErrorHelper(conn, VIR_FROM_THIS, code, __FILE__, \
|
||||
__FUNCTION__, __LINE__, fmt)
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Domain and Connections allocations *
|
||||
* *
|
||||
************************************************************************/
|
||||
/**
|
||||
* virLibConnError:
|
||||
* @conn: the connection if available
|
||||
* @error: the error number
|
||||
* @info: extra information string
|
||||
*
|
||||
* Handle an error at the connection level
|
||||
*/
|
||||
static void
|
||||
virLibConnError(virConnectPtr conn, virErrorNumber error, const char *info)
|
||||
{
|
||||
const char *errmsg;
|
||||
|
||||
if (error == VIR_ERR_OK)
|
||||
return;
|
||||
|
||||
errmsg = virErrorMsg(error, info);
|
||||
virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
|
||||
errmsg, info, NULL, 0, 0, errmsg, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* virDomainFreeName:
|
||||
|
||||
+5
-2
@@ -2068,7 +2068,10 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
|
||||
VIR_FREE(tmp);
|
||||
}
|
||||
|
||||
if ((n = virXPathNodeSet(conn, "./features/*", ctxt, &nodes)) > 0) {
|
||||
n = virXPathNodeSet(conn, "./features/*", ctxt, &nodes);
|
||||
if (n < 0)
|
||||
goto error;
|
||||
if (n) {
|
||||
for (i = 0 ; i < n ; i++) {
|
||||
int val = virDomainFeatureTypeFromString((const char *)nodes[i]->name);
|
||||
if (val < 0) {
|
||||
@@ -2079,8 +2082,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
|
||||
}
|
||||
def->features |= (1 << val);
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if (virDomainLifecycleParseXML(conn, ctxt, "string(./on_reboot[1])",
|
||||
&def->onReboot, VIR_DOMAIN_LIFECYCLE_RESTART) < 0)
|
||||
|
||||
+8
-8
@@ -74,8 +74,8 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
|
||||
buf++;
|
||||
if (*buf != ':') {
|
||||
virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR,
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"parsing cpuinfo processor");
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"%s", _("parsing cpuinfo processor"));
|
||||
return -1;
|
||||
}
|
||||
nodeinfo->cpus++;
|
||||
@@ -87,8 +87,8 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
|
||||
buf++;
|
||||
if (*buf != ':' || !buf[1]) {
|
||||
virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR,
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"parsing cpuinfo cpu MHz");
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"%s", _("parsing cpuinfo cpu MHz"));
|
||||
return -1;
|
||||
}
|
||||
if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
|
||||
@@ -103,8 +103,8 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
|
||||
buf++;
|
||||
if (*buf != ':' || !buf[1]) {
|
||||
virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR,
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"parsing cpuinfo cpu cores %c", *buf);
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"parsing cpuinfo cpu cores %c", *buf);
|
||||
return -1;
|
||||
}
|
||||
if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
|
||||
@@ -116,8 +116,8 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
|
||||
|
||||
if (!nodeinfo->cpus) {
|
||||
virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR,
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"no cpus found");
|
||||
VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
|
||||
"%s", _("no cpus found"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -5538,6 +5538,11 @@ xenDaemonFormatSxpr(virConnectPtr conn,
|
||||
|
||||
virBufferAddLit(&buf, ")"); /* closes (vm */
|
||||
|
||||
if (virBufferError(&buf)) {
|
||||
virReportOOMError(conn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return virBufferContentAndReset(&buf);
|
||||
|
||||
error:
|
||||
|
||||
Reference in New Issue
Block a user