Commit 2569da0cb64506ea05323544c26f3aaffbf3f9fe

Authored by aliguori
1 parent 2a7e8dda

Accept password as an argument to 'change vnc password' monitor command (Chris Webb)

This allows easier use of the change vnc password monitor command from
management scripts, without having to implement expect(1)-like behaviour.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5967 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 13 additions and 9 deletions
monitor.c
... ... @@ -429,12 +429,16 @@ static void do_change_block(const char *device, const char *filename, const char
429 429 qemu_key_check(bs, filename);
430 430 }
431 431  
432   -static void do_change_vnc(const char *target)
  432 +static void do_change_vnc(const char *target, const char *arg)
433 433 {
434 434 if (strcmp(target, "passwd") == 0 ||
435 435 strcmp(target, "password") == 0) {
436 436 char password[9];
437   - monitor_readline("Password: ", 1, password, sizeof(password));
  437 + if (arg) {
  438 + strncpy(password, arg, sizeof(password));
  439 + password[sizeof(password) - 1] = '\0';
  440 + } else
  441 + monitor_readline("Password: ", 1, password, sizeof(password));
438 442 if (vnc_display_password(NULL, password) < 0)
439 443 term_printf("could not set VNC server password\n");
440 444 } else {
... ... @@ -443,12 +447,12 @@ static void do_change_vnc(const char *target)
443 447 }
444 448 }
445 449  
446   -static void do_change(const char *device, const char *target, const char *fmt)
  450 +static void do_change(const char *device, const char *target, const char *arg)
447 451 {
448 452 if (strcmp(device, "vnc") == 0) {
449   - do_change_vnc(target);
  453 + do_change_vnc(target, arg);
450 454 } else {
451   - do_change_block(device, target, fmt);
  455 + do_change_block(device, target, arg);
452 456 }
453 457 }
454 458  
... ...
qemu-doc.texi
... ... @@ -1241,11 +1241,11 @@ and @var{options} are described at @ref{sec_invocation}. eg
1241 1241 (qemu) change vnc localhost:1
1242 1242 @end example
1243 1243  
1244   -@item change vnc password
  1244 +@item change vnc password [@var{password}]
1245 1245  
1246   -Change the password associated with the VNC server. The monitor will prompt for
1247   -the new password to be entered. VNC passwords are only significant upto 8 letters.
1248   -eg.
  1246 +Change the password associated with the VNC server. If the new password is not
  1247 +supplied, the monitor will prompt for it to be entered. VNC passwords are only
  1248 +significant up to 8 letters. eg
1249 1249  
1250 1250 @example
1251 1251 (qemu) change vnc password
... ...