mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
qapi: Convert change
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
903a881481
commit
333a96ec9f
9 changed files with 181 additions and 98 deletions
74
monitor.c
74
monitor.c
|
@ -810,80 +810,6 @@ static void do_trace_print_events(Monitor *mon)
|
|||
trace_print_events((FILE *)mon, &monitor_fprintf);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VNC
|
||||
static int change_vnc_password(const char *password)
|
||||
{
|
||||
if (!password || !password[0]) {
|
||||
if (vnc_display_disable_login(NULL)) {
|
||||
qerror_report(QERR_SET_PASSWD_FAILED);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vnc_display_password(NULL, password) < 0) {
|
||||
qerror_report(QERR_SET_PASSWD_FAILED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void change_vnc_password_cb(Monitor *mon, const char *password,
|
||||
void *opaque)
|
||||
{
|
||||
change_vnc_password(password);
|
||||
monitor_read_command(mon, 1);
|
||||
}
|
||||
|
||||
static int do_change_vnc(Monitor *mon, const char *target, const char *arg)
|
||||
{
|
||||
if (strcmp(target, "passwd") == 0 ||
|
||||
strcmp(target, "password") == 0) {
|
||||
if (arg) {
|
||||
char password[9];
|
||||
strncpy(password, arg, sizeof(password));
|
||||
password[sizeof(password) - 1] = '\0';
|
||||
return change_vnc_password(password);
|
||||
} else {
|
||||
return monitor_read_password(mon, change_vnc_password_cb, NULL);
|
||||
}
|
||||
} else {
|
||||
if (vnc_display_open(NULL, target) < 0) {
|
||||
qerror_report(QERR_VNC_SERVER_FAILED, target);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int do_change_vnc(Monitor *mon, const char *target, const char *arg)
|
||||
{
|
||||
qerror_report(QERR_FEATURE_DISABLED, "vnc");
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* do_change(): Change a removable medium, or VNC configuration
|
||||
*/
|
||||
static int do_change(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
{
|
||||
const char *device = qdict_get_str(qdict, "device");
|
||||
const char *target = qdict_get_str(qdict, "target");
|
||||
const char *arg = qdict_get_try_str(qdict, "arg");
|
||||
int ret;
|
||||
|
||||
if (strcmp(device, "vnc") == 0) {
|
||||
ret = do_change_vnc(mon, target, arg);
|
||||
} else {
|
||||
ret = do_change_block(mon, device, target, arg);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int add_graphics_client(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||
{
|
||||
const char *protocol = qdict_get_str(qdict, "protocol");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue