Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/vmware/vmware_conf.c | 9 +++--
src/vmware/vmware_driver.c | 69 ++++++++++++++++----------------------
2 files changed, 32 insertions(+), 46 deletions(-)
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index fd62bb96f7..8bea9c3b12 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -436,8 +436,7 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath)
int
vmwareMoveFile(char *srcFile, char *dstFile)
{
- const char *cmdmv[] =
- { "mv", PROGRAM_SENTINEL, PROGRAM_SENTINEL, NULL };
+ g_autoptr(virCommand) cmd = NULL;
if (!virFileExists(srcFile)) {
virReportError(VIR_ERR_INTERNAL_ERROR, _("file %s does not exist"),
@@ -448,9 +447,9 @@ vmwareMoveFile(char *srcFile, char *dstFile)
if (STREQ(srcFile, dstFile))
return 0;
- vmwareSetSentinal(cmdmv, srcFile);
- vmwareSetSentinal(cmdmv, dstFile);
- if (virRun(cmdmv, NULL) < 0) {
+ cmd = virCommandNewArgList("mv", srcFile, dstFile, NULL);
+
+ if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to move file to %s "), dstFile);
return -1;
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index d5dd6e4f5e..5b4057a8f6 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -347,15 +347,12 @@ vmwareStopVM(struct vmware_driver *driver,
virDomainObjPtr vm,
virDomainShutoffReason reason)
{
- const char *cmd[] = {
- driver->vmrun, "-T", PROGRAM_SENTINEL, "stop",
- PROGRAM_SENTINEL, "soft", NULL
- };
+ g_autoptr(virCommand) cmd = virCommandNew(driver->vmrun);
- vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type));
- vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
+ virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type),
+ "stop", ((vmwareDomainPtr) vm->privateData)->vmxPath,
"soft", NULL);
- if (virRun(cmd, NULL) < 0)
+ if (virCommandRun(cmd, NULL) < 0)
return -1;
vm->def->id = -1;
@@ -367,26 +364,22 @@ vmwareStopVM(struct vmware_driver *driver,
static int
vmwareStartVM(struct vmware_driver *driver, virDomainObjPtr vm)
{
- const char *cmd[] = {
- driver->vmrun, "-T", PROGRAM_SENTINEL, "start",
- PROGRAM_SENTINEL, PROGRAM_SENTINEL, NULL
- };
+ g_autoptr(virCommand) cmd = virCommandNew(driver->vmrun);
const char *vmxPath = ((vmwareDomainPtr) vm->privateData)->vmxPath;
+ virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type),
+ "start", vmxPath, NULL);
+
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_SHUTOFF) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not in shutoff state"));
return -1;
}
- vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type));
- vmwareSetSentinal(cmd, vmxPath);
if (!((vmwareDomainPtr) vm->privateData)->gui)
- vmwareSetSentinal(cmd, NOGUI);
- else
- vmwareSetSentinal(cmd, NULL);
+ virCommandAddArg(cmd, NOGUI);
- if (virRun(cmd, NULL) < 0)
+ if (virCommandRun(cmd, NULL) < 0)
return -1;
if ((vm->def->id = vmwareExtractPid(vmxPath)) < 0) {
@@ -543,12 +536,9 @@ static int
vmwareDomainSuspend(virDomainPtr dom)
{
struct vmware_driver *driver = dom->conn->privateData;
+ g_autoptr(virCommand) cmd = virCommandNew(driver->vmrun);
virDomainObjPtr vm;
- const char *cmd[] = {
- driver->vmrun, "-T", PROGRAM_SENTINEL, "pause",
- PROGRAM_SENTINEL, NULL
- };
int ret = -1;
if (driver->type == VMWARE_DRIVER_PLAYER) {
@@ -561,15 +551,17 @@ vmwareDomainSuspend(virDomainPtr dom)
if (!(vm = vmwareDomObjFromDomain(driver, dom->uuid)))
return -1;
- vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type));
- vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
}
- if (virRun(cmd, NULL) < 0)
+ virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type),
+ "pause", ((vmwareDomainPtr)
vm->privateData)->vmxPath,
+ NULL);
+
+ if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER);
@@ -584,12 +576,9 @@ static int
vmwareDomainResume(virDomainPtr dom)
{
struct vmware_driver *driver = dom->conn->privateData;
+ g_autoptr(virCommand) cmd = virCommandNew(driver->vmrun);
virDomainObjPtr vm;
- const char *cmd[] = {
- driver->vmrun, "-T", PROGRAM_SENTINEL, "unpause",
PROGRAM_SENTINEL,
- NULL
- };
int ret = -1;
if (driver->type == VMWARE_DRIVER_PLAYER) {
@@ -602,15 +591,17 @@ vmwareDomainResume(virDomainPtr dom)
if (!(vm = vmwareDomObjFromDomain(driver, dom->uuid)))
return -1;
- vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type));
- vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in suspend state"));
goto cleanup;
}
- if (virRun(cmd, NULL) < 0)
+ virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type),
+ "unpause", ((vmwareDomainPtr)
vm->privateData)->vmxPath,
+ NULL);
+
+ if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNPAUSED);
@@ -625,12 +616,8 @@ static int
vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
{
struct vmware_driver *driver = dom->conn->privateData;
- const char * vmxPath = NULL;
+ g_autoptr(virCommand) cmd = virCommandNew(driver->vmrun);
virDomainObjPtr vm;
- const char *cmd[] = {
- driver->vmrun, "-T", PROGRAM_SENTINEL,
- "reset", PROGRAM_SENTINEL, "soft", NULL
- };
int ret = -1;
virCheckFlags(0, -1);
@@ -638,10 +625,6 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
if (!(vm = vmwareDomObjFromDomain(driver, dom->uuid)))
return -1;
- vmxPath = ((vmwareDomainPtr) vm->privateData)->vmxPath;
- vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type));
- vmwareSetSentinal(cmd, vmxPath);
-
if (vmwareUpdateVMStatus(driver, vm) < 0)
goto cleanup;
@@ -651,7 +634,11 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
goto cleanup;
}
- if (virRun(cmd, NULL) < 0)
+ virCommandAddArgList(cmd, "-T", vmwareDriverTypeToString(driver->type),
+ "reset", ((vmwareDomainPtr)
vm->privateData)->vmxPath,
+ "soft", NULL);
+
+ if (virCommandRun(cmd, NULL) < 0)
goto cleanup;
ret = 0;
--
2.25.1