Revision 2bac6019

b/hw/usb-msd.c
522 522
    bdrv = bdrv_new("usb");
523 523
    if (bdrv_open(bdrv, filename, 0) < 0)
524 524
        goto fail;
525
    if (qemu_key_check(bdrv, filename))
526
        goto fail;
525 527
    s->bs = bdrv;
526 528

  
527 529
    s->dev.speed = USB_SPEED_FULL;
b/monitor.c
386 386
static void do_change(const char *device, const char *filename)
387 387
{
388 388
    BlockDriverState *bs;
389
    int i;
390
    char password[256];
391 389

  
392 390
    bs = bdrv_find(device);
393 391
    if (!bs) {
......
397 395
    if (eject_device(bs, 0) < 0)
398 396
        return;
399 397
    bdrv_open(bs, filename, 0);
400
    if (bdrv_is_encrypted(bs)) {
401
        term_printf("%s is encrypted.\n", device);
402
        for(i = 0; i < 3; i++) {
403
            monitor_readline("Password: ", 1, password, sizeof(password));
404
            if (bdrv_set_key(bs, password) == 0)
405
                break;
406
            term_printf("invalid password\n");
407
        }
408
    }
398
    qemu_key_check(bs, filename);
409 399
}
410 400

  
411 401
static void do_screen_dump(const char *filename)
b/vl.c
6714 6714

  
6715 6715
/* password input */
6716 6716

  
6717
int qemu_key_check(BlockDriverState *bs, const char *name)
6718
{
6719
    char password[256];
6720
    int i;
6721

  
6722
    if (!bdrv_is_encrypted(bs))
6723
        return 0;
6724

  
6725
    term_printf("%s is encrypted.\n", name);
6726
    for(i = 0; i < 3; i++) {
6727
        monitor_readline("Password: ", 1, password, sizeof(password));
6728
        if (bdrv_set_key(bs, password) == 0)
6729
            return 0;
6730
        term_printf("invalid password\n");
6731
    }
6732
    return -EPERM;
6733
}
6734

  
6717 6735
static BlockDriverState *get_bdrv(int index)
6718 6736
{
6719 6737
    BlockDriverState *bs;
......
6731 6749
static void read_passwords(void)
6732 6750
{
6733 6751
    BlockDriverState *bs;
6734
    int i, j;
6735
    char password[256];
6752
    int i;
6736 6753

  
6737 6754
    for(i = 0; i < 6; i++) {
6738 6755
        bs = get_bdrv(i);
6739
        if (bs && bdrv_is_encrypted(bs)) {
6740
            term_printf("%s is encrypted.\n", bdrv_get_device_name(bs));
6741
            for(j = 0; j < 3; j++) {
6742
                monitor_readline("Password: ", 
6743
                                 1, password, sizeof(password));
6744
                if (bdrv_set_key(bs, password) == 0)
6745
                    break;
6746
                term_printf("invalid password\n");
6747
            }
6748
        }
6756
        if (bs)
6757
            qemu_key_check(bs, bdrv_get_device_name(bs));
6749 6758
    }
6750 6759
}
6751 6760

  
......
7622 7631
        }
7623 7632
    }
7624 7633

  
7625
    /* Open the virtual parallel flash bloc devices */
7634
    /* Open the virtual parallel flash block devices */
7626 7635
    for(i = 0; i < MAX_PFLASH; i++) {
7627 7636
        if (pflash_filename[i]) {
7628 7637
            if (!pflash_table[i]) {
......
7648 7657
                      snapshot ? BDRV_O_SNAPSHOT : 0) < 0) {
7649 7658
            fprintf(stderr, "qemu: could not open SD card image %s\n",
7650 7659
                    sd_filename);
7651
        }
7660
        } else
7661
            qemu_key_check(bs, sd_filename);
7652 7662
    }
7653 7663

  
7654 7664
    register_savevm("timer", 0, 2, timer_save, timer_load, NULL);
b/vl.h
632 632
void qemu_aio_wait(void);
633 633
void qemu_aio_wait_end(void);
634 634

  
635
int qemu_key_check(BlockDriverState *bs, const char *name);
636

  
635 637
/* Ensure contents are flushed to disk.  */
636 638
void bdrv_flush(BlockDriverState *bs);
637 639

  

Also available in: Unified diff