virtio, pc: fixes and features
The following changes since commit 48f592118ab42f83a1a7561c4bfd2b72a100f241:
bsd-user: fix FreeBSD build after d148d90e (2016-10-07 15:17:53 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to dea651a95af6dad0997b840241a0bf6059d9a776:
intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE (2016-10-10 02:38:14 +0300)
----------------------------------------------------------------
virtio, pc: fixes and features
more guest error handling for virtio devices
virtio migration rework
pc fixes
----------------------------------------------------------------
Daniel P. Berrange (1):
net: don't poke at chardev internal QemuOpts
Feng Wu (1):
intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE
Greg Kurz (9):
virtio-9p: add parentheses to sizeof operator
virtio-blk: make some functions static
virtio-9p: handle handle_9p_output() error
virtio-blk: handle virtio_blk_handle_request() errors
virtio-net: handle virtio_net_handle_ctrl() error
virtio-net: handle virtio_net_receive() errors
virtio-net: handle virtio_net_flush_tx() errors
virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error()
virtio-scsi: handle virtio_scsi_set_config() error
Halil Pasic (12):
virtio: prepare change VMSTATE_VIRTIO_DEVICE macro
virtio-blk: convert VMSTATE_VIRTIO_DEVICE
virtio-net: convert VMSTATE_VIRTIO_DEVICE
virtio-9p: convert VMSTATE_VIRTIO_DEVICE
virtio-serial: convert VMSTATE_VIRTIO_DEVICE
virtio-gpu: convert VMSTATE_VIRTIO_DEVICE
virtio-input: convert VMSTATE_VIRTIO_DEVICE
virtio-scsi: convert VMSTATE_VIRTIO_DEVICE
virtio-balloon: convert VMSTATE_VIRTIO_DEVICE
virtio-rng: convert VMSTATE_VIRTIO_DEVICE
vhost-vsock: convert VMSTATE_VIRTIO_DEVICE
virtio: cleanup VMSTATE_VIRTIO_DEVICE
Igor Mammedov (4):
numa: reduce code duplication by adding helper numa_get_node_for_cpu()
acpi: provide _PXM method for CPU devices if QEMU is started numa enabled
tests: acpi: extend cphp testcase with numa check
tests: acpi tables expected blobs update
Liang Li (1):
virtio-balloon: Remove needless precompiled directive
Sascha Silbe (2):
virtio-serial: add plumbing for virtio console emergency write support
virtio-serial: enable virtio console emergency write feature
Stefan Hajnoczi (3):
virtio: add virtio_detach_element()
virtio-blk: add missing virtio_detach_element() call
virtio-serial: add missing virtio_detach_element() call
include/hw/compat.h | 4 ++ include/hw/virtio/virtio-blk.h | 8 --- include/hw/virtio/virtio-serial.h | 2 + include/hw/virtio/virtio.h | 29 ++++------- include/sysemu/char.h | 21 +++++++- include/sysemu/numa.h | 3 ++ hmp.c | 1 + hw/9pfs/virtio-9p-device.c | 45 ++++++++++++----- hw/acpi/cpu.c | 12 +++++ hw/arm/virt-acpi-build.c | 6 +-- hw/arm/virt.c | 7 ++- hw/block/virtio-blk.c | 72 +++++++++++++++----------- hw/char/virtio-serial-bus.c | 79 +++++++++++++++++++++++++---- hw/display/virtio-gpu.c | 39 ++++++++++----- hw/i386/acpi-build.c | 7 +-- hw/i386/intel_iommu.c | 12 +++++ hw/i386/pc.c | 8 ++- hw/input/virtio-input.c | 21 ++++---- hw/net/virtio-net.c | 100 +++++++++++++++++++++---------------- hw/ppc/spapr_cpu_core.c | 6 +-- hw/scsi/virtio-scsi.c | 77 ++++++++++++++++------------ hw/virtio/vhost-vsock.c | 42 ++++++++-------- hw/virtio/virtio-balloon.c | 17 ++++--- hw/virtio/virtio-rng.c | 19 ++++--- hw/virtio/virtio.c | 44 ++++++++++++++-- net/colo-compare.c | 30 +---------- net/vhost-user.c | 41 +++------------ numa.c | 12 +++++ qemu-char.c | 22 ++++++-- tests/bios-tables-test.c | 6 ++- tests/acpi-test-data/pc/DSDT.cphp | Bin 6435 -> 6471 bytes tests/acpi-test-data/pc/SRAT.cphp | Bin 0 -> 304 bytes tests/acpi-test-data/q35/DSDT.cphp | Bin 9197 -> 9233 bytes tests/acpi-test-data/q35/SRAT.cphp | Bin 0 -> 304 bytes 34 files changed, 484 insertions(+), 308 deletions(-) create mode 100644 tests/acpi-test-data/pc/SRAT.cphp create mode 100644 tests/acpi-test-data/q35/SRAT.cphp
[Qemu-devel] [PULL 01/33] virtio-balloon: Remove needless precompiled directive
From: Liang Li <[email protected]>
Since there in wrapper around madvise(), the virtio-balloon code is able to work without the precompiled directive, the directive can be removed.
--- hw/virtio/virtio-balloon.c | 2 -- 1 file changed, 2 deletions(-)
hw/virtio/virtio-balloon.c +0 -2
@@ -34,13 +34,11 @@static void balloon_page (void *addr,int deflate) { -#if defined(__linux__)if (!qemu_balloon_is_inhibited () && (!kvm_enabled () ||kvm_has_sync_mmu ())) {qemu_madvise (addr,BALLOON_PAGE_SIZE , deflate ?QEMU_MADV_WILLNEED :QEMU_MADV_DONTNEED ); } -#endif }static const char *balloon_stat_names[] = {
Signature · 1 line
MST
[Qemu-devel] [PULL 02/33] virtio-serial: add plumbing for virtio console emergency write support
In reply to Michael S. TsirkinFrom: Sascha Silbe <[email protected]>
Add the infrastructure required for the virtio 1.0 "emergency write" (VIRTIO_CONSOLE_F_EMERG_WRITE) feature. Because we don't touch the size of the configuration area, guests will not be able to actually make use of this without further patches.
--- hw/char/virtio-serial-bus.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
hw/char/virtio-serial-bus.c +37 -0
@@ -75,6 +75,19 @@ static VirtIOSerialPort *find_port_by_name(char *name)return NULL ; } +static VirtIOSerialPort *find_first_connected_console (VirtIOSerial *vser) +{ +VirtIOSerialPort *port; + + QTAILQ_FOREACH(port, &vser->ports, next) { +VirtIOSerialPortClass const *vsc =VIRTIO_SERIAL_PORT_GET_CLASS (port); +if (vsc->is_console && port->host_connected) { +return port; + } + } +return NULL ; +} +static bool use_multiport (VirtIOSerial *vser) {VirtIODevice *vdev =VIRTIO_DEVICE (vser);
@@ -547,6 +560,29 @@ static void get_config(VirtIODevice *vdev, uint8_t *config_data) vser->serial.max_virtserial_ports); } +/* Guest sent new config info */ +static void set_config (VirtIODevice *vdev,const uint8_t *config_data) +{ +VirtIOSerial *vser =VIRTIO_SERIAL (vdev); +struct virtio_console_config *config = + (struct virtio_console_config *)config_data; +uint8_t emerg_wr_lo =le32_to_cpu (config->emerg_wr); +VirtIOSerialPort *port =find_first_connected_console (vser); +VirtIOSerialPortClass *vsc; + +if (!config->emerg_wr) { +return ; + } +/* Make sure we don't misdetect an emergency write when the guest +* does a short config write after an emergency write. */ + config->emerg_wr =0 ; +if (!port) { +return ; + } + vsc =VIRTIO_SERIAL_PORT_GET_CLASS (port); + (void )vsc->have_data (port, &emerg_wr_lo,1 ); +} +static void guest_reset (VirtIOSerial *vser) {VirtIOSerialPort *port;
@@ -1098,6 +1134,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data) vdc->unrealize = virtio_serial_device_unrealize; vdc->get_features = get_features; vdc->get_config = get_config; + vdc->set_config = set_config; vdc->set_status = set_status; vdc->reset = vser_reset; vdc->save = virtio_serial_save_device;
Signature · 1 line
MST
[Qemu-devel] [PULL 03/33] virtio-serial: enable virtio console emergency write feature
In reply to Michael S. TsirkinFrom: Sascha Silbe <[email protected]>
Add support for enabling the virtio 1.0 "emergency write" (VIRTIO_CONSOLE_F_EMERG_WRITE) feature. The previous patch introduced the plumbing required for this; now we expose the virtio feature to the guest. The feature is disabled for compatibility machines to avoid exposing a new feature to existing guests.
As required by the virtio 1.0 spec, the emergency write functionality is available to the guest even if the guest doesn't negotatiate the feature, as well as before feature negotation.
--- include/hw/compat.h | 4 ++++ include/hw/virtio/virtio-serial.h | 2 ++ hw/char/virtio-serial-bus.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-)
include/hw/compat.h +4 -0
@@ -7,6 +7,10 @@ .property = "page-per-vq",\ .value = "on",\ },{\ + .driver = "virtio-serial-device",\ + .property = "emergency-write",\ + .value = "off",\ + },{\ .driver = "ioapic",\ .property = "version",\ .value = "0x11",\
include/hw/virtio/virtio-serial.h +2 -0
@@ -184,6 +184,8 @@ struct VirtIOSerial {struct VirtIOSerialPostLoad *post_load;virtio_serial_conf serial; + +uint64_t host_features; };/* Interface to the virtio-serial bus */
hw/char/virtio-serial-bus.c +9 -3
@@ -541,6 +541,7 @@ static uint64_t get_features(VirtIODevice *vdev, uint64_t features, vser =VIRTIO_SERIAL (vdev); + features |= vser->host_features;if (vser->bus.max_nr_ports >1 ) {virtio_add_feature (&features,VIRTIO_CONSOLE_F_MULTIPORT ); }
@@ -1003,6 +1004,7 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)VirtIODevice *vdev =VIRTIO_DEVICE (dev);VirtIOSerial *vser =VIRTIO_SERIAL (dev);uint32_t i, max_supported_ports; +size_t config_size =sizeof (struct virtio_console_config );if (!vser->serial.max_virtserial_ports) {error_setg (errp,"Maximum number of serial ports not specified" );
@@ -1017,10 +1019,12 @@ static void virtio_serial_device_realize(DeviceState *dev, Error **errp)return ; } -/* We don't support emergency write, skip it for now. */ -/* TODO: cleaner fix, depending on host features. */ +if (!virtio_has_feature (vser->host_features, +VIRTIO_CONSOLE_F_EMERG_WRITE )) { + config_size = offsetof(struct virtio_console_config , emerg_wr); + }virtio_init (vdev,"virtio-serial" ,VIRTIO_ID_CONSOLE , - offsetof(struct virtio_console_config , emerg_wr)); + config_size);/* Spawn a new virtio-serial bus on which the ports will ride as devices */ qbus_create_inplace(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS,
@@ -1116,6 +1120,8 @@ VMSTATE_VIRTIO_DEVICE(console, 3, virtio_serial_load, virtio_vmstate_save);static Property virtio_serial_properties[] = {DEFINE_PROP_UINT32 ("max_ports" , VirtIOSerial, serial.max_virtserial_ports,31 ), +DEFINE_PROP_BIT64 ("emergency-write" , VirtIOSerial, host_features, +VIRTIO_CONSOLE_F_EMERG_WRITE , true),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
MST
[Qemu-devel] [PULL 05/33] acpi: provide _PXM method for CPU devices if QEMU is started numa enabled
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Workaround for long standing issue where Linux kernel assigns hotplugged CPU to 1st numa node as it discards proximity for possible CPUs from SRAT after it's parsed.
_PXM method allows linux query proximity directly from hotplugged CPU object, which allows Linux to assing CPU to the correct numa node.
--- hw/acpi/cpu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
hw/acpi/cpu.c +12 -0
@@ -4,6 +4,7 @@#include "qapi/error.h" #include "qapi-event.h" #include "trace.h" +#include "sysemu/numa.h" #define ACPI_CPU_HOTPLUG_REG_LEN 12#define ACPI_CPU_SELECTOR_OFFSET_WR 0
@@ -503,6 +504,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,/* build Processor object for each processor */ for (i =0 ; i < arch_ids->len; i++) { +int j;Aml *dev;Aml *uid =aml_int (i);GArray *madt_buf =g_array_new (0 ,1 ,1 );
@@ -546,6 +548,16 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_arg(1), aml_arg(2)) );aml_append (dev, method); + +/* Linux guests discard SRAT info for non-present CPUs +* as a result _PXM is required for all CPUs which might +* be hot-plugged. For simplicity, add it for all CPUs. +*/ + j =numa_get_node_for_cpu (i); +if (j < nb_numa_nodes) { +aml_append (dev,aml_name_decl ("_PXM" ,aml_int (j))); + } +aml_append (cpus_dev, dev); } }
Signature · 1 line
MST
[Qemu-devel] [PULL 06/33] tests: acpi: extend cphp testcase with numa check
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
so it would be possible to verify _PXM generation in DSDT and SRAT tables.
--- tests/bios-tables-test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tests/bios-tables-test.c +4 -2
@@ -811,7 +811,8 @@ static void test_acpi_piix4_tcg_cphp(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_PC ; data.variant =".cphp" ; -test_acpi_one ("-smp 2,cores=3,sockets=2,maxcpus=6" , +test_acpi_one ("-smp 2,cores=3,sockets=2,maxcpus=6" +" -numa node -numa node" , &data);free_test_data (&data); }
@@ -823,7 +824,8 @@ static void test_acpi_q35_tcg_cphp(void)memset (&data,0 ,sizeof (data)); data.machine =MACHINE_Q35 ; data.variant =".cphp" ; -test_acpi_one (" -smp 2,cores=3,sockets=2,maxcpus=6" , +test_acpi_one (" -smp 2,cores=3,sockets=2,maxcpus=6" +" -numa node -numa node" , &data);free_test_data (&data); }
Signature · 1 line
MST
[Qemu-devel] [PULL 07/33] tests: acpi tables expected blobs update
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
--- tests/acpi-test-data/pc/DSDT.cphp | Bin 6435 -> 6471 bytes tests/acpi-test-data/pc/SRAT.cphp | Bin 0 -> 304 bytes tests/acpi-test-data/q35/DSDT.cphp | Bin 9197 -> 9233 bytes tests/acpi-test-data/q35/SRAT.cphp | Bin 0 -> 304 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/acpi-test-data/pc/SRAT.cphp create mode 100644 tests/acpi-test-data/q35/SRAT.cphp
tests/acpi-test-data/pc/DSDT.cphp binary +0 -0
tests/acpi-test-data/pc/SRAT.cphp new file binary +0 -0
tests/acpi-test-data/q35/DSDT.cphp binary +0 -0
tests/acpi-test-data/q35/SRAT.cphp new file binary +0 -0
Signature · 1 line
MST
[Qemu-devel] [PULL 08/33] virtio: add virtio_detach_element()
In reply to Michael S. TsirkinFrom: Stefan Hajnoczi <[email protected]>
During device reset or similar situations a VirtQueueElement needs to be freed without pushing it onto the used ring or rewinding the virtqueue. Extract a new function to do this.
Later patches add virtio_detach_element() calls to existing device so that scatter-gather lists are unmapped and vq->inuse goes back to zero during device reset. Currently some devices don't bother and simply call g_free(elem) which is not a clean way to throw away a VirtQueueElement.
--- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio.c | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-)
include/hw/virtio/virtio.h +2 -0
@@ -155,6 +155,8 @@ void *virtqueue_alloc_element(size_t sz, unsigned out_num, unsigned in_num);void virtqueue_push (VirtQueue *vq,const VirtQueueElement *elem,unsigned int len);void virtqueue_flush (VirtQueue *vq,unsigned int count); +void virtqueue_detach_element (VirtQueue *vq,const VirtQueueElement *elem, +unsigned int len);void virtqueue_discard (VirtQueue *vq,const VirtQueueElement *elem,unsigned int len);bool virtqueue_rewind (VirtQueue *vq,unsigned int num);
hw/virtio/virtio.c +25 -2
@@ -264,12 +264,35 @@ static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem, 0, elem->out_sg[i].iov_len); } +/* virtqueue_detach_element: +* @vq: The #VirtQueue +* @elem: The #VirtQueueElement +* @len: number of bytes written +* +* Detach the element from the virtqueue. This function is suitable for device +* reset or other situations where a #VirtQueueElement is simply freed and will +* not be pushed or discarded. +*/ +void virtqueue_detach_element (VirtQueue *vq,const VirtQueueElement *elem, +unsigned int len) +{ + vq->inuse--; +virtqueue_unmap_sg (vq, elem, len); +} + +/* virtqueue_discard: +* @vq: The #VirtQueue +* @elem: The #VirtQueueElement +* @len: number of bytes written +* +* Pretend the most recent element wasn't popped from the virtqueue. The next +* call to virtqueue_pop() will refetch the element. +*/ void virtqueue_discard (VirtQueue *vq,const VirtQueueElement *elem,unsigned int len) { vq->last_avail_idx--; - vq->inuse--; -virtqueue_unmap_sg (vq, elem, len); +virtqueue_detach_element (vq, elem, len); }/* virtqueue_rewind:
Signature · 1 line
MST
[Qemu-arm] [PULL 04/33] numa: reduce code duplication by adding helper numa_get_node_for_cpu()
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
Replace repeated pattern
for (i = 0; i < nb_numa_nodes; i++) {
if (test_bit(idx, numa_info[i].node_cpu)) {
...
break;with a helper function to lookup numa node index for cpu.
--- include/sysemu/numa.h | 3 +++ hw/arm/virt-acpi-build.c | 6 ++---- hw/arm/virt.c | 7 +++---- hw/i386/acpi-build.c | 7 ++----- hw/i386/pc.c | 8 +++----- hw/ppc/spapr_cpu_core.c | 6 ++---- numa.c | 12 ++++++++++++ 7 files changed, 27 insertions(+), 22 deletions(-)
include/sysemu/numa.h +3 -0
@@ -32,4 +32,7 @@ void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);void numa_unset_mem_node_id (ram_addr_t addr,uint64_t size,uint32_t node);uint32_t numa_get_node (ram_addr_t addr,Error **errp); +/* on success returns node index in numa_info, +* on failure returns nb_numa_nodes */ +int numa_get_node_for_cpu (int idx);#endif
hw/arm/virt-acpi-build.c +2 -4
@@ -427,11 +427,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtGuestInfo *guest_info)uint32_t *cpu_node =g_malloc0 (guest_info->smp_cpus *sizeof (uint32_t ));for (i =0 ; i < guest_info->smp_cpus; i++) { -for (j =0 ; j < nb_numa_nodes; j++) { -if (test_bit (i, numa_info[j].node_cpu)) { + j =numa_get_node_for_cpu (i); +if (j < nb_numa_nodes) { cpu_node[i] = j; -break ; - } } }
hw/arm/virt.c +3 -4
@@ -413,10 +413,9 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi) armcpu->mp_affinity); } -for (i =0 ; i < nb_numa_nodes; i++) { -if (test_bit (cpu, numa_info[i].node_cpu)) { -qemu_fdt_setprop_cell (vbi->fdt, nodename,"numa-node-id" , i); - } + i =numa_get_node_for_cpu (cpu); +if (i < nb_numa_nodes) { +qemu_fdt_setprop_cell (vbi->fdt, nodename,"numa-node-id" , i); }g_free (nodename);
hw/i386/acpi-build.c +2 -5
@@ -2410,18 +2410,15 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) srat->reserved1 =cpu_to_le32 (1 );for (i =0 ; i < apic_ids->len; i++) { -int j; +int j =numa_get_node_for_cpu (i);int apic_id = apic_ids->cpus[i].arch_id; core =acpi_data_push (table_data,sizeof *core); core->type =ACPI_SRAT_PROCESSOR_APIC ; core->length =sizeof (*core); core->local_apic_id = apic_id; -for (j =0 ; j < nb_numa_nodes; j++) { -if (test_bit (i, numa_info[j].node_cpu)) { +if (j < nb_numa_nodes) { core->proximity_lo = j; -break ; - } }memset (core->proximity_hi,0 ,3 ); core->local_sapic_eid =0 ;
hw/i386/pc.c +3 -5
@@ -779,11 +779,9 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms)for (i =0 ; i < max_cpus; i++) {unsigned int apic_id =x86_cpu_apic_id_from_index (i);assert (apic_id < pcms->apic_id_limit); -for (j =0 ; j < nb_numa_nodes; j++) { -if (test_bit (i, numa_info[j].node_cpu)) { - numa_fw_cfg[apic_id +1 ] =cpu_to_le64 (j); -break ; - } + j =numa_get_node_for_cpu (i); +if (j < nb_numa_nodes) { + numa_fw_cfg[apic_id +1 ] =cpu_to_le64 (j); } }for (i =0 ; i < nb_numa_nodes; i++) {
hw/ppc/spapr_cpu_core.c +2 -4
@@ -69,11 +69,9 @@ void spapr_cpu_init(sPAPRMachineState *spapr, PowerPCCPU *cpu, Error **errp) }/* Set NUMA node for the added CPUs */ -for (i =0 ; i < nb_numa_nodes; i++) { -if (test_bit (cs->cpu_index, numa_info[i].node_cpu)) { + i =numa_get_node_for_cpu (cs->cpu_index); +if (i < nb_numa_nodes) { cs->numa_node = i; -break ; - } }xics_cpu_setup (spapr->xics, cpu);
numa.c +12 -0
@@ -550,3 +550,15 @@ MemdevList *qmp_query_memdev(Error **errp)object_child_foreach (obj, query_memdev, &list);return list; } + +int numa_get_node_for_cpu (int idx) +{ +int i; + +for (i =0 ; i < nb_numa_nodes; i++) { +if (test_bit (idx, numa_info[i].node_cpu)) { +break ; + } + } +return i; +}
Signature · 1 line
MST
[Qemu-devel] [PULL 09/33] virtio-blk: add missing virtio_detach_element() call
In reply to Michael S. TsirkinFrom: Stefan Hajnoczi <[email protected]>
Make sure to unmap the scatter-gather list and decrement vq->inuse before freeing requests in virtio_blk_reset().
--- hw/block/virtio-blk.c | 1 + 1 file changed, 1 insertion(+)
hw/block/virtio-blk.c +1 -0
@@ -665,6 +665,7 @@ static void virtio_blk_reset(VirtIODevice *vdev)while (s->rq) { req = s->rq; s->rq = req->next; +virtqueue_detach_element (req->vq, &req->elem,0 );virtio_blk_free_request (req); }
Signature · 1 line
MST
[Qemu-devel] [PULL 10/33] virtio-serial: add missing virtio_detach_element() call
In reply to Michael S. TsirkinFrom: Stefan Hajnoczi <[email protected]>
Ports enter a "throttled" state when writing to the chardev would block. The current output VirtQueueElement is kept around until the chardev becomes writable again.
There are several places in the virtio-serial lifecycle where the VirtQueueElement should be thrown away. For example, if the virtio device is reset then virtqueue elements are no longer valid.
This patch adds the discard_throttle_data() function to unmap the scatter-gather list and decrement vq->inuse. This ensures that the VirtQueueElement is freed properly.
--- hw/char/virtio-serial-bus.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
hw/char/virtio-serial-bus.c +14 -0
@@ -145,6 +145,15 @@ static void discard_vq_data(VirtQueue *vq, VirtIODevice *vdev)virtio_notify (vdev, vq); } +static void discard_throttle_data (VirtIOSerialPort *port) +{ +if (port->elem) { +virtqueue_detach_element (port->ovq, port->elem,0 ); +g_free (port->elem); + port->elem =NULL ; + } +} +static void do_flush_queued_data (VirtIOSerialPort *port,VirtQueue *vq,VirtIODevice *vdev) {
@@ -267,6 +276,7 @@ int virtio_serial_close(VirtIOSerialPort *port)* consume, reset the throttling flag and discard the data. */ port->throttled = false; +discard_throttle_data (port);discard_vq_data (port->ovq,VIRTIO_DEVICE (port->vser));send_control_event (port->vser, port->id,VIRTIO_CONSOLE_PORT_OPEN ,0 );
@@ -591,6 +601,9 @@ static void guest_reset(VirtIOSerial *vser) QTAILQ_FOREACH(port, &vser->ports, next) { vsc =VIRTIO_SERIAL_PORT_GET_CLASS (port); + +discard_throttle_data (port); +if (port->guest_connected) { port->guest_connected = false;if (vsc->set_guest_connected) {
@@ -901,6 +914,7 @@ static void remove_port(VirtIOSerial *vser, uint32_t port_id)assert (port);/* Flush out any unconsumed buffers first */ +discard_throttle_data (port);discard_vq_data (port->ovq,VIRTIO_DEVICE (port->vser));send_control_event (vser, port->id,VIRTIO_CONSOLE_PORT_REMOVE ,1 );
Signature · 1 line
MST
[Qemu-devel] [PULL 11/33] virtio-9p: add parentheses to sizeof operator
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
--- hw/9pfs/virtio-9p-device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/9pfs/virtio-9p-device.c +3 -3
@@ -57,12 +57,12 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq) }BUG_ON (elem->out_num ==0 || elem->in_num ==0 ); -QEMU_BUILD_BUG_ON (sizeof out !=7 ); +QEMU_BUILD_BUG_ON (sizeof (out) !=7 ); v->elems[pdu->idx] = elem; len =iov_to_buf (elem->out_sg, elem->out_num,0 , - &out,sizeof out); -BUG_ON (len !=sizeof out); + &out,sizeof (out)); +BUG_ON (len !=sizeof (out)); pdu->size =le32_to_cpu (out.size_le);
Signature · 1 line
MST
[Qemu-devel] [PULL 13/33] virtio-9p: handle handle_9p_output() error
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
A broken guest may send a request without providing buffers for the reply or for the request itself, and virtqueue_pop() will return an element with either in_num == 0 or out_num == 0.
All 9P requests are expected to start with the following 7-byte header:
uint32_t size_le;
uint8_t id;
uint16_t tag_le;If iov_to_buf() fails to return these 7 bytes, then something is wrong in the guest.
In both cases, it is wrong to crash QEMU, since the root cause lies in the guest.
This patch hence does the following:
- keep the check of in_num since pdu_complete() assumes it has enough space to store the reply and we will send something broken to the guest
- let iov_to_buf() handle out_num == 0, since it will return 0 just like if the guest had provided an zero-sized buffer.
- call virtio_error() to inform the guest that the device is now broken, instead of aborting
- detach the request from the virtqueue and free it
--- hw/9pfs/virtio-9p-device.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
hw/9pfs/virtio-9p-device.c +21 -5
@@ -41,6 +41,7 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)V9fsState *s = &v->state;V9fsPDU *pdu;ssize_t len; +VirtQueueElement *elem;while ((pdu =pdu_alloc (s))) {struct {
@@ -48,21 +49,28 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)uint8_t id;uint16_t tag_le; }QEMU_PACKED out; -VirtQueueElement *elem; elem =virtqueue_pop (vq,sizeof (VirtQueueElement));if (!elem) { -pdu_free (pdu); -break ; + goto out_free_pdu; } -BUG_ON (elem->out_num ==0 || elem->in_num ==0 ); +if (elem->in_num ==0 ) { +virtio_error (vdev, +"The guest sent a VirtFS request without space for " +"the reply" ); + goto out_free_req; + }QEMU_BUILD_BUG_ON (sizeof (out) !=7 ); v->elems[pdu->idx] = elem; len =iov_to_buf (elem->out_sg, elem->out_num,0 , &out,sizeof (out)); -BUG_ON (len !=sizeof (out)); +if (len !=sizeof (out)) { +virtio_error (vdev,"The guest sent a malformed VirtFS request: " +"header size is %zd, should be 7" , len); + goto out_free_req; + } pdu->size =le32_to_cpu (out.size_le);
@@ -72,6 +80,14 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)qemu_co_queue_init (&pdu->complete);pdu_submit (pdu); } + +return ; + +out_free_req: +virtqueue_detach_element (vq, elem,0 ); +g_free (elem); +out_free_pdu: +pdu_free (pdu); } static uint64_t virtio_9p_get_features(VirtIODevice *vdev, uint64_t features,
Signature · 1 line
MST
[Qemu-devel] [PULL 15/33] virtio-net: handle virtio_net_handle_ctrl() error
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
This error is caused by a buggy guest: let's switch the device to the broken state instead of terminating QEMU. Also we detach the element from the virtqueue and free it.
--- hw/net/virtio-net.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/net/virtio-net.c +5 -2
@@ -880,6 +880,7 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd,return VIRTIO_NET_OK ; } +static void virtio_net_handle_ctrl (VirtIODevice *vdev,VirtQueue *vq) {VirtIONet *n =VIRTIO_NET (vdev);
@@ -897,8 +898,10 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) }if (iov_size (elem->in_sg, elem->in_num) <sizeof (status) ||iov_size (elem->out_sg, elem->out_num) <sizeof (ctrl)) { -error_report ("virtio-net ctrl missing headers" ); -exit (1 ); +virtio_error (vdev,"virtio-net ctrl missing headers" ); +virtqueue_detach_element (vq, elem,0 ); +g_free (elem); +break ; } iov_cnt = elem->out_num;
Signature · 1 line
MST
[Qemu-devel] [PULL 16/33] virtio-net: handle virtio_net_receive() errors
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
All these errors are caused by a buggy guest: let's switch the device to the broken state instead of terminating QEMU. Also we detach the element from the virtqueue and free it.
--- hw/net/virtio-net.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
hw/net/virtio-net.c +15 -12
@@ -1130,21 +1130,24 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t elem =virtqueue_pop (q->rx_vq,sizeof (VirtQueueElement));if (!elem) { -if (i ==0 ) -return -1 ; -error_report ("virtio-net unexpected empty queue: " -"i %zd mergeable %d offset %zd, size %zd, " -"guest hdr len %zd, host hdr len %zd " -"guest features 0x%" PRIx64, - i, n->mergeable_rx_bufs, offset, size, - n->guest_hdr_len, n->host_hdr_len, - vdev->guest_features); -exit (1 ); +if (i) { +virtio_error (vdev,"virtio-net unexpected empty queue: " +"i %zd mergeable %d offset %zd, size %zd, " +"guest hdr len %zd, host hdr len %zd " +"guest features 0x%" PRIx64, + i, n->mergeable_rx_bufs, offset, size, + n->guest_hdr_len, n->host_hdr_len, + vdev->guest_features); + } +return -1 ; }if (elem->in_num <1 ) { -error_report ("virtio-net receive queue contains no in buffers" ); -exit (1 ); +virtio_error (vdev, +"virtio-net receive queue contains no in buffers" ); +virtqueue_detach_element (q->rx_vq, elem,0 ); +g_free (elem); +return -1 ; } sg = elem->in_sg;
Signature · 1 line
MST
[Qemu-devel] [PULL 17/33] virtio-net: handle virtio_net_flush_tx() errors
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
All these errors are caused by a buggy guest: let's switch the device to the broken state instead of terminating QEMU. Also we detach the element from the virtqueue and free it.
If this happens, virtio_net_flush_tx() also returns -EINVAL, so that all callers can stop processing the virtqueue immediatly.
--- hw/net/virtio-net.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
hw/net/virtio-net.c +18 -8
@@ -1249,15 +1249,19 @@ static int32_t virtio_net_flush_tx(VirtIONetQueue *q) out_num = elem->out_num; out_sg = elem->out_sg;if (out_num <1 ) { -error_report ("virtio-net header not in first element" ); -exit (1 ); +virtio_error (vdev,"virtio-net header not in first element" ); +virtqueue_detach_element (q->tx_vq, elem,0 ); +g_free (elem); +return -EINVAL ; }if (n->has_vnet_hdr) {if (iov_to_buf (out_sg, out_num,0 , &mhdr, n->guest_hdr_len) < n->guest_hdr_len) { -error_report ("virtio-net header incorrect" ); -exit (1 ); +virtio_error (vdev,"virtio-net header incorrect" ); +virtqueue_detach_element (q->tx_vq, elem,0 ); +g_free (elem); +return -EINVAL ; }if (n->needs_vnet_hdr_swap) {virtio_net_hdr_swap (vdev, (void *) &mhdr);
@@ -1325,7 +1329,9 @@ static void virtio_net_handle_tx_timer(VirtIODevice *vdev, VirtQueue *vq)virtio_queue_set_notification (vq,1 );timer_del (q->tx_timer); q->tx_waiting =0 ; -virtio_net_flush_tx (q); +if (virtio_net_flush_tx (q) == -EINVAL ) { +return ; + } }else {timer_mod (q->tx_timer,qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + n->tx_timeout);
@@ -1396,8 +1402,9 @@ static void virtio_net_tx_bh(void *opaque) } ret =virtio_net_flush_tx (q); -if (ret == -EBUSY ) { -return ;/* Notification re-enable handled by tx_complete */ +if (ret == -EBUSY || ret == -EINVAL ) { +return ;/* Notification re-enable handled by tx_complete or device +* broken */ }/* If we flush a full burst of packets, assume there are
@@ -1412,7 +1419,10 @@ static void virtio_net_tx_bh(void *opaque)* anything that may have come in while we weren't looking. If * we find something, assume the guest is still active and reschedule */ virtio_queue_set_notification (q->tx_vq,1 ); -if (virtio_net_flush_tx (q) >0 ) { + ret =virtio_net_flush_tx (q); +if (ret == -EINVAL ) { +return ; + }else if (ret >0 ) {virtio_queue_set_notification (q->tx_vq,0 );qemu_bh_schedule (q->tx_bh); q->tx_waiting =1 ;
Signature · 1 line
MST
[Qemu-devel] [PULL 18/33] virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error()
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
The virtio_scsi_bad_req() function is called when a guest sends a request with missing or ill-sized headers. This generally happens when the virtio_scsi_parse_req() function returns an error.
With this patch, virtio_scsi_bad_req() will mark the device as broken, detach the request from the virtqueue and free it, instead of forcing QEMU to exit.
In nearly all locations where virtio_scsi_bad_req() is called, the only thing to do next is to return to the caller.
The virtio_scsi_handle_cmd_req_prepare() function is an exception though.
It is called in a loop by virtio_scsi_handle_cmd_vq() and passed requests freshly popped from a cmd virtqueue; virtio_scsi_handle_cmd_req_prepare() does some sanity checks on the request and returns a boolean flag to indicate whether the request should be queued or not. In the latter case, virtio_scsi_handle_cmd_req_prepare() has detected a non-fatal error and sent a response back to the guest.
We have now a new condition to take into account: the device is broken and should stop all processing.
The return value of virtio_scsi_handle_cmd_req_prepare() is hence changed to an int. A return value of zero means that the request should be queued. Other non-fatal error cases where the request shoudn't be queued return a negative errno (values are vaguely inspired by the error condition, but the only goal here is to discriminate the case we're interested in).
And finally, if virtio_scsi_bad_req() was called, -EINVAL is returned. In this case, virtio_scsi_handle_cmd_vq() detaches and frees already queued requests, instead of submitting them.
--- hw/scsi/virtio-scsi.c | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-)
hw/scsi/virtio-scsi.c +32 -14
@@ -81,10 +81,11 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req)virtio_scsi_free_req (req); } -static void virtio_scsi_bad_req (void ) +static void virtio_scsi_bad_req (VirtIOSCSIReq *req) { -error_report ("wrong size for virtio-scsi headers" ); -exit (1 ); +virtio_error (VIRTIO_DEVICE (req->dev),"wrong size for virtio-scsi headers" ); +virtqueue_detach_element (req->vq, &req->elem,0 ); +virtio_scsi_free_req (req); } static size_t qemu_sgl_concat(VirtIOSCSIReq *req, struct iovec *iov,
@@ -387,7 +388,7 @@ static void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req)if (iov_to_buf (req->elem.out_sg, req->elem.out_num,0 , &type,sizeof (type)) <sizeof (type)) { -virtio_scsi_bad_req (); +virtio_scsi_bad_req (req);return ; }
@@ -395,7 +396,8 @@ static void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req)if (type ==VIRTIO_SCSI_T_TMF ) {if (virtio_scsi_parse_req (req,sizeof (VirtIOSCSICtrlTMFReq),sizeof (VirtIOSCSICtrlTMFResp)) <0 ) { -virtio_scsi_bad_req (); +virtio_scsi_bad_req (req); +return ; }else { r =virtio_scsi_do_tmf (s, req); }
@@ -404,7 +406,8 @@ static void virtio_scsi_handle_ctrl_req(VirtIOSCSI *s, VirtIOSCSIReq *req) type == VIRTIO_SCSI_T_AN_SUBSCRIBE) {if (virtio_scsi_parse_req (req,sizeof (VirtIOSCSICtrlANReq),sizeof (VirtIOSCSICtrlANResp)) <0 ) { -virtio_scsi_bad_req (); +virtio_scsi_bad_req (req); +return ; }else { req->resp.an.event_actual =0 ; req->resp.an.response =VIRTIO_SCSI_S_OK ;
@@ -521,7 +524,7 @@ static void virtio_scsi_fail_cmd_req(VirtIOSCSIReq *req)virtio_scsi_complete_cmd_req (req); } -static bool virtio_scsi_handle_cmd_req_prepare (VirtIOSCSI *s,VirtIOSCSIReq *req) +static int virtio_scsi_handle_cmd_req_prepare (VirtIOSCSI *s,VirtIOSCSIReq *req) {VirtIOSCSICommon *vs = &s->parent_obj;SCSIDevice *d;
@@ -532,17 +535,18 @@ static bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *reqif (rc <0 ) {if (rc == -ENOTSUP ) {virtio_scsi_fail_cmd_req (req); +return -ENOTSUP ; }else { -virtio_scsi_bad_req (); +virtio_scsi_bad_req (req); +return -EINVAL ; } -return false; } d =virtio_scsi_device_find (s, req->req.cmd.lun);if (!d) { req->resp.cmd.response =VIRTIO_SCSI_S_BAD_TARGET ;virtio_scsi_complete_cmd_req (req); -return false; +return -ENOENT ; }virtio_scsi_ctx_check (s, d); req->sreq = scsi_req_new(d, req->req.cmd.tag,
@@ -554,11 +558,11 @@ static bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req req->sreq->cmd.xfer > req->qsgl.size)) { req->resp.cmd.response =VIRTIO_SCSI_S_OVERRUN ;virtio_scsi_complete_cmd_req (req); -return false; +return -ENOBUFS ; }scsi_req_ref (req->sreq);blk_io_plug (d->conf.blk); -return true; +return 0 ; }static void virtio_scsi_handle_cmd_req_submit (VirtIOSCSI *s,VirtIOSCSIReq *req)
@@ -574,11 +578,24 @@ static void virtio_scsi_handle_cmd_req_submit(VirtIOSCSI *s, VirtIOSCSIReq *req)void virtio_scsi_handle_cmd_vq (VirtIOSCSI *s,VirtQueue *vq) {VirtIOSCSIReq *req, *next; +int ret; + QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);while ((req =virtio_scsi_pop_req (s, vq))) { -if (virtio_scsi_handle_cmd_req_prepare (s, req)) { + ret =virtio_scsi_handle_cmd_req_prepare (s, req); +if (!ret) {QTAILQ_INSERT_TAIL (&reqs, req, next); + }else if (ret == -EINVAL ) { +/* The device is broken and shouldn't process any request */ +while (!QTAILQ_EMPTY (&reqs)) { + req =QTAILQ_FIRST (&reqs); +QTAILQ_REMOVE (&reqs, req, next); +blk_io_unplug (req->sreq->dev->conf.blk); +scsi_req_unref (req->sreq); +virtqueue_detach_element (req->vq, &req->elem,0 ); +virtio_scsi_free_req (req); + } } }
@@ -708,7 +725,8 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, }if (virtio_scsi_parse_req (req,0 ,sizeof (VirtIOSCSIEvent))) { -virtio_scsi_bad_req (); +virtio_scsi_bad_req (req); + goto out; } evt = &req->resp.event;
Signature · 1 line
MST
[Qemu-devel] [PULL 19/33] virtio-scsi: handle virtio_scsi_set_config() error
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
This error is caused by a buggy guest: let's switch the device to the broken state instead of terminating QEMU.
--- hw/scsi/virtio-scsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/scsi/virtio-scsi.c +3 -2
@@ -644,8 +644,9 @@ static void virtio_scsi_set_config(VirtIODevice *vdev,if ((uint32_t )virtio_ldl_p (vdev, &scsiconf->sense_size) >=65536 || (uint32_t )virtio_ldl_p (vdev, &scsiconf->cdb_size) >=256 ) { -error_report ("bad data written to virtio-scsi configuration space" ); -exit (1 ); +virtio_error (vdev, +"bad data written to virtio-scsi configuration space" ); +return ; } vs->sense_size =virtio_ldl_p (vdev, &scsiconf->sense_size);
Signature · 1 line
MST
[Qemu-devel] [PULL 23/33] virtio-net: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/net/virtio-net.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
hw/net/virtio-net.c +21 -21
@@ -11,6 +11,8 @@* */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qemu/iov.h" #include "hw/virtio/virtio.h"
@@ -1514,17 +1516,6 @@ static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue)virtio_net_set_queues (n); } -static void virtio_net_save (QEMUFile *f,void *opaque,size_t size) -{ -VirtIONet *n = opaque; -VirtIODevice *vdev =VIRTIO_DEVICE (n); - -/* At this point, backend must be stopped, otherwise -* it might keep writing to memory. */ -assert (!n->vhost_started); -virtio_save (vdev, f); -} -static void virtio_net_save_device (VirtIODevice *vdev,QEMUFile *f) {VirtIONet *n =VIRTIO_NET (vdev);
@@ -1560,14 +1551,6 @@ static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f) } } -static int virtio_net_load (QEMUFile *f,void *opaque,size_t size) -{ -VirtIONet *n = opaque; -VirtIODevice *vdev =VIRTIO_DEVICE (n); - -return virtio_load (vdev, f,VIRTIO_NET_VM_VERSION ); -} -static int virtio_net_load_device (VirtIODevice *vdev,QEMUFile *f,int version_id) {
@@ -1870,8 +1853,25 @@ static void virtio_net_instance_init(Object *obj) DEVICE(n), NULL); } -VMSTATE_VIRTIO_DEVICE (net,VIRTIO_NET_VM_VERSION , virtio_net_load, - virtio_net_save); +static void virtio_net_pre_save (void *opaque) +{ +VirtIONet *n = opaque; + +/* At this point, backend must be stopped, otherwise +* it might keep writing to memory. */ +assert (!n->vhost_started); +} + +static const VMStateDescription vmstate_virtio_net = { + .name ="virtio-net" , + .minimum_version_id =VIRTIO_NET_VM_VERSION , + .version_id =VIRTIO_NET_VM_VERSION , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, + .pre_save = virtio_net_pre_save, +};static Property virtio_net_properties[] = {DEFINE_PROP_BIT ("csum" , VirtIONet, host_features,VIRTIO_NET_F_CSUM , true),
Signature · 1 line
MST
[Qemu-devel] [PULL 24/33] virtio-9p: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/9pfs/virtio-9p-device.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
hw/9pfs/virtio-9p-device.c +11 -6
@@ -11,6 +11,8 @@* */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "hw/virtio/virtio.h" #include "qemu/sockets.h"
@@ -113,11 +115,6 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)g_free (cfg); } -static int virtio_9p_load (QEMUFile *f,void *opaque,size_t size) -{ -return virtio_load (VIRTIO_DEVICE (opaque), f,1 ); -} -static void virtio_9p_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);
@@ -184,7 +181,15 @@ void virtio_init_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,/* virtio-9p device */ -VMSTATE_VIRTIO_DEVICE (9p ,1 , virtio_9p_load, virtio_vmstate_save); +static const VMStateDescription vmstate_virtio_9p = { + .name ="virtio-9p" , + .minimum_version_id =1 , + .version_id =1 , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, +};static Property virtio_9p_properties[] = {DEFINE_PROP_STRING ("mount_tag" , V9fsVirtioState, state.fsconf.tag),
Signature · 1 line
MST
[Qemu-devel] [PULL 25/33] virtio-serial: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/char/virtio-serial-bus.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
hw/char/virtio-serial-bus.c +11 -7
@@ -18,6 +18,8 @@* GNU GPL, version 2 or (at your option) any later version. */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/iov.h"
@@ -778,12 +780,6 @@ static int fetch_active_ports_list(QEMUFile *f,return 0 ; } -static int virtio_serial_load (QEMUFile *f,void *opaque,size_t size) -{ -/* The virtio device */ -return virtio_load (VIRTIO_DEVICE (opaque), f,3 ); -} -static int virtio_serial_load_device (VirtIODevice *vdev,QEMUFile *f,int version_id) {
@@ -1129,7 +1125,15 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp) }/* Note: 'console' is used for backwards compatibility */ -VMSTATE_VIRTIO_DEVICE (console,3 , virtio_serial_load, virtio_vmstate_save); +static const VMStateDescription vmstate_virtio_console = { + .name ="virtio-console" , + .minimum_version_id =3 , + .version_id =3 , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, +};static Property virtio_serial_properties[] = { DEFINE_PROP_UINT32("max_ports", VirtIOSerial, serial.max_virtserial_ports,
Signature · 1 line
MST
[Qemu-devel] [PULL 27/33] virtio-input: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/input/virtio-input.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
hw/input/virtio-input.c +13 -10
@@ -4,6 +4,8 @@* top-level directory. */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/iov.h"
@@ -217,19 +219,12 @@ static void virtio_input_reset(VirtIODevice *vdev) } } -static int virtio_input_load (QEMUFile *f,void *opaque,size_t size) +static int virtio_input_post_load (void *opaque,int version_id) {VirtIOInput *vinput = opaque;VirtIOInputClass *vic =VIRTIO_INPUT_GET_CLASS (vinput);VirtIODevice *vdev =VIRTIO_DEVICE (vinput); -int ret; - - ret =virtio_load (vdev, f,VIRTIO_INPUT_VM_VERSION ); -if (ret) { -return ret; - } -/* post_load() */ vinput->active = vdev->status &VIRTIO_CONFIG_S_DRIVER_OK ;if (vic->change_active) { vic->change_active (vinput);
@@ -296,8 +291,16 @@ static void virtio_input_device_unrealize(DeviceState *dev, Error **errp)virtio_cleanup (vdev); } -VMSTATE_VIRTIO_DEVICE (input,VIRTIO_INPUT_VM_VERSION , virtio_input_load, - virtio_vmstate_save); +static const VMStateDescription vmstate_virtio_input = { + .name ="virtio-input" , + .minimum_version_id =VIRTIO_INPUT_VM_VERSION , + .version_id =VIRTIO_INPUT_VM_VERSION , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, + .post_load = virtio_input_post_load, +};static Property virtio_input_properties[] = {DEFINE_PROP_STRING ("serial" , VirtIOInput, serial),
Signature · 1 line
MST
[Qemu-devel] [PULL 28/33] virtio-scsi: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/scsi/virtio-scsi.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
hw/scsi/virtio-scsi.c +11 -17
@@ -13,6 +13,8 @@* */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qapi/error.h" #include "standard-headers/linux/virtio_ids.h"
@@ -681,22 +683,6 @@ static void virtio_scsi_reset(VirtIODevice *vdev) s->events_dropped = false; } -/* The device does not have anything to save beyond the virtio data. -* Request data is saved with callbacks from SCSI devices. -*/ -static void virtio_scsi_save (QEMUFile *f,void *opaque,size_t size) -{ -VirtIODevice *vdev =VIRTIO_DEVICE (opaque); -virtio_save (vdev, f); -} - -static int virtio_scsi_load (QEMUFile *f,void *opaque,size_t size) -{ -VirtIODevice *vdev =VIRTIO_DEVICE (opaque); - -return virtio_load (vdev, f,1 ); -} -void virtio_scsi_push_event (VirtIOSCSI *s,SCSIDevice *dev,uint32_t event,uint32_t reason) {
@@ -940,7 +926,15 @@ static Property virtio_scsi_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -VMSTATE_VIRTIO_DEVICE (scsi,1 , virtio_scsi_load, virtio_scsi_save); +static const VMStateDescription vmstate_virtio_scsi = { + .name ="virtio-scsi" , + .minimum_version_id =1 , + .version_id =1 , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, +};static void virtio_scsi_common_class_init (ObjectClass *klass,void *data) {
Signature · 1 line
MST
[Qemu-devel] [PULL 20/33] net: don't poke at chardev internal QemuOpts
In reply to Michael S. TsirkinFrom: "Daniel P. Berrange" <[email protected]>
The vhost-user & colo code is poking at the QemuOpts instance in the CharDriverState struct, not realizing that it is valid for this to be NULL. e.g. the following crash shows a codepath where it will be NULL:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617
617 QTAILQ_FOREACH(opt, &opts->head, next) {
[Current thread is 1 (Thread 0x7f1d4970bb40 (LWP 6603))]
(gdb) bt
#0 0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617 #1 0x000055baf696b7da in net_vhost_parse_chardev (opts=0x55baf8ff9260, errp=0x7ffc51368e48) at net/vhost-user.c:314 #2 0x000055baf696b985 in net_init_vhost_user (netdev=0x55baf8ff9250, name=0x55baf879d270 "hostnet2", peer=0x0, errp=0x7ffc51368e48) at net/vhost-user.c:360 #3 0x000055baf6960216 in net_client_init1 (object=0x55baf8ff9250, is_netdev=true, errp=0x7ffc51368e48) at net/net.c:1051 #4 0x000055baf6960518 in net_client_init (opts=0x55baf776e7e0, is_netdev=true, errp=0x7ffc51368f00) at net/net.c:1108 #5 0x000055baf696083f in netdev_add (opts=0x55baf776e7e0, errp=0x7ffc51368f00) at net/net.c:1186 #6 0x000055baf69608c7 in qmp_netdev_add (qdict=0x55baf7afaf60, ret=0x7ffc51368f50, errp=0x7ffc51368f48) at net/net.c:1205 #7 0x000055baf6622135 in handle_qmp_command (parser=0x55baf77fb590, tokens=0x7f1d24011960) at /path/to/qemu.git/monitor.c:3978 #8 0x000055baf6a9d099 in json_message_process_token (lexer=0x55baf77fb598, input=0x55baf75acd20, type=JSON_RCURLY, x=113, y=19) at qobject/json-streamer.c:105 #9 0x000055baf6abf7aa in json_lexer_feed_char (lexer=0x55baf77fb598, ch=125 '}', flush=false) at qobject/json-lexer.c:319
#10 0x000055baf6abf8f2 in json_lexer_feed (lexer=0x55baf77fb598, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-lexer.c:369 #11 0x000055baf6a9d13c in json_message_parser_feed (parser=0x55baf77fb590, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-streamer.c:124 #12 0x000055baf66221f7 in monitor_qmp_read (opaque=0x55baf77fb530, buf=0x7ffc51369170 "}R\204\367\272U", size=1) at /path/to/qemu.git/monitor.c:3994 #13 0x000055baf6757014 in qemu_chr_be_write_impl (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:387
#14 0x000055baf6757076 in qemu_chr_be_write (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:399
#15 0x000055baf675b3b0 in tcp_chr_read (chan=0x55baf90244b0, cond=G_IO_IN, opaque=0x55baf7610a40) at qemu-char.c:2927
#16 0x000055baf6a5d655 in qio_channel_fd_source_dispatch (source=0x55baf7610df0, callback=0x55baf675b25a <tcp_chr_read>, user_data=0x55baf7610a40) at io/channel-watch.c:84 #17 0x00007f1d3e80cbbd in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#18 0x000055baf69d3720 in glib_pollfds_poll () at main-loop.c:213
#19 0x000055baf69d37fd in os_host_main_loop_wait (timeout=126000000) at main-loop.c:258
#20 0x000055baf69d38ad in main_loop_wait (nonblocking=0) at main-loop.c:506
#21 0x000055baf676587b in main_loop () at vl.c:1908
#22 0x000055baf676d3bf in main (argc=101, argv=0x7ffc5136a6c8, envp=0x7ffc5136a9f8) at vl.c:4604
(gdb) p opts
$1 = (QemuOpts *) 0x0
The crash occurred when attaching vhost-user net via QMP:
{
"execute": "chardev-add",
"arguments": {
"id": "charnet2",
"backend": {
"type": "socket",
"data": {
"addr": {
"type": "unix",
"data": {
"path": "/var/run/openvswitch/vhost-user1"
}
},
"wait": false,
"server": false
}
}
},
"id": "libvirt-19"
}
{
"return": {
},
"id": "libvirt-19"
}
{
"execute": "netdev_add",
"arguments": {
"type": "vhost-user",
"chardev": "charnet2",
"id": "hostnet2"
},
"id": "libvirt-20"
}Code using chardevs should not be poking at the internals of the CharDriverState struct. What vhost-user wants is a chardev that is operating as reconnectable network service, along with the ability to do FD passing over the connection. The colo code simply wants a network service. Add a feature concept to the char drivers so that chardev users can query the actual features they wish to have supported. The QemuOpts member is removed to prevent future mistakes in this area.
--- include/sysemu/char.h | 21 ++++++++++++++++++++- hmp.c | 1 + net/colo-compare.c | 30 ++---------------------------- net/vhost-user.c | 41 +++++++---------------------------------- qemu-char.c | 22 +++++++++++++++++++--- 5 files changed, 49 insertions(+), 66 deletions(-)
include/sysemu/char.h +20 -1
@@ -9,6 +9,7 @@#include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" #include "qemu/main-loop.h" +#include "qemu/bitmap.h" /* character device */
@@ -58,6 +59,20 @@ struct ParallelIOArg {typedef void IOEventHandler (void *opaque,int event); +typedef enum { +/* Whether the chardev peer is able to close and +* reopen the data channel, thus requiring support +* for qemu_chr_wait_connected() to wait for a +* valid connection */ +QEMU_CHAR_FEATURE_RECONNECTABLE , +/* Whether it is possible to send/recv file descriptors +* over the data channel */ +QEMU_CHAR_FEATURE_FD_PASS , + +QEMU_CHAR_FEATURE_LAST , +}CharDriverFeature ; + +struct CharDriverState {QemuMutex chr_write_lock;void (*init)(struct CharDriverState *s);
@@ -93,8 +108,8 @@ struct CharDriverState {int avail_connections;int is_mux;guint fd_in_tag; -QemuOpts *opts;bool replay; +DECLARE_BITMAP (features,QEMU_CHAR_FEATURE_LAST );QTAILQ_ENTRY (CharDriverState) next; };
@@ -437,6 +452,10 @@ int qemu_chr_add_client(CharDriverState *s, int fd);CharDriverState *qemu_chr_find (const char *name);bool chr_is_ringbuf (const CharDriverState *chr); +bool qemu_chr_has_feature (CharDriverState *chr, +CharDriverFeature feature); +void qemu_chr_set_feature (CharDriverState *chr, +CharDriverFeature feature);QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename); void register_char_driver(const char *name, ChardevBackendKind kind,
hmp.c +1 -0
@@ -1909,6 +1909,7 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict)error_setg (&err,"Parsing chardev args failed" ); }else {qemu_chr_new_from_opts (opts,NULL , &err); +qemu_opts_del (opts); }hmp_handle_error (mon, &err); }
net/colo-compare.c +2 -28
@@ -564,29 +564,6 @@ static void compare_sec_rs_finalize(SocketReadState *sec_rs) } } -static int compare_chardev_opts (void *opaque, -const char *name,const char *value, -Error **errp) -{ -CompareChardevProps *props = opaque; - -if (strcmp (name,"backend" ) ==0 && -strcmp (value,"socket" ) ==0 ) { - props->is_socket = true; -return 0 ; - }else if (strcmp (name,"host" ) ==0 || - (strcmp (name,"port" ) ==0 ) || - (strcmp (name,"server" ) ==0 ) || - (strcmp (name,"wait" ) ==0 ) || - (strcmp (name,"path" ) ==0 )) { -return 0 ; - }else { -error_setg (errp, -"COLO-compare does not support a chardev with option %s=%s" , - name, value); -return -1 ; - } -}/* * Return 0 is success.
@@ -606,12 +583,9 @@ static int find_and_check_chardev(CharDriverState **chr, }memset (&props,0 ,sizeof (props)); -if (qemu_opt_foreach ((*chr)->opts, compare_chardev_opts, &props, errp)) { -return 1 ; - } -if (!props.is_socket) { -error_setg (errp,"chardev \"%s\" is not a tcp socket" , +if (!qemu_chr_has_feature (*chr,QEMU_CHAR_FEATURE_RECONNECTABLE )) { +error_setg (errp,"chardev \"%s\" is not reconnectable" , chr_name);return 1 ; }
net/vhost-user.c +7 -34
70 lines not on this page · raw message
qemu-char.c +19 -3
@@ -3996,7 +3996,6 @@ CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, } chr =qemu_chr_find (id); - chr->opts = opts; qapi_out:qapi_free_ChardevBackend (backend);
@@ -4005,7 +4004,6 @@ qapi_out:return chr; err: -qemu_opts_del (opts);return NULL ; }
@@ -4033,6 +4031,7 @@ CharDriverState *qemu_chr_new_noreplay(const char *label, const char *filename,qemu_chr_fe_claim_no_fail (chr);monitor_init (chr,MONITOR_USE_READLINE ); } +qemu_opts_del (opts);return chr; }
@@ -4132,7 +4131,6 @@ static void qemu_chr_free_common(CharDriverState *chr) {g_free (chr->filename);g_free (chr->label); -qemu_opts_del (chr->opts);if (chr->logfd !=-1 ) {close (chr->logfd); }
@@ -4513,6 +4511,11 @@ static CharDriverState *qmp_chardev_open_socket(const char *id, s->addr =QAPI_CLONE (SocketAddress, sock->addr); +qemu_chr_set_feature (chr,QEMU_CHAR_FEATURE_RECONNECTABLE ); +if (s->is_unix) { +qemu_chr_set_feature (chr,QEMU_CHAR_FEATURE_FD_PASS ); + } + chr->opaque = s; chr->chr_wait_connected = tcp_chr_wait_connected; chr->chr_write = tcp_chr_write;
@@ -4596,6 +4599,19 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,return qemu_chr_open_udp (sioc, common, errp); } + +bool qemu_chr_has_feature (CharDriverState *chr, +CharDriverFeature feature) +{ +return test_bit (feature, chr->features); +} + +void qemu_chr_set_feature (CharDriverState *chr, +CharDriverFeature feature) +{ +return set_bit (feature, chr->features); +} +ChardevReturn *qmp_chardev_add (const char *id,ChardevBackend *backend,Error **errp) {
Signature · 1 line
MST
[Qemu-devel] [PULL 21/33] virtio: prepare change VMSTATE_VIRTIO_DEVICE macro
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
In most cases the functions passed to VMSTATE_VIRTIO_DEVICE only call the virtio_load and virtio_save wrappers. Some include some pre- and post- massaging too. The massaging is better expressed as such in the VMStateDescription.
Let us prepare for changing the semantic of the VMSTATE_VIRTIO_DEVICE macro so that it is more similar to the other VMSTATE_*_DEVICE macros in a sense that it is a field definition.
The preprocessor conditionals are going to be removed as soon as every usage is converted to the new semantic.
--- include/hw/virtio/virtio.h | 16 ++++++++++++++++ hw/virtio/virtio.c | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+)
include/hw/virtio/virtio.h +16 -0
@@ -179,6 +179,20 @@ void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);void virtio_save (VirtIODevice *vdev,QEMUFile *f);void virtio_vmstate_save (QEMUFile *f,void *opaque,size_t size); +extern const VMStateInfo virtio_vmstate_info; + +#ifdef VMSTATE_VIRTIO_DEVICE_USE_NEW + +#define VMSTATE_VIRTIO_DEVICE \ + { \ + .name = "virtio", \ + .info = &virtio_vmstate_info, \ + .flags = VMS_SINGLE, \ + } + +#else +/* TODO remove conditional as soon as all users are converted */ +#define VMSTATE_VIRTIO_DEVICE (devname, v, getf, putf) \ static const VMStateDescription vmstate_virtio_ ## devname = { \ .name = "virtio-" #devname , \
@@ -198,6 +212,8 @@ void virtio_vmstate_save(QEMUFile *f, void *opaque, size_t size); } \ } +#endif +int virtio_load (VirtIODevice *vdev,QEMUFile *f,int version_id);void virtio_notify_config (VirtIODevice *vdev);
hw/virtio/virtio.c +21 -0
@@ -1645,6 +1645,27 @@ void virtio_vmstate_save(QEMUFile *f, void *opaque, size_t size)virtio_save (VIRTIO_DEVICE (opaque), f); } +/* A wrapper for use as a VMState .put function */ +static void virtio_device_put (QEMUFile *f,void *opaque,size_t size) +{ +virtio_save (VIRTIO_DEVICE (opaque), f); +} + +/* A wrapper for use as a VMState .get function */ +static int virtio_device_get (QEMUFile *f,void *opaque,size_t size) +{ +VirtIODevice *vdev =VIRTIO_DEVICE (opaque); +DeviceClass *dc =DEVICE_CLASS (VIRTIO_DEVICE_GET_CLASS (vdev)); + +return virtio_load (vdev, f, dc->vmsd->version_id); +} + +const VMStateInfo virtio_vmstate_info = { + .name ="virtio" , + .get = virtio_device_get, + .put = virtio_device_put, +}; +static int virtio_set_features_nocheck (VirtIODevice *vdev,uint64_t val) {VirtioDeviceClass *k =VIRTIO_DEVICE_GET_CLASS (vdev);
Signature · 1 line
MST
[Qemu-devel] [PULL 22/33] virtio-blk: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/block/virtio-blk.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-)
hw/block/virtio-blk.c +11 -16
@@ -11,6 +11,8 @@* */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h"
@@ -822,13 +824,6 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) } } -static void virtio_blk_save (QEMUFile *f,void *opaque,size_t size) -{ -VirtIODevice *vdev =VIRTIO_DEVICE (opaque); - -virtio_save (vdev, f); -} -static void virtio_blk_save_device (VirtIODevice *vdev,QEMUFile *f) {VirtIOBlock *s =VIRTIO_BLK (vdev);
@@ -847,14 +842,6 @@ static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)qemu_put_sbyte (f,0 ); } -static int virtio_blk_load (QEMUFile *f,void *opaque,size_t size) -{ -VirtIOBlock *s = opaque; -VirtIODevice *vdev =VIRTIO_DEVICE (s); - -return virtio_load (vdev, f,2 ); -} -static int virtio_blk_load_device (VirtIODevice *vdev,QEMUFile *f,int version_id) {
@@ -975,7 +962,15 @@ static void virtio_blk_instance_init(Object *obj) DEVICE(obj), NULL); } -VMSTATE_VIRTIO_DEVICE (blk,2 , virtio_blk_load, virtio_blk_save); +static const VMStateDescription vmstate_virtio_blk = { + .name ="virtio-blk" , + .minimum_version_id =2 , + .version_id =2 , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, +};static Property virtio_blk_properties[] = {DEFINE_BLOCK_PROPERTIES (VirtIOBlock, conf.conf),
Signature · 1 line
MST
[Qemu-devel] [PULL 26/33] virtio-gpu: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro. The device virtio-gpu is special because it actually does not adhere to the virtio migration schema, because device state is last.
--- hw/display/virtio-gpu.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-)
hw/display/virtio-gpu.c +29 -12
@@ -11,6 +11,8 @@* See the COPYING file in the top-level directory. */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/iov.h"
@@ -990,12 +992,9 @@ static const VMStateDescription vmstate_virtio_gpu_scanouts = {static void virtio_gpu_save (QEMUFile *f,void *opaque,size_t size) {VirtIOGPU *g = opaque; -VirtIODevice *vdev =VIRTIO_DEVICE (g);struct virtio_gpu_simple_resource *res;int i; -virtio_save (vdev, f); -/* in 2d mode we should never find unprocessed commands here */ assert (QTAILQ_EMPTY (&g->cmdq));
@@ -1020,16 +1019,10 @@ static void virtio_gpu_save(QEMUFile *f, void *opaque, size_t size)static int virtio_gpu_load (QEMUFile *f,void *opaque,size_t size) {VirtIOGPU *g = opaque; -VirtIODevice *vdev =VIRTIO_DEVICE (g);struct virtio_gpu_simple_resource *res;struct virtio_gpu_scanout *scanout;uint32_t resource_id, pformat; -int i, ret; - - ret =virtio_load (vdev, f,VIRTIO_GPU_VM_VERSION ); -if (ret) { -return ret; - } +int i; resource_id =qemu_get_be32 (f);while (resource_id !=0 ) {
@@ -1219,8 +1212,32 @@ static void virtio_gpu_reset(VirtIODevice *vdev)#endif } -VMSTATE_VIRTIO_DEVICE (gpu,VIRTIO_GPU_VM_VERSION , virtio_gpu_load, - virtio_gpu_save); +/* +* For historical reasons virtio_gpu does not adhere to virtio migration +* scheme as described in doc/virtio-migration.txt, in a sense that no +* save/load callback are provided to the core. Instead the device data +* is saved/loaded after the core data. +* +* Because of this we need a special vmsd. +*/ +static const VMStateDescription vmstate_virtio_gpu = { + .name ="virtio-gpu" , + .minimum_version_id =VIRTIO_GPU_VM_VERSION , + .version_id =VIRTIO_GPU_VM_VERSION , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE /* core */ , + { + .name ="virtio-gpu" , + .info = &(const VMStateInfo ) { + .name ="virtio-gpu" , + .get = virtio_gpu_load, + .put = virtio_gpu_save, + }, + .flags =VMS_SINGLE , + }/* device */ , +VMSTATE_END_OF_LIST () + }, +};static Property virtio_gpu_properties[] = {DEFINE_PROP_UINT32 ("max_outputs" , VirtIOGPU, conf.max_outputs,1 ),
Signature · 1 line
MST
[Qemu-devel] [PULL 29/33] virtio-balloon: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/virtio/virtio-balloon.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
hw/virtio/virtio-balloon.c +11 -6
@@ -13,6 +13,8 @@* */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qemu/iov.h" #include "qemu/timer.h"
@@ -402,11 +404,6 @@ static void virtio_balloon_save_device(VirtIODevice *vdev, QEMUFile *f)qemu_put_be32 (f, s->actual); } -static int virtio_balloon_load (QEMUFile *f,void *opaque,size_t size) -{ -return virtio_load (VIRTIO_DEVICE (opaque), f,1 ); -} -static int virtio_balloon_load_device (VirtIODevice *vdev,QEMUFile *f,int version_id) {
@@ -492,7 +489,15 @@ static void virtio_balloon_instance_init(Object *obj) NULL, s, NULL); } -VMSTATE_VIRTIO_DEVICE (balloon,1 , virtio_balloon_load, virtio_vmstate_save); +static const VMStateDescription vmstate_virtio_balloon = { + .name ="virtio-balloon" , + .minimum_version_id =1 , + .version_id =1 , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, +};static Property virtio_balloon_properties[] = { DEFINE_PROP_BIT("deflate-on-oom", VirtIOBalloon, host_features,
Signature · 1 line
MST
[Qemu-devel] [PULL 30/33] virtio-rng: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/virtio/virtio-rng.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
hw/virtio/virtio-rng.c +13 -8
@@ -9,6 +9,8 @@* top-level directory. */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/iov.h"
@@ -120,15 +122,9 @@ static uint64_t get_features(VirtIODevice *vdev, uint64_t f, Error **errp)return f; } -static int virtio_rng_load (QEMUFile *f,void *opaque,size_t size) +static int virtio_rng_post_load (void *opaque,int version_id) {VirtIORNG *vrng = opaque; -int ret; - - ret =virtio_load (VIRTIO_DEVICE (vrng), f,1 ); -if (ret !=0 ) { -return ret; - }/* We may have an element ready but couldn't process it due to a quota * limit. Make sure to try again after live migration when the quota may
@@ -216,7 +212,16 @@ static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)virtio_cleanup (vdev); } -VMSTATE_VIRTIO_DEVICE (rng,1 , virtio_rng_load, virtio_vmstate_save); +static const VMStateDescription vmstate_virtio_rng = { + .name ="virtio-rng" , + .minimum_version_id =1 , + .version_id =1 , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, + .post_load = virtio_rng_post_load, +};static Property virtio_rng_properties[] = {/* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s. If
Signature · 1 line
MST
[Qemu-devel] [PULL 12/33] virtio-blk: make some functions static
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
Some functions that were called from the dataplane code are now only used locally:
virtio_blk_init_request()virtio_blk_handle_request()virtio_blk_submit_multireq()
since commit "03de2f527499 virtio-blk: do not use vring in dataplane", and
virtio_blk_free_request()
since commit "6aa46d8ff1ee virtio: move VirtQueueElement at the beginning of the structs".
This patch converts them to static.
--- include/hw/virtio/virtio-blk.h | 8 -------- hw/block/virtio-blk.c | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-)
include/hw/virtio/virtio-blk.h +0 -8
@@ -80,14 +80,6 @@ typedef struct MultiReqBuffer { bool is_write; } MultiReqBuffer; -void virtio_blk_init_request (VirtIOBlock *s,VirtQueue *vq, -VirtIOBlockReq *req); -void virtio_blk_free_request (VirtIOBlockReq *req); - -void virtio_blk_handle_request (VirtIOBlockReq *req,MultiReqBuffer *mrb); - -void virtio_blk_submit_multireq (BlockBackend *blk,MultiReqBuffer *mrb); -void virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq);#endif
hw/block/virtio-blk.c +5 -5
@@ -29,8 +29,8 @@#include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" -void virtio_blk_init_request (VirtIOBlock *s,VirtQueue *vq, -VirtIOBlockReq *req) +static void virtio_blk_init_request (VirtIOBlock *s,VirtQueue *vq, +VirtIOBlockReq *req) { req->dev = s; req->vq = vq;
@@ -40,7 +40,7 @@ void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, req->mr_next =NULL ; } -void virtio_blk_free_request (VirtIOBlockReq *req) +static void virtio_blk_free_request (VirtIOBlockReq *req) {if (req) {g_free (req);
@@ -381,7 +381,7 @@ static int multireq_compare(const void *a, const void *b) } } -void virtio_blk_submit_multireq (BlockBackend *blk,MultiReqBuffer *mrb) +static void virtio_blk_submit_multireq (BlockBackend *blk,MultiReqBuffer *mrb) {int i =0 , start =0 , num_reqs =0 , niov =0 , nb_sectors =0 ;uint32_t max_transfer;
@@ -468,7 +468,7 @@ static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,return true; } -void virtio_blk_handle_request (VirtIOBlockReq *req,MultiReqBuffer *mrb) +static void virtio_blk_handle_request (VirtIOBlockReq *req,MultiReqBuffer *mrb) {uint32_t type;struct iovec *in_iov = req->elem.in_sg;
Signature · 1 line
MST
[Qemu-devel] [PULL 14/33] virtio-blk: handle virtio_blk_handle_request() errors
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
All these errors are caused by a buggy guest: QEMU should not exit.
With this patch, if virtio_blk_handle_request() detects a buggy request, it marks the device as broken and returns an error to the caller so it takes appropriate action.
In the case of virtio_blk_handle_vq(), we detach the request from the virtqueue, free its allocated memory and stop popping new requests. We don't need to bother about multireq since virtio_blk_handle_request() errors out early and mrb.num_reqs == 0.
In the case of virtio_blk_dma_restart_bh(), we need to detach and free all queued requests as well.
--- hw/block/virtio-blk.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-)
hw/block/virtio-blk.c +28 -10
@@ -468,30 +468,32 @@ static bool virtio_blk_sect_range_ok(VirtIOBlock *dev,return true; } -static void virtio_blk_handle_request (VirtIOBlockReq *req,MultiReqBuffer *mrb) +static int virtio_blk_handle_request (VirtIOBlockReq *req,MultiReqBuffer *mrb) {uint32_t type;struct iovec *in_iov = req->elem.in_sg;struct iovec *iov = req->elem.out_sg;unsigned in_num = req->elem.in_num;unsigned out_num = req->elem.out_num; +VirtIOBlock *s = req->dev; +VirtIODevice *vdev =VIRTIO_DEVICE (s);if (req->elem.out_num <1 || req->elem.in_num <1 ) { -error_report ("virtio-blk missing headers" ); -exit (1 ); +virtio_error (vdev,"virtio-blk missing headers" ); +return -1 ; }if (unlikely (iov_to_buf (iov, out_num,0 , &req->out,sizeof (req->out)) !=sizeof (req->out))) { -error_report ("virtio-blk request outhdr too short" ); -exit (1 ); +virtio_error (vdev,"virtio-blk request outhdr too short" ); +return -1 ; }iov_discard_front (&iov, &out_num,sizeof (req->out));if (in_iov[in_num -1 ].iov_len <sizeof (struct virtio_blk_inhdr )) { -error_report ("virtio-blk request inhdr too short" ); -exit (1 ); +virtio_error (vdev,"virtio-blk request inhdr too short" ); +return -1 ; }/* We always touch the last byte, so just see how big in_iov is. */
@@ -529,7 +531,7 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)block_acct_invalid (blk_get_stats (req->dev->blk), is_write ?BLOCK_ACCT_WRITE :BLOCK_ACCT_READ );virtio_blk_free_request (req); -return ; +return 0 ; } block_acct_start(blk_get_stats(req->dev->blk),
@@ -576,6 +578,7 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)virtio_blk_req_complete (req,VIRTIO_BLK_S_UNSUPP );virtio_blk_free_request (req); } +return 0 ; }void virtio_blk_handle_vq (VirtIOBlock *s,VirtQueue *vq)
@@ -586,7 +589,11 @@ void virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq)blk_io_plug (s->blk);while ((req =virtio_blk_get_request (s, vq))) { -virtio_blk_handle_request (req, &mrb); +if (virtio_blk_handle_request (req, &mrb)) { +virtqueue_detach_element (req->vq, &req->elem,0 ); +virtio_blk_free_request (req); +break ; + } }if (mrb.num_reqs) {
@@ -625,7 +632,18 @@ static void virtio_blk_dma_restart_bh(void *opaque)while (req) {VirtIOBlockReq *next = req->next; -virtio_blk_handle_request (req, &mrb); +if (virtio_blk_handle_request (req, &mrb)) { +/* Device is now broken and won't do any processing until it gets +* reset. Already queued requests will be lost: let's purge them. +*/ +while (req) { + next = req->next; +virtqueue_detach_element (req->vq, &req->elem,0 ); +virtio_blk_free_request (req); + req = next; + } +break ; + } req = next; }
Signature · 1 line
MST
[Qemu-devel] [PULL 31/33] vhost-vsock: convert VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Use the new VMSTATE_VIRTIO_DEVICE macro.
--- hw/virtio/vhost-vsock.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
hw/virtio/vhost-vsock.c +23 -21
@@ -11,6 +11,8 @@* top-level directory. */ +#define VMSTATE_VIRTIO_DEVICE_USE_NEW +#include <sys/ioctl.h> #include "qemu/osdep.h" #include "standard-headers/linux/virtio_vsock.h"
@@ -236,17 +238,6 @@ out:g_free (elem); } -static void vhost_vsock_save (QEMUFile *f,void *opaque,size_t size) -{ -VHostVSock *vsock = opaque; -VirtIODevice *vdev =VIRTIO_DEVICE (vsock); - -/* At this point, backend must be stopped, otherwise -* it might keep writing to memory. */ -assert (!vsock->vhost_dev.started); -virtio_save (vdev, f); -} -static void vhost_vsock_post_load_timer_cleanup (VHostVSock *vsock) {if (!vsock->post_load_timer) {
@@ -266,16 +257,19 @@ static void vhost_vsock_post_load_timer_cb(void *opaque)vhost_vsock_send_transport_reset (vsock); } -static int vhost_vsock_load (QEMUFile *f,void *opaque,size_t size) +static void vhost_vsock_pre_save (void *opaque) {VHostVSock *vsock = opaque; -VirtIODevice *vdev =VIRTIO_DEVICE (vsock); -int ret; - ret =virtio_load (vdev, f,VHOST_VSOCK_SAVEVM_VERSION ); -if (ret) { -return ret; - } +/* At this point, backend must be stopped, otherwise +* it might keep writing to memory. */ +assert (!vsock->vhost_dev.started); +} + +static int vhost_vsock_post_load (void *opaque,int version_id) +{ +VHostVSock *vsock = opaque; +VirtIODevice *vdev =VIRTIO_DEVICE (vsock);if (virtio_queue_get_addr (vdev,2 )) {/* Defer transport reset event to a vm clock timer so that virtqueue
@@ -288,12 +282,20 @@ static int vhost_vsock_load(QEMUFile *f, void *opaque, size_t size) vsock);timer_mod (vsock->post_load_timer,1 ); } -return 0 ; } -VMSTATE_VIRTIO_DEVICE (vhost_vsock,VHOST_VSOCK_SAVEVM_VERSION , - vhost_vsock_load, vhost_vsock_save); +static const VMStateDescription vmstate_virtio_vhost_vsock = { + .name ="virtio-vhost_vsock" , + .minimum_version_id =VHOST_VSOCK_SAVEVM_VERSION , + .version_id =VHOST_VSOCK_SAVEVM_VERSION , + .fields = (VMStateField []) { +VMSTATE_VIRTIO_DEVICE , +VMSTATE_END_OF_LIST () + }, + .pre_save = vhost_vsock_pre_save, + .post_load = vhost_vsock_post_load, +};static void vhost_vsock_device_realize (DeviceState *dev,Error **errp) {
Signature · 1 line
MST
[Qemu-devel] [PULL 33/33] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE
In reply to Michael S. TsirkinFrom: Feng Wu <[email protected]>
The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.
--- hw/i386/intel_iommu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
hw/i386/intel_iommu.c +12 -0
@@ -27,6 +27,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" #include "hw/i386/pc.h" +#include "hw/i386/apic-msidef.h" #include "hw/boards.h" #include "hw/i386/x86-iommu.h" #include "hw/pci-host/q35.h"
@@ -2209,6 +2210,8 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu, } }else {uint8_t vector = origin->data &0xff ; +uint8_t trigger_mode = (origin->data >>MSI_DATA_TRIGGER_SHIFT ) &0x1 ; +VTD_DPRINTF (IR ,"received IOAPIC interrupt" );/* IOAPIC entry vector should be aligned with IRTE vector * (see vt-d spec 5.1.5.1). */
@@ -2217,6 +2220,15 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,"entry: %d, IRTE: %d, index: %d" , vector, irq.vector, index); } + +/* The Trigger Mode field must match the Trigger Mode in the IRTE. +* (see vt-d spec 5.1.5.1). */ +if (trigger_mode != irq.trigger_mode) { +VTD_DPRINTF (GENERAL ,"IOAPIC trigger mode inconsistent: " +"entry: %u, IRTE: %u, index: %d" , + trigger_mode, irq.trigger_mode, index); + } + }/*
Signature · 1 line
MST
[Qemu-devel] [PULL 32/33] virtio: cleanup VMSTATE_VIRTIO_DEVICE
In reply to Michael S. TsirkinFrom: Halil Pasic <[email protected]>
Now all the usages of the old version of VMSTATE_VIRTIO_DEVICE are gone, so we can get rid of the conditionals, and the old macro.
--- include/hw/virtio/virtio.h | 27 --------------------------- hw/9pfs/virtio-9p-device.c | 2 -- hw/block/virtio-blk.c | 2 -- hw/char/virtio-serial-bus.c | 2 -- hw/display/virtio-gpu.c | 2 -- hw/input/virtio-input.c | 2 -- hw/net/virtio-net.c | 2 -- hw/scsi/virtio-scsi.c | 2 -- hw/virtio/vhost-vsock.c | 2 -- hw/virtio/virtio-balloon.c | 2 -- hw/virtio/virtio-rng.c | 2 -- hw/virtio/virtio.c | 6 ------ 12 files changed, 53 deletions(-)
include/hw/virtio/virtio.h +0 -27
@@ -177,12 +177,9 @@ bool virtio_should_notify(VirtIODevice *vdev, VirtQueue *vq);void virtio_notify (VirtIODevice *vdev,VirtQueue *vq);void virtio_save (VirtIODevice *vdev,QEMUFile *f); -void virtio_vmstate_save (QEMUFile *f,void *opaque,size_t size);extern const VMStateInfo virtio_vmstate_info; -#ifdef VMSTATE_VIRTIO_DEVICE_USE_NEW -#define VMSTATE_VIRTIO_DEVICE \ { \ .name = "virtio", \
@@ -190,30 +187,6 @@ extern const VMStateInfo virtio_vmstate_info; .flags = VMS_SINGLE, \ } -#else -/* TODO remove conditional as soon as all users are converted */ - -#define VMSTATE_VIRTIO_DEVICE (devname, v, getf, putf) \ - static const VMStateDescription vmstate_virtio_ ## devname = { \ - .name = "virtio-" #devname , \ - .minimum_version_id = v, \ - .version_id = v, \ - .fields = (VMStateField[]) { \ - { \ - .name = "virtio", \ - .info = &(const VMStateInfo) {\ - .name = "virtio", \ - .get = getf, \ - .put = putf, \ - }, \ - .flags = VMS_SINGLE, \ - }, \ - VMSTATE_END_OF_LIST() \ - } \ - } - -#endif -int virtio_load (VirtIODevice *vdev,QEMUFile *f,int version_id);void virtio_notify_config (VirtIODevice *vdev);
hw/9pfs/virtio-9p-device.c +0 -2
@@ -11,8 +11,6 @@* */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "hw/virtio/virtio.h" #include "qemu/sockets.h"
hw/block/virtio-blk.c +0 -2
@@ -11,8 +11,6 @@* */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h"
hw/char/virtio-serial-bus.c +0 -2
@@ -18,8 +18,6 @@* GNU GPL, version 2 or (at your option) any later version. */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/iov.h"
hw/display/virtio-gpu.c +0 -2
@@ -11,8 +11,6 @@* See the COPYING file in the top-level directory. */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/iov.h"
hw/input/virtio-input.c +0 -2
@@ -4,8 +4,6 @@* top-level directory. */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/iov.h"
hw/net/virtio-net.c +0 -2
@@ -11,8 +11,6 @@* */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qemu/iov.h" #include "hw/virtio/virtio.h"
hw/scsi/virtio-scsi.c +0 -2
@@ -13,8 +13,6 @@* */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qapi/error.h" #include "standard-headers/linux/virtio_ids.h"
hw/virtio/vhost-vsock.c +0 -2
@@ -11,8 +11,6 @@* top-level directory. */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include <sys/ioctl.h> #include "qemu/osdep.h" #include "standard-headers/linux/virtio_vsock.h"
hw/virtio/virtio-balloon.c +0 -2
@@ -13,8 +13,6 @@* */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qemu/iov.h" #include "qemu/timer.h"
hw/virtio/virtio-rng.c +0 -2
@@ -9,8 +9,6 @@* top-level directory. */ -#define VMSTATE_VIRTIO_DEVICE_USE_NEW -#include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/iov.h"
hw/virtio/virtio.c +0 -6
@@ -1640,12 +1640,6 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) }/* A wrapper for use as a VMState .put function */ -void virtio_vmstate_save (QEMUFile *f,void *opaque,size_t size) -{ -virtio_save (VIRTIO_DEVICE (opaque), f); -} - -/* A wrapper for use as a VMState .put function */ static void virtio_device_put (QEMUFile *f,void *opaque,size_t size) {virtio_save (VIRTIO_DEVICE (opaque), f);
Signature · 1 line
MST
Quoted 12 lines · Michael S. Tsirkin
The following changes since commit
48f592118ab42f83a1a7561c4bfd2b72a100f241:bsd-user: fix FreeBSD build after
d148d90e(2016-10-07 15:17:53 +0100)are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
dea651a95af6dad0997b840241a0bf6059d9a776:intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE (2016-10-10 02:38:14 +0300)
Quoted 8 lines
----------------------------------------------------------------
virtio, pc: fixes and featuresmore guest error handling for virtio devices
virtio migration rework
pc fixesSigned-off-by Michael S. Tsirkin <[email protected]>
This failed 'make check' on aarch64 host (everything else was ok):
TEST: tests/pxe-test... (pid=11699)
/ppc64/pxe/virtio: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020 == 0x0000dead)
FAIL
GTester: last random seed: R02S87a02de849c98998299177b1a4c7a31b (pid=19477)
/ppc64/pxe/spapr-vlan: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020 == 0x0000dead)
FAIL
GTester: last random seed: R02Sf9cf55ad239a137dd20d3085abf91524 (pid=24055)
FAIL: tests/pxe-test
thanks
-- PMM
Quoted 24 lines · Peter Maydell
Quoted 12 lines · Michael S. Tsirkin
The following changes since commit
48f592118ab42f83a1a7561c4bfd2b72a100f241:bsd-user: fix FreeBSD build after
d148d90e(2016-10-07 15:17:53 +0100)are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
dea651a95af6dad0997b840241a0bf6059d9a776:intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE (2016-10-10 02:38:14 +0300)
Quoted 8 lines
----------------------------------------------------------------
virtio, pc: fixes and featuresmore guest error handling for virtio devices
virtio migration rework
pc fixesSigned-off-by Michael S. Tsirkin <[email protected]>This failed 'make check' on aarch64 host (everything else was ok):
Quoted 16 lines
TEST: tests/pxe-test... (pid=11699)
/ppc64/pxe/virtio: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02S87a02de849c98998299177b1a4c7a31b (pid=19477)
/ppc64/pxe/spapr-vlan: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02Sf9cf55ad239a137dd20d3085abf91524 (pid=24055)
FAIL: tests/pxe-test
Several subsequent test runs passed, so I'm inclined to suspect this is not related to the pull request but is actually an over-enthusiastic timeout and the build machine was heavily loaded or something.
Anyway, I've pushed the merge to master.
thanks
-- PMM
Quoted 47 lines · Peter Maydell
Quoted 24 lines · Peter Maydell
Quoted 12 lines · Michael S. Tsirkin
The following changes since commit
48f592118ab42f83a1a7561c4bfd2b72a100f241:bsd-user: fix FreeBSD build after
d148d90e(2016-10-07 15:17:53 +0100)are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
dea651a95af6dad0997b840241a0bf6059d9a776:intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE (2016-10-10 02:38:14 +0300)
Quoted 8 lines
----------------------------------------------------------------
virtio, pc: fixes and featuresmore guest error handling for virtio devices
virtio migration rework
pc fixesSigned-off-by Michael S. Tsirkin <[email protected]>This failed 'make check' on aarch64 host (everything else was ok):
Quoted 16 lines
TEST: tests/pxe-test... (pid=11699)
/ppc64/pxe/virtio: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02S87a02de849c98998299177b1a4c7a31b (pid=19477)
/ppc64/pxe/spapr-vlan: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02Sf9cf55ad239a137dd20d3085abf91524 (pid=24055)
FAIL: tests/pxe-testSeveral subsequent test runs passed, so I'm inclined to suspect this is not related to the pull request but is actually an over-enthusiastic timeout and the build machine was heavily loaded or something.
Quoted 4 lines
Anyway, I've pushed the merge to master.
thanks
-- PMM
Could be. I think we should have code to detect this though. How about using e.g. time to report elapsed system and user time?
Signature · 1 line
MST
Dear Peter,
Quoted 20 lines · Peter Maydell
Quoted 18 lines · Peter Maydell
This failed 'make check' on aarch64 host (everything else was ok):
TEST: tests/pxe-test... (pid=11699)
/ppc64/pxe/virtio: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02S87a02de849c98998299177b1a4c7a31b (pid=19477)
/ppc64/pxe/spapr-vlan: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02Sf9cf55ad239a137dd20d3085abf91524 (pid=24055)
FAIL: tests/pxe-test
Quoted 4 lines
Several subsequent test runs passed, so I'm inclined to suspect this is not related to the pull request but is actually an over-enthusiastic timeout and the build machine was heavily loaded or something.
There's a race condition in the tests. Both the "i386" and the "x86_64" set of tests are creating and removing the same set of files:
tests/acpi-test-disk.raw (hard-coded in tests/bios-tables-test.c) and tests/pxe-test-disk.raw (hard-coded in tests/pxe-test.c).
FWIW, it's not obvious at first sight that the tests added to check-qtest-i386-y will also be included in check-qtest-x86_64-y. The line responsible for that is hiding in the midst of other assignments, without even a blank line separating it from the rest.
Assigning to a common variable first and then including it in both check-qtest-i386-y and check-qtest-x86_64-y would make it a lot easier to understand IMO.
Sascha
Signature · 3 lines
Softwareentwicklung Sascha Silbe, Niederhofenstraße 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr.: DE281696641
Quoted 4 lines · Sascha Silbe
There's a race condition in the tests. Both the "i386" and the "
x86_64" set of tests are creating and removing the same set of files:
tests/acpi-test-disk.raw (hard-coded intests/bios-tables-test.c) and tests/pxe-test-disk.raw (hard-coded intests/pxe-test.c).
Ooh, thanks for tracking that down. I was really not looking forward to trying to figure out why this wasn't passing...
-- PMM
Quoted 29 lines · Sascha Silbe
Dear Peter,
Quoted 20 lines · Peter Maydell
Quoted 18 lines · Peter Maydell
This failed 'make check' on aarch64 host (everything else was ok):
TEST: tests/pxe-test... (pid=11699)
/ppc64/pxe/virtio: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02S87a02de849c98998299177b1a4c7a31b (pid=19477)
/ppc64/pxe/spapr-vlan: **
ERROR:/home/petmay01/qemu/tests/boot-sector.c:120:boot_sector_test:
assertion failed (signature == SIGN
ATURE): (0x00002020==0x0000dead)
FAIL
GTester: last random seed: R02Sf9cf55ad239a137dd20d3085abf91524 (pid=24055)
FAIL: tests/pxe-testQuoted 4 lines
Several subsequent test runs passed, so I'm inclined to suspect this is not related to the pull request but is actually an over-enthusiastic timeout and the build machine was heavily loaded or something.
Quoted 4 lines
There's a race condition in the tests. Both the "i386" and the "
x86_64" set of tests are creating and removing the same set of files:
tests/acpi-test-disk.raw (hard-coded intests/bios-tables-test.c) and tests/pxe-test-disk.raw (hard-coded intests/pxe-test.c).
Hmm, it's likely even worse - the new ppc64 test is using the same file name, too - with different content in the file. So if the tests are running in parallel, they will likely disturb each other.
I think we should use mkstemp() instead for creating a unique file. Is anybody working on a patch already? If not, I could have a look...
Quoted 8 lines
FWIW, it's not obvious at first sight that the tests added to check-qtest-i386-y will also be included in check-qtest-x86_64-y. The line responsible for that is hiding in the midst of other assignments, without even a blank line separating it from the rest.
Assigning to a common variable first and then including it in both check-qtest-i386-y and check-qtest-x86_64-y would make it a lot easier to understand IMO.
Could you maybe provide a patch for this, Sascha? (at least for adding some blank lines inbetween - currently it is really hard to read)
Thomas
Dear Thomas,
Quoted 1 line · Thomas Huth
On 11.10.2016 10:27, Sascha Silbe wrote:
[pxe-test failing during "make check"]
Quoted 8 lines
Quoted 4 lines
There's a race condition in the tests. Both the "i386" and the "
x86_64" set of tests are creating and removing the same set of files:
tests/acpi-test-disk.raw (hard-coded intests/bios-tables-test.c) and tests/pxe-test-disk.raw (hard-coded intests/pxe-test.c).Hmm, it's likely even worse - the new ppc64 test is using the same file name, too - with different content in the file. So if the tests are running in parallel, they will likely disturb each other.
Ouch.
Quoted 2 lines
I think we should use
mkstemp()instead for creating a unique file. Is anybody working on a patch already? If not, I could have a look...
Feel free to go ahead. In the long run we'll probably want a more systematic approach; I've fixed several instances in the past (see 50455700, 5f1525a6, 6bb6f6cd, 0145b4e1). But that shouldn't prevent us From fixing a known issue in the meantime.
Quoted 11 lines
Quoted 8 lines
FWIW, it's not obvious at first sight that the tests added to check-qtest-i386-y will also be included in check-qtest-x86_64-y. The line responsible for that is hiding in the midst of other assignments, without even a blank line separating it from the rest.
Assigning to a common variable first and then including it in both check-qtest-i386-y and check-qtest-x86_64-y would make it a lot easier to understand IMO.
Could you maybe provide a patch for this, Sascha? (at least for adding some blank lines inbetween - currently it is really hard to read)
I'll try to whip up a patch in the next few days. Unless someone has a strong preference to stay with the current scheme, I'll implement the common variable approach I outlined above.
Sascha
Signature · 3 lines
Softwareentwicklung Sascha Silbe, Niederhofenstraße 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr.: DE281696641