mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
Remove low level monitor APIs from header file
* src/qemu/qemu_monitor_text.h: Remove qemudMonitorCommand, qemudMonitorCommandWithFd, qemudMonitorCommandWithHandler, qemudMonitorCommandExtra low level APIs * src/qemu/qemu_monitor_text.c: Replace s/qemud/qemuMonitor/
This commit is contained in:
parent
b06c97e51d
commit
79f45855a6
@ -41,7 +41,17 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||||
|
|
||||||
static char *qemudEscape(const char *in, int shell)
|
#define QEMU_CMD_PROMPT "\n(qemu) "
|
||||||
|
#define QEMU_PASSWD_PROMPT "Password: "
|
||||||
|
|
||||||
|
/* Return -1 for error, 0 for success */
|
||||||
|
typedef int qemuMonitorExtraPromptHandler(const virDomainObjPtr vm,
|
||||||
|
const char *buf,
|
||||||
|
const char *prompt,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
|
||||||
|
static char *qemuMonitorEscape(const char *in, int shell)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -113,14 +123,14 @@ static char *qemudEscape(const char *in, int shell)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *qemudEscapeMonitorArg(const char *in)
|
static char *qemuMonitorEscapeArg(const char *in)
|
||||||
{
|
{
|
||||||
return qemudEscape(in, 0);
|
return qemuMonitorEscape(in, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *qemudEscapeShellArg(const char *in)
|
static char *qemuMonitorEscapeShell(const char *in)
|
||||||
{
|
{
|
||||||
return qemudEscape(in, 1);
|
return qemuMonitorEscape(in, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Throw away any data available on the monitor
|
/* Throw away any data available on the monitor
|
||||||
@ -144,10 +154,10 @@ qemuMonitorDiscardPendingData(virDomainObjPtr vm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemudMonitorSendUnix(const virDomainObjPtr vm,
|
qemuMonitorSendUnix(const virDomainObjPtr vm,
|
||||||
const char *cmd,
|
const char *cmd,
|
||||||
size_t cmdlen,
|
size_t cmdlen,
|
||||||
int scm_fd)
|
int scm_fd)
|
||||||
{
|
{
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct iovec iov[1];
|
struct iovec iov[1];
|
||||||
@ -183,9 +193,9 @@ qemudMonitorSendUnix(const virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemudMonitorSend(const virDomainObjPtr vm,
|
qemuMonitorSend(const virDomainObjPtr vm,
|
||||||
const char *cmd,
|
const char *cmd,
|
||||||
int scm_fd)
|
int scm_fd)
|
||||||
{
|
{
|
||||||
char *full;
|
char *full;
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -198,7 +208,7 @@ qemudMonitorSend(const virDomainObjPtr vm,
|
|||||||
|
|
||||||
switch (vm->monitor_chr->type) {
|
switch (vm->monitor_chr->type) {
|
||||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||||
if (qemudMonitorSendUnix(vm, full, len, scm_fd) < 0)
|
if (qemuMonitorSendUnix(vm, full, len, scm_fd) < 0)
|
||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -214,14 +224,14 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
qemudMonitorCommandWithHandler(const virDomainObjPtr vm,
|
qemuMonitorCommandWithHandler(const virDomainObjPtr vm,
|
||||||
const char *cmd,
|
const char *cmd,
|
||||||
const char *extraPrompt,
|
const char *extraPrompt,
|
||||||
qemudMonitorExtraPromptHandler extraHandler,
|
qemuMonitorExtraPromptHandler extraHandler,
|
||||||
void *handlerData,
|
void *handlerData,
|
||||||
int scm_fd,
|
int scm_fd,
|
||||||
char **reply) {
|
char **reply) {
|
||||||
int size = 0;
|
int size = 0;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
@ -233,7 +243,7 @@ qemudMonitorCommandWithHandler(const virDomainObjPtr vm,
|
|||||||
qemuMonitorDiscardPendingData(vm);
|
qemuMonitorDiscardPendingData(vm);
|
||||||
|
|
||||||
VIR_DEBUG("Send '%s'", cmd);
|
VIR_DEBUG("Send '%s'", cmd);
|
||||||
if (qemudMonitorSend(vm, cmd, scm_fd) < 0)
|
if (qemuMonitorSend(vm, cmd, scm_fd) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
*reply = NULL;
|
*reply = NULL;
|
||||||
@ -324,23 +334,23 @@ struct extraHandlerData
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemudMonitorCommandSimpleExtraHandler(const virDomainObjPtr vm,
|
qemuMonitorCommandSimpleExtraHandler(const virDomainObjPtr vm,
|
||||||
const char *buf ATTRIBUTE_UNUSED,
|
const char *buf ATTRIBUTE_UNUSED,
|
||||||
const char *prompt ATTRIBUTE_UNUSED,
|
const char *prompt ATTRIBUTE_UNUSED,
|
||||||
void *data_)
|
void *data_)
|
||||||
{
|
{
|
||||||
struct extraHandlerData *data = data_;
|
struct extraHandlerData *data = data_;
|
||||||
|
|
||||||
if (!data->first)
|
if (!data->first)
|
||||||
return 0;
|
return 0;
|
||||||
if (qemudMonitorSend(vm, data->reply, -1) < 0)
|
if (qemuMonitorSend(vm, data->reply, -1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
data->first = false;
|
data->first = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
qemudMonitorCommandExtra(const virDomainObjPtr vm,
|
qemuMonitorCommandExtra(const virDomainObjPtr vm,
|
||||||
const char *cmd,
|
const char *cmd,
|
||||||
const char *extra,
|
const char *extra,
|
||||||
const char *extraPrompt,
|
const char *extraPrompt,
|
||||||
@ -350,24 +360,24 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
|
|||||||
|
|
||||||
data.reply = extra;
|
data.reply = extra;
|
||||||
data.first = true;
|
data.first = true;
|
||||||
return qemudMonitorCommandWithHandler(vm, cmd, extraPrompt,
|
return qemuMonitorCommandWithHandler(vm, cmd, extraPrompt,
|
||||||
qemudMonitorCommandSimpleExtraHandler,
|
qemuMonitorCommandSimpleExtraHandler,
|
||||||
&data, scm_fd, reply);
|
&data, scm_fd, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
qemudMonitorCommandWithFd(const virDomainObjPtr vm,
|
qemuMonitorCommandWithFd(const virDomainObjPtr vm,
|
||||||
const char *cmd,
|
const char *cmd,
|
||||||
int scm_fd,
|
int scm_fd,
|
||||||
char **reply) {
|
char **reply) {
|
||||||
return qemudMonitorCommandExtra(vm, cmd, NULL, NULL, scm_fd, reply);
|
return qemuMonitorCommandExtra(vm, cmd, NULL, NULL, scm_fd, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
qemudMonitorCommand(const virDomainObjPtr vm,
|
qemuMonitorCommand(const virDomainObjPtr vm,
|
||||||
const char *cmd,
|
const char *cmd,
|
||||||
char **reply) {
|
char **reply) {
|
||||||
return qemudMonitorCommandWithFd(vm, cmd, -1, reply);
|
return qemuMonitorCommandWithFd(vm, cmd, -1, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -467,10 +477,10 @@ findVolumeQcowPassphrase(virConnectPtr conn, virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemudMonitorSendVolumePassphrase(const virDomainObjPtr vm,
|
qemuMonitorSendVolumePassphrase(const virDomainObjPtr vm,
|
||||||
const char *buf,
|
const char *buf,
|
||||||
const char *prompt,
|
const char *prompt,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
virConnectPtr conn = data;
|
virConnectPtr conn = data;
|
||||||
char *passphrase, *path;
|
char *passphrase, *path;
|
||||||
@ -498,7 +508,7 @@ qemudMonitorSendVolumePassphrase(const virDomainObjPtr vm,
|
|||||||
if (passphrase == NULL)
|
if (passphrase == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
res = qemudMonitorSend(vm, passphrase, -1);
|
res = qemuMonitorSend(vm, passphrase, -1);
|
||||||
|
|
||||||
memset(passphrase, 0, passphrase_len);
|
memset(passphrase, 0, passphrase_len);
|
||||||
VIR_FREE(passphrase);
|
VIR_FREE(passphrase);
|
||||||
@ -511,9 +521,9 @@ qemuMonitorStartCPUs(virConnectPtr conn,
|
|||||||
const virDomainObjPtr vm) {
|
const virDomainObjPtr vm) {
|
||||||
char *reply;
|
char *reply;
|
||||||
|
|
||||||
if (qemudMonitorCommandWithHandler(vm, "cont", ") is encrypted.",
|
if (qemuMonitorCommandWithHandler(vm, "cont", ") is encrypted.",
|
||||||
qemudMonitorSendVolumePassphrase, conn,
|
qemuMonitorSendVolumePassphrase, conn,
|
||||||
-1, &reply) < 0)
|
-1, &reply) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
qemudDebug ("%s: cont reply: %s", vm->def->name, info);
|
qemudDebug ("%s: cont reply: %s", vm->def->name, info);
|
||||||
VIR_FREE(reply);
|
VIR_FREE(reply);
|
||||||
@ -525,7 +535,7 @@ int
|
|||||||
qemuMonitorStopCPUs(const virDomainObjPtr vm) {
|
qemuMonitorStopCPUs(const virDomainObjPtr vm) {
|
||||||
char *info;
|
char *info;
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, "stop", &info) < 0) {
|
if (qemuMonitorCommand(vm, "stop", &info) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("cannot stop CPU execution"));
|
"%s", _("cannot stop CPU execution"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -538,7 +548,7 @@ qemuMonitorStopCPUs(const virDomainObjPtr vm) {
|
|||||||
int qemuMonitorSystemPowerdown(const virDomainObjPtr vm) {
|
int qemuMonitorSystemPowerdown(const virDomainObjPtr vm) {
|
||||||
char *info;
|
char *info;
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, "system_powerdown", &info) < 0) {
|
if (qemuMonitorCommand(vm, "system_powerdown", &info) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("system shutdown operation failed"));
|
"%s", _("system shutdown operation failed"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -557,7 +567,7 @@ int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
|
|||||||
pid_t *cpupids = NULL;
|
pid_t *cpupids = NULL;
|
||||||
size_t ncpupids = 0;
|
size_t ncpupids = 0;
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, "info cpus", &qemucpus) < 0) {
|
if (qemuMonitorCommand(vm, "info cpus", &qemucpus) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("cannot run monitor command to fetch CPU thread info"));
|
"%s", _("cannot run monitor command to fetch CPU thread info"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -645,7 +655,7 @@ int qemuMonitorGetBalloonInfo(const virDomainObjPtr vm,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *offset;
|
char *offset;
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, "info balloon", &reply) < 0) {
|
if (qemuMonitorCommand(vm, "info balloon", &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("could not query memory balloon allocation"));
|
"%s", _("could not query memory balloon allocation"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -690,7 +700,7 @@ int qemuMonitorGetBlockStatsInfo(const virDomainObjPtr vm,
|
|||||||
const char *p, *eol;
|
const char *p, *eol;
|
||||||
int devnamelen = strlen(devname);
|
int devnamelen = strlen(devname);
|
||||||
|
|
||||||
if (qemudMonitorCommand (vm, "info blockstats", &info) < 0) {
|
if (qemuMonitorCommand (vm, "info blockstats", &info) < 0) {
|
||||||
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError (NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("'info blockstats' command failed"));
|
"%s", _("'info blockstats' command failed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -785,10 +795,10 @@ int qemuMonitorSetVNCPassword(const virDomainObjPtr vm,
|
|||||||
const char *password)
|
const char *password)
|
||||||
{
|
{
|
||||||
char *info = NULL;
|
char *info = NULL;
|
||||||
if (qemudMonitorCommandExtra(vm, "change vnc password",
|
if (qemuMonitorCommandExtra(vm, "change vnc password",
|
||||||
password,
|
password,
|
||||||
QEMU_PASSWD_PROMPT,
|
QEMU_PASSWD_PROMPT,
|
||||||
-1, &info) < 0) {
|
-1, &info) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("setting VNC password failed"));
|
"%s", _("setting VNC password failed"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -817,7 +827,7 @@ int qemuMonitorSetBalloon(const virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("could not balloon memory allocation"));
|
"%s", _("could not balloon memory allocation"));
|
||||||
VIR_FREE(cmd);
|
VIR_FREE(cmd);
|
||||||
@ -851,7 +861,7 @@ int qemuMonitorEjectMedia(const virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("could not eject media on %s"), devname);
|
_("could not eject media on %s"), devname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -885,7 +895,7 @@ int qemuMonitorChangeMedia(const virDomainObjPtr vm,
|
|||||||
char *safepath = NULL;
|
char *safepath = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(safepath = qemudEscapeMonitorArg(newmedia))) {
|
if (!(safepath = qemuMonitorEscapeArg(newmedia))) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -895,7 +905,7 @@ int qemuMonitorChangeMedia(const virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("could not eject media on %s"), devname);
|
_("could not eject media on %s"), devname);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -931,7 +941,7 @@ static int qemuMonitorSaveMemory(const virDomainObjPtr vm,
|
|||||||
char *safepath = NULL;
|
char *safepath = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(safepath = qemudEscapeMonitorArg(path))) {
|
if (!(safepath = qemuMonitorEscapeArg(path))) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -941,7 +951,7 @@ static int qemuMonitorSaveMemory(const virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("could save memory region to '%s'"), path);
|
_("could save memory region to '%s'"), path);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -988,7 +998,7 @@ int qemuMonitorSetMigrationSpeed(const virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &info) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &info) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("could restrict migration speed"));
|
"%s", _("could restrict migration speed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1029,7 +1039,7 @@ int qemuMonitorGetMigrationStatus(const virDomainObjPtr vm,
|
|||||||
*remaining = 0;
|
*remaining = 0;
|
||||||
*total = 0;
|
*total = 0;
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, "info migration", &reply) < 0) {
|
if (qemuMonitorCommand(vm, "info migration", &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("cannot query migration status"));
|
"%s", _("cannot query migration status"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -1100,7 +1110,7 @@ static int qemuMonitorMigrate(const virDomainObjPtr vm,
|
|||||||
char *cmd = NULL;
|
char *cmd = NULL;
|
||||||
char *info = NULL;
|
char *info = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *safedest = qemudEscapeMonitorArg(dest);
|
char *safedest = qemuMonitorEscapeArg(dest);
|
||||||
|
|
||||||
if (!safedest) {
|
if (!safedest) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
@ -1112,7 +1122,7 @@ static int qemuMonitorMigrate(const virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &info) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &info) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unable to start migration to %s"), dest);
|
_("unable to start migration to %s"), dest);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1180,7 +1190,7 @@ int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Migrate to file */
|
/* Migrate to file */
|
||||||
safe_target = qemudEscapeShellArg(target);
|
safe_target = qemuMonitorEscapeShell(target);
|
||||||
if (!safe_target) {
|
if (!safe_target) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1209,7 +1219,7 @@ int qemuMonitorAddUSBDisk(const virDomainObjPtr vm,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *info = NULL;
|
char *info = NULL;
|
||||||
|
|
||||||
safepath = qemudEscapeMonitorArg(path);
|
safepath = qemuMonitorEscapeArg(path);
|
||||||
if (!safepath) {
|
if (!safepath) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1220,7 +1230,7 @@ int qemuMonitorAddUSBDisk(const virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &info) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &info) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("cannot run monitor command to add usb disk"));
|
"%s", _("cannot run monitor command to add usb disk"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1256,7 +1266,7 @@ static int qemuMonitorAddUSBDevice(const virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("cannot attach usb device"));
|
"%s", _("cannot attach usb device"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1407,7 +1417,7 @@ int qemuMonitorAddPCIHostDevice(const virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("cannot attach host pci device"));
|
"%s", _("cannot attach host pci device"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1449,7 +1459,7 @@ int qemuMonitorAddPCIDisk(const virDomainObjPtr vm,
|
|||||||
int tryOldSyntax = 0;
|
int tryOldSyntax = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
safe_path = qemudEscapeMonitorArg(path);
|
safe_path = qemuMonitorEscapeArg(path);
|
||||||
if (!safe_path) {
|
if (!safe_path) {
|
||||||
virReportOOMError(NULL);
|
virReportOOMError(NULL);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1462,7 +1472,7 @@ try_command:
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("cannot attach %s disk %s"), bus, path);
|
_("cannot attach %s disk %s"), bus, path);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1507,7 +1517,7 @@ int qemuMonitorAddPCINetwork(const virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("failed to add NIC with '%s'"), cmd);
|
_("failed to add NIC with '%s'"), cmd);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1553,7 +1563,7 @@ try_command:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
"%s", _("failed to remove PCI device"));
|
"%s", _("failed to remove PCI device"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1603,7 +1613,7 @@ int qemuMonitorSendFileHandle(const virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommandWithFd(vm, cmd, fd, &reply) < 0) {
|
if (qemuMonitorCommandWithFd(vm, cmd, fd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("failed to pass fd to qemu with '%s'"), cmd);
|
_("failed to pass fd to qemu with '%s'"), cmd);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1641,7 +1651,7 @@ int qemuMonitorCloseFileHandle(const virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("failed to close fd in qemu with '%s'"), cmd);
|
_("failed to close fd in qemu with '%s'"), cmd);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1679,7 +1689,7 @@ int qemuMonitorAddHostNetwork(const virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("failed to close fd in qemu with '%s'"), cmd);
|
_("failed to close fd in qemu with '%s'"), cmd);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1711,7 +1721,7 @@ int qemuMonitorRemoveHostNetwork(const virDomainObjPtr vm,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemudMonitorCommand(vm, cmd, &reply) < 0) {
|
if (qemuMonitorCommand(vm, cmd, &reply) < 0) {
|
||||||
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
|
||||||
_("failed to remove host metnwork in qemu with '%s'"), cmd);
|
_("failed to remove host metnwork in qemu with '%s'"), cmd);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -29,39 +29,6 @@
|
|||||||
|
|
||||||
#include "domain_conf.h"
|
#include "domain_conf.h"
|
||||||
|
|
||||||
/* XXX remove these two from public header */
|
|
||||||
#define QEMU_CMD_PROMPT "\n(qemu) "
|
|
||||||
#define QEMU_PASSWD_PROMPT "Password: "
|
|
||||||
|
|
||||||
/* Return -1 for error, 0 for success */
|
|
||||||
typedef int qemudMonitorExtraPromptHandler(const virDomainObjPtr vm,
|
|
||||||
const char *buf,
|
|
||||||
const char *prompt,
|
|
||||||
void *data);
|
|
||||||
|
|
||||||
/* These first 4 APIs are generic monitor interaction. They will
|
|
||||||
* go away eventually
|
|
||||||
*/
|
|
||||||
int qemudMonitorCommand(const virDomainObjPtr vm,
|
|
||||||
const char *cmd,
|
|
||||||
char **reply);
|
|
||||||
int qemudMonitorCommandWithFd(const virDomainObjPtr vm,
|
|
||||||
const char *cmd,
|
|
||||||
int scm_fd,
|
|
||||||
char **reply);
|
|
||||||
int qemudMonitorCommandWithHandler(const virDomainObjPtr vm,
|
|
||||||
const char *cmd,
|
|
||||||
const char *extraPrompt,
|
|
||||||
qemudMonitorExtraPromptHandler extraHandler,
|
|
||||||
void *handlerData,
|
|
||||||
int scm_fd,
|
|
||||||
char **reply);
|
|
||||||
int qemudMonitorCommandExtra(const virDomainObjPtr vm,
|
|
||||||
const char *cmd,
|
|
||||||
const char *extra,
|
|
||||||
const char *extraPrompt,
|
|
||||||
int scm_fd,
|
|
||||||
char **reply);
|
|
||||||
|
|
||||||
/* Formal APIs for each required monitor command */
|
/* Formal APIs for each required monitor command */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user