Revision 702ec69c

b/include/ui/console.h
450 450
void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
451 451
                       int dst_x, int dst_y, int w, int h);
452 452

  
453
typedef CharDriverState *(VcHandler)(QemuOpts *);
453
typedef CharDriverState *(VcHandler)(ChardevVC *vc);
454 454

  
455
CharDriverState *vc_init(QemuOpts *opts);
455
CharDriverState *vc_init(ChardevVC *vc);
456 456
void register_vc_handler(VcHandler *handler);
457 457

  
458 458
/* sdl.c */
b/qapi-schema.json
3231 3231
{ 'type': 'ChardevSpicePort', 'data': { 'fqdn'  : 'str' } }
3232 3232

  
3233 3233
##
3234
# @ChardevVC:
3235
#
3236
# Configuration info for virtual console chardevs.
3237
#
3238
# @width:  console width,  in pixels
3239
# @height: console height, in pixels
3240
# @cols:   console width,  in chars
3241
# @rows:   console height, in chars
3242
#
3243
# Since: 1.5
3244
##
3245
{ 'type': 'ChardevVC', 'data': { '*width'  : 'int',
3246
                                 '*height' : 'int',
3247
                                 '*cols'   : 'int',
3248
                                 '*rows'   : 'int' } }
3249

  
3250
##
3234 3251
# @ChardevBackend:
3235 3252
#
3236 3253
# Configuration info for the new chardev backend.
......
3252 3269
                                       'stdio'  : 'ChardevStdio',
3253 3270
                                       'console': 'ChardevDummy',
3254 3271
                                       'spicevmc' : 'ChardevSpiceChannel',
3255
                                       'spiceport' : 'ChardevSpicePort' } }
3272
                                       'spiceport' : 'ChardevSpicePort',
3273
                                       'vc'     : 'ChardevVC' } }
3256 3274

  
3257 3275
##
3258 3276
# @ChardevReturn:
b/qemu-char.c
3737 3737
        chr = qemu_chr_open_spice_port(backend->spiceport->fqdn);
3738 3738
        break;
3739 3739
#endif
3740
    case CHARDEV_BACKEND_KIND_VC:
3741
        chr = vc_init(backend->vc);
3742
        break;
3740 3743
    default:
3741 3744
        error_setg(errp, "unknown chardev backend (%d)", backend->kind);
3742 3745
        break;
b/ui/console.c
1537 1537
        chr->init(chr);
1538 1538
}
1539 1539

  
1540
static CharDriverState *text_console_init(QemuOpts *opts)
1540
static CharDriverState *text_console_init(ChardevVC *vc)
1541 1541
{
1542 1542
    CharDriverState *chr;
1543 1543
    QemuConsole *s;
1544
    unsigned width;
1545
    unsigned height;
1544
    unsigned width = 0;
1545
    unsigned height = 0;
1546 1546

  
1547 1547
    chr = g_malloc0(sizeof(CharDriverState));
1548 1548

  
1549
    width = qemu_opt_get_number(opts, "width", 0);
1550
    if (width == 0)
1551
        width = qemu_opt_get_number(opts, "cols", 0) * FONT_WIDTH;
1549
    if (vc->has_width) {
1550
        width = vc->width;
1551
    } else if (vc->has_cols) {
1552
        width = vc->cols * FONT_WIDTH;
1553
    }
1552 1554

  
1553
    height = qemu_opt_get_number(opts, "height", 0);
1554
    if (height == 0)
1555
        height = qemu_opt_get_number(opts, "rows", 0) * FONT_HEIGHT;
1555
    if (vc->has_height) {
1556
        height = vc->height;
1557
    } else if (vc->has_rows) {
1558
        height = vc->rows * FONT_HEIGHT;
1559
    }
1556 1560

  
1557 1561
    if (width == 0 || height == 0) {
1558 1562
        s = new_console(NULL, TEXT_CONSOLE);
......
1575 1579

  
1576 1580
static VcHandler *vc_handler = text_console_init;
1577 1581

  
1578
CharDriverState *vc_init(QemuOpts *opts)
1582
CharDriverState *vc_init(ChardevVC *vc)
1579 1583
{
1580
    return vc_handler(opts);
1584
    return vc_handler(vc);
1581 1585
}
1582 1586

  
1583 1587
void register_vc_handler(VcHandler *handler)
......
1740 1744
    return pf;
1741 1745
}
1742 1746

  
1747
static void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend,
1748
                              Error **errp)
1749
{
1750
    int val;
1751

  
1752
    backend->vc = g_new0(ChardevVC, 1);
1753

  
1754
    val = qemu_opt_get_number(opts, "width", 0);
1755
    if (val != 0) {
1756
        backend->vc->has_width = true;
1757
        backend->vc->width = val;
1758
    }
1759

  
1760
    val = qemu_opt_get_number(opts, "height", 0);
1761
    if (val != 0) {
1762
        backend->vc->has_height = true;
1763
        backend->vc->height = val;
1764
    }
1765

  
1766
    val = qemu_opt_get_number(opts, "cols", 0);
1767
    if (val != 0) {
1768
        backend->vc->has_cols = true;
1769
        backend->vc->cols = val;
1770
    }
1771

  
1772
    val = qemu_opt_get_number(opts, "rows", 0);
1773
    if (val != 0) {
1774
        backend->vc->has_rows = true;
1775
        backend->vc->rows = val;
1776
    }
1777
}
1778

  
1743 1779
static void register_types(void)
1744 1780
{
1745
    register_char_driver("vc", text_console_init);
1781
    register_char_driver_qapi("vc", CHARDEV_BACKEND_KIND_VC,
1782
                              qemu_chr_parse_vc);
1746 1783
}
1747 1784

  
1748 1785
type_init(register_types);
b/ui/gtk.c
991 991
static int nb_vcs;
992 992
static CharDriverState *vcs[MAX_VCS];
993 993

  
994
static CharDriverState *gd_vc_handler(QemuOpts *opts)
994
static CharDriverState *gd_vc_handler(ChardevVC *unused)
995 995
{
996 996
    CharDriverState *chr;
997 997

  

Also available in: Unified diff