You need to sign in or sign up before continuing.
提交 3aee2615 编写于 作者: D Daniel P. Berrange

Add API for 'change vnc password' monitor command

* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a
  new qemuMonitorSetVNCPassword() API
* src/qemu/qemu_driver.c: Refactor qemudInitPasswords to
  call qemuMonitorSetVNCPassword()
上级 f38b654e
...@@ -1275,29 +1275,21 @@ qemudInitCpus(virConnectPtr conn, ...@@ -1275,29 +1275,21 @@ qemudInitCpus(virConnectPtr conn,
static int static int
qemudInitPasswords(virConnectPtr conn, qemudInitPasswords(struct qemud_driver *driver,
struct qemud_driver *driver,
virDomainObjPtr vm) { virDomainObjPtr vm) {
char *info = NULL; int ret = 0;
if ((vm->def->ngraphics == 1) && if ((vm->def->ngraphics == 1) &&
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
(vm->def->graphics[0]->data.vnc.passwd || driver->vncPassword)) { (vm->def->graphics[0]->data.vnc.passwd || driver->vncPassword)) {
if (qemudMonitorCommandExtra(vm, "change vnc password", ret = qemuMonitorSetVNCPassword(vm,
vm->def->graphics[0]->data.vnc.passwd ? vm->def->graphics[0]->data.vnc.passwd ?
vm->def->graphics[0]->data.vnc.passwd : vm->def->graphics[0]->data.vnc.passwd :
driver->vncPassword, driver->vncPassword);
QEMU_PASSWD_PROMPT,
-1, &info) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("setting VNC password failed"));
return -1;
}
VIR_FREE(info);
} }
return 0; return ret;
} }
...@@ -2144,7 +2136,7 @@ static int qemudStartVMDaemon(virConnectPtr conn, ...@@ -2144,7 +2136,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if ((qemudWaitForMonitor(conn, driver, vm, pos) < 0) || if ((qemudWaitForMonitor(conn, driver, vm, pos) < 0) ||
(qemuDetectVcpuPIDs(conn, vm) < 0) || (qemuDetectVcpuPIDs(conn, vm) < 0) ||
(qemudInitCpus(conn, vm, migrateFrom) < 0) || (qemudInitCpus(conn, vm, migrateFrom) < 0) ||
(qemudInitPasswords(conn, driver, vm) < 0) || (qemudInitPasswords(driver, vm) < 0) ||
(qemudDomainSetMemoryBalloon(conn, vm, vm->def->memory) < 0) || (qemudDomainSetMemoryBalloon(conn, vm, vm->def->memory) < 0) ||
(virDomainSaveStatus(conn, driver->stateDir, vm) < 0)) { (virDomainSaveStatus(conn, driver->stateDir, vm) < 0)) {
qemudShutdownVMDaemon(conn, driver, vm); qemudShutdownVMDaemon(conn, driver, vm);
......
...@@ -520,3 +520,18 @@ error: ...@@ -520,3 +520,18 @@ error:
} }
int qemuMonitorSetVNCPassword(const virDomainObjPtr vm,
const char *password)
{
char *info = NULL;
if (qemudMonitorCommandExtra(vm, "change vnc password",
password,
QEMU_PASSWD_PROMPT,
-1, &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("setting VNC password failed"));
return -1;
}
VIR_FREE(info);
return 0;
}
...@@ -71,4 +71,7 @@ int qemudMonitorSendCont(virConnectPtr conn, ...@@ -71,4 +71,7 @@ int qemudMonitorSendCont(virConnectPtr conn,
int qemuMonitorGetCPUInfo(const virDomainObjPtr vm, int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
int **pids); int **pids);
int qemuMonitorSetVNCPassword(const virDomainObjPtr vm,
const char *password);
#endif /* QEMU_MONITOR_TEXT_H */ #endif /* QEMU_MONITOR_TEXT_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册