From 9a77a0f58923443913e1071ffb47b74c54566e70 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 1 Nov 2012 17:15:01 +0100 Subject: usb: split packet result into actual_length + status Since with the ehci and xhci controllers a single packet can be larger then maxpacketsize, it is possible for the result of a single packet to be both having transferred some data as well as the transfer to have an error. An example would be an input transfer from a bulk endpoint successfully receiving 1 or more maxpacketsize packets from the device, followed by a packet signalling halt. While already touching all the devices and controllers handle_packet / handle_data / handle_control code, also change the return type of these functions to void, solely storing the status in the packet. To make the code paths for regular versus async packet handling more uniform. This patch unfortunately is somewhat invasive, since makeing the qemu usb core deal with this requires changes everywhere. This patch only prepares the usb core for this, all the hcd / device changes are done in such a way that there are no functional changes. This patch has been tested with uhci and ehci hcds, together with usb-audio, usb-hid and usb-storage devices, as well as with usb-redir redirection with a wide variety of real devices. Note that there is usually no need to directly set packet->actual_length form devices handle_data callback, as that is done by usb_packet_copy() Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- hw/usb/host-bsd.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'hw/usb/host-bsd.c') diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c index ec26266620..6473e8b747 100644 --- a/hw/usb/host-bsd.c +++ b/hw/usb/host-bsd.c @@ -121,7 +121,7 @@ static void usb_host_handle_reset(USBDevice *dev) * -check device states against transfer requests * and return appropriate response */ -static int usb_host_handle_control(USBDevice *dev, +static void usb_host_handle_control(USBDevice *dev, USBPacket *p, int request, int value, @@ -139,7 +139,6 @@ static int usb_host_handle_control(USBDevice *dev, /* specific SET_ADDRESS support */ dev->addr = value; - return 0; } else if ((request >> 8) == UT_WRITE_DEVICE && (request & 0xff) == UR_SET_CONFIG) { @@ -151,10 +150,8 @@ static int usb_host_handle_control(USBDevice *dev, printf("handle_control: failed to set configuration - %s\n", strerror(errno)); #endif - return USB_RET_STALL; + p->status = USB_RET_STALL; } - - return 0; } else if ((request >> 8) == UT_WRITE_INTERFACE && (request & 0xff) == UR_SET_INTERFACE) { @@ -168,10 +165,8 @@ static int usb_host_handle_control(USBDevice *dev, printf("handle_control: failed to set alternate interface - %s\n", strerror(errno)); #endif - return USB_RET_STALL; + p->status = USB_RET_STALL; } - - return 0; } else { req.ucr_request.bmRequestType = request >> 8; req.ucr_request.bRequest = request & 0xff; @@ -201,14 +196,14 @@ static int usb_host_handle_control(USBDevice *dev, printf("handle_control: error after request - %s\n", strerror(errno)); #endif - return USB_RET_NAK; // STALL + p->status = USB_RET_NAK; /* STALL */ } else { - return req.ucr_actlen; + p->actual_length = req.ucr_actlen; } } } -static int usb_host_handle_data(USBDevice *dev, USBPacket *p) +static void usb_host_handle_data(USBDevice *dev, USBPacket *p) { USBHostDevice *s = (USBHostDevice *)dev; int ret, fd, mode; @@ -232,7 +227,8 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) fd = ensure_ep_open(s, devep, mode); if (fd < 0) { sigprocmask(SIG_SETMASK, &old_mask, NULL); - return USB_RET_NODEV; + p->status = USB_RET_NODEV; + return; } if (ioctl(fd, USB_SET_TIMEOUT, &timeout) < 0) { @@ -267,12 +263,13 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) switch(errno) { case ETIMEDOUT: case EINTR: - return USB_RET_NAK; + p->status = USB_RET_NAK; + break; default: - return USB_RET_STALL; + p->status = USB_RET_STALL; } } else { - return ret; + p->actual_length = ret; } } -- cgit v1.2.3-55-g7522 From be41efde3ca0372dbf7543e09ff473b4eec25057 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 17 Nov 2012 12:47:15 +0100 Subject: usb: Don't allow USB_RET_ASYNC for interrupt packets It is tempting to use USB_RET_ASYNC for interrupt packets, rather then the current NAK + polling approach, but this causes issues for migration, as an async completed packet will not getting written back to guest memory until the next poll time, and if a migration happens in between it will get lost! Make an exception for host devices, because: 1) host-linux actually uses async completion for interrupt endpoints 2) host devices don't migrate anyways Ideally we would convert host-linux.c to handle (input) interrupt endpoints in a buffered manner like it does for isoc endpoints, keeping multiple urbs submitted to ensure the devices timing requirements are met, as well as making its interrupt ep handling the same as other usb-devices. Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- hw/usb.h | 1 + hw/usb/core.c | 4 ++++ hw/usb/host-bsd.c | 1 + hw/usb/host-linux.c | 1 + 4 files changed, 7 insertions(+) (limited to 'hw/usb/host-bsd.c') diff --git a/hw/usb.h b/hw/usb.h index 7d6de69ec4..58f812f7d0 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -197,6 +197,7 @@ struct USBEndpoint { enum USBDeviceFlags { USB_DEV_FLAG_FULL_PATH, + USB_DEV_FLAG_IS_HOST, }; /* definition of a USB device */ diff --git a/hw/usb/core.c b/hw/usb/core.c index 52b53108cd..8e360d3ec0 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -406,7 +406,11 @@ void usb_handle_packet(USBDevice *dev, USBPacket *p) if (QTAILQ_EMPTY(&p->ep->queue) || p->ep->pipeline) { usb_process_one(p); if (p->status == USB_RET_ASYNC) { + /* hcd drivers cannot handle async for isoc */ assert(p->ep->type != USB_ENDPOINT_XFER_ISOC); + /* using async for interrupt packets breaks migration */ + assert(p->ep->type != USB_ENDPOINT_XFER_INT || + (dev->flags & USB_DEV_FLAG_IS_HOST)); usb_packet_set_state(p, USB_PACKET_ASYNC); QTAILQ_INSERT_TAIL(&p->ep->queue, p, queue); } else if (p->status == USB_RET_ADD_TO_QUEUE) { diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c index 6473e8b747..dae0009378 100644 --- a/hw/usb/host-bsd.c +++ b/hw/usb/host-bsd.c @@ -292,6 +292,7 @@ static void usb_host_handle_destroy(USBDevice *opaque) static int usb_host_initfn(USBDevice *dev) { + dev->flags |= (1 << USB_DEV_FLAG_IS_HOST); return 0; } diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index aa77b7704d..bdafb6bc87 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -1476,6 +1476,7 @@ static int usb_host_initfn(USBDevice *dev) { USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev); + dev->flags |= (1 << USB_DEV_FLAG_IS_HOST); dev->auto_attach = 0; s->fd = -1; s->hub_fd = -1; -- cgit v1.2.3-55-g7522 From 83c9089e73b81c69dc1ecdf859fa84d2c500fb5f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:19:49 +0100 Subject: monitor: move include files to include/monitor/ Signed-off-by: Paolo Bonzini --- arch_init.c | 2 +- audio/audio.c | 2 +- audio/wavcapture.c | 2 +- balloon.c | 2 +- balloon.h | 2 +- block.c | 2 +- blockdev-nbd.c | 2 +- blockdev.c | 2 +- blockjob.c | 2 +- cpus.c | 2 +- disas.c | 2 +- dump.c | 2 +- gdbstub.c | 2 +- hmp.c | 2 +- hw/acpi.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/device-hotplug.c | 2 +- hw/i8259.c | 2 +- hw/ide/ahci.c | 2 +- hw/isa-bus.c | 2 +- hw/kvm/pci-assign.c | 2 +- hw/lm32_pic.c | 2 +- hw/loader.c | 2 +- hw/pc.c | 2 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci-stub.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pcie_aer.c | 2 +- hw/qdev-monitor.c | 2 +- hw/qdev-monitor.h | 2 +- hw/qxl.c | 2 +- hw/s390-virtio-bus.c | 2 +- hw/s390-virtio.c | 2 +- hw/s390x/event-facility.c | 2 +- hw/slavio_intctl.c | 2 +- hw/spapr_vio.c | 2 +- hw/sun4c_intctl.c | 2 +- hw/sysbus.c | 2 +- hw/usb/bus.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- hw/usb/dev-storage.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/host-bsd.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/host-stub.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio-serial-bus.c | 2 +- hw/watchdog.c | 2 +- include/block/block_int.h | 2 +- include/monitor/monitor.h | 101 ++++++++++++++++++++++++++++++++++++++++++ include/monitor/readline.h | 55 +++++++++++++++++++++++ include/ui/console.h | 2 +- include/ui/qemu-spice.h | 4 +- migration-fd.c | 2 +- migration.c | 2 +- monitor.c | 4 +- monitor.h | 101 ------------------------------------------ net/hub.c | 2 +- net/net.c | 2 +- net/slirp.c | 2 +- net/socket.c | 2 +- net/tap.c | 2 +- osdep.c | 2 +- qemu-char.c | 2 +- qemu-error.c | 2 +- qemu-sockets.c | 2 +- qemu-timer.c | 2 +- qemu-tool.c | 2 +- qemu-user.c | 2 +- qerror.c | 2 +- readline.c | 4 +- readline.h | 55 ----------------------- savevm.c | 2 +- slirp/misc.c | 4 +- stubs/fdset-add-fd.c | 2 +- stubs/fdset-find-fd.c | 2 +- stubs/fdset-get-fd.c | 2 +- stubs/fdset-remove-fd.c | 2 +- stubs/get-fd.c | 2 +- target-i386/helper.c | 2 +- ui/input.c | 2 +- ui/spice-core.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.h | 2 +- vl.c | 2 +- 86 files changed, 242 insertions(+), 242 deletions(-) create mode 100644 include/monitor/monitor.h create mode 100644 include/monitor/readline.h delete mode 100644 monitor.h delete mode 100644 readline.h (limited to 'hw/usb/host-bsd.c') diff --git a/arch_init.c b/arch_init.c index e15cedad04..93d1e52f4a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -29,7 +29,7 @@ #include #endif #include "config.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "bitops.h" #include "bitmap.h" diff --git a/audio/audio.c b/audio/audio.c index 1c7738930b..a0cc727020 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -23,7 +23,7 @@ */ #include "hw/hw.h" #include "audio.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "sysemu.h" diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 4f785f5f49..9d94623225 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -1,5 +1,5 @@ #include "hw/hw.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "audio.h" typedef struct { diff --git a/balloon.c b/balloon.c index c24458b5f9..d1de4352b4 100644 --- a/balloon.c +++ b/balloon.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "monitor.h" +#include "monitor/monitor.h" #include "exec/cpu-common.h" #include "kvm.h" #include "balloon.h" diff --git a/balloon.h b/balloon.h index b803a00741..bd9d39505d 100644 --- a/balloon.h +++ b/balloon.h @@ -14,7 +14,7 @@ #ifndef _QEMU_BALLOON_H #define _QEMU_BALLOON_H -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi-types.h" typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); diff --git a/block.c b/block.c index 5eab9e2519..0e7f18c6d3 100644 --- a/block.c +++ b/block.c @@ -24,7 +24,7 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" #include "module.h" diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 81aa1d34ef..596b47499d 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -11,7 +11,7 @@ #include "blockdev.h" #include "hw/block-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "sysemu.h" #include "qmp-commands.h" diff --git a/blockdev.c b/blockdev.c index ff6b333f69..a2308fa718 100644 --- a/blockdev.c +++ b/blockdev.c @@ -10,7 +10,7 @@ #include "blockdev.h" #include "hw/block-common.h" #include "block/blockjob.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "qemu-option.h" #include "qemu-config.h" diff --git a/blockjob.c b/blockjob.c index 004480d714..4bc60c7378 100644 --- a/blockjob.c +++ b/blockjob.c @@ -26,7 +26,7 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "block/block.h" #include "block/blockjob.h" #include "block/block_int.h" diff --git a/cpus.c b/cpus.c index 8926873ad1..3a66401e0d 100644 --- a/cpus.c +++ b/cpus.c @@ -25,7 +25,7 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "exec/gdbstub.h" #include "dma.h" diff --git a/disas.c b/disas.c index 8157b96fc1..a46faeed80 100644 --- a/disas.c +++ b/disas.c @@ -374,7 +374,7 @@ const char *lookup_symbol(target_ulong orig_addr) #if !defined(CONFIG_USER_ONLY) -#include "monitor.h" +#include "monitor/monitor.h" static int monitor_disas_is_physical; diff --git a/dump.c b/dump.c index e70e0f3b21..871ee1727a 100644 --- a/dump.c +++ b/dump.c @@ -16,7 +16,7 @@ #include "cpu.h" #include "exec/cpu-all.h" #include "exec/hwaddr.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "kvm.h" #include "dump.h" #include "sysemu.h" diff --git a/gdbstub.c b/gdbstub.c index 70ad79a748..9395c829a2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -29,7 +29,7 @@ #include "qemu.h" #else -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-char.h" #include "sysemu.h" #include "exec/gdbstub.h" diff --git a/hmp.c b/hmp.c index f235134bb6..a76a8f06ea 100644 --- a/hmp.c +++ b/hmp.c @@ -20,7 +20,7 @@ #include "qemu-timer.h" #include "qmp-commands.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" static void hmp_handle_error(Monitor *mon, Error **errp) diff --git a/hw/acpi.c b/hw/acpi.c index ae29a59077..fe9b76a9b0 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -22,7 +22,7 @@ #include "hw.h" #include "pc.h" #include "acpi.h" -#include "monitor.h" +#include "monitor/monitor.h" struct acpi_table_header { uint16_t _length; /* our length, not actual part of the hdr */ diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index f4a6da4283..845a764446 100644 --- a/hw/ccid-card-emulated.c +++ b/hw/ccid-card-emulated.c @@ -33,7 +33,7 @@ #include "qemu-thread.h" #include "qemu-char.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" #define DPRINTF(card, lvl, fmt, ...) \ diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index bd6c77777d..f5b4794e90 100644 --- a/hw/ccid-card-passthru.c +++ b/hw/ccid-card-passthru.c @@ -10,7 +10,7 @@ #include "qemu-char.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" #include "libcacard/vscard_common.h" diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 336ffc2274..809a598e3a 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -27,7 +27,7 @@ #include "blockdev.h" #include "qemu-config.h" #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" DriveInfo *add_init_drive(const char *optstr) { diff --git a/hw/i8259.c b/hw/i8259.c index af0ba4d7c6..5e935e7f99 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -24,7 +24,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "i8259_internal.h" diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index f32a84761d..d38c6e4574 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -27,7 +27,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #include "dma.h" #include "exec/cpu-common.h" #include "internal.h" diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 8f40974166..a2be67df56 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "hw.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "sysemu.h" #include "isa.h" diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 2629775589..ff0dc0dfd4 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -31,7 +31,7 @@ #include "qemu-error.h" #include "ui/console.h" #include "hw/loader.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "range.h" #include "sysemu.h" #include "hw/pci/pci.h" diff --git a/hw/lm32_pic.c b/hw/lm32_pic.c index 32f65db7f1..42d5602cf0 100644 --- a/hw/lm32_pic.c +++ b/hw/lm32_pic.c @@ -21,7 +21,7 @@ #include "hw.h" #include "pc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "trace.h" #include "lm32_pic.h" diff --git a/hw/loader.c b/hw/loader.c index 03f0318d91..f5ef575b52 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -44,7 +44,7 @@ #include "hw.h" #include "disas/disas.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "uboot_image.h" #include "loader.h" diff --git a/hw/pc.c b/hw/pc.c index 2452fd4214..7aaff0f2fd 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -28,7 +28,7 @@ #include "fdc.h" #include "ide.h" #include "pci/pci.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "fw_cfg.h" #include "hpet_emul.h" #include "smbios.h" diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index 5ba7558ecd..e5e8a7ab58 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -27,7 +27,7 @@ #include "hw/pci/pci.h" #include "net/net.h" #include "hw/pc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/scsi.h" #include "hw/virtio-blk.h" #include "qemu-config.h" diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c index b5c43a935b..5891dc959d 100644 --- a/hw/pci/pci-stub.c +++ b/hw/pci/pci-stub.c @@ -19,7 +19,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/pci/pci.h" #include "qmp-commands.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fa0f08eb0a..e062f66088 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -25,7 +25,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "net/net.h" #include "sysemu.h" #include "hw/loader.h" diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index b6f4f8510f..f7f3633f5b 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -20,7 +20,7 @@ #include "sysemu.h" #include "qapi/qmp/types.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pcie.h" #include "hw/pci/msix.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 5aaf74b98a..207282c4a4 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -18,7 +18,7 @@ */ #include "qdev.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qmp-commands.h" #include "arch_init.h" #include "qemu-config.h" diff --git a/hw/qdev-monitor.h b/hw/qdev-monitor.h index 220ceba4c5..fae1b1ec84 100644 --- a/hw/qdev-monitor.h +++ b/hw/qdev-monitor.h @@ -2,7 +2,7 @@ #define QEMU_QDEV_MONITOR_H #include "qdev-core.h" -#include "monitor.h" +#include "monitor/monitor.h" /*** monitor commands ***/ diff --git a/hw/qxl.c b/hw/qxl.c index 96887c4aad..ad0214827e 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -23,7 +23,7 @@ #include "qemu-common.h" #include "qemu-timer.h" #include "qemu-queue.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index f7e1939288..769015c136 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -21,7 +21,7 @@ #include "block/block.h" #include "sysemu.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/virtio.h" diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index 0a15625b73..7dfe87ade3 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -23,7 +23,7 @@ #include "sysemu.h" #include "net/net.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/virtio.h" diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index bc9cea9e1b..748118d0f0 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -15,7 +15,7 @@ * */ -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "sclp.h" diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c index 6aafa8b233..a44ce95c1f 100644 --- a/hw/slavio_intctl.c +++ b/hw/slavio_intctl.c @@ -23,7 +23,7 @@ */ #include "sun4m.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index 1f19fedd0e..fdf8db9158 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -22,7 +22,7 @@ #include "hw.h" #include "sysemu.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/sysbus.h" diff --git a/hw/sun4c_intctl.c b/hw/sun4c_intctl.c index 702e9f5444..b78d54f232 100644 --- a/hw/sun4c_intctl.c +++ b/hw/sun4c_intctl.c @@ -24,7 +24,7 @@ #include "hw.h" #include "sun4m.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" //#define DEBUG_IRQ_COUNT diff --git a/hw/sysbus.c b/hw/sysbus.c index 7ab250463c..49a41775f8 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -18,7 +18,7 @@ */ #include "sysbus.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "exec/address-spaces.h" static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 8264c240ee..74728c94e5 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -2,7 +2,7 @@ #include "hw/usb.h" #include "hw/qdev.h" #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index de955b709f..3862c9b6c9 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -38,7 +38,7 @@ #include "qemu-error.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index de56fea610..0d7597b4d1 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -14,7 +14,7 @@ #include "hw/usb/desc.h" #include "hw/scsi.h" #include "ui/console.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "blockdev.h" diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 837c63be85..740f7309fb 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -20,7 +20,7 @@ #include "hw/hw.h" #include "qemu-timer.h" #include "hw/usb.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" #include "dma.h" #include "sysemu.h" diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c index dae0009378..340c21aeb4 100644 --- a/hw/usb/host-bsd.c +++ b/hw/usb/host-bsd.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/usb.h" /* usb.h declares these */ diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index bdafb6bc87..5a56e99891 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -32,7 +32,7 @@ #include "qemu-common.h" #include "qemu-timer.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/usb/host-stub.c b/hw/usb/host-stub.c index e8da3221f6..58423a0f5c 100644 --- a/hw/usb/host-stub.c +++ b/hw/usb/host-stub.c @@ -33,7 +33,7 @@ #include "qemu-common.h" #include "ui/console.h" #include "hw/usb.h" -#include "monitor.h" +#include "monitor/monitor.h" void usb_host_info(Monitor *mon) { diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 9e7f6453f7..3621076020 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -27,7 +27,7 @@ #include "qemu-common.h" #include "qemu-timer.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "iov.h" diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 155da58dcd..5559518a93 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -19,7 +19,7 @@ */ #include "iov.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-queue.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/watchdog.c b/hw/watchdog.c index f878bec860..623b299f71 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -24,7 +24,7 @@ #include "qemu-config.h" #include "qemu-queue.h" #include "qapi/qmp/types.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "hw/watchdog.h" diff --git a/include/block/block_int.h b/include/block/block_int.h index d06de2637b..14c57afd54 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -31,7 +31,7 @@ #include "qemu-timer.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" -#include "monitor.h" +#include "monitor/monitor.h" #define BLOCK_FLAG_ENCRYPT 1 #define BLOCK_FLAG_COMPAT6 4 diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h new file mode 100644 index 0000000000..87fb49c092 --- /dev/null +++ b/include/monitor/monitor.h @@ -0,0 +1,101 @@ +#ifndef MONITOR_H +#define MONITOR_H + +#include "qemu-common.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/qdict.h" +#include "block/block.h" +#include "monitor/readline.h" + +extern Monitor *cur_mon; +extern Monitor *default_mon; + +/* flags for monitor_init */ +#define MONITOR_IS_DEFAULT 0x01 +#define MONITOR_USE_READLINE 0x02 +#define MONITOR_USE_CONTROL 0x04 +#define MONITOR_USE_PRETTY 0x08 + +/* flags for monitor commands */ +#define MONITOR_CMD_ASYNC 0x0001 + +/* QMP events */ +typedef enum MonitorEvent { + QEVENT_SHUTDOWN, + QEVENT_RESET, + QEVENT_POWERDOWN, + QEVENT_STOP, + QEVENT_RESUME, + QEVENT_VNC_CONNECTED, + QEVENT_VNC_INITIALIZED, + QEVENT_VNC_DISCONNECTED, + QEVENT_BLOCK_IO_ERROR, + QEVENT_RTC_CHANGE, + QEVENT_WATCHDOG, + QEVENT_SPICE_CONNECTED, + QEVENT_SPICE_INITIALIZED, + QEVENT_SPICE_DISCONNECTED, + QEVENT_BLOCK_JOB_COMPLETED, + QEVENT_BLOCK_JOB_CANCELLED, + QEVENT_BLOCK_JOB_ERROR, + QEVENT_BLOCK_JOB_READY, + QEVENT_DEVICE_TRAY_MOVED, + QEVENT_SUSPEND, + QEVENT_SUSPEND_DISK, + QEVENT_WAKEUP, + QEVENT_BALLOON_CHANGE, + QEVENT_SPICE_MIGRATE_COMPLETED, + + /* Add to 'monitor_event_names' array in monitor.c when + * defining new events here */ + + QEVENT_MAX, +} MonitorEvent; + +int monitor_cur_is_qmp(void); + +void monitor_protocol_event(MonitorEvent event, QObject *data); +void monitor_init(CharDriverState *chr, int flags); + +int monitor_suspend(Monitor *mon); +void monitor_resume(Monitor *mon); + +int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, + BlockDriverCompletionFunc *completion_cb, + void *opaque); +int monitor_read_block_device_key(Monitor *mon, const char *device, + BlockDriverCompletionFunc *completion_cb, + void *opaque); + +int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); +int monitor_handle_fd_param(Monitor *mon, const char *fdname); + +void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); +void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +void monitor_print_filename(Monitor *mon, const char *filename); +void monitor_flush(Monitor *mon); +int monitor_set_cpu(int cpu_index); +int monitor_get_cpu_index(void); + +typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); + +void monitor_set_error(Monitor *mon, QError *qerror); +void monitor_read_command(Monitor *mon, int show_prompt); +ReadLineState *monitor_get_rs(Monitor *mon); +int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, + void *opaque); + +int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); + +int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); + +AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, + bool has_opaque, const char *opaque, + Error **errp); +int monitor_fdset_get_fd(int64_t fdset_id, int flags); +int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); +int monitor_fdset_dup_fd_remove(int dup_fd); +int monitor_fdset_dup_fd_find(int dup_fd); + +#endif /* !MONITOR_H */ diff --git a/include/monitor/readline.h b/include/monitor/readline.h new file mode 100644 index 0000000000..fc9806ecf1 --- /dev/null +++ b/include/monitor/readline.h @@ -0,0 +1,55 @@ +#ifndef READLINE_H +#define READLINE_H + +#include "qemu-common.h" + +#define READLINE_CMD_BUF_SIZE 4095 +#define READLINE_MAX_CMDS 64 +#define READLINE_MAX_COMPLETIONS 256 + +typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); +typedef void ReadLineCompletionFunc(const char *cmdline); + +typedef struct ReadLineState { + char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int cmd_buf_index; + int cmd_buf_size; + + char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int last_cmd_buf_index; + int last_cmd_buf_size; + + int esc_state; + int esc_param; + + char *history[READLINE_MAX_CMDS]; + int hist_entry; + + ReadLineCompletionFunc *completion_finder; + char *completions[READLINE_MAX_COMPLETIONS]; + int nb_completions; + int completion_index; + + ReadLineFunc *readline_func; + void *readline_opaque; + int read_password; + char prompt[256]; + Monitor *mon; +} ReadLineState; + +void readline_add_completion(ReadLineState *rs, const char *str); +void readline_set_completion_index(ReadLineState *rs, int completion_index); + +const char *readline_get_history(ReadLineState *rs, unsigned int index); + +void readline_handle_byte(ReadLineState *rs, int ch); + +void readline_start(ReadLineState *rs, const char *prompt, int read_password, + ReadLineFunc *readline_func, void *opaque); +void readline_restart(ReadLineState *rs); +void readline_show_prompt(ReadLineState *rs); + +ReadLineState *readline_init(Monitor *mon, + ReadLineCompletionFunc *completion_finder); + +#endif /* !READLINE_H */ diff --git a/include/ui/console.h b/include/ui/console.h index eff5cc92d6..3db6635b0a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -4,7 +4,7 @@ #include "ui/qemu-pixman.h" #include "qapi/qmp/qdict.h" #include "notify.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" #include "qapi-types.h" #include "qapi/error.h" diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 5857b8a92e..3e08be06bf 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -24,7 +24,7 @@ #include "qemu-option.h" #include "qemu-config.h" -#include "monitor.h" +#include "monitor/monitor.h" extern int using_spice; @@ -47,7 +47,7 @@ void do_info_spice(Monitor *mon, QObject **ret_data); CharDriverState *qemu_chr_open_spice(QemuOpts *opts); #else /* CONFIG_SPICE */ -#include "monitor.h" +#include "monitor/monitor.h" #define using_spice 0 static inline int qemu_spice_set_passwd(const char *passwd, diff --git a/migration-fd.c b/migration-fd.c index e86228823f..73a1dfcc93 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -16,7 +16,7 @@ #include "qemu-common.h" #include "qemu_socket.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "buffered_file.h" #include "block/block.h" #include "qemu_socket.h" diff --git a/migration.c b/migration.c index 1fce152548..27a272eace 100644 --- a/migration.c +++ b/migration.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "buffered_file.h" #include "sysemu.h" #include "block/block.h" diff --git a/monitor.c b/monitor.c index a3e010968e..94c6bb6672 100644 --- a/monitor.c +++ b/monitor.c @@ -36,8 +36,8 @@ #include "qemu-char.h" #include "ui/qemu-spice.h" #include "sysemu.h" -#include "monitor.h" -#include "readline.h" +#include "monitor/monitor.h" +#include "monitor/readline.h" #include "ui/console.h" #include "blockdev.h" #include "audio/audio.h" diff --git a/monitor.h b/monitor.h deleted file mode 100644 index 9e96e83f5f..0000000000 --- a/monitor.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef MONITOR_H -#define MONITOR_H - -#include "qemu-common.h" -#include "qapi/qmp/qerror.h" -#include "qapi/qmp/qdict.h" -#include "block/block.h" -#include "readline.h" - -extern Monitor *cur_mon; -extern Monitor *default_mon; - -/* flags for monitor_init */ -#define MONITOR_IS_DEFAULT 0x01 -#define MONITOR_USE_READLINE 0x02 -#define MONITOR_USE_CONTROL 0x04 -#define MONITOR_USE_PRETTY 0x08 - -/* flags for monitor commands */ -#define MONITOR_CMD_ASYNC 0x0001 - -/* QMP events */ -typedef enum MonitorEvent { - QEVENT_SHUTDOWN, - QEVENT_RESET, - QEVENT_POWERDOWN, - QEVENT_STOP, - QEVENT_RESUME, - QEVENT_VNC_CONNECTED, - QEVENT_VNC_INITIALIZED, - QEVENT_VNC_DISCONNECTED, - QEVENT_BLOCK_IO_ERROR, - QEVENT_RTC_CHANGE, - QEVENT_WATCHDOG, - QEVENT_SPICE_CONNECTED, - QEVENT_SPICE_INITIALIZED, - QEVENT_SPICE_DISCONNECTED, - QEVENT_BLOCK_JOB_COMPLETED, - QEVENT_BLOCK_JOB_CANCELLED, - QEVENT_BLOCK_JOB_ERROR, - QEVENT_BLOCK_JOB_READY, - QEVENT_DEVICE_TRAY_MOVED, - QEVENT_SUSPEND, - QEVENT_SUSPEND_DISK, - QEVENT_WAKEUP, - QEVENT_BALLOON_CHANGE, - QEVENT_SPICE_MIGRATE_COMPLETED, - - /* Add to 'monitor_event_names' array in monitor.c when - * defining new events here */ - - QEVENT_MAX, -} MonitorEvent; - -int monitor_cur_is_qmp(void); - -void monitor_protocol_event(MonitorEvent event, QObject *data); -void monitor_init(CharDriverState *chr, int flags); - -int monitor_suspend(Monitor *mon); -void monitor_resume(Monitor *mon); - -int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, - BlockDriverCompletionFunc *completion_cb, - void *opaque); -int monitor_read_block_device_key(Monitor *mon, const char *device, - BlockDriverCompletionFunc *completion_cb, - void *opaque); - -int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); -int monitor_handle_fd_param(Monitor *mon, const char *fdname); - -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) - GCC_FMT_ATTR(2, 0); -void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -void monitor_print_filename(Monitor *mon, const char *filename); -void monitor_flush(Monitor *mon); -int monitor_set_cpu(int cpu_index); -int monitor_get_cpu_index(void); - -typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); - -void monitor_set_error(Monitor *mon, QError *qerror); -void monitor_read_command(Monitor *mon, int show_prompt); -ReadLineState *monitor_get_rs(Monitor *mon); -int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, - void *opaque); - -int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); - -int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); - -AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, - bool has_opaque, const char *opaque, - Error **errp); -int monitor_fdset_get_fd(int64_t fdset_id, int flags); -int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); -int monitor_fdset_dup_fd_remove(int dup_fd); -int monitor_fdset_dup_fd_find(int dup_fd); - -#endif /* !MONITOR_H */ diff --git a/net/hub.c b/net/hub.c index 8508ecf380..81a73b54a7 100644 --- a/net/hub.c +++ b/net/hub.c @@ -12,7 +12,7 @@ * */ -#include "monitor.h" +#include "monitor/monitor.h" #include "net/net.h" #include "clients.h" #include "hub.h" diff --git a/net/net.c b/net/net.c index ead7e96fe1..e4d85a9cfa 100644 --- a/net/net.c +++ b/net/net.c @@ -29,7 +29,7 @@ #include "net/slirp.h" #include "util.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-common.h" #include "qemu_socket.h" #include "qemu-config.h" diff --git a/net/slirp.c b/net/slirp.c index 5a11ac5859..c37a5ef959 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -32,7 +32,7 @@ #include "net/net.h" #include "clients.h" #include "hub.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu_socket.h" #include "slirp/libslirp.h" #include "qemu-char.h" diff --git a/net/socket.c b/net/socket.c index 8430f1a161..bc2b951832 100644 --- a/net/socket.c +++ b/net/socket.c @@ -25,7 +25,7 @@ #include "net/net.h" #include "clients.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-common.h" #include "qemu-error.h" #include "qemu-option.h" diff --git a/net/tap.c b/net/tap.c index f8cabc4f86..9a677e9864 100644 --- a/net/tap.c +++ b/net/tap.c @@ -35,7 +35,7 @@ #include "net/net.h" #include "clients.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "qemu-common.h" #include "qemu-error.h" diff --git a/osdep.c b/osdep.c index 3a63d26e75..807e90cf97 100644 --- a/osdep.c +++ b/osdep.c @@ -48,7 +48,7 @@ extern int madvise(caddr_t, size_t, int); #include "qemu-common.h" #include "trace.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" static bool fips_enabled = false; diff --git a/qemu-char.c b/qemu-char.c index bc53d09a9b..16021c5a43 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "qemu-timer.h" diff --git a/qemu-error.c b/qemu-error.c index 7cd5ffe1e9..08a36f480c 100644 --- a/qemu-error.c +++ b/qemu-error.c @@ -11,7 +11,7 @@ */ #include -#include "monitor.h" +#include "monitor/monitor.h" /* * Print to current monitor if we have one, else to stderr. diff --git a/qemu-sockets.c b/qemu-sockets.c index c52a40a411..cea0a4b8ac 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -22,7 +22,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu_socket.h" #include "qemu-common.h" /* for qemu_isdigit */ #include "main-loop.h" diff --git a/qemu-timer.c b/qemu-timer.c index 5a99403fda..8e0dccc087 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -23,7 +23,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "hw/hw.h" diff --git a/qemu-tool.c b/qemu-tool.c index b46631e422..40453fdd99 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "qemu-log.h" #include "migration.h" diff --git a/qemu-user.c b/qemu-user.c index 08ccb0fe8e..f8b450c03d 100644 --- a/qemu-user.c +++ b/qemu-user.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" Monitor *cur_mon; diff --git a/qerror.c b/qerror.c index 8c78104277..3aee1cf6a6 100644 --- a/qerror.c +++ b/qerror.c @@ -10,7 +10,7 @@ * See the COPYING.LIB file in the top-level directory. */ -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qerror.h" #include "qemu-common.h" diff --git a/readline.c b/readline.c index 540cd8a025..5fc9643c2b 100644 --- a/readline.c +++ b/readline.c @@ -21,8 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "readline.h" -#include "monitor.h" +#include "monitor/readline.h" +#include "monitor/monitor.h" #define IS_NORM 0 #define IS_ESC 1 diff --git a/readline.h b/readline.h deleted file mode 100644 index fc9806ecf1..0000000000 --- a/readline.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef READLINE_H -#define READLINE_H - -#include "qemu-common.h" - -#define READLINE_CMD_BUF_SIZE 4095 -#define READLINE_MAX_CMDS 64 -#define READLINE_MAX_COMPLETIONS 256 - -typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); -typedef void ReadLineCompletionFunc(const char *cmdline); - -typedef struct ReadLineState { - char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; - int cmd_buf_index; - int cmd_buf_size; - - char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; - int last_cmd_buf_index; - int last_cmd_buf_size; - - int esc_state; - int esc_param; - - char *history[READLINE_MAX_CMDS]; - int hist_entry; - - ReadLineCompletionFunc *completion_finder; - char *completions[READLINE_MAX_COMPLETIONS]; - int nb_completions; - int completion_index; - - ReadLineFunc *readline_func; - void *readline_opaque; - int read_password; - char prompt[256]; - Monitor *mon; -} ReadLineState; - -void readline_add_completion(ReadLineState *rs, const char *str); -void readline_set_completion_index(ReadLineState *rs, int completion_index); - -const char *readline_get_history(ReadLineState *rs, unsigned int index); - -void readline_handle_byte(ReadLineState *rs, int ch); - -void readline_start(ReadLineState *rs, const char *prompt, int read_password, - ReadLineFunc *readline_func, void *opaque); -void readline_restart(ReadLineState *rs); -void readline_show_prompt(ReadLineState *rs); - -ReadLineState *readline_init(Monitor *mon, - ReadLineCompletionFunc *completion_finder); - -#endif /* !READLINE_H */ diff --git a/savevm.c b/savevm.c index cb33501ecc..bf341bb25f 100644 --- a/savevm.c +++ b/savevm.c @@ -73,7 +73,7 @@ #include "hw/hw.h" #include "hw/qdev.h" #include "net/net.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "qemu-timer.h" #include "audio/audio.h" diff --git a/slirp/misc.c b/slirp/misc.c index 664532a663..d4df972d13 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -8,7 +8,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #ifdef DEBUG int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR; @@ -242,7 +242,7 @@ strdup(str) } #endif -#include "monitor.h" +#include "monitor/monitor.h" void lprint(const char *format, ...) { diff --git a/stubs/fdset-add-fd.c b/stubs/fdset-add-fd.c index 09fe2a839a..ee1643708c 100644 --- a/stubs/fdset-add-fd.c +++ b/stubs/fdset-add-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd) { diff --git a/stubs/fdset-find-fd.c b/stubs/fdset-find-fd.c index f82baa066c..4f18344bad 100644 --- a/stubs/fdset-find-fd.c +++ b/stubs/fdset-find-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_find(int dup_fd) { diff --git a/stubs/fdset-get-fd.c b/stubs/fdset-get-fd.c index 4106cf90f0..7112c155e3 100644 --- a/stubs/fdset-get-fd.c +++ b/stubs/fdset-get-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_get_fd(int64_t fdset_id, int flags) { diff --git a/stubs/fdset-remove-fd.c b/stubs/fdset-remove-fd.c index 861b31247e..b3886d9f45 100644 --- a/stubs/fdset-remove-fd.c +++ b/stubs/fdset-remove-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_remove(int dupfd) { diff --git a/stubs/get-fd.c b/stubs/get-fd.c index 3561ab60e2..9f2c65cf0a 100644 --- a/stubs/get-fd.c +++ b/stubs/get-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_get_fd(Monitor *mon, const char *name, Error **errp) { diff --git a/target-i386/helper.c b/target-i386/helper.c index 00341c5233..bd47b8e58e 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -21,7 +21,7 @@ #include "kvm.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #endif //#define DEBUG_MMU diff --git a/ui/input.c b/ui/input.c index 65950af9af..05f6c0c849 100644 --- a/ui/input.c +++ b/ui/input.c @@ -23,7 +23,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "qapi/error.h" #include "qmp-commands.h" diff --git a/ui/spice-core.c b/ui/spice-core.c index 0550805b38..379677554e 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -35,7 +35,7 @@ #include "qapi/qmp/qjson.h" #include "notify.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/hw.h" #include "ui/spice-display.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index 681fe32fed..56ebf80805 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -19,7 +19,7 @@ #include "ui/qemu-spice.h" #include "qemu-timer.h" #include "qemu-queue.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "trace.h" diff --git a/ui/vnc.h b/ui/vnc.h index 7ec183372a..e5c043ff45 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -31,7 +31,7 @@ #include "qemu-queue.h" #include "qemu-thread.h" #include "ui/console.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "audio/audio.h" #include "bitmap.h" #include diff --git a/vl.c b/vl.c index 015f0a4757..9adaf28e64 100644 --- a/vl.c +++ b/vl.c @@ -129,7 +129,7 @@ int main(int argc, char **argv) #include "bt-host.h" #include "net/net.h" #include "net/slirp.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "exec/gdbstub.h" -- cgit v1.2.3-55-g7522