diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-01-30 10:23:20 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-01-30 10:23:20 +0000 |
commit | a0def594286d9110a6035e02eef558cf3cf5d847 (patch) | |
tree | 32275a1bfdd6c17682788f2b2e018a15c3b30214 /include | |
parent | 3aca12f841fcd6f3a7477076dad0d564360500de (diff) | |
parent | 6da67de6803e93cbb7e93ac3497865832f8c00ea (diff) | |
download | qemu-a0def594286d9110a6035e02eef558cf3cf5d847.zip qemu-a0def594286d9110a6035e02eef558cf3cf5d847.tar.gz qemu-a0def594286d9110a6035e02eef558cf3cf5d847.tar.bz2 |
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* SCSI max_transfer support for scsi-generic (Eric)
* x86 SMI broadcast (Laszlo)
* Character device QOMification (Marc-André)
* Record/replay improvements (Pavel)
* iscsi fixes (Peter L.)
* "info mtree -f" command (Peter Xu)
* TSC clock rate reporting (Phil)
* DEVICE_CATEGORY_CPU (Thomas)
* Memory sign-extension fix (Ladi)
# gpg: Signature made Fri 27 Jan 2017 17:08:51 GMT
# gpg: using RSA key 0xBFFBD25F78C7AE83
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>"
# gpg: aka "Paolo Bonzini <pbonzini@redhat.com>"
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1
# Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83
* remotes/bonzini/tags/for-upstream: (41 commits)
memory: don't sign-extend 32-bit writes
chardev: qom-ify
vc: use a common prefix for chr callbacks
baum: use a common prefix for chr callbacks
gtk: overwrite the console.c char driver
char: use error_report()
spice-char: improve error reporting
char: rename TCPChardev and NetChardev
char: rename CharDriverState Chardev
bt: use qemu_chr_alloc()
char: allocate CharDriverState as a single object
char: use a feature bit for replay
char: introduce generic qemu_chr_get_kind()
char: fold single-user functions in caller
char: move callbacks in CharDriver
char: use a static array for backends
char: use a const CharDriver
doc: fix spelling
char: add qemu_chr_fe_add_watch() Returns description
qemu-options: stdio is available on win32
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
30 files changed, 163 insertions, 95 deletions
diff --git a/include/block/block.h b/include/block/block.h index 8b0dcda..4e81f20 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -116,6 +116,7 @@ typedef struct HDGeometry { #define BDRV_REQUEST_MAX_SECTORS MIN(SIZE_MAX >> BDRV_SECTOR_BITS, \ INT_MAX >> BDRV_SECTOR_BITS) +#define BDRV_REQUEST_MAX_BYTES (BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS) /* * Allocation status flags diff --git a/include/exec/memory.h b/include/exec/memory.h index a10044f..987f925 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1250,7 +1250,7 @@ void memory_global_dirty_log_start(void); */ void memory_global_dirty_log_stop(void); -void mtree_info(fprintf_function mon_printf, void *f); +void mtree_info(fprintf_function mon_printf, void *f, bool flatview); /** * memory_region_dispatch_read: perform a read directly to the specified diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h index 76bb6d4..d9e0801 100644 --- a/include/hw/arm/exynos4210.h +++ b/include/hw/arm/exynos4210.h @@ -131,7 +131,7 @@ void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, DeviceState *exynos4210_uart_create(hwaddr addr, int fifo_size, int channel, - CharDriverState *chr, + Chardev *chr, qemu_irq irq); #endif /* EXYNOS4210_H */ diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h index f25870b..cac1b2b 100644 --- a/include/hw/arm/omap.h +++ b/include/hw/arm/omap.h @@ -664,14 +664,14 @@ struct omap_uart_s; struct omap_uart_s *omap_uart_init(hwaddr base, qemu_irq irq, omap_clk fclk, omap_clk iclk, qemu_irq txdma, qemu_irq rxdma, - const char *label, CharDriverState *chr); + const char *label, Chardev *chr); struct omap_uart_s *omap2_uart_init(MemoryRegion *sysmem, struct omap_target_agent_s *ta, qemu_irq irq, omap_clk fclk, omap_clk iclk, qemu_irq txdma, qemu_irq rxdma, - const char *label, CharDriverState *chr); + const char *label, Chardev *chr); void omap_uart_reset(struct omap_uart_s *s); -void omap_uart_attach(struct omap_uart_s *s, CharDriverState *chr); +void omap_uart_attach(struct omap_uart_s *s, Chardev *chr); struct omap_mpuio_s; qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s); diff --git a/include/hw/bt.h b/include/hw/bt.h index 2fa22bd..b5e11d4 100644 --- a/include/hw/bt.h +++ b/include/hw/bt.h @@ -127,8 +127,8 @@ enum { csrhci_pin_wakeup, __csrhci_pins, }; -qemu_irq *csrhci_pins_get(CharDriverState *chr); -CharDriverState *uart_hci_init(void); +qemu_irq *csrhci_pins_get(Chardev *chr); +Chardev *uart_hci_init(void); /* bt-l2cap.c */ struct bt_l2cap_device_s; diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h index ca75eb5..c836db4 100644 --- a/include/hw/char/cadence_uart.h +++ b/include/hw/char/cadence_uart.h @@ -51,7 +51,7 @@ typedef struct { static inline DeviceState *cadence_uart_create(hwaddr addr, qemu_irq irq, - CharDriverState *chr) + Chardev *chr) { DeviceState *dev; SysBusDevice *s; diff --git a/include/hw/char/escc.h b/include/hw/char/escc.h index 297e2eb..08ae122 100644 --- a/include/hw/char/escc.h +++ b/include/hw/char/escc.h @@ -5,7 +5,7 @@ #define TYPE_ESCC "escc" #define ESCC_SIZE 4 MemoryRegion *escc_init(hwaddr base, qemu_irq irqA, qemu_irq irqB, - CharDriverState *chrA, CharDriverState *chrB, + Chardev *chrA, Chardev *chrB, int clock, int it_shift); void slavio_serial_ms_kbd_init(hwaddr base, qemu_irq irq, diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index 0ca7c19..8364932 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -17,7 +17,7 @@ static inline DeviceState *pl011_create(hwaddr addr, qemu_irq irq, - CharDriverState *chr) + Chardev *chr) { DeviceState *dev; SysBusDevice *s; @@ -34,7 +34,7 @@ static inline DeviceState *pl011_create(hwaddr addr, static inline DeviceState *pl011_luminary_create(hwaddr addr, qemu_irq irq, - CharDriverState *chr) + Chardev *chr) { DeviceState *dev; SysBusDevice *s; diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index c928d7d..daebb07 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -88,11 +88,11 @@ void serial_set_frequency(SerialState *s, uint32_t frequency); /* legacy pre qom */ SerialState *serial_init(int base, qemu_irq irq, int baudbase, - CharDriverState *chr, MemoryRegion *system_io); + Chardev *chr, MemoryRegion *system_io); SerialState *serial_mm_init(MemoryRegion *address_space, hwaddr base, int it_shift, qemu_irq irq, int baudbase, - CharDriverState *chr, enum device_endian end); + Chardev *chr, enum device_endian end); /* serial-isa.c */ #define TYPE_ISA_SERIAL "isa-serial" diff --git a/include/hw/char/xilinx_uartlite.h b/include/hw/char/xilinx_uartlite.h index 8b4fc54..634086b 100644 --- a/include/hw/char/xilinx_uartlite.h +++ b/include/hw/char/xilinx_uartlite.h @@ -17,7 +17,7 @@ static inline DeviceState *xilinx_uartlite_create(hwaddr addr, qemu_irq irq, - CharDriverState *chr) + Chardev *chr) { DeviceState *dev; SysBusDevice *s; diff --git a/include/hw/cris/etraxfs.h b/include/hw/cris/etraxfs.h index 723a275..8da965a 100644 --- a/include/hw/cris/etraxfs.h +++ b/include/hw/cris/etraxfs.h @@ -48,7 +48,7 @@ etraxfs_eth_init(NICInfo *nd, hwaddr base, int phyaddr, static inline DeviceState *etraxfs_ser_create(hwaddr addr, qemu_irq irq, - CharDriverState *chr) + Chardev *chr) { DeviceState *dev; SysBusDevice *s; diff --git a/include/hw/devices.h b/include/hw/devices.h index c60bcab..7475b71 100644 --- a/include/hw/devices.h +++ b/include/hw/devices.h @@ -65,6 +65,6 @@ qemu_irq tc6393xb_l3v_get(TC6393xbState *s); /* sm501.c */ void sm501_init(struct MemoryRegion *address_space_mem, uint32_t base, uint32_t local_mem_bytes, qemu_irq irq, - CharDriverState *chr); + Chardev *chr); #endif diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index 1209eb4..20ad28c 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -189,6 +189,8 @@ struct APICCommonState { DeviceState *vapic; hwaddr vapic_paddr; /* note: persistence via kvmvapic */ bool legacy_instance_id; + + int apic_irq_delivered; /* for saving static variable */ }; typedef struct VAPICState { diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h index 5fd7e97..18dcca7 100644 --- a/include/hw/i386/ich9.h +++ b/include/hw/i386/ich9.h @@ -64,6 +64,16 @@ typedef struct ICH9LPCState { uint8_t rst_cnt; MemoryRegion rst_cnt_mem; + /* SMI feature negotiation via fw_cfg */ + uint64_t smi_host_features; /* guest-invisible, host endian */ + uint8_t smi_host_features_le[8]; /* guest-visible, read-only, little + * endian uint64_t */ + uint8_t smi_guest_features_le[8]; /* guest-visible, read-write, little + * endian uint64_t */ + uint8_t smi_features_ok; /* guest-visible, read-only; selecting it + * triggers feature lockdown */ + uint64_t smi_negotiated_features; /* guest-invisible, host endian */ + /* isa bus */ ISABus *isa_bus; MemoryRegion rcrb_mem; /* root complex register block */ @@ -240,4 +250,7 @@ Object *ich9_lpc_find(void); #define ICH9_SMB_HST_D1 0x06 #define ICH9_SMB_HOST_BLOCK_DB 0x07 +/* bit positions used in fw_cfg SMI feature negotiation */ +#define ICH9_LPC_SMI_F_BROADCAST_BIT 0 + #endif /* HW_ICH9_H */ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 5a20c5e..079e8d9 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -181,7 +181,7 @@ void parallel_hds_isa_init(ISABus *bus, int n); bool parallel_mm_init(MemoryRegion *address_space, hwaddr base, int it_shift, qemu_irq irq, - CharDriverState *chr); + Chardev *chr); /* i8259.c */ @@ -381,6 +381,16 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .property = "x-mach-use-reliable-get-clock",\ .value = "off",\ },\ + {\ + .driver = "ICH9-LPC",\ + .property = "x-smi-broadcast",\ + .value = "off",\ + },\ + {\ + .driver = TYPE_X86_CPU,\ + .property = "vmware-cpuid-freq",\ + .value = "off",\ + }, #define PC_COMPAT_2_7 \ HW_COMPAT_2_7 \ diff --git a/include/hw/m68k/mcf.h b/include/hw/m68k/mcf.h index bf43998..9a0bcfa 100644 --- a/include/hw/m68k/mcf.h +++ b/include/hw/m68k/mcf.h @@ -11,10 +11,10 @@ uint64_t mcf_uart_read(void *opaque, hwaddr addr, unsigned size); void mcf_uart_write(void *opaque, hwaddr addr, uint64_t val, unsigned size); -void *mcf_uart_init(qemu_irq irq, CharDriverState *chr); +void *mcf_uart_init(qemu_irq irq, Chardev *chr); void mcf_uart_mm_init(struct MemoryRegion *sysmem, hwaddr base, - qemu_irq irq, CharDriverState *chr); + qemu_irq irq, Chardev *chr); /* mcf_intc.c */ qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem, diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index 14f5022..fc6f673 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -127,7 +127,7 @@ int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq); VIOsPAPRDevice *vty_lookup(sPAPRMachineState *spapr, target_ulong reg); void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len); -void spapr_vty_create(VIOsPAPRBus *bus, CharDriverState *chardev); +void spapr_vty_create(VIOsPAPRBus *bus, Chardev *chardev); void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd); void spapr_vscsi_create(VIOsPAPRBus *bus); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 2c97347..b44b476 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -26,6 +26,7 @@ typedef enum DeviceCategory { DEVICE_CATEGORY_DISPLAY, DEVICE_CATEGORY_SOUND, DEVICE_CATEGORY_MISC, + DEVICE_CATEGORY_CPU, DEVICE_CATEGORY_MAX } DeviceCategory; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 306bbab..7ac3153 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -184,7 +184,7 @@ void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value); void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value); void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value); void qdev_prop_set_string(DeviceState *dev, const char *name, const char *value); -void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value); +void qdev_prop_set_chr(DeviceState *dev, const char *name, Chardev *value); void qdev_prop_set_netdev(DeviceState *dev, const char *name, NetClientState *value); void qdev_prop_set_drive(DeviceState *dev, const char *name, BlockBackend *value, Error **errp); diff --git a/include/hw/sh4/sh.h b/include/hw/sh4/sh.h index e59b9e7..767a2df 100644 --- a/include/hw/sh4/sh.h +++ b/include/hw/sh4/sh.h @@ -42,7 +42,7 @@ void tmu012_init(struct MemoryRegion *sysmem, hwaddr base, #define SH_SERIAL_FEAT_SCIF (1 << 0) void sh_serial_init(MemoryRegion *sysmem, hwaddr base, int feat, - uint32_t freq, CharDriverState *chr, + uint32_t freq, Chardev *chr, qemu_irq eri_source, qemu_irq rxi_source, qemu_irq txi_source, diff --git a/include/hw/sparc/grlib.h b/include/hw/sparc/grlib.h index afbb9bc..61a345c 100644 --- a/include/hw/sparc/grlib.h +++ b/include/hw/sparc/grlib.h @@ -100,7 +100,7 @@ DeviceState *grlib_gptimer_create(hwaddr base, static inline DeviceState *grlib_apbuart_create(hwaddr base, - CharDriverState *serial, + Chardev *serial, qemu_irq irq) { DeviceState *dev; diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index a8f3afb..09c2ce5 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -37,7 +37,7 @@ int xen_is_pirq_msi(uint32_t msi_data); qemu_irq *xen_interrupt_controller_init(void); -void xenstore_store_pv_console_info(int i, struct CharDriverState *chr); +void xenstore_store_pv_console_info(int i, struct Chardev *chr); void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory); diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 8cc532e..e64b944 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -16,7 +16,7 @@ extern Monitor *cur_mon; bool monitor_cur_is_qmp(void); -void monitor_init(CharDriverState *chr, int flags); +void monitor_init(Chardev *chr, int flags); void monitor_cleanup(void); int monitor_suspend(Monitor *mon); diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 9a8bcbd..e95f28c 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -17,7 +17,7 @@ typedef struct BlockBackendRootState BlockBackendRootState; typedef struct BlockDriverState BlockDriverState; typedef struct BusClass BusClass; typedef struct BusState BusState; -typedef struct CharDriverState CharDriverState; +typedef struct Chardev Chardev; typedef struct CompatProperty CompatProperty; typedef struct CPUAddressSpace CPUAddressSpace; typedef struct CPUState CPUState; diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 0a14942..da0e7dd 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -10,6 +10,7 @@ #include "qapi/qmp/qstring.h" #include "qemu/main-loop.h" #include "qemu/bitmap.h" +#include "qom/object.h" /* character device */ @@ -69,14 +70,16 @@ typedef enum { /* Whether it is possible to send/recv file descriptors * over the data channel */ QEMU_CHAR_FEATURE_FD_PASS, + /* Whether replay or record mode is enabled */ + QEMU_CHAR_FEATURE_REPLAY, QEMU_CHAR_FEATURE_LAST, } CharDriverFeature; /* This is the backend as seen by frontend, the actual backend is - * CharDriverState */ + * Chardev */ typedef struct CharBackend { - CharDriverState *chr; + Chardev *chr; IOEventHandler *chr_event; IOCanReadHandler *chr_can_read; IOReadHandler *chr_read; @@ -85,49 +88,23 @@ typedef struct CharBackend { int fe_open; } CharBackend; -struct CharDriverState { +typedef struct CharDriver CharDriver; + +struct Chardev { + Object parent_obj; + QemuMutex chr_write_lock; - int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); - int (*chr_sync_read)(struct CharDriverState *s, - const uint8_t *buf, int len); - GSource *(*chr_add_watch)(struct CharDriverState *s, GIOCondition cond); - void (*chr_update_read_handler)(struct CharDriverState *s, - GMainContext *context); - int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); - int (*get_msgfds)(struct CharDriverState *s, int* fds, int num); - int (*set_msgfds)(struct CharDriverState *s, int *fds, int num); - int (*chr_add_client)(struct CharDriverState *chr, int fd); - int (*chr_wait_connected)(struct CharDriverState *chr, Error **errp); - void (*chr_free)(struct CharDriverState *chr); - void (*chr_disconnect)(struct CharDriverState *chr); - void (*chr_accept_input)(struct CharDriverState *chr); - void (*chr_set_echo)(struct CharDriverState *chr, bool echo); - void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open); CharBackend *be; - void *opaque; char *label; char *filename; int logfd; int be_open; - int is_mux; guint fd_in_tag; - bool replay; DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST); - QTAILQ_ENTRY(CharDriverState) next; + QTAILQ_ENTRY(Chardev) next; }; /** - * qemu_chr_alloc: - * @backend: the common backend config - * @errp: pointer to a NULL-initialized error object - * - * Allocate and initialize a new CharDriverState. - * - * Returns: a newly allocated CharDriverState, or NULL on error. - */ -CharDriverState *qemu_chr_alloc(ChardevCommon *backend, Error **errp); - -/** * @qemu_chr_new_from_opts: * * Create a new character backend from a QemuOpts list. @@ -136,8 +113,8 @@ CharDriverState *qemu_chr_alloc(ChardevCommon *backend, Error **errp); * * Returns: a new character backend */ -CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, - Error **errp); +Chardev *qemu_chr_new_from_opts(QemuOpts *opts, + Error **errp); /** * @qemu_chr_parse_common: @@ -159,7 +136,7 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend); * * Returns: a new character backend */ -CharDriverState *qemu_chr_new(const char *label, const char *filename); +Chardev *qemu_chr_new(const char *label, const char *filename); /** @@ -197,7 +174,7 @@ int qemu_chr_fe_wait_connected(CharBackend *be, Error **errp); * * Returns: a new character backend */ -CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename); +Chardev *qemu_chr_new_noreplay(const char *label, const char *filename); /** * @qemu_chr_delete: @@ -205,14 +182,14 @@ CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename); * Destroy a character backend and remove it from the list of * identified character backends. */ -void qemu_chr_delete(CharDriverState *chr); +void qemu_chr_delete(Chardev *chr); /** * @qemu_chr_free: * * Destroy a character backend. */ -void qemu_chr_free(CharDriverState *chr); +void qemu_chr_free(Chardev *chr); /** * @qemu_chr_fe_set_echo: @@ -258,6 +235,8 @@ void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...) * @cond the condition to poll for * @func the function to call when the condition happens * @user_data the opaque pointer to pass to @func + * + * Returns: the source tag */ guint qemu_chr_fe_add_watch(CharBackend *be, GIOCondition cond, GIOFunc func, void *user_data); @@ -366,7 +345,7 @@ int qemu_chr_fe_set_msgfds(CharBackend *be, int *fds, int num); * * Returns: the number of bytes the front end can receive via @qemu_chr_be_write */ -int qemu_chr_be_can_write(CharDriverState *s); +int qemu_chr_be_can_write(Chardev *s); /** * @qemu_chr_be_write: @@ -378,7 +357,7 @@ int qemu_chr_be_can_write(CharDriverState *s); * @buf a buffer to receive data from the front end * @len the number of bytes to receive from the front end */ -void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len); +void qemu_chr_be_write(Chardev *s, uint8_t *buf, int len); /** * @qemu_chr_be_write_impl: @@ -388,7 +367,7 @@ void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len); * @buf a buffer to receive data from the front end * @len the number of bytes to receive from the front end */ -void qemu_chr_be_write_impl(CharDriverState *s, uint8_t *buf, int len); +void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len); /** * @qemu_chr_be_event: @@ -397,7 +376,7 @@ void qemu_chr_be_write_impl(CharDriverState *s, uint8_t *buf, int len); * * @event the event to send */ -void qemu_chr_be_event(CharDriverState *s, int event); +void qemu_chr_be_event(Chardev *s, int event); /** * @qemu_chr_fe_init: @@ -408,7 +387,7 @@ void qemu_chr_be_event(CharDriverState *s, int event); * * Returns: false on error. */ -bool qemu_chr_fe_init(CharBackend *b, CharDriverState *s, Error **errp); +bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp); /** * @qemu_chr_fe_get_driver: @@ -416,7 +395,7 @@ bool qemu_chr_fe_init(CharBackend *b, CharDriverState *s, Error **errp); * Returns the driver associated with a CharBackend or NULL if no * associated CharDriver. */ -CharDriverState *qemu_chr_fe_get_driver(CharBackend *be); +Chardev *qemu_chr_fe_get_driver(CharBackend *be); /** * @qemu_chr_fe_deinit: @@ -461,33 +440,83 @@ void qemu_chr_fe_set_handlers(CharBackend *b, */ void qemu_chr_fe_take_focus(CharBackend *b); -void qemu_chr_be_generic_open(CharDriverState *s); +void qemu_chr_be_generic_open(Chardev *s); void qemu_chr_fe_accept_input(CharBackend *be); -int qemu_chr_add_client(CharDriverState *s, int fd); -CharDriverState *qemu_chr_find(const char *name); -bool chr_is_ringbuf(const CharDriverState *chr); +int qemu_chr_add_client(Chardev *s, int fd); +Chardev *qemu_chr_find(const char *name); -bool qemu_chr_has_feature(CharDriverState *chr, +bool qemu_chr_has_feature(Chardev *chr, CharDriverFeature feature); -void qemu_chr_set_feature(CharDriverState *chr, +void qemu_chr_set_feature(Chardev *chr, CharDriverFeature feature); QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); -typedef void CharDriverParse(QemuOpts *opts, ChardevBackend *backend, - Error **errp); -typedef CharDriverState *CharDriverCreate(const char *id, - ChardevBackend *backend, - ChardevReturn *ret, bool *be_opened, - Error **errp); +#define TYPE_CHARDEV "chardev" +#define CHARDEV(obj) OBJECT_CHECK(Chardev, (obj), TYPE_CHARDEV) +#define CHARDEV_CLASS(klass) \ + OBJECT_CLASS_CHECK(ChardevClass, (klass), TYPE_CHARDEV) +#define CHARDEV_GET_CLASS(obj) \ + OBJECT_GET_CLASS(ChardevClass, (obj), TYPE_CHARDEV) + +#define TYPE_CHARDEV_NULL "chardev-null" +#define TYPE_CHARDEV_MUX "chardev-mux" +#define TYPE_CHARDEV_RINGBUF "chardev-ringbuf" +#define TYPE_CHARDEV_PTY "chardev-pty" +#define TYPE_CHARDEV_CONSOLE "chardev-console" +#define TYPE_CHARDEV_STDIO "chardev-stdio" +#define TYPE_CHARDEV_PIPE "chardev-pipe" +#define TYPE_CHARDEV_MEMORY "chardev-memory" +#define TYPE_CHARDEV_PARALLEL "chardev-parallel" +#define TYPE_CHARDEV_FILE "chardev-file" +#define TYPE_CHARDEV_SERIAL "chardev-serial" +#define TYPE_CHARDEV_SOCKET "chardev-socket" +#define TYPE_CHARDEV_UDP "chardev-udp" + +#define CHARDEV_IS_MUX(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX) +#define CHARDEV_IS_RINGBUF(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_RINGBUF) +#define CHARDEV_IS_PTY(chr) \ + object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_PTY) + +typedef struct ChardevClass { + ObjectClass parent_class; + + bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */ + + void (*open)(Chardev *chr, ChardevBackend *backend, + bool *be_opened, Error **errp); + + int (*chr_write)(Chardev *s, const uint8_t *buf, int len); + int (*chr_sync_read)(Chardev *s, const uint8_t *buf, int len); + GSource *(*chr_add_watch)(Chardev *s, GIOCondition cond); + void (*chr_update_read_handler)(Chardev *s, GMainContext *context); + int (*chr_ioctl)(Chardev *s, int cmd, void *arg); + int (*get_msgfds)(Chardev *s, int* fds, int num); + int (*set_msgfds)(Chardev *s, int *fds, int num); + int (*chr_add_client)(Chardev *chr, int fd); + int (*chr_wait_connected)(Chardev *chr, Error **errp); + void (*chr_free)(Chardev *chr); + void (*chr_disconnect)(Chardev *chr); + void (*chr_accept_input)(Chardev *chr); + void (*chr_set_echo)(Chardev *chr, bool echo); + void (*chr_set_fe_open)(Chardev *chr, int fe_open); +} ChardevClass; + +struct CharDriver { + ChardevBackendKind kind; + const char *alias; + void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp); +}; -void register_char_driver(const char *name, ChardevBackendKind kind, - CharDriverParse *parse, CharDriverCreate *create); +Chardev *qemu_chardev_new(const char *id, const char *typename, + ChardevBackend *backend, Error **errp); -extern int term_escape_char; +void register_char_driver(const CharDriver *driver); +extern int term_escape_char; /* console.c */ -typedef CharDriverState *(VcHandler)(ChardevVC *vc, Error **errp); -void register_vc_handler(VcHandler *handler); +void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp); #endif diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index abb35ca..7aad20b 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -43,6 +43,9 @@ typedef struct ReplayNetState ReplayNetState; extern ReplayMode replay_mode; +/* Name of the initial VM snapshot */ +extern char *replay_snapshot; + /* Replay process control functions */ /*! Enables recording or saving event log with specified parameters */ @@ -125,9 +128,9 @@ uint64_t blkreplay_next_id(void); /* Character device */ /*! Registers char driver to save it's events */ -void replay_register_char_driver(struct CharDriverState *chr); +void replay_register_char_driver(struct Chardev *chr); /*! Saves write to char device event to the log */ -void replay_chr_be_write(struct CharDriverState *s, uint8_t *buf, int len); +void replay_chr_be_write(struct Chardev *s, uint8_t *buf, int len); /*! Writes char write return value to the replay log. */ void replay_char_write_event_save(int res, int offset); /*! Reads char write return value from the replay log. */ @@ -149,4 +152,10 @@ void replay_unregister_net(ReplayNetState *rns); void replay_net_packet_event(ReplayNetState *rns, unsigned flags, const struct iovec *iov, int iovcnt); +/* VM state operations */ + +/*! Called at the start of execution. + Loads or saves initial vmstate depending on execution mode. */ +void replay_vmstate_init(void); + #endif diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index ff8ffb5..4d50694 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -74,6 +74,7 @@ void qemu_add_machine_init_done_notifier(Notifier *notify); void qemu_remove_machine_init_done_notifier(Notifier *notify); void hmp_savevm(Monitor *mon, const QDict *qdict); +int save_vmstate(Monitor *mon, const char *name); int load_vmstate(const char *name); void hmp_delvm(Monitor *mon, const QDict *qdict); void hmp_info_snapshots(Monitor *mon, const QDict *qdict); @@ -189,13 +190,13 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict); #define MAX_SERIAL_PORTS 4 -extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; +extern Chardev *serial_hds[MAX_SERIAL_PORTS]; /* parallel ports */ #define MAX_PARALLEL_PORTS 3 -extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; +extern Chardev *parallel_hds[MAX_PARALLEL_PORTS]; void hmp_usb_add(Monitor *mon, const QDict *qdict); void hmp_usb_del(Monitor *mon, const QDict *qdict); diff --git a/include/ui/console.h b/include/ui/console.h index b59e7b8..af6350e 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -383,6 +383,8 @@ void graphic_hw_invalidate(QemuConsole *con); void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); void graphic_hw_gl_block(QemuConsole *con, bool block); +void qemu_console_early_init(void); + QemuConsole *qemu_console_lookup_by_index(unsigned int index); QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head); QemuConsole *qemu_console_lookup_by_device_name(const char *device_id, diff --git a/include/ui/gtk.h b/include/ui/gtk.h index b3b5005..47ffddb 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -64,7 +64,7 @@ typedef struct VirtualVteConsole { GtkWidget *box; GtkWidget *scrollbar; GtkWidget *terminal; - CharDriverState *chr; + Chardev *chr; bool echo; } VirtualVteConsole; #endif diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 75e1239..52a9f88 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -51,7 +51,7 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, #if SPICE_SERVER_VERSION >= 0x000c02 void qemu_spice_register_ports(void); #else -static inline CharDriverState *qemu_chr_open_spice_port(const char *name) +static inline Chardev *qemu_chr_open_spice_port(const char *name) { return NULL; } #endif |