On Wed, Jul 18, 2012 at 19:40:45 +0100, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Update the libxl driver to use virReportError instead of
the libxlError custom macro
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
cfg.mk | 1 -
src/libxl/libxl_conf.c | 42 ++--
src/libxl/libxl_conf.h | 4 -
src/libxl/libxl_driver.c | 614 +++++++++++++++++++++++-----------------------
4 files changed, 328 insertions(+), 333 deletions(-)
ACK
The following patch is worth applying while we are changing all the error
messages:
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index d3ce733..28966cd 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -397,7 +397,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config
*d_config)
* only 32 can be represented.
*/
if (def->maxvcpus > 32 || def->vcpus > 32) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("This version of libxenlight only supports 32 "
"vcpus per domain"));
return -1;
@@ -917,13 +917,13 @@ libxlMakeCapabilities(libxl_ctx *ctx)
regcomp (&xen_cap_rec, xen_cap_re, REG_EXTENDED);
if (libxl_get_physinfo(ctx, &phy_info) != 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to get node physical info from
libxenlight"));
return NULL;
}
if ((ver_info = libxl_get_version_info(ctx)) == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to get version info from libxenlight"));
return NULL;
}
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 0e39484..edf5c33 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -168,13 +168,13 @@ libxlDoNodeGetInfo(libxlDriverPrivatePtr driver, virNodeInfoPtr
info)
struct utsname utsname;
if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxl_get_physinfo_info failed"));
return -1;
}
if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxl_get_version_info failed"));
return -1;
}
@@ -696,7 +696,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
if (libxl_userdata_store(&priv->ctx, domid, "libvirt-xml",
(uint8_t *)dom_xml, strlen(dom_xml) + 1)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("libxenlight failed to store userdata"));
goto error;
}
@@ -1851,13 +1851,13 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr
vm,
hdr.xmlLen = xml_len;
if (safewrite(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to write save file header"));
goto cleanup;
}
if (safewrite(fd, xml, xml_len) != xml_len) {
- virReportError(VIR_ERR_OPERATION_FAILED,
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to write xml description"));
goto cleanup;
}
@@ -2250,7 +2250,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
if (!nvcpus) {
- virReportError(VIR_ERR_INVALID_ARG, _("nvcpus is zero"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("nvcpus is
zero"));
return -1;
}
@@ -2813,7 +2813,7 @@ libxlDomainUndefineFlags(virDomainPtr dom,
if (virFileExists(name)) {
if (flags & VIR_DOMAIN_UNDEFINE_MANAGED_SAVE) {
if (unlink(name) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to remove domain managed save
image"));
goto cleanup;
}
@@ -3179,7 +3179,7 @@ libxlDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
virDomainDeviceDefPtr dev)
}
orig = vmdef->disks[i];
if (!(orig->device == VIR_DOMAIN_DISK_DEVICE_CDROM)) {
- virReportError(VIR_ERR_INVALID_ARG,
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("this disk doesn't support update"));
goto cleanup;
}
@@ -3378,12 +3378,14 @@ libxlNodeGetFreeMemory(virConnectPtr conn)
libxlDriverPrivatePtr driver = conn->privateData;
if (libxl_get_physinfo(&driver->ctx, &phy_info)) {
- virReportError(VIR_ERR_INTERNAL_ERROR, _("libxl_get_physinfo_info
failed"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libxl_get_physinfo_info failed"));
return 0;
}
if ((ver_info = libxl_get_version_info(&driver->ctx)) == NULL) {
- virReportError(VIR_ERR_INTERNAL_ERROR, _("libxl_get_version_info
failed"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libxl_get_version_info failed"));
return 0;
}
@@ -3621,7 +3623,7 @@ libxlDomainGetSchedulerParametersFlags(virDomainPtr dom,
}
if (sched_id != XEN_SCHEDULER_CREDIT) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only 'credit' scheduler is supported"));
goto cleanup;
}
@@ -3707,7 +3709,7 @@ libxlDomainSetSchedulerParametersFlags(virDomainPtr dom,
}
if (sched_id != XEN_SCHEDULER_CREDIT) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Only 'credit' scheduler is supported"));
goto cleanup;
}
--
1.7.11.1