From e06cbc376ea79061c009f529df196a3efde47d9e Mon Sep 17 00:00:00 2001 From: Nikolay Nikolaev Date: Thu, 19 Jun 2014 20:35:42 +0300 Subject: [PATCH 01/12] qtest: enable vhost-user-test Use qtest-obj-y to get the right library order. CONFIG_POSIX ensures mingw compilation won't break. Signed-off-by: Nikolay Nikolaev Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin MST: whitespace tweak --- tests/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 7e53d0d618..1fcd633871 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -158,7 +158,7 @@ gcov-files-i386-y += hw/usb/hcd-ehci.c gcov-files-i386-y += hw/usb/hcd-uhci.c gcov-files-i386-y += hw/usb/dev-hid.c gcov-files-i386-y += hw/usb/dev-storage.c -#check-qtest-i386-y += tests/vhost-user-test$(EXESUF) +check-qtest-i386-$(CONFIG_POSIX) += tests/vhost-user-test$(EXESUF) check-qtest-x86_64-y = $(check-qtest-i386-y) gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y)) @@ -333,11 +333,13 @@ tests/es1370-test$(EXESUF): tests/es1370-test.o tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y) -tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o libqemuutil.a libqemustub.a +tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o qemu-char.o qemu-timer.o $(qtest-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a -#LIBS+= -lutil +ifeq ($(CONFIG_POSIX),y) +LIBS += -lutil +endif # QTest rules From 0462faee67eb9ee39e51f764891fb6b767602eed Mon Sep 17 00:00:00 2001 From: Hu Tao Date: Mon, 30 Jun 2014 18:28:15 +0800 Subject: [PATCH 02/12] numa: check for busy memory backend Specifying the same memory backend twice leads to an assert: ./x86_64-softmmu/qemu-system-x86_64 -m 512M -enable-kvm -object memory-backend-ram,size=256M,id=ram0 -numa node,nodeid=0,memdev=ram0 -numa node,nodeid=1,memdev=ram0 qemu-system-x86_64: /scm/qemu/memory.c:1506: memory_region_add_subregion_common: Assertion `!subregion->container' failed. Aborted (core dumped) Detect and exit with an error message instead. Reviewed-by: Igor Mammedov Signed-off-by: Hu Tao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- numa.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/numa.c b/numa.c index 2fde7409bf..7bf7834b7f 100644 --- a/numa.c +++ b/numa.c @@ -301,6 +301,14 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, exit(1); } + if (memory_region_is_mapped(seg)) { + char *path = object_get_canonical_path_component(OBJECT(backend)); + error_report("memory backend %s is used multiple times. Each " + "-numa option must use a different memdev value.", + path); + exit(1); + } + memory_region_add_subregion(mr, addr, seg); vmstate_register_ram_global(seg); addr += size; From 9b79a76cdbb43b0b00aaf6e9421298842fc68841 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Mon, 30 Jun 2014 12:43:29 +0200 Subject: [PATCH 03/12] pc-dimm: error out if memory hotplug is not enabled fixes QEMU abort in case it's started without memory hotplug enabled. as result of fix it will print following messages: " -device pc-dimm,id=d1,memdev=m1: memory hotplug is not enabled, enable it on startup -device pc-dimm,id=d1,memdev=m1: Device 'pc-dimm' could not be initialized " Also fixup assert condition to detect hotplug address space overflow. Signed-off-by: Igor Mammedov Reported-by: Hu Tao Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/pc-dimm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index ad176b700b..08f49ed53b 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -146,7 +146,13 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t new_addr, ret = 0; uint64_t address_space_end = address_space_start + address_space_size; - assert(address_space_end > address_space_size); + if (!address_space_size) { + error_setg(errp, "memory hotplug is not enabled, " + "please add maxmem option"); + goto out; + } + + assert(address_space_end > address_space_start); object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); if (hint) { From 85d1277e668106294d134a101729c6f36289da1a Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Tue, 1 Jul 2014 00:01:58 +0800 Subject: [PATCH 04/12] virtio: move common virtio properties to bus class device The two common virtio features can be defined per bus, so move all into bus class device to make code more clean. As discussed with cornelia, s390-virtio-blk doesn't support the two features at all, so keep s390-virtio as it. Acked-by: Cornelia Huck #for s390 ccw Suggested-by: Paolo Bonzini Signed-off-by: Ming Lei Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin MST: rebase and resolve conflicts --- hw/s390x/s390-virtio-bus.c | 2 ++ hw/s390x/virtio-ccw.c | 11 ++++++----- hw/virtio/virtio-pci.c | 12 ++++++------ include/hw/virtio/virtio-blk.h | 3 --- include/hw/virtio/virtio-net.h | 1 - include/hw/virtio/virtio-scsi.h | 1 - 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index c0dc3658c7..6b6fb61c47 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -494,6 +494,7 @@ static unsigned virtio_s390_get_features(DeviceState *d) static Property s390_virtio_net_properties[] = { DEFINE_NIC_PROPERTIES(VirtIONetS390, vdev.nic_conf), + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features), DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features), DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetS390, vdev.net_conf), DEFINE_PROP_END_OF_LIST(), @@ -614,6 +615,7 @@ static const TypeInfo virtio_s390_device_info = { static Property s390_virtio_scsi_properties[] = { DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSIS390, vdev.parent_obj.conf), + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features), DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device, host_features), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index c2799685f2..33a1d863b1 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1402,7 +1402,6 @@ static const TypeInfo virtio_ccw_net = { static Property virtio_ccw_blk_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_BLK_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_END_OF_LIST(), @@ -1430,7 +1429,6 @@ static const TypeInfo virtio_ccw_blk = { static Property virtio_ccw_serial_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtioSerialCcw, vdev.serial), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_END_OF_LIST(), @@ -1457,7 +1455,6 @@ static const TypeInfo virtio_ccw_serial = { static Property virtio_ccw_balloon_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_END_OF_LIST(), @@ -1514,7 +1511,6 @@ static const TypeInfo virtio_ccw_scsi = { static Property vhost_ccw_scsi_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), DEFINE_VHOST_SCSI_PROPERTIES(VirtIOSCSICcw, vdev.parent_obj.conf), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_END_OF_LIST(), }; @@ -1551,7 +1547,6 @@ static void virtio_ccw_rng_instance_init(Object *obj) static Property virtio_ccw_rng_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORNGCcw, vdev.conf), DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), @@ -1617,10 +1612,16 @@ static int virtio_ccw_busdev_unplug(DeviceState *dev) return 0; } +static Property virtio_ccw_properties[] = { + DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]), + DEFINE_PROP_END_OF_LIST(), +}; + static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->props = virtio_ccw_properties; dc->init = virtio_ccw_busdev_init; dc->exit = virtio_ccw_busdev_exit; dc->unplug = virtio_ccw_busdev_unplug; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 3c42cda82b..710272808f 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -914,7 +914,6 @@ static Property virtio_9p_pci_properties[] = { DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VIRTIO_9P_PROPERTIES(V9fsPCIState, vdev.fsconf), DEFINE_PROP_END_OF_LIST(), }; @@ -1037,11 +1036,17 @@ static void virtio_pci_reset(DeviceState *qdev) proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } +static Property virtio_pci_properties[] = { + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), + DEFINE_PROP_END_OF_LIST(), +}; + static void virtio_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + dc->props = virtio_pci_properties; k->init = virtio_pci_init; k->exit = virtio_pci_exit; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; @@ -1066,7 +1071,6 @@ static Property virtio_blk_pci_properties[] = { DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), - DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features), DEFINE_PROP_END_OF_LIST(), }; @@ -1191,7 +1195,6 @@ static const TypeInfo virtio_scsi_pci_info = { static Property vhost_scsi_pci_properties[] = { DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, DEV_NVECTORS_UNSPECIFIED), - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSIPCI, vdev.parent_obj.conf), DEFINE_PROP_END_OF_LIST(), }; @@ -1272,7 +1275,6 @@ static void balloon_pci_stats_set_poll_interval(Object *obj, struct Visitor *v, } static Property virtio_balloon_pci_properties[] = { - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -1375,7 +1377,6 @@ static Property virtio_serial_pci_properties[] = { VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2), DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0), - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOSerialPCI, vdev.serial), DEFINE_PROP_END_OF_LIST(), }; @@ -1471,7 +1472,6 @@ static const TypeInfo virtio_net_pci_info = { /* virtio-rng-pci */ static Property virtio_rng_pci_properties[] = { - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features), DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORngPCI, vdev.conf), DEFINE_PROP_END_OF_LIST(), }; diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 223530e18a..b3080a2144 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -152,9 +152,6 @@ typedef struct VirtIOBlockReq { BlockAcctCookie acct; } VirtIOBlockReq; -#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \ - DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) - int virtio_blk_handle_scsi_req(VirtIOBlock *blk, VirtQueueElement *elem); diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index f7fccc08a4..6ceb5aa92e 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -258,7 +258,6 @@ struct virtio_net_ctrl_mq { #define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0 #define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \ - DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \ DEFINE_PROP_BIT("any_layout", _state, _field, VIRTIO_F_ANY_LAYOUT, true), \ DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \ DEFINE_PROP_BIT("guest_csum", _state, _field, VIRTIO_NET_F_GUEST_CSUM, true), \ diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index a8f618578b..0419ee4252 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -178,7 +178,6 @@ typedef struct { DEFINE_PROP_UINT32("cmd_per_lun", _state, _conf_field.cmd_per_lun, 128) #define DEFINE_VIRTIO_SCSI_FEATURES(_state, _feature_field) \ - DEFINE_VIRTIO_COMMON_FEATURES(_state, _feature_field), \ DEFINE_PROP_BIT("hotplug", _state, _feature_field, VIRTIO_SCSI_F_HOTPLUG, \ true), \ DEFINE_PROP_BIT("param_change", _state, _feature_field, \ From 812c1057f6175ac9a9829fa2920a2b5783814193 Mon Sep 17 00:00:00 2001 From: Kirill Batuzov Date: Tue, 1 Jul 2014 15:52:32 +0400 Subject: [PATCH 05/12] Handle G_IO_HUP in tcp_chr_read for tcp chardev Since commit cdaa86a54b232572bba594bf87a7416e527e460c ("Add G_IO_HUP handler for socket chardev") GLib limitation results in a bug on Windows host. Steps to reproduce: Start qemu: qemu-system-i386 -qmp tcp:127.0.0.1:4444:server:nowait Connect with telnet: telnet 127.0.0.1 4444 Try sending some data from telnet. Expected result: answers from QEMU. Observed result: no answers (actually tcp_chr_read is not called at all). Due to GLib limitations it is not possible to create several watches on one channel on Windows hosts. See bug #338943 in GNOME bugzilla for details: https://bugzilla.gnome.org/show_bug.cgi?id=338943 This reimplements commit cdaa86a54b232572bba594bf87a7416e527e460c ("Add G_IO_HUP handler for socket chardev") using a single watch: Handle G_IO_HUP in tcp_chr_read instead. It is already watched by a corresponding watch. Remove the second watch with its handler. Cc: Antonios Motakis Cc: Nikolay Nikolaev Cc: Michael S. Tsirkin Signed-off-by: Kirill Batuzov Signed-off-by: Nikita Belov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/sysemu/char.h | 1 - qemu-char.c | 27 ++++++--------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/include/sysemu/char.h b/include/sysemu/char.h index c8b15f9729..0bbd631e72 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -84,7 +84,6 @@ struct CharDriverState { int avail_connections; int is_mux; guint fd_in_tag; - guint fd_hup_tag; QemuOpts *opts; QTAILQ_ENTRY(CharDriverState) next; }; diff --git a/qemu-char.c b/qemu-char.c index 51917de462..22a9777f49 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2673,6 +2673,12 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) uint8_t buf[READ_BUF_LEN]; int len, size; + if (cond & G_IO_HUP) { + /* connection closed */ + tcp_chr_disconnect(chr); + return TRUE; + } + if (!s->connected || s->max_size <= 0) { return TRUE; } @@ -2724,25 +2730,6 @@ CharDriverState *qemu_chr_open_eventfd(int eventfd) } #endif -static gboolean tcp_chr_chan_close(GIOChannel *channel, GIOCondition cond, - void *opaque) -{ - CharDriverState *chr = opaque; - - if (cond != G_IO_HUP) { - return FALSE; - } - - /* connection closed */ - tcp_chr_disconnect(chr); - if (chr->fd_hup_tag) { - g_source_remove(chr->fd_hup_tag); - chr->fd_hup_tag = 0; - } - - return TRUE; -} - static void tcp_chr_connect(void *opaque) { CharDriverState *chr = opaque; @@ -2752,8 +2739,6 @@ static void tcp_chr_connect(void *opaque) if (s->chan) { chr->fd_in_tag = io_add_watch_poll(s->chan, tcp_chr_read_poll, tcp_chr_read, chr); - chr->fd_hup_tag = g_io_add_watch(s->chan, G_IO_HUP, tcp_chr_chan_close, - chr); } qemu_chr_be_generic_open(chr); } From efc8188e9398e54567b238b756eec2cc746cd2a4 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Wed, 2 Jul 2014 08:06:35 +0800 Subject: [PATCH 06/12] pci: assign devfn to pci_dev before calling pci_device_iommu_address_space() In function do_pci_register_device() in file hw/pci/pci.c, move the assignment of pci_dev->devfn to the position before the call to pci_device_iommu_address_space(pci_dev) which will use the value of pci_dev->devfn. Fixes: 9eda7d373e9c691c070eddcbe3467b991f67f6bd pci: Introduce helper to retrieve a PCI device's DMA address space Cc: qemu-stable@nongnu.org Signed-off-by: Le Tan Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 17ed5107ad..351d320470 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -827,6 +827,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, } pci_dev->bus = bus; + pci_dev->devfn = devfn; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, @@ -836,7 +837,6 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); - pci_dev->devfn = devfn; pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev); From 22dc50d75838e83b4bb05ae5554728be9f266e87 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Wed, 2 Jul 2014 11:16:33 +0200 Subject: [PATCH 07/12] acpi: fix typo in memory hotplug MMIO region name Reported-by: Sergey Fionov Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Peter Crosthwaite --- hw/acpi/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 38ca415f64..ed3924126f 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -159,7 +159,7 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count); memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state, - "apci-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN); + "acpi-mem-hotplug", ACPI_MEMORY_HOTPLUG_IO_LEN); memory_region_add_subregion(as, ACPI_MEMORY_HOTPLUG_BASE, &state->io); } From b7c9285b8d60d1b235a2ef03d48168d372367c5a Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Wed, 4 Jun 2014 10:05:55 +0800 Subject: [PATCH 08/12] hw/virtio: enable common virtio feature for mmio device Both 'indirect_desc' and 'event_idx' are bus independent features, and they should be enabled for mmio devices too. On arm64 quad core VM(qemu-kvm), the patch can increase block I/O performance a lot with latest linux tree: - without the patch: 14K IOPS - with the patch: 34K IOPS fio script: [global] direct=1 bsrange=4k-4k timeout=10 numjobs=4 ioengine=libaio iodepth=64 filename=/dev/vdc group_reporting=1 [f1] rw=randread Cc: Peter Maydell Signed-off-by: Ming Lei Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 8829eb0e26..18c6e5b55c 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -369,10 +369,16 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp) sysbus_init_mmio(sbd, &proxy->iomem); } +static Property virtio_mmio_properties[] = { + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOMMIOProxy, host_features), + DEFINE_PROP_END_OF_LIST(), +}; + static void virtio_mmio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->props = virtio_mmio_properties; dc->realize = virtio_mmio_realizefn; dc->reset = virtio_mmio_reset; set_bit(DEVICE_CATEGORY_MISC, dc->categories); From 319627006a8f4c43b3618932ccac615c4662dfdc Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 3 Jul 2014 16:45:34 -0300 Subject: [PATCH 09/12] qdev: Don't abort() in case globals can't be set It would be much better if we didn't terminate QEMU inside device_post_init(), but at least exiting cleanly is better than aborting and dumping core. Before this patch: $ qemu-system-x86_64 -global cpu.xxx=y qemu-system-x86_64: Property '.xxx' not found Aborted (core dumped) After this patch: $ qemu-system-x86_64 -global cpu.xxx=y qemu-system-x86_64: Property '.xxx' not found Reviewed-by: Michael S. Tsirkin Reviewed-By: Igor Mammedov Signed-off-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Signed-off-by: Eduardo Habkost --- hw/core/qdev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 3bdda8ef66..da1ba48c99 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -957,7 +957,13 @@ static void device_initfn(Object *obj) static void device_post_init(Object *obj) { - qdev_prop_set_globals(DEVICE(obj), &error_abort); + Error *err = NULL; + qdev_prop_set_globals(DEVICE(obj), &err); + if (err) { + qerror_report_err(err); + error_free(err); + exit(EXIT_FAILURE); + } } /* Unlink device from bus and free the structure. */ From dd98b71f4885814de9a64e7acc0e17b38ab7c38b Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 3 Jul 2014 16:45:35 -0300 Subject: [PATCH 10/12] qdev: Fix crash when using non-device class name on -global This fixes the following crash: $ qemu-system-x86_64 -global container.xxx=y hw/core/qdev-properties-system.c:399:qdev_add_one_global: Object 0x7f7eff234100 is not an instance of type device Aborted (core dumped) New behavior will be to just warn, just like when non-existing clas names are used: $ qemu-system-x86_64 -global container.xxx=y qemu-system-x86_64: Warning: "-global container.xxx=y" not used Signed-off-by: Eduardo Habkost Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Signed-off-by: Eduardo Habkost Tested-by: Don Slutz --- hw/core/qdev-properties-system.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 8e140af46f..ae0900f651 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -394,7 +394,8 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque) g->driver = qemu_opt_get(opts, "driver"); g->property = qemu_opt_get(opts, "property"); g->value = qemu_opt_get(opts, "value"); - oc = object_class_by_name(g->driver); + oc = object_class_dynamic_cast(object_class_by_name(g->driver), + TYPE_DEVICE); if (oc) { DeviceClass *dc = DEVICE_CLASS(oc); From 8b81bb3b069d4007bc44c8d5888d630b7f0b42ff Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 4 Jul 2014 11:43:49 +0200 Subject: [PATCH 11/12] virtio-pci: fix MSI memory region use after free After memory region QOMification QEMU is stricter in detecting wrong usage of the memory region API. Here it detected a memory_region_destroy done before the corresponding memory_region_del_subregion; the memory_region_destroy is done by msix_uninit_exclusive_bar, the memory_region_del_subregion is done by the PCI core's pci_unregister_io_regions before pc->exit is called. The problem was introduced by commit 06a1307379fcd6c551185ad87679cd7ed896b9ea virtio-pci: add device_unplugged callback As noted in that commit log, virtio device kick callbacks need to be stopped before generic virtio is cleaned up. This is because these are notifications from pci proxy to the generic virtio device so they need to be stopped in the unplug call before the virtio device is unrealized. However interrupts are notifications from the virtio device to the pci proxy so they need to stay around while the device is realized. The memory API misuse caused an assertion when hot-unplugging virtio devices. Using the API correctly fixes the assertion. Signed-off-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 710272808f..3007319740 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1002,11 +1002,9 @@ static void virtio_pci_device_plugged(DeviceState *d) static void virtio_pci_device_unplugged(DeviceState *d) { - PCIDevice *pci_dev = PCI_DEVICE(d); VirtIOPCIProxy *proxy = VIRTIO_PCI(d); virtio_pci_stop_ioeventfd(proxy); - msix_uninit_exclusive_bar(pci_dev); } static int virtio_pci_init(PCIDevice *pci_dev) @@ -1023,6 +1021,8 @@ static int virtio_pci_init(PCIDevice *pci_dev) static void virtio_pci_exit(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); + + msix_uninit_exclusive_bar(pci_dev); memory_region_destroy(&proxy->bar); } From 3f0838ab8557c6071a5931183b2d7fed568cd35c Mon Sep 17 00:00:00 2001 From: Kirill Batuzov Date: Fri, 4 Jul 2014 16:43:15 +0400 Subject: [PATCH 12/12] qemu-char: add chr_add_watch support in mux chardev Forward chr_add_watch call from mux chardev to underlying implementation. This should fix bug #1335444 Signed-off-by: Kirill Batuzov Acked-by: Paolo Bonzini Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qemu-char.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qemu-char.c b/qemu-char.c index 22a9777f49..55e372cf32 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -581,6 +581,12 @@ static Notifier muxes_realize_notify = { .notify = muxes_realize_done, }; +static GSource *mux_chr_add_watch(CharDriverState *s, GIOCondition cond) +{ + MuxDriver *d = s->opaque; + return d->drv->chr_add_watch(d->drv, cond); +} + static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) { CharDriverState *chr; @@ -597,6 +603,9 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) chr->chr_accept_input = mux_chr_accept_input; /* Frontend guest-open / -close notification is not support with muxes */ chr->chr_set_fe_open = NULL; + if (drv->chr_add_watch) { + chr->chr_add_watch = mux_chr_add_watch; + } /* only default to opened state if we've realized the initial * set of muxes */