~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to vl.c

  • Committer: aliguori
  • Date: 2009-01-16 19:04:14 UTC
  • Revision ID: git-v1:3023f3329d87a6203d03a0e9ccb948772940da96
graphical_console_init change (Stefano Stabellini)

Patch 5/7

This patch changes the graphical_console_init function to return an
allocated DisplayState instead of a QEMUConsole.

This patch contains just the graphical_console_init change and few other
modifications mainly in console.c and vl.c.
It was necessary to move the display frontends (e.g. sdl and vnc)
initialization after machine->init in vl.c.

This patch does *not* include any required changes to any device, these
changes come with the following patches.

Patch 6/7

This patch changes the QEMUMachine init functions not to take a
DisplayState as an argument because is not needed any more;

In few places the graphic hardware initialization function was called
only if DisplayState was not NULL, now they are always called.
Apart from these cases, the rest are all mechanical substitutions.

Patch 7/7

This patch updates the graphic device code to use the new
graphical_console_init function.

As for the previous patch, in few places graphical_console_init was called
only if DisplayState was not NULL, now it is always called.
Apart from these cases, the rest are all mechanical substitutions.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6344 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
187
187
int nb_drives;
188
188
static int vga_ram_size;
189
189
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
190
 
DisplayState display_state;
 
190
static DisplayState *display_state;
191
191
int nographic;
192
192
static int curses;
193
193
static int sdl;
2756
2756
}
2757
2757
 
2758
2758
/***********************************************************/
 
2759
/* register display */
 
2760
 
 
2761
void register_displaystate(DisplayState *ds)
 
2762
{
 
2763
    DisplayState **s;
 
2764
    s = &display_state;
 
2765
    while (*s != NULL)
 
2766
        s = &(*s)->next;
 
2767
    ds->next = NULL;
 
2768
    *s = ds;
 
2769
}
 
2770
 
 
2771
DisplayState *get_displaystate(void)
 
2772
{
 
2773
    return display_state;
 
2774
}
 
2775
 
2759
2776
/* dumb display */
2760
2777
 
2761
2778
static void dumb_update(DisplayState *ds, int x, int y, int w, int h)
4502
4519
    const char *initrd_filename;
4503
4520
    const char *kernel_filename, *kernel_cmdline;
4504
4521
    const char *boot_devices = "";
4505
 
    DisplayState *ds = &display_state;
 
4522
    DisplayState *ds;
4506
4523
    DisplayChangeListener *dcl;
4507
4524
    int cyls, heads, secs, translation;
4508
4525
    const char *net_clients[MAX_NET_CLIENTS];
5414
5431
    register_savevm("timer", 0, 2, timer_save, timer_load, NULL);
5415
5432
    register_savevm_live("ram", 0, 3, ram_save_live, NULL, ram_load, NULL);
5416
5433
 
 
5434
#ifndef _WIN32
 
5435
    /* must be after terminal init, SDL library changes signal handlers */
 
5436
    termsig_setup();
 
5437
#endif
 
5438
 
 
5439
    /* Maintain compatibility with multiple stdio monitors */
 
5440
    if (!strcmp(monitor_device,"stdio")) {
 
5441
        for (i = 0; i < MAX_SERIAL_PORTS; i++) {
 
5442
            const char *devname = serial_devices[i];
 
5443
            if (devname && !strcmp(devname,"mon:stdio")) {
 
5444
                monitor_device = NULL;
 
5445
                break;
 
5446
            } else if (devname && !strcmp(devname,"stdio")) {
 
5447
                monitor_device = NULL;
 
5448
                serial_devices[i] = "mon:stdio";
 
5449
                break;
 
5450
            }
 
5451
        }
 
5452
    }
 
5453
 
 
5454
    if (kvm_enabled()) {
 
5455
        int ret;
 
5456
 
 
5457
        ret = kvm_init(smp_cpus);
 
5458
        if (ret < 0) {
 
5459
            fprintf(stderr, "failed to initialize KVM\n");
 
5460
            exit(1);
 
5461
        }
 
5462
    }
 
5463
 
 
5464
    machine->init(ram_size, vga_ram_size, boot_devices,
 
5465
                  kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
 
5466
 
 
5467
    /* Set KVM's vcpu state to qemu's initial CPUState. */
 
5468
    if (kvm_enabled()) {
 
5469
        int ret;
 
5470
 
 
5471
        ret = kvm_sync_vcpus();
 
5472
        if (ret < 0) {
 
5473
            fprintf(stderr, "failed to initialize vcpus\n");
 
5474
            exit(1);
 
5475
        }
 
5476
    }
 
5477
 
 
5478
    /* init USB devices */
 
5479
    if (usb_enabled) {
 
5480
        for(i = 0; i < usb_devices_index; i++) {
 
5481
            if (usb_device_add(usb_devices[i]) < 0) {
 
5482
                fprintf(stderr, "Warning: could not add USB device %s\n",
 
5483
                        usb_devices[i]);
 
5484
            }
 
5485
        }
 
5486
    }
 
5487
 
 
5488
    /* just use the first displaystate for the moment */
 
5489
    ds = display_state;
5417
5490
    /* terminal init */
5418
 
    memset(&display_state, 0, sizeof(display_state));
5419
 
    ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4);
5420
5491
    if (nographic) {
5421
5492
        if (curses) {
5422
5493
            fprintf(stderr, "fatal: -nographic can't be used with -curses\n");
5448
5519
            }
5449
5520
    }
5450
5521
    dpy_resize(ds);
5451
 
#ifndef _WIN32
5452
 
    /* must be after terminal init, SDL library changes signal handlers */
5453
 
    termsig_setup();
5454
 
#endif
5455
5522
 
5456
 
    /* Maintain compatibility with multiple stdio monitors */
5457
 
    if (!strcmp(monitor_device,"stdio")) {
5458
 
        for (i = 0; i < MAX_SERIAL_PORTS; i++) {
5459
 
            const char *devname = serial_devices[i];
5460
 
            if (devname && !strcmp(devname,"mon:stdio")) {
5461
 
                monitor_device = NULL;
5462
 
                break;
5463
 
            } else if (devname && !strcmp(devname,"stdio")) {
5464
 
                monitor_device = NULL;
5465
 
                serial_devices[i] = "mon:stdio";
5466
 
                break;
5467
 
            }
 
5523
    dcl = ds->listeners;
 
5524
    while (dcl != NULL) {
 
5525
        if (dcl->dpy_refresh != NULL) {
 
5526
            ds->gui_timer = qemu_new_timer(rt_clock, gui_update, ds);
 
5527
            qemu_mod_timer(ds->gui_timer, qemu_get_clock(rt_clock));
5468
5528
        }
 
5529
        dcl = dcl->next;
5469
5530
    }
 
5531
 
5470
5532
    if (monitor_device) {
5471
5533
        monitor_hd = qemu_chr_open("monitor", monitor_device);
5472
5534
        if (!monitor_hd) {
5524
5586
        }
5525
5587
    }
5526
5588
 
5527
 
    if (kvm_enabled()) {
5528
 
        int ret;
5529
 
 
5530
 
        ret = kvm_init(smp_cpus);
5531
 
        if (ret < 0) {
5532
 
            fprintf(stderr, "failed to initialize KVM\n");
5533
 
            exit(1);
5534
 
        }
5535
 
    }
5536
 
 
5537
 
    machine->init(ram_size, vga_ram_size, boot_devices, ds,
5538
 
                  kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
5539
 
 
5540
 
    /* Set KVM's vcpu state to qemu's initial CPUState. */
5541
 
    if (kvm_enabled()) {
5542
 
        int ret;
5543
 
 
5544
 
        ret = kvm_sync_vcpus();
5545
 
        if (ret < 0) {
5546
 
            fprintf(stderr, "failed to initialize vcpus\n");
5547
 
            exit(1);
5548
 
        }
5549
 
    }
5550
 
 
5551
 
    /* init USB devices */
5552
 
    if (usb_enabled) {
5553
 
        for(i = 0; i < usb_devices_index; i++) {
5554
 
            if (usb_device_add(usb_devices[i]) < 0) {
5555
 
                fprintf(stderr, "Warning: could not add USB device %s\n",
5556
 
                        usb_devices[i]);
5557
 
            }
5558
 
        }
5559
 
    }
5560
 
 
5561
 
    dcl = ds->listeners;
5562
 
    while (dcl != NULL) {
5563
 
        if (dcl->dpy_refresh != NULL) {
5564
 
            display_state.gui_timer = qemu_new_timer(rt_clock, gui_update, &display_state);
5565
 
            qemu_mod_timer(display_state.gui_timer, qemu_get_clock(rt_clock));
5566
 
        }
5567
 
        dcl = dcl->next;
5568
 
    }
5569
5589
#ifdef CONFIG_GDBSTUB
5570
5590
    if (use_gdbstub) {
5571
5591
        /* XXX: use standard host:port notation and modify options