qemu: Introduce nbd-server-stop command

This will be used after all migration work is done
to stop NBD server running on destination.  It
doesn't take any arguments, just issues a command.
This commit is contained in:
Michal Privoznik 2013-01-31 14:47:49 +01:00
parent c833d8111d
commit f1748e34e2
4 changed files with 42 additions and 0 deletions

View File

@ -3507,3 +3507,22 @@ int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
return qemuMonitorJSONNBDServerAdd(mon, deviceID, writable);
}
int qemuMonitorNBDServerStop(qemuMonitorPtr mon)
{
VIR_DEBUG("mon=%p", mon);
if (!mon) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("monitor must not be NULL"));
return -1;
}
if (!mon->json) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("JSON monitor is required"));
return -1;
}
return qemuMonitorJSONNBDServerStop(mon);
}

View File

@ -682,6 +682,7 @@ int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
int qemuMonitorNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
bool writable);
int qemuMonitorNBDServerStop(qemuMonitorPtr);
/**
* When running two dd process and using <> redirection, we need a
* shell that will not truncate files. These two strings serve that

View File

@ -4688,3 +4688,24 @@ qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
virJSONValueFree(reply);
return ret;
}
int
qemuMonitorJSONNBDServerStop(qemuMonitorPtr mon)
{
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-stop",
NULL)))
return ret;
ret = qemuMonitorJSONCommand(mon, cmd, &reply);
if (ret == 0)
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}

View File

@ -340,4 +340,5 @@ int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
int qemuMonitorJSONNBDServerAdd(qemuMonitorPtr mon,
const char *deviceID,
bool writable);
int qemuMonitorJSONNBDServerStop(qemuMonitorPtr mon);
#endif /* QEMU_MONITOR_JSON_H */