提交 cb78198a 编写于 作者: D Daniel P. Berrange

Replace use of vmwareError with virReportError

Update the VMWare driver to use virReportError instead of
the vmwareError custom macro
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 e578bc26
......@@ -543,7 +543,6 @@ msg_gen_function += virSecurityReportError
msg_gen_function += virXenInotifyError
msg_gen_function += virXenStoreError
msg_gen_function += virXendError
msg_gen_function += vmwareError
msg_gen_function += xenapiSessionErrorHandler
msg_gen_function += xenUnifiedError
msg_gen_function += xenXMError
......
......@@ -252,14 +252,14 @@ vmwareExtractVersion(struct vmware_driver *driver)
goto cleanup;
if ((tmp = STRSKIP(outbuf, pattern)) == NULL) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("failed to parse %s version"), bin);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to parse %s version"), bin);
goto cleanup;
}
if (virParseVersionString(tmp, &version, false) < 0) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("version parsing error"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("version parsing error"));
goto cleanup;
}
......@@ -303,8 +303,8 @@ vmwareParsePath(char *path, char **directory, char **filename)
*separator++ = '\0';
if (*separator == '\0') {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("path '%s' doesn't reference a file"), path);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("path '%s' doesn't reference a file"), path);
return -1;
}
......@@ -361,9 +361,9 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath)
* isn't perfect but should work in the majority of cases.
*/
if (vmdef->ndisks < 1) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Domain XML doesn't contain any disks, "
"cannot deduce datastore and path for VMX file"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Domain XML doesn't contain any disks, "
"cannot deduce datastore and path for VMX file"));
goto cleanup;
}
......@@ -376,16 +376,16 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath)
}
if (disk == NULL) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Domain XML doesn't contain any file-based harddisks, "
"cannot deduce datastore and path for VMX file"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Domain XML doesn't contain any file-based harddisks, "
"cannot deduce datastore and path for VMX file"));
goto cleanup;
}
if (disk->src == NULL) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("First file-based harddisk has no source, cannot "
"deduce datastore and path for VMX file"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("First file-based harddisk has no source, cannot "
"deduce datastore and path for VMX file"));
goto cleanup;
}
......@@ -394,9 +394,9 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath)
}
if (!virFileHasSuffix(fileName, ".vmdk")) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("Expecting source '%s' of first file-based harddisk "
"to be a VMDK image"), disk->src);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expecting source '%s' of first file-based harddisk "
"to be a VMDK image"), disk->src);
goto cleanup;
}
......@@ -420,8 +420,8 @@ vmwareMoveFile(char *srcFile, char *dstFile)
{ "mv", PROGRAM_SENTINAL, PROGRAM_SENTINAL, NULL };
if (!virFileExists(srcFile)) {
vmwareError(VIR_ERR_INTERNAL_ERROR, _("file %s does not exist"),
srcFile);
virReportError(VIR_ERR_INTERNAL_ERROR, _("file %s does not exist"),
srcFile);
return -1;
}
......@@ -431,8 +431,8 @@ vmwareMoveFile(char *srcFile, char *dstFile)
vmwareSetSentinal(cmdmv, srcFile);
vmwareSetSentinal(cmdmv, dstFile);
if (virRun(cmdmv, NULL) < 0) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("failed to move file to %s "), dstFile);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to move file to %s "), dstFile);
return -1;
}
......@@ -472,14 +472,14 @@ vmwareExtractPid(const char * vmxPath)
goto cleanup;
if (!fgets(line, sizeof(line), logFile)) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unable to read vmware log file"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unable to read vmware log file"));
goto cleanup;
}
if ((tmp = strstr(line, " pid=")) == NULL) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot find pid in vmware log file"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot find pid in vmware log file"));
goto cleanup;
}
......@@ -488,8 +488,8 @@ vmwareExtractPid(const char * vmxPath)
/* Although 64-bit windows allows 64-bit pid_t, a domain id has to be
* 32 bits. For now, we just reject pid values that overflow int. */
if (virStrToLong_i(tmp, &tmp, 10, &pid_value) < 0 || *tmp != ' ') {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot parse pid in vmware log file"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot parse pid in vmware log file"));
goto cleanup;
}
......
......@@ -30,10 +30,6 @@
# define VIR_FROM_THIS VIR_FROM_VMWARE
# define PROGRAM_SENTINAL ((char *)0x1)
# define vmwareError(code, ...) \
virReportErrorHelper(VIR_FROM_VMWARE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
# define TYPE_PLAYER 0
# define TYPE_WORKSTATION 1
......
......@@ -98,9 +98,9 @@ vmwareOpen(virConnectPtr conn,
/* If path isn't /session, then they typoed, so tell them correct path */
if (conn->uri->path == NULL || STRNEQ(conn->uri->path, "/session")) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("unexpected VMware URI path '%s', try vmwareplayer:///session or vmwarews:///session"),
NULLSTR(conn->uri->path));
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected VMware URI path '%s', try vmwareplayer:///session or vmwarews:///session"),
NULLSTR(conn->uri->path));
return VIR_DRV_OPEN_ERROR;
}
}
......@@ -111,8 +111,8 @@ vmwareOpen(virConnectPtr conn,
vmrun = virFindFileInPath(VMRUN);
if (vmrun == NULL) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("%s utility is missing"), VMRUN);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s utility is missing"), VMRUN);
return VIR_DRV_OPEN_ERROR;
} else {
VIR_FREE(vmrun);
......@@ -273,8 +273,8 @@ vmwareStartVM(struct vmware_driver *driver, virDomainObjPtr vm)
const char *vmxPath = ((vmwareDomainPtr) vm->privateData)->vmxPath;
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_SHUTOFF) {
vmwareError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not in shutoff state"));
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not in shutoff state"));
return -1;
}
......@@ -334,8 +334,8 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
/* create vmx file */
if (virFileWriteStr(vmxPath, vmx, S_IRUSR|S_IWUSR) < 0) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("Failed to write vmx file '%s'"), vmxPath);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to write vmx file '%s'"), vmxPath);
goto cleanup;
}
......@@ -386,8 +386,8 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -395,8 +395,8 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
goto cleanup;
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
}
......@@ -435,9 +435,9 @@ vmwareDomainSuspend(virDomainPtr dom)
int ret = -1;
if (driver->type == TYPE_PLAYER) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vmplayer does not support libvirt suspend/resume"
" (vmware pause/unpause) operation "));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vmplayer does not support libvirt suspend/resume"
" (vmware pause/unpause) operation "));
return ret;
}
......@@ -446,16 +446,16 @@ vmwareDomainSuspend(virDomainPtr dom)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
vmwareSetSentinal(cmd, vmw_types[driver->type]);
vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
}
......@@ -484,9 +484,9 @@ vmwareDomainResume(virDomainPtr dom)
int ret = -1;
if (driver->type == TYPE_PLAYER) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vmplayer does not support libvirt suspend/resume"
"(vmware pause/unpause) operation "));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vmplayer does not support libvirt suspend/resume"
"(vmware pause/unpause) operation "));
return ret;
}
......@@ -495,16 +495,16 @@ vmwareDomainResume(virDomainPtr dom)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
vmwareSetSentinal(cmd, vmw_types[driver->type]);
vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in suspend state"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in suspend state"));
goto cleanup;
}
......@@ -539,8 +539,8 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -552,8 +552,8 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
goto cleanup;
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
}
......@@ -605,8 +605,8 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
/* create vmx file */
if (virFileWriteStr(vmxPath, vmx, S_IRUSR|S_IWUSR) < 0) {
vmwareError(VIR_ERR_INTERNAL_ERROR,
_("Failed to write vmx file '%s'"), vmxPath);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to write vmx file '%s'"), vmxPath);
goto cleanup;
}
......@@ -656,8 +656,8 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
vmwareError(VIR_ERR_NO_DOMAIN,
_("No domain with matching uuid '%s'"), uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
_("No domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
......@@ -665,8 +665,8 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
goto cleanup;
if (virDomainObjIsActive(vm)) {
vmwareError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is already running"));
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is already running"));
goto cleanup;
}
......@@ -702,14 +702,14 @@ vmwareDomainUndefineFlags(virDomainPtr dom,
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
vmwareError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
virReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
if (!vm->persistent) {
vmwareError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot undefine transient domain"));
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot undefine transient domain"));
goto cleanup;
}
......@@ -750,7 +750,7 @@ vmwareDomainLookupByID(virConnectPtr conn, int id)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -776,7 +776,7 @@ vmwareGetOSType(virDomainPtr dom)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -802,7 +802,7 @@ vmwareDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -828,7 +828,7 @@ vmwareDomainLookupByName(virConnectPtr conn, const char *name)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
......@@ -853,7 +853,7 @@ vmwareDomainIsActive(virDomainPtr dom)
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
vmwareDriverUnlock(driver);
if (!obj) {
vmwareError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
ret = virDomainObjIsActive(obj);
......@@ -876,7 +876,7 @@ vmwareDomainIsPersistent(virDomainPtr dom)
obj = virDomainFindByUUID(&driver->domains, dom->uuid);
vmwareDriverUnlock(driver);
if (!obj) {
vmwareError(VIR_ERR_NO_DOMAIN, NULL);
virReportError(VIR_ERR_NO_DOMAIN, NULL);
goto cleanup;
}
ret = obj->persistent;
......@@ -902,8 +902,8 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -928,8 +928,8 @@ vmwareDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
virCheckFlags(0, NULL);
if (STRNEQ(nativeFormat, "vmware-vmx")) {
vmwareError(VIR_ERR_INVALID_ARG,
_("Unsupported config format '%s'"), nativeFormat);
virReportError(VIR_ERR_INVALID_ARG,
_("Unsupported config format '%s'"), nativeFormat);
return NULL;
}
......@@ -1029,8 +1029,8 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......@@ -1067,8 +1067,8 @@ vmwareDomainGetState(virDomainPtr dom,
vmwareDriverUnlock(driver);
if (!vm) {
vmwareError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
virReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册