提交 e081c24d 编写于 作者: P Peter Maydell

Merge remote-tracking branch 'remotes/ehabkost/tags/machine-pull-request' into staging

Machine Core queue, 2016-05-20

# gpg: Signature made Fri 20 May 2016 21:26:49 BST using RSA key ID 984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"

* remotes/ehabkost/tags/machine-pull-request: (21 commits)
  Use &error_fatal when initializing crypto on qemu-{img,io,nbd}
  vl: Use &error_fatal when parsing monitor options
  vl: Use &error_fatal when parsing VNC options
  machine: add properties to compat_props incrementaly
  vl: Simplify global property registration
  vl: Make display_remote a local variable
  vl: Move DisplayType typedef to vl.c
  vl: Make display_type a local variable
  vl: Replace DT_NOGRAPHIC with machine option
  milkymist: Move DT_NOGRAPHIC check outside milkymist_tmu2_create()
  spice: Initialization stubs on qemu-spice.h
  gtk: Initialization stubs
  cocoa: cocoa_display_init() stub
  sdl: Initialization stubs
  curses: curses_display_init() stub
  vnc: Initialization stubs
  vl: Add DT_COCOA DisplayType value
  vl: Replace *_vga_available() functions with class_names field
  vl: Table-based select_vgahw()
  vl: Use exit(1) when requested VGA interface is unavailable
  ...
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
......@@ -1418,13 +1418,9 @@ static void virt_2_6_instance_init(Object *obj)
static void virt_2_6_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
static GlobalProperty compat_props[] = {
{ /* end of list */ }
};
mc->desc = "QEMU 2.6 ARM Virtual Machine";
mc->alias = "virt";
mc->compat_props = compat_props;
}
static const TypeInfo machvirt_info = {
......
......@@ -257,6 +257,20 @@ static void machine_set_usb(Object *obj, bool value, Error **errp)
ms->usb_disabled = !value;
}
static bool machine_get_graphics(Object *obj, Error **errp)
{
MachineState *ms = MACHINE(obj);
return ms->enable_graphics;
}
static void machine_set_graphics(Object *obj, bool value, Error **errp)
{
MachineState *ms = MACHINE(obj);
ms->enable_graphics = value;
}
static bool machine_get_igd_gfx_passthru(Object *obj, Error **errp)
{
MachineState *ms = MACHINE(obj);
......@@ -382,6 +396,7 @@ static void machine_initfn(Object *obj)
ms->kvm_shadow_mem = -1;
ms->dump_guest_core = true;
ms->mem_merge = true;
ms->enable_graphics = true;
object_property_add_str(obj, "accel",
machine_get_accel, machine_set_accel, NULL);
......@@ -460,6 +475,12 @@ static void machine_initfn(Object *obj)
object_property_set_description(obj, "usb",
"Set on/off to enable/disable usb",
NULL);
object_property_add_bool(obj, "graphics",
machine_get_graphics,
machine_set_graphics, NULL);
object_property_set_description(obj, "graphics",
"Set on/off to enable/disable graphics emulation",
NULL);
object_property_add_bool(obj, "igd-passthru",
machine_get_igd_gfx_passthru,
machine_set_igd_gfx_passthru, NULL);
......@@ -550,6 +571,15 @@ bool machine_mem_merge(MachineState *machine)
return machine->mem_merge;
}
static void machine_class_finalize(ObjectClass *klass, void *data)
{
MachineClass *mc = MACHINE_CLASS(klass);
if (mc->compat_props) {
g_array_free(mc->compat_props, true);
}
}
static const TypeInfo machine_info = {
.name = TYPE_MACHINE,
.parent = TYPE_OBJECT,
......@@ -557,6 +587,7 @@ static const TypeInfo machine_info = {
.class_size = sizeof(MachineClass),
.class_init = machine_class_init,
.class_base_init = machine_class_base_init,
.class_finalize = machine_class_finalize,
.instance_size = sizeof(MachineState),
.instance_init = machine_initfn,
.instance_finalize = machine_finalize,
......
......@@ -582,7 +582,6 @@ DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
#define PC_COMPAT_1_3 \
PC_COMPAT_1_4 \
{\
.driver = "usb-tablet",\
.property = "usb_version",\
......@@ -614,7 +613,6 @@ DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
#define PC_COMPAT_1_2 \
PC_COMPAT_1_3 \
{\
.driver = "nec-usb-xhci",\
.property = "msi",\
......@@ -653,7 +651,6 @@ DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
#define PC_COMPAT_1_1 \
PC_COMPAT_1_2 \
{\
.driver = "virtio-scsi-pci",\
.property = "hotplug",\
......@@ -696,7 +693,6 @@ DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
#define PC_COMPAT_1_0 \
PC_COMPAT_1_1 \
{\
.driver = TYPE_ISA_FDC,\
.property = "check_media_rate",\
......@@ -726,14 +722,10 @@ DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
pc_i440fx_1_0_machine_options);
#define PC_COMPAT_0_15 \
PC_COMPAT_1_0
static void pc_i440fx_0_15_machine_options(MachineClass *m)
{
pc_i440fx_1_0_machine_options(m);
m->hw_version = "0.15";
SET_MACHINE_COMPAT(m, PC_COMPAT_0_15);
}
DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
......@@ -741,7 +733,6 @@ DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
#define PC_COMPAT_0_14 \
PC_COMPAT_0_15 \
{\
.driver = "virtio-blk-pci",\
.property = "event_idx",\
......@@ -780,7 +771,6 @@ DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
#define PC_COMPAT_0_13 \
PC_COMPAT_0_14 \
{\
.driver = TYPE_PCI_DEVICE,\
.property = "command_serr_enable",\
......@@ -817,7 +807,6 @@ DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
#define PC_COMPAT_0_12 \
PC_COMPAT_0_13 \
{\
.driver = "virtio-serial-pci",\
.property = "max_ports",\
......@@ -852,7 +841,6 @@ DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
#define PC_COMPAT_0_11 \
PC_COMPAT_0_12 \
{\
.driver = "virtio-blk-pci",\
.property = "vectors",\
......@@ -883,7 +871,6 @@ DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
#define PC_COMPAT_0_10 \
PC_COMPAT_0_11 \
{\
.driver = "virtio-blk-pci",\
.property = "class",\
......
......@@ -108,10 +108,6 @@ static inline DeviceState *milkymist_tmu2_create(hwaddr base,
int nelements;
int ver_major, ver_minor;
if (display_type == DT_NOGRAPHIC) {
return NULL;
}
/* check that GLX will work */
d = XOpenDisplay(NULL);
if (d == NULL) {
......
......@@ -167,7 +167,9 @@ milkymist_init(MachineState *machine)
milkymist_memcard_create(0x60004000);
milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]);
milkymist_pfpu_create(0x60006000, irq[8]);
milkymist_tmu2_create(0x60007000, irq[9]);
if (machine->enable_graphics) {
milkymist_tmu2_create(0x60007000, irq[9]);
}
milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]);
milkymist_softusb_create(0x6000f000, irq[15],
0x20000000, 0x1000, 0x20020000, 0x2000);
......
......@@ -25,6 +25,7 @@
#include "hw/hw.h"
#include "sysemu/sysemu.h"
#include "sysemu/dma.h"
#include "hw/boards.h"
#include "hw/isa/isa.h"
#include "hw/nvram/fw_cfg.h"
#include "hw/sysbus.h"
......@@ -868,16 +869,17 @@ static void fw_cfg_machine_ready(struct Notifier *n, void *data)
static void fw_cfg_init1(DeviceState *dev)
{
FWCfgState *s = FW_CFG(dev);
MachineState *machine = MACHINE(qdev_get_machine());
assert(!object_resolve_path(FW_CFG_PATH, NULL));
object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s), NULL);
object_property_add_child(OBJECT(machine), FW_CFG_NAME, OBJECT(s), NULL);
qdev_init_nofail(dev);
fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4);
fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16);
fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC));
fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphics);
fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus);
fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu);
fw_cfg_bootsplash(s);
......
......@@ -2387,7 +2387,6 @@ DEFINE_SPAPR_MACHINE(2_5, "2.5", false);
* pseries-2.4
*/
#define SPAPR_COMPAT_2_4 \
SPAPR_COMPAT_2_5 \
HW_COMPAT_2_4
static void spapr_machine_2_4_instance_options(MachineState *machine)
......@@ -2410,7 +2409,6 @@ DEFINE_SPAPR_MACHINE(2_4, "2.4", false);
* pseries-2.3
*/
#define SPAPR_COMPAT_2_3 \
SPAPR_COMPAT_2_4 \
HW_COMPAT_2_3 \
{\
.driver = "spapr-pci-host-bridge",\
......@@ -2438,7 +2436,6 @@ DEFINE_SPAPR_MACHINE(2_3, "2.3", false);
*/
#define SPAPR_COMPAT_2_2 \
SPAPR_COMPAT_2_3 \
HW_COMPAT_2_2 \
{\
.driver = TYPE_SPAPR_PCI_HOST_BRIDGE,\
......@@ -2463,7 +2460,6 @@ DEFINE_SPAPR_MACHINE(2_2, "2.2", false);
* pseries-2.1
*/
#define SPAPR_COMPAT_2_1 \
SPAPR_COMPAT_2_2 \
HW_COMPAT_2_1
static void spapr_machine_2_1_instance_options(MachineState *machine)
......
......@@ -330,7 +330,6 @@ static const TypeInfo ccw_machine_info = {
HW_COMPAT_2_5
#define CCW_COMPAT_2_4 \
CCW_COMPAT_2_5 \
HW_COMPAT_2_4 \
{\
.driver = TYPE_S390_SKEYS,\
......
......@@ -1000,7 +1000,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14],
display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1);
!machine->enable_graphics, ESCC_CLOCK, 1);
/* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device
Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */
escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15],
......
......@@ -114,7 +114,7 @@ struct MachineClass {
const char *default_machine_opts;
const char *default_boot_order;
const char *default_display;
GlobalProperty *compat_props;
GArray *compat_props;
const char *hw_version;
ram_addr_t default_ram_size;
bool option_rom_has_mr;
......@@ -154,6 +154,7 @@ struct MachineState {
bool iommu;
bool suppress_vmdesc;
bool enforce_config_section;
bool enable_graphics;
ram_addr_t ram_size;
ram_addr_t maxram_size;
......@@ -185,11 +186,18 @@ struct MachineState {
#define SET_MACHINE_COMPAT(m, COMPAT) \
do { \
int i; \
static GlobalProperty props[] = { \
COMPAT \
{ /* end of list */ } \
}; \
(m)->compat_props = props; \
if (!m->compat_props) { \
m->compat_props = g_array_new(false, false, sizeof(void *)); \
} \
for (i = 0; props[i].driver != NULL; i++) { \
GlobalProperty *prop = &props[i]; \
g_array_append_val(m->compat_props, prop); \
} \
} while (0)
#endif
......@@ -360,7 +360,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
HW_COMPAT_2_5
#define PC_COMPAT_2_4 \
PC_COMPAT_2_5 \
HW_COMPAT_2_4 \
{\
.driver = "Haswell-" TYPE_X86_CPU,\
......@@ -431,7 +430,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
#define PC_COMPAT_2_3 \
PC_COMPAT_2_4 \
HW_COMPAT_2_3 \
{\
.driver = TYPE_X86_CPU,\
......@@ -512,7 +510,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
},
#define PC_COMPAT_2_2 \
PC_COMPAT_2_3 \
HW_COMPAT_2_2 \
{\
.driver = "kvm64" "-" TYPE_X86_CPU,\
......@@ -606,7 +603,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
},
#define PC_COMPAT_2_1 \
PC_COMPAT_2_2 \
HW_COMPAT_2_1 \
{\
.driver = "coreduo" "-" TYPE_X86_CPU,\
......@@ -620,7 +616,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
},
#define PC_COMPAT_2_0 \
PC_COMPAT_2_1 \
{\
.driver = "virtio-scsi-pci",\
.property = "any_layout",\
......@@ -680,7 +675,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
},
#define PC_COMPAT_1_7 \
PC_COMPAT_2_0 \
{\
.driver = TYPE_USB_DEVICE,\
.property = "msos-desc",\
......@@ -698,7 +692,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
},
#define PC_COMPAT_1_6 \
PC_COMPAT_1_7 \
{\
.driver = "e1000",\
.property = "mitigation",\
......@@ -722,7 +715,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
},
#define PC_COMPAT_1_5 \
PC_COMPAT_1_6 \
{\
.driver = "Conroe-" TYPE_X86_CPU,\
.property = "model",\
......@@ -766,7 +758,6 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
},
#define PC_COMPAT_1_4 \
PC_COMPAT_1_5 \
{\
.driver = "scsi-hd",\
.property = "discard_granularity",\
......
......@@ -20,8 +20,6 @@
#include "sysemu/hostmem.h"
#include "hw/qdev.h"
#define DEFAULT_PC_DIMMSIZE (1024*1024*1024)
#define TYPE_PC_DIMM "pc-dimm"
#define PC_DIMM(obj) \
OBJECT_CHECK(PCDIMMDevice, (obj), TYPE_PC_DIMM)
......@@ -72,7 +70,7 @@ typedef struct PCDIMMDeviceClass {
/**
* MemoryHotplugState:
* @base: address in guest RAM address space where hotplug memory
* @base: address in guest physical address space where hotplug memory
* address space begins.
* @mr: hotplug memory address space container
*/
......
......@@ -131,21 +131,12 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name,
int qemu_loadvm_state(QEMUFile *f);
typedef enum DisplayType
{
DT_DEFAULT,
DT_CURSES,
DT_SDL,
DT_GTK,
DT_NOGRAPHIC,
DT_NONE,
} DisplayType;
extern int autostart;
typedef enum {
VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
VGA_TCX, VGA_CG3, VGA_DEVICE, VGA_VIRTIO,
VGA_TYPE_MAX,
} VGAInterfaceType;
extern int vga_interface_type;
......@@ -154,7 +145,6 @@ extern int vga_interface_type;
extern int graphic_width;
extern int graphic_height;
extern int graphic_depth;
extern DisplayType display_type;
extern int display_opengl;
extern const char *keyboard_layout;
extern int win2k_install_hack;
......
......@@ -6,6 +6,8 @@
#include "qapi/qmp/qdict.h"
#include "qemu/notify.h"
#include "qapi-types.h"
#include "qemu/error-report.h"
#include "qapi/error.h"
#ifdef CONFIG_OPENGL
# include <epoxy/gl.h>
......@@ -420,20 +422,45 @@ void surface_gl_setup_viewport(ConsoleGLState *gls,
#endif
/* sdl.c */
#ifdef CONFIG_SDL
void sdl_display_early_init(int opengl);
void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
#else
static inline void sdl_display_early_init(int opengl)
{
/* This must never be called if CONFIG_SDL is disabled */
error_report("SDL support is disabled");
abort();
}
static inline void sdl_display_init(DisplayState *ds, int full_screen,
int no_frame)
{
/* This must never be called if CONFIG_SDL is disabled */
error_report("SDL support is disabled");
abort();
}
#endif
/* cocoa.m */
#ifdef CONFIG_COCOA
void cocoa_display_init(DisplayState *ds, int full_screen);
#else
static inline void cocoa_display_init(DisplayState *ds, int full_screen)
{
/* This must never be called if CONFIG_COCOA is disabled */
error_report("Cocoa support is disabled");
abort();
}
#endif
/* vnc.c */
void vnc_display_init(const char *id);
void vnc_display_open(const char *id, Error **errp);
void vnc_display_add_client(const char *id, int csock, bool skipauth);
char *vnc_display_local_addr(const char *id);
#ifdef CONFIG_VNC
int vnc_display_password(const char *id, const char *password);
int vnc_display_pw_expire(const char *id, time_t expires);
char *vnc_display_local_addr(const char *id);
QemuOpts *vnc_parse(const char *str, Error **errp);
int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
#else
......@@ -445,16 +472,58 @@ static inline int vnc_display_pw_expire(const char *id, time_t expires)
{
return -ENODEV;
};
static inline QemuOpts *vnc_parse(const char *str, Error **errp)
{
error_setg(errp, "VNC support is disabled");
return NULL;
}
static inline int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
{
error_setg(errp, "VNC support is disabled");
return -1;
}
static inline char *vnc_display_local_addr(const char *id)
{
/* This must never be called if CONFIG_VNC is disabled */
error_report("VNC support is disabled");
abort();
}
#endif
/* curses.c */
#ifdef CONFIG_CURSES
void curses_display_init(DisplayState *ds, int full_screen);
#else
static inline void curses_display_init(DisplayState *ds, int full_screen)
{
/* This must never be called if CONFIG_CURSES is disabled */
error_report("curses support is disabled");
abort();
}
#endif
/* input.c */
int index_from_key(const char *key, size_t key_length);
/* gtk.c */
#ifdef CONFIG_GTK
void early_gtk_display_init(int opengl);
void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover);
#else
static inline void gtk_display_init(DisplayState *ds, bool full_screen,
bool grab_on_hover)
{
/* This must never be called if CONFIG_GTK is disabled */
error_report("GTK support is disabled");
abort();
}
static inline void early_gtk_display_init(int opengl)
{
/* This must never be called if CONFIG_GTK is disabled */
error_report("GTK support is disabled");
abort();
}
#endif
#endif
......@@ -51,6 +51,8 @@ static inline CharDriverState *qemu_chr_open_spice_port(const char *name)
#else /* CONFIG_SPICE */
#include "qemu/error-report.h"
#define using_spice 0
#define spice_displays 0
static inline int qemu_spice_set_passwd(const char *passwd,
......@@ -75,6 +77,17 @@ static inline int qemu_spice_display_add_client(int csock, int skipauth,
return -1;
}
static inline void qemu_spice_display_init(void)
{
/* This must never be called if CONFIG_SPICE is disabled */
error_report("spice support is disabled");
abort();
}
static inline void qemu_spice_init(void)
{
}
#endif /* CONFIG_SPICE */
static inline bool qemu_using_spice(Error **errp)
......
......@@ -3492,10 +3492,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
if (qcrypto_init(&local_error) < 0) {
error_reportf_err(local_error, "cannot initialize crypto: ");
exit(1);
}
qcrypto_init(&error_fatal);
module_call_init(MODULE_INIT_QOM);
bdrv_init();
......
......@@ -466,10 +466,7 @@ int main(int argc, char **argv)
progname = basename(argv[0]);
qemu_init_exec_dir(argv[0]);
if (qcrypto_init(&local_error) < 0) {
error_reportf_err(local_error, "cannot initialize crypto: ");
exit(1);
}
qcrypto_init(&error_fatal);
module_call_init(MODULE_INIT_QOM);
qemu_add_opts(&qemu_object_opts);
......
......@@ -527,10 +527,7 @@ int main(int argc, char **argv)
sa_sigterm.sa_handler = termsig_handler;
sigaction(SIGTERM, &sa_sigterm, NULL);
if (qcrypto_init(&local_err) < 0) {
error_reportf_err(local_err, "cannot initialize crypto: ");
exit(1);
}
qcrypto_init(&error_fatal);
module_call_init(MODULE_INIT_QOM);
qemu_add_opts(&qemu_object_opts);
......
......@@ -129,10 +129,8 @@ static const char *data_dir[16];
static int data_dir_idx;
const char *bios_name = NULL;
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
DisplayType display_type = DT_DEFAULT;
int request_opengl = -1;
int display_opengl;
static int display_remote;
const char* keyboard_layout = NULL;
ram_addr_t ram_size;
const char *mem_path = NULL;
......@@ -148,9 +146,7 @@ int vga_interface_type = VGA_NONE;
static int full_screen = 0;
static int no_frame = 0;
int no_quit = 0;
#ifdef CONFIG_GTK
static bool grab_on_hover;
#endif
CharDriverState *serial_hds[MAX_SERIAL_PORTS];
CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
......@@ -892,16 +888,13 @@ static void configure_rtc(QemuOpts *opts)
value = qemu_opt_get(opts, "driftfix");
if (value) {
if (!strcmp(value, "slew")) {
static GlobalProperty slew_lost_ticks[] = {
{
.driver = "mc146818rtc",
.property = "lost_tick_policy",
.value = "slew",
},
{ /* end of list */ }
static GlobalProperty slew_lost_ticks = {
.driver = "mc146818rtc",
.property = "lost_tick_policy",
.value = "slew",
};
qdev_prop_register_global_list(slew_lost_ticks);
qdev_prop_register_global(&slew_lost_ticks);
} else if (!strcmp(value, "none")) {
/* discard is default */
} else {
......@@ -1981,99 +1974,86 @@ static const QEMUOption qemu_options[] = {
{ NULL },
};
static bool vga_available(void)
{
return object_class_by_name("VGA") || object_class_by_name("isa-vga");
}
static bool cirrus_vga_available(void)
{
return object_class_by_name("cirrus-vga")
|| object_class_by_name("isa-cirrus-vga");
}
static bool vmware_vga_available(void)
{
return object_class_by_name("vmware-svga");
}
static bool qxl_vga_available(void)
{
return object_class_by_name("qxl-vga");
}
static bool tcx_vga_available(void)
{
return object_class_by_name("SUNW,tcx");
}
typedef struct VGAInterfaceInfo {
const char *opt_name; /* option name */
const char *name; /* human-readable name */
/* Class names indicating that support is available.
* If no class is specified, the interface is always available */
const char *class_names[2];
} VGAInterfaceInfo;
static VGAInterfaceInfo vga_interfaces[VGA_TYPE_MAX] = {
[VGA_NONE] = {
.opt_name = "none",
},
[VGA_STD] = {
.opt_name = "std",
.name = "standard VGA",
.class_names = { "VGA", "isa-vga" },
},
[VGA_CIRRUS] = {
.opt_name = "cirrus",
.name = "Cirrus VGA",
.class_names = { "cirrus-vga", "isa-cirrus-vga" },
},
[VGA_VMWARE] = {
.opt_name = "vmware",
.name = "VMWare SVGA",
.class_names = { "vmware-svga" },
},
[VGA_VIRTIO] = {
.opt_name = "virtio",
.name = "Virtio VGA",
.class_names = { "virtio-vga" },
},
[VGA_QXL] = {
.opt_name = "qxl",
.name = "QXL VGA",
.class_names = { "qxl-vga" },
},
[VGA_TCX] = {
.opt_name = "tcx",
.name = "TCX framebuffer",
.class_names = { "SUNW,tcx" },
},
[VGA_CG3] = {
.opt_name = "cg3",
.name = "CG3 framebuffer",
.class_names = { "cgthree" },
},
[VGA_XENFB] = {
.opt_name = "xenfb",
},
};
static bool cg3_vga_available(void)
static bool vga_interface_available(VGAInterfaceType t)
{
return object_class_by_name("cgthree");
}
VGAInterfaceInfo *ti = &vga_interfaces[t];
static bool virtio_vga_available(void)
{
return object_class_by_name("virtio-vga");
assert(t < VGA_TYPE_MAX);
return !ti->class_names[0] ||
object_class_by_name(ti->class_names[0]) ||
object_class_by_name(ti->class_names[1]);
}
static void select_vgahw (const char *p)
static void select_vgahw(const char *p)
{
const char *opts;
int t;
assert(vga_interface_type == VGA_NONE);
if (strstart(p, "std", &opts)) {
if (vga_available()) {
vga_interface_type = VGA_STD;
} else {
error_report("standard VGA not available");
exit(0);
}
} else if (strstart(p, "cirrus", &opts)) {
if (cirrus_vga_available()) {
vga_interface_type = VGA_CIRRUS;
} else {
error_report("Cirrus VGA not available");
exit(0);
}
} else if (strstart(p, "vmware", &opts)) {
if (vmware_vga_available()) {
vga_interface_type = VGA_VMWARE;
} else {
error_report("VMWare SVGA not available");
exit(0);
}
} else if (strstart(p, "virtio", &opts)) {
if (virtio_vga_available()) {
vga_interface_type = VGA_VIRTIO;
} else {
error_report("Virtio VGA not available");
exit(0);
}
} else if (strstart(p, "xenfb", &opts)) {
vga_interface_type = VGA_XENFB;
} else if (strstart(p, "qxl", &opts)) {
if (qxl_vga_available()) {
vga_interface_type = VGA_QXL;
} else {
error_report("QXL VGA not available");
exit(0);
}
} else if (strstart(p, "tcx", &opts)) {
if (tcx_vga_available()) {
vga_interface_type = VGA_TCX;
} else {
error_report("TCX framebuffer not available");
exit(0);
}
} else if (strstart(p, "cg3", &opts)) {
if (cg3_vga_available()) {
vga_interface_type = VGA_CG3;
} else {
error_report("CG3 framebuffer not available");
exit(0);
for (t = 0; t < VGA_TYPE_MAX; t++) {
VGAInterfaceInfo *ti = &vga_interfaces[t];
if (ti->opt_name && strstart(p, ti->opt_name, &opts)) {
if (!vga_interface_available(t)) {
error_report("%s not available", ti->name);
exit(1);
}
vga_interface_type = t;
break;
}
} else if (!strstart(p, "none", &opts)) {
}
if (t == VGA_TYPE_MAX) {
invalid_vga:
error_report("unknown vga type: %s", p);
exit(1);
......@@ -2093,6 +2073,15 @@ static void select_vgahw (const char *p)
}
}
typedef enum DisplayType {
DT_DEFAULT,
DT_CURSES,
DT_SDL,
DT_COCOA,
DT_GTK,
DT_NONE,
} DisplayType;
static DisplayType select_display(const char *p)
{
const char *opts;
......@@ -2161,21 +2150,12 @@ static DisplayType select_display(const char *p)
exit(1);
#endif
} else if (strstart(p, "vnc", &opts)) {
#ifdef CONFIG_VNC
if (*opts == '=') {
Error *err = NULL;
if (vnc_parse(opts + 1, &err) == NULL) {
error_report_err(err);
exit(1);
}
vnc_parse(opts + 1, &error_fatal);
} else {
error_report("VNC requires a display argument vnc=<display>");
exit(1);
}
#else
error_report("VNC support is disabled");
exit(1);
#endif
} else if (strstart(p, "curses", &opts)) {
#ifdef CONFIG_CURSES
display = DT_CURSES;
......@@ -2424,7 +2404,6 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
static void monitor_parse(const char *optarg, const char *mode, bool pretty)
{
static int monitor_device_index = 0;
Error *local_err = NULL;
QemuOpts *opts;
const char *p;
char label[32];
......@@ -2445,11 +2424,7 @@ static void monitor_parse(const char *optarg, const char *mode, bool pretty)
}
}
opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, &local_err);
if (!opts) {
error_report_err(local_err);
exit(1);
}
opts = qemu_opts_create(qemu_find_opts("mon"), label, 1, &error_fatal);
qemu_opt_set(opts, "mode", mode, &error_abort);
qemu_opt_set(opts, "chardev", label, &error_abort);
qemu_opt_set_bool(opts, "pretty", pretty, &error_abort);
......@@ -2979,11 +2954,12 @@ int main(int argc, char **argv, char **envp)
const char *qtest_log = NULL;
const char *pid_file = NULL;
const char *incoming = NULL;
#ifdef CONFIG_VNC
int show_vnc_port = 0;
#endif
bool defconfig = true;
bool userconfig = true;
bool nographic = false;
DisplayType display_type = DT_DEFAULT;
int display_remote = 0;
const char *log_mask = NULL;
const char *log_file = NULL;
char *trace_file = NULL;
......@@ -3228,7 +3204,10 @@ int main(int argc, char **argv, char **envp)
display_type = select_display(optarg);
break;
case QEMU_OPTION_nographic:
display_type = DT_NOGRAPHIC;
olist = qemu_find_opts("machine");
qemu_opts_parse_noisily(olist, "graphics=off", false);
nographic = true;
display_type = DT_NONE;
break;
case QEMU_OPTION_curses:
#ifdef CONFIG_CURSES
......@@ -3635,16 +3614,13 @@ int main(int argc, char **argv, char **envp)
win2k_install_hack = 1;
break;
case QEMU_OPTION_rtc_td_hack: {
static GlobalProperty slew_lost_ticks[] = {
{
.driver = "mc146818rtc",
.property = "lost_tick_policy",
.value = "slew",
},
{ /* end of list */ }
static GlobalProperty slew_lost_ticks = {
.driver = "mc146818rtc",
.property = "lost_tick_policy",
.value = "slew",
};
qdev_prop_register_global_list(slew_lost_ticks);
qdev_prop_register_global(&slew_lost_ticks);
break;
}
case QEMU_OPTION_acpitable:
......@@ -3691,18 +3667,15 @@ int main(int argc, char **argv, char **envp)
break;
}
case QEMU_OPTION_no_kvm_pit_reinjection: {
static GlobalProperty kvm_pit_lost_tick_policy[] = {
{
.driver = "kvm-pit",
.property = "lost_tick_policy",
.value = "discard",
},
{ /* end of list */ }
static GlobalProperty kvm_pit_lost_tick_policy = {
.driver = "kvm-pit",
.property = "lost_tick_policy",
.value = "discard",
};
error_report("warning: deprecated, replaced by "
"-global kvm-pit.lost_tick_policy=discard");
qdev_prop_register_global_list(kvm_pit_lost_tick_policy);
qdev_prop_register_global(&kvm_pit_lost_tick_policy);
break;
}
case QEMU_OPTION_usb:
......@@ -3727,20 +3700,8 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_vnc:
{
#ifdef CONFIG_VNC
Error *local_err = NULL;
if (vnc_parse(optarg, &local_err) == NULL) {
error_report_err(local_err);
exit(1);
}
#else
error_report("VNC support is disabled");
exit(1);
#endif
vnc_parse(optarg, &error_fatal);
break;
}
case QEMU_OPTION_no_acpi:
acpi_enabled = 0;
break;
......@@ -4194,7 +4155,7 @@ int main(int argc, char **argv, char **envp)
* -nographic _and_ redirects all ports explicitly - this is valid
* usage, -nographic is just a no-op in this case.
*/
if (display_type == DT_NOGRAPHIC
if (nographic
&& (default_parallel || default_serial
|| default_monitor || default_virtcon)) {
error_report("-nographic cannot be used with -daemonize");
......@@ -4208,7 +4169,7 @@ int main(int argc, char **argv, char **envp)
#endif
}
if (display_type == DT_NOGRAPHIC) {
if (nographic) {
if (default_parallel)
add_device_config(DEV_PARALLEL, "null");
if (default_serial && default_monitor) {
......@@ -4250,8 +4211,10 @@ int main(int argc, char **argv, char **envp)
if (display_type == DT_DEFAULT && !display_remote) {
#if defined(CONFIG_GTK)
display_type = DT_GTK;
#elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
#elif defined(CONFIG_SDL)
display_type = DT_SDL;
#elif defined(CONFIG_COCOA)
display_type = DT_COCOA;
#elif defined(CONFIG_VNC)
vnc_parse("localhost:0,to=99,id=default", &error_abort);
show_vnc_port = 1;
......@@ -4269,16 +4232,14 @@ int main(int argc, char **argv, char **envp)
"ignoring option");
}
#if defined(CONFIG_GTK)
if (display_type == DT_GTK) {
early_gtk_display_init(request_opengl);
}
#endif
#if defined(CONFIG_SDL)
if (display_type == DT_SDL) {
sdl_display_early_init(request_opengl);
}
#endif
if (request_opengl == 1 && display_opengl == 0) {
#if defined(CONFIG_OPENGL)
error_report("OpenGL is not supported by the display");
......@@ -4387,10 +4348,8 @@ int main(int argc, char **argv, char **envp)
os_set_line_buffering();
#ifdef CONFIG_SPICE
/* spice needs the timers to be initialized by this point */
qemu_spice_init();
#endif
cpu_ticks_init();
if (icount_opts) {
......@@ -4481,9 +4440,9 @@ int main(int argc, char **argv, char **envp)
if (default_vga) {
if (machine_class->default_display) {
vga_model = machine_class->default_display;
} else if (cirrus_vga_available()) {
} else if (vga_interface_available(VGA_CIRRUS)) {
vga_model = "cirrus";
} else if (vga_available()) {
} else if (vga_interface_available(VGA_STD)) {
vga_model = "std";
}
}
......@@ -4498,7 +4457,11 @@ int main(int argc, char **argv, char **envp)
}
if (machine_class->compat_props) {
qdev_prop_register_global_list(machine_class->compat_props);
GlobalProperty *p;
for (i = 0; i < machine_class->compat_props->len; i++) {
p = g_array_index(machine_class->compat_props, GlobalProperty *, i);
qdev_prop_register_global(p);
}
}
qemu_add_globals();
......@@ -4560,28 +4523,18 @@ int main(int argc, char **argv, char **envp)
/* init local displays */
switch (display_type) {
case DT_NOGRAPHIC:
(void)ds; /* avoid warning if no display is configured */
break;
#if defined(CONFIG_CURSES)
case DT_CURSES:
curses_display_init(ds, full_screen);
break;
#endif
#if defined(CONFIG_SDL)
case DT_SDL:
sdl_display_init(ds, full_screen, no_frame);
break;
#elif defined(CONFIG_COCOA)
case DT_SDL:
case DT_COCOA:
cocoa_display_init(ds, full_screen);
break;
#endif
#if defined(CONFIG_GTK)
case DT_GTK:
gtk_display_init(ds, full_screen, grab_on_hover);
break;
#endif
default:
break;
}
......@@ -4589,7 +4542,6 @@ int main(int argc, char **argv, char **envp)
/* must be after terminal init, SDL library changes signal handlers */
os_setup_signal_handling();
#ifdef CONFIG_VNC
/* init remote displays */
qemu_opts_foreach(qemu_find_opts("vnc"),
vnc_init_func, NULL, NULL);
......@@ -4598,12 +4550,10 @@ int main(int argc, char **argv, char **envp)
printf("VNC server running on '%s'\n", ret);
g_free(ret);
}
#endif
#ifdef CONFIG_SPICE
if (using_spice) {
qemu_spice_display_init();
}
#endif
if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
exit(1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册