ui/spice-display.c: add missing initialization for valgrind
PATCH v2 1/3 ui/spice-display.c: add missing initialization for valgrind
We can't initialize QXLDevSurfaceCreate field by field because it has a pa hole, and so 4 bytes remain uninitialized when building on x86-64, so just memset.
--- ui/spice-display.c | 2 ++ 1 file changed, 2 insertions(+)
ui/spice-display.c +2 -0
@@ -244,6 +244,8 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd) {QXLDevSurfaceCreate surface; +memset (&surface,0 ,sizeof (surface)); +dprint (1 ,"%s: %dx%d\n" , __FUNCTION__,ds_get_width (ssd->ds),ds_get_height (ssd->ds));
Signature · 1 line
1.7.10.1
PATCH v2 2/3 hw/qxl: s/qxl_guest_bug/qxl_set_guest_bug/
--- hw/qxl.c | 49 +++++++++++++++++++++++++++---------------------- hw/qxl.h | 3 ++- 2 files changed, 29 insertions(+), 23 deletions(-)
hw/qxl.c +27 -22
@@ -30,7 +30,7 @@/* * NOTE: SPICE_RING_PROD_ITEM accesses memory on the pci bar and as * such can be changed by the guest, so to avoid a guest trigerrable -* abort we just set qxl_guest_bug and set the return to NULL. Still +* abort we just qxl_set_guest_bug and set the return to NULL. Still * it may happen as a result of emulator bug as well. */ #undef SPICE_RING_PROD_ITEM
@@ -40,7 +40,7 @@uint32_t prod = (r)->prod &SPICE_RING_INDEX_MASK (r); \ typeof(&(r)->items[prod]) m_item = &(r)->items[prod]; \if (!((uint8_t *)m_item >= (uint8_t *)(start ) && (uint8_t *)(m_item +1 ) <= (uint8_t *)(end))) { \ -qxl_guest_bug (qxl,"SPICE_RING_PROD_ITEM indices mismatch " \ +qxl_set_guest_bug (qxl,"SPICE_RING_PROD_ITEM indices mismatch " \"! %p <= %p < %p" , (uint8_t *)start, \ (uint8_t *)m_item, (uint8_t *)end); \ ret =NULL ; \
@@ -56,7 +56,7 @@uint32_t cons = (r)->cons &SPICE_RING_INDEX_MASK (r); \ typeof(&(r)->items[cons]) m_item = &(r)->items[cons]; \if (!((uint8_t *)m_item >= (uint8_t *)(start ) && (uint8_t *)(m_item +1 ) <= (uint8_t *)(end))) { \ -qxl_guest_bug (qxl,"SPICE_RING_CONS_ITEM indices mismatch " \ +qxl_set_guest_bug (qxl,"SPICE_RING_CONS_ITEM indices mismatch " \"! %p <= %p < %p" , (uint8_t *)start, \ (uint8_t *)m_item, (uint8_t *)end); \ ret =NULL ; \
@@ -138,7 +138,7 @@ static void qxl_reset_memslots(PCIQXLDevice *d);static void qxl_reset_surfaces (PCIQXLDevice *d);static void qxl_ring_set_dirty (PCIQXLDevice *qxl); -void qxl_guest_bug (PCIQXLDevice *qxl,const char *msg, ...) +void qxl_set_guest_bug (PCIQXLDevice *qxl,const char *msg, ...) {qxl_send_events (qxl,QXL_INTERRUPT_ERROR ); qxl->guest_bug =1 ;
@@ -412,7 +412,8 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)uint32_t id =le32_to_cpu (cmd->surface_id);if (id >=NUM_SURFACES ) { -qxl_guest_bug (qxl,"QXL_CMD_SURFACE id %d >= %d" , id,NUM_SURFACES ); +qxl_set_guest_bug (qxl,"QXL_CMD_SURFACE id %d >= %d" , id, +NUM_SURFACES );return 1 ; }qemu_mutex_lock (&qxl->track_lock);
@@ -1062,12 +1063,12 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,trace_qxl_memslot_add_guest (d->id, slot_id, guest_start, guest_end);if (slot_id >=NUM_MEMSLOTS ) { -qxl_guest_bug (d,"%s: slot_id >= NUM_MEMSLOTS %d >= %d" , __func__, +qxl_set_guest_bug (d,"%s: slot_id >= NUM_MEMSLOTS %d >= %d" , __func__, slot_id,NUM_MEMSLOTS );return 1 ; }if (guest_start > guest_end) { -qxl_guest_bug (d,"%s: guest_start > guest_end 0x%" PRIx64 +qxl_set_guest_bug (d,"%s: guest_start > guest_end 0x%" PRIx64" > 0x%" PRIx64, __func__, guest_start, guest_end);return 1 ; }
@@ -1092,7 +1093,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,break ; }if (i ==ARRAY_SIZE (regions)) { -qxl_guest_bug (d,"%s: finished loop without match" , __func__); +qxl_set_guest_bug (d,"%s: finished loop without match" , __func__);return 1 ; }
@@ -1106,7 +1107,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,break ;default :/* should not happen */ -qxl_guest_bug (d,"%s: pci_region = %d" , __func__, pci_region); +qxl_set_guest_bug (d,"%s: pci_region = %d" , __func__, pci_region);return 1 ; }
@@ -1157,21 +1158,24 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)return (void *)(intptr_t )offset;case MEMSLOT_GROUP_GUEST :if (slot >=NUM_MEMSLOTS ) { -qxl_guest_bug (qxl,"slot too large %d >= %d" , slot,NUM_MEMSLOTS ); +qxl_set_guest_bug (qxl,"slot too large %d >= %d" , slot, +NUM_MEMSLOTS );return NULL ; }if (!qxl->guest_slots[slot].active) { -qxl_guest_bug (qxl,"inactive slot %d\n" , slot); +qxl_set_guest_bug (qxl,"inactive slot %d\n" , slot);return NULL ; }if (offset < qxl->guest_slots[slot].delta) { -qxl_guest_bug (qxl,"slot %d offset %" PRIu64" < delta %" PRIu64"\n" , +qxl_set_guest_bug (qxl, +"slot %d offset %" PRIu64" < delta %" PRIu64"\n" , slot, offset, qxl->guest_slots[slot].delta);return NULL ; } offset -= qxl->guest_slots[slot].delta;if (offset > qxl->guest_slots[slot].size) { -qxl_guest_bug (qxl,"slot %d offset %" PRIu64" > size %" PRIu64"\n" , +qxl_set_guest_bug (qxl, +"slot %d offset %" PRIu64" > size %" PRIu64"\n" , slot, offset, qxl->guest_slots[slot].size);return NULL ; }
@@ -1193,7 +1197,7 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,QXLSurfaceCreate *sc = &qxl->guest_primary.surface;if (qxl->mode ==QXL_MODE_NATIVE ) { -qxl_guest_bug (qxl,"%s: nop since already in QXL_MODE_NATIVE" , +qxl_set_guest_bug (qxl,"%s: nop since already in QXL_MODE_NATIVE" , __func__); }qxl_exit_vga_mode (qxl);
@@ -1347,7 +1351,7 @@ async_common: async =QXL_ASYNC ;qemu_mutex_lock (&d->async_lock);if (d->current_async !=QXL_UNDEFINED_IO ) { -qxl_guest_bug (d,"%d async started before last (%d) complete" , +qxl_set_guest_bug (d,"%d async started before last (%d) complete" , io_port, d->current_async);qemu_mutex_unlock (&d->async_lock);return ;
@@ -1409,11 +1413,12 @@ async_common:break ;case QXL_IO_MEMSLOT_ADD :if (val >=NUM_MEMSLOTS ) { -qxl_guest_bug (d,"QXL_IO_MEMSLOT_ADD: val out of range" ); +qxl_set_guest_bug (d,"QXL_IO_MEMSLOT_ADD: val out of range" );break ; }if (d->guest_slots[val].active) { -qxl_guest_bug (d,"QXL_IO_MEMSLOT_ADD: memory slot already active" ); +qxl_set_guest_bug (d, +"QXL_IO_MEMSLOT_ADD: memory slot already active" );break ; } d->guest_slots[val].slot = d->ram->mem_slot;
@@ -1421,14 +1426,14 @@ async_common:break ;case QXL_IO_MEMSLOT_DEL :if (val >=NUM_MEMSLOTS ) { -qxl_guest_bug (d,"QXL_IO_MEMSLOT_DEL: val out of range" ); +qxl_set_guest_bug (d,"QXL_IO_MEMSLOT_DEL: val out of range" );break ; }qxl_del_memslot (d, val);break ;case QXL_IO_CREATE_PRIMARY :if (val !=0 ) { -qxl_guest_bug (d,"QXL_IO_CREATE_PRIMARY (async=%d): val != 0" , +qxl_set_guest_bug (d,"QXL_IO_CREATE_PRIMARY (async=%d): val != 0" , async); goto cancel_async; }
@@ -1437,7 +1442,7 @@ async_common:break ;case QXL_IO_DESTROY_PRIMARY :if (val !=0 ) { -qxl_guest_bug (d,"QXL_IO_DESTROY_PRIMARY (async=%d): val != 0" , +qxl_set_guest_bug (d,"QXL_IO_DESTROY_PRIMARY (async=%d): val != 0" , async); goto cancel_async; }
@@ -1449,7 +1454,7 @@ async_common:break ;case QXL_IO_DESTROY_SURFACE_WAIT :if (val >=NUM_SURFACES ) { -qxl_guest_bug (d,"QXL_IO_DESTROY_SURFACE (async=%d):" +qxl_set_guest_bug (d,"QXL_IO_DESTROY_SURFACE (async=%d):" "%" PRIu64" >= NUM_SURFACES" , async, val); goto cancel_async; }
@@ -1473,7 +1478,7 @@ async_common:qxl_spice_destroy_surfaces (d, async);break ;default : -qxl_guest_bug (d,"%s: unexpected ioport=0x%x\n" , __func__, io_port); +qxl_set_guest_bug (d,"%s: unexpected ioport=0x%x\n" , __func__, io_port); }return ; cancel_async:
hw/qxl.h +2 -1
@@ -132,7 +132,8 @@ typedef struct PCIQXLDevice {/* qxl.c */ void *qxl_phys2virt (PCIQXLDevice *qxl,QXLPHYSICAL phys,int group_id); -void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...) GCC_FMT_ATTR(2, 3); +void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...) + GCC_FMT_ATTR(2, 3); void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id, struct QXLRect *area, struct QXLRect *dirty_rects,
Signature · 1 line
1.7.10.1
PATCH v2 3/3 hmp/qxl: info spice: add qxl info
In reply to Alon LevyFor all devices print id, mode and guest_bug status.
Known problems: Prints devices from highest id to lowest.
--- hmp.c | 11 +++++++++++ hw/qxl.c | 22 ++++++++++++++++++++++ qapi-schema.json | 47 +++++++++++++++++++++++++++++++++++++++++++++-- ui/qemu-spice.h | 5 +++++ ui/spice-core.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 130 insertions(+), 3 deletions(-)
hmp.c +11 -0
@@ -331,6 +331,7 @@ void hmp_info_spice(Monitor *mon) {SpiceChannelList *chan;SpiceInfo *info; +QXLInfoList *qxl; info =qmp_query_spice (NULL );
@@ -353,6 +354,16 @@ void hmp_info_spice(Monitor *mon)monitor_printf (mon," mouse-mode: %s\n" , SpiceQueryMouseMode_lookup[info->mouse_mode]); +for (qxl = info->qxl; qxl; qxl = qxl->next) { +if (qxl->value->guest_bug ==-1 || qxl->value->mode ==-1 ) { +continue ; + } +monitor_printf (mon,"qxl-%d:\n" , qxl->value->id); +monitor_printf (mon," mode: %s\n" , + SpiceQueryQXLMode_lookup[qxl->value->mode]); +monitor_printf (mon," guest_bug: %" PRIu64"\n" , qxl->value->guest_bug); + } +if (!info->has_channels || info->channels ==NULL ) {monitor_printf (mon,"Channels: none\n" ); }else {
hw/qxl.c +22 -0
@@ -1705,6 +1705,28 @@ static DisplayChangeListener display_listener = { .dpy_refresh = display_refresh, }; +/* helpers for spice_info */ +int qxl_get_guest_bug (DeviceState *dev) +{ +PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci.qdev, dev); + +return qxl->guest_bug; +} + +int qxl_get_mode (DeviceState *dev) +{ +PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci.qdev, dev); + +return qxl->mode; +} + +int qxl_get_id (DeviceState *dev) +{ +PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci.qdev, dev); + +return qxl->id; +} +static void qxl_init_ramsize (PCIQXLDevice *qxl,uint32_t ram_min_mb) {/* vga ram (bar 0) */
qapi-schema.json +45 -2
70 lines not on this page · raw message
ui/qemu-spice.h +5 -0
@@ -47,6 +47,11 @@ void do_info_spice(Monitor *mon, QObject **ret_data);CharDriverState *qemu_chr_open_spice (QemuOpts *opts); +/* implemented in hw/qxl.c */ +int qxl_get_guest_bug (DeviceState *dev); +int qxl_get_mode (DeviceState *dev); +int qxl_get_id (DeviceState *dev); +#else /* CONFIG_SPICE */ #include "monitor.h"
ui/spice-core.c +47 -1
72 lines not on this page · raw message
Signature · 1 line
1.7.10.1
Quoted 3 lines · Alon Levy
We can't initialize QXLDevSurfaceCreate field by field because it has a pa hole, and so 4 bytes remain uninitialized when building on x86-64, so just memset.
So you get valgrind warnings for the hole? why? nobody should ever access the hole, so the missing initialization should not hurt in theory ...
Quoted 18 lines
Signed-off-by Alon Levy <[email protected]>--- ui/spice-display.c | 2 ++ 1 file changed, 2 insertions(+)ui/spice-display.c +2
-0@@ -244,6 +244,8 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd) {QXLDevSurfaceCreate surface; +memset (&surface,0 ,sizeof (surface)); +dprint (1 ,"%s: %dx%d\n" , __FUNCTION__,ds_get_width (ssd->ds),ds_get_height (ssd->ds));
Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines · Alon Levy
We can't initialize QXLDevSurfaceCreate field by field because it has a pa hole, and so 4 bytes remain uninitialized when building on x86-64, so just memset.
So you get valgrind warnings for the hole? why? nobody should ever access the hole, so the missing initialization should not hurt in theory ...
Because we allocate this struct on the stack and then copy it over an fd to spice, through the dispatcher pipe.
echo quit | valgrind --log-file=/tmp/valgrind.log --leak-check=full ./x86_64-softmmu/qemu-system-x86_64 -monitor stdio -spice port=1234 -vga qxl
==2677== Syscall param write(buf) points to uninitialised byte(s)
==2677== at 0x659504D: ??? (syscall-template.S:82) ==2677== by 0x91BCD54: write_safe (dispatcher.c:103) ==2677== by 0x91BD168: dispatcher_send_message (dispatcher.c:182) ==2677== by 0x91BEC24: red_dispatcher_create_primary_surface_sync (red_dispatcher.c:489) ==2677== by 0x91BECAD: red_dispatcher_create_primary_surface (red_dispatcher.c:502) ==2677== by 0x91BED03: qxl_worker_create_primary_surface (red_dispatcher.c:509) ==2677== by 0x3403CC: qemu_spice_create_primary_surface (spice-display.c:106) ==2677== by 0x340BAB: qemu_spice_create_host_primary (spice-display.c:260) ==2677== by 0x40EC50: qxl_enter_vga_mode (qxl.c:931) ==2677== by 0x40EFCA: qxl_soft_reset (qxl.c:982) ==2677== by 0x40F088: qxl_hard_reset (qxl.c:1004) ==2677== by 0x40F0DA: qxl_reset_handler (qxl.c:1011)
==2677== Address 0x7feffef98 is on thread 1's stack
Quoted 20 lines
Quoted 19 lines
Signed-off-by Alon Levy <[email protected]>--- ui/spice-display.c | 2 ++ 1 file changed, 2 insertions(+)ui/spice-display.c +2
-0@@ -244,6 +244,8 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd) {QXLDevSurfaceCreate surface; +memset (&surface,0 ,sizeof (surface)); +dprint (1 ,"%s: %dx%d\n" , __FUNCTION__,ds_get_width (ssd->ds),ds_get_height (ssd->ds));
Quoted 11 lines · Alon Levy
Quoted 7 lines · Gerd Hoffmann
Quoted 3 lines · Alon Levy
We can't initialize QXLDevSurfaceCreate field by field because it has a pa hole, and so 4 bytes remain uninitialized when building on x86-64, so just memset.
So you get valgrind warnings for the hole? why? nobody should ever access the hole, so the missing initialization should not hurt in theory ...
Because we allocate this struct on the stack and then copy it over an fd to spice, through the dispatcher pipe.
Ah, yea, copying will make valgrind complain of course ...
I'll go queue it up.
cheers,
Gerd
Hi,
Quoted 1 line
I'll go queue it up.
Ahem, doesn't apply cleanly. Guess this is just a patch ordering issue though. Can you send all your pending qxl bits as single patch series please, so I don't have to play trial-and-error to figure the correct order?
thanks,
Gerd
PATCH 1/4 ui/spice-display.c: add missing initialization for valgrind
We can't initialize QXLDevSurfaceCreate field by field because it has a pa hole, and so 4 bytes remain uninitialized when building on x86-64, so just memset.
--- ui/spice-display.c | 2 ++ 1 file changed, 2 insertions(+)
ui/spice-display.c +2 -0
@@ -244,6 +244,8 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd) {QXLDevSurfaceCreate surface; +memset (&surface,0 ,sizeof (surface)); +dprint (1 ,"%s: %dx%d\n" , __FUNCTION__,ds_get_width (ssd->ds),ds_get_height (ssd->ds));
Signature · 1 line
1.7.10.1
PATCH 2/4 hw/qxl: s/qxl_guest_bug/qxl_set_guest_bug/
--- hw/qxl.c | 49 +++++++++++++++++++++++++++---------------------- hw/qxl.h | 3 ++- 2 files changed, 29 insertions(+), 23 deletions(-)
hw/qxl.c +27 -22
@@ -30,7 +30,7 @@/* * NOTE: SPICE_RING_PROD_ITEM accesses memory on the pci bar and as * such can be changed by the guest, so to avoid a guest trigerrable -* abort we just set qxl_guest_bug and set the return to NULL. Still +* abort we just qxl_set_guest_bug and set the return to NULL. Still * it may happen as a result of emulator bug as well. */ #undef SPICE_RING_PROD_ITEM
@@ -40,7 +40,7 @@uint32_t prod = (r)->prod &SPICE_RING_INDEX_MASK (r); \ typeof(&(r)->items[prod]) m_item = &(r)->items[prod]; \if (!((uint8_t *)m_item >= (uint8_t *)(start ) && (uint8_t *)(m_item +1 ) <= (uint8_t *)(end))) { \ -qxl_guest_bug (qxl,"SPICE_RING_PROD_ITEM indices mismatch " \ +qxl_set_guest_bug (qxl,"SPICE_RING_PROD_ITEM indices mismatch " \"! %p <= %p < %p" , (uint8_t *)start, \ (uint8_t *)m_item, (uint8_t *)end); \ ret =NULL ; \
@@ -56,7 +56,7 @@uint32_t cons = (r)->cons &SPICE_RING_INDEX_MASK (r); \ typeof(&(r)->items[cons]) m_item = &(r)->items[cons]; \if (!((uint8_t *)m_item >= (uint8_t *)(start ) && (uint8_t *)(m_item +1 ) <= (uint8_t *)(end))) { \ -qxl_guest_bug (qxl,"SPICE_RING_CONS_ITEM indices mismatch " \ +qxl_set_guest_bug (qxl,"SPICE_RING_CONS_ITEM indices mismatch " \"! %p <= %p < %p" , (uint8_t *)start, \ (uint8_t *)m_item, (uint8_t *)end); \ ret =NULL ; \
@@ -138,7 +138,7 @@ static void qxl_reset_memslots(PCIQXLDevice *d);static void qxl_reset_surfaces (PCIQXLDevice *d);static void qxl_ring_set_dirty (PCIQXLDevice *qxl); -void qxl_guest_bug (PCIQXLDevice *qxl,const char *msg, ...) +void qxl_set_guest_bug (PCIQXLDevice *qxl,const char *msg, ...) {qxl_send_events (qxl,QXL_INTERRUPT_ERROR );if (qxl->guestdebug) {
@@ -411,7 +411,8 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)uint32_t id =le32_to_cpu (cmd->surface_id);if (id >=NUM_SURFACES ) { -qxl_guest_bug (qxl,"QXL_CMD_SURFACE id %d >= %d" , id,NUM_SURFACES ); +qxl_set_guest_bug (qxl,"QXL_CMD_SURFACE id %d >= %d" , id, +NUM_SURFACES );return 1 ; }qemu_mutex_lock (&qxl->track_lock);
@@ -1061,12 +1062,12 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,trace_qxl_memslot_add_guest (d->id, slot_id, guest_start, guest_end);if (slot_id >=NUM_MEMSLOTS ) { -qxl_guest_bug (d,"%s: slot_id >= NUM_MEMSLOTS %d >= %d" , __func__, +qxl_set_guest_bug (d,"%s: slot_id >= NUM_MEMSLOTS %d >= %d" , __func__, slot_id,NUM_MEMSLOTS );return 1 ; }if (guest_start > guest_end) { -qxl_guest_bug (d,"%s: guest_start > guest_end 0x%" PRIx64 +qxl_set_guest_bug (d,"%s: guest_start > guest_end 0x%" PRIx64" > 0x%" PRIx64, __func__, guest_start, guest_end);return 1 ; }
@@ -1091,7 +1092,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,break ; }if (i ==ARRAY_SIZE (regions)) { -qxl_guest_bug (d,"%s: finished loop without match" , __func__); +qxl_set_guest_bug (d,"%s: finished loop without match" , __func__);return 1 ; }
@@ -1105,7 +1106,7 @@ static int qxl_add_memslot(PCIQXLDevice *d, uint32_t slot_id, uint64_t delta,break ;default :/* should not happen */ -qxl_guest_bug (d,"%s: pci_region = %d" , __func__, pci_region); +qxl_set_guest_bug (d,"%s: pci_region = %d" , __func__, pci_region);return 1 ; }
@@ -1156,21 +1157,24 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)return (void *)(intptr_t )offset;case MEMSLOT_GROUP_GUEST :if (slot >=NUM_MEMSLOTS ) { -qxl_guest_bug (qxl,"slot too large %d >= %d" , slot,NUM_MEMSLOTS ); +qxl_set_guest_bug (qxl,"slot too large %d >= %d" , slot, +NUM_MEMSLOTS );return NULL ; }if (!qxl->guest_slots[slot].active) { -qxl_guest_bug (qxl,"inactive slot %d\n" , slot); +qxl_set_guest_bug (qxl,"inactive slot %d\n" , slot);return NULL ; }if (offset < qxl->guest_slots[slot].delta) { -qxl_guest_bug (qxl,"slot %d offset %" PRIu64" < delta %" PRIu64"\n" , +qxl_set_guest_bug (qxl, +"slot %d offset %" PRIu64" < delta %" PRIu64"\n" , slot, offset, qxl->guest_slots[slot].delta);return NULL ; } offset -= qxl->guest_slots[slot].delta;if (offset > qxl->guest_slots[slot].size) { -qxl_guest_bug (qxl,"slot %d offset %" PRIu64" > size %" PRIu64"\n" , +qxl_set_guest_bug (qxl, +"slot %d offset %" PRIu64" > size %" PRIu64"\n" , slot, offset, qxl->guest_slots[slot].size);return NULL ; }
@@ -1192,7 +1196,7 @@ static void qxl_create_guest_primary(PCIQXLDevice *qxl, int loadvm,QXLSurfaceCreate *sc = &qxl->guest_primary.surface;if (qxl->mode ==QXL_MODE_NATIVE ) { -qxl_guest_bug (qxl,"%s: nop since already in QXL_MODE_NATIVE" , +qxl_set_guest_bug (qxl,"%s: nop since already in QXL_MODE_NATIVE" , __func__); }qxl_exit_vga_mode (qxl);
@@ -1342,7 +1346,7 @@ async_common: async =QXL_ASYNC ;qemu_mutex_lock (&d->async_lock);if (d->current_async !=QXL_UNDEFINED_IO ) { -qxl_guest_bug (d,"%d async started before last (%d) complete" , +qxl_set_guest_bug (d,"%d async started before last (%d) complete" , io_port, d->current_async);qemu_mutex_unlock (&d->async_lock);return ;
@@ -1403,11 +1407,12 @@ async_common:break ;case QXL_IO_MEMSLOT_ADD :if (val >=NUM_MEMSLOTS ) { -qxl_guest_bug (d,"QXL_IO_MEMSLOT_ADD: val out of range" ); +qxl_set_guest_bug (d,"QXL_IO_MEMSLOT_ADD: val out of range" );break ; }if (d->guest_slots[val].active) { -qxl_guest_bug (d,"QXL_IO_MEMSLOT_ADD: memory slot already active" ); +qxl_set_guest_bug (d, +"QXL_IO_MEMSLOT_ADD: memory slot already active" );break ; } d->guest_slots[val].slot = d->ram->mem_slot;
@@ -1415,14 +1420,14 @@ async_common:break ;case QXL_IO_MEMSLOT_DEL :if (val >=NUM_MEMSLOTS ) { -qxl_guest_bug (d,"QXL_IO_MEMSLOT_DEL: val out of range" ); +qxl_set_guest_bug (d,"QXL_IO_MEMSLOT_DEL: val out of range" );break ; }qxl_del_memslot (d, val);break ;case QXL_IO_CREATE_PRIMARY :if (val !=0 ) { -qxl_guest_bug (d,"QXL_IO_CREATE_PRIMARY (async=%d): val != 0" , +qxl_set_guest_bug (d,"QXL_IO_CREATE_PRIMARY (async=%d): val != 0" , async); goto cancel_async; }
@@ -1431,7 +1436,7 @@ async_common:break ;case QXL_IO_DESTROY_PRIMARY :if (val !=0 ) { -qxl_guest_bug (d,"QXL_IO_DESTROY_PRIMARY (async=%d): val != 0" , +qxl_set_guest_bug (d,"QXL_IO_DESTROY_PRIMARY (async=%d): val != 0" , async); goto cancel_async; }
@@ -1443,7 +1448,7 @@ async_common:break ;case QXL_IO_DESTROY_SURFACE_WAIT :if (val >=NUM_SURFACES ) { -qxl_guest_bug (d,"QXL_IO_DESTROY_SURFACE (async=%d):" +qxl_set_guest_bug (d,"QXL_IO_DESTROY_SURFACE (async=%d):" "%" PRIu64" >= NUM_SURFACES" , async, val); goto cancel_async; }
@@ -1467,7 +1472,7 @@ async_common:qxl_spice_destroy_surfaces (d, async);break ;default : -qxl_guest_bug (d,"%s: unexpected ioport=0x%x\n" , __func__, io_port); +qxl_set_guest_bug (d,"%s: unexpected ioport=0x%x\n" , __func__, io_port); }return ; cancel_async:
hw/qxl.h +2 -1
@@ -127,7 +127,8 @@ typedef struct PCIQXLDevice {/* qxl.c */ void *qxl_phys2virt (PCIQXLDevice *qxl,QXLPHYSICAL phys,int group_id); -void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...) GCC_FMT_ATTR(2, 3); +void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...) + GCC_FMT_ATTR(2, 3); void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id, struct QXLRect *area, struct QXLRect *dirty_rects,
Signature · 1 line
1.7.10.1
PATCH 3/4 hmp/qxl: info spice: add qxl info
In reply to Alon LevyFor all devices print id, mode and guest_bug status.
Known problems: Prints devices from highest id to lowest.
--- hmp.c | 11 +++++++++++ hw/qxl.c | 22 ++++++++++++++++++++++ qapi-schema.json | 47 +++++++++++++++++++++++++++++++++++++++++++++-- ui/qemu-spice.h | 5 +++++ ui/spice-core.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 130 insertions(+), 3 deletions(-)
hmp.c +11 -0
@@ -331,6 +331,7 @@ void hmp_info_spice(Monitor *mon) {SpiceChannelList *chan;SpiceInfo *info; +QXLInfoList *qxl; info =qmp_query_spice (NULL );
@@ -353,6 +354,16 @@ void hmp_info_spice(Monitor *mon)monitor_printf (mon," mouse-mode: %s\n" , SpiceQueryMouseMode_lookup[info->mouse_mode]); +for (qxl = info->qxl; qxl; qxl = qxl->next) { +if (qxl->value->guest_bug ==-1 || qxl->value->mode ==-1 ) { +continue ; + } +monitor_printf (mon,"qxl-%" PRId64":\n" , qxl->value->id); +monitor_printf (mon," mode: %s\n" , + SpiceQueryQXLMode_lookup[qxl->value->mode]); +monitor_printf (mon," guest_bug: %" PRIu64"\n" , qxl->value->guest_bug); + } +if (!info->has_channels || info->channels ==NULL ) {monitor_printf (mon,"Channels: none\n" ); }else {
hw/qxl.c +22 -0
@@ -1699,6 +1699,28 @@ static DisplayChangeListener display_listener = { .dpy_refresh = display_refresh, }; +/* helpers for spice_info */ +int qxl_get_guest_bug (DeviceState *dev) +{ +PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci.qdev, dev); + +return qxl->guest_bug; +} + +int qxl_get_mode (DeviceState *dev) +{ +PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci.qdev, dev); + +return qxl->mode; +} + +int qxl_get_id (DeviceState *dev) +{ +PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci.qdev, dev); + +return qxl->id; +} +static void qxl_init_ramsize (PCIQXLDevice *qxl,uint32_t ram_min_mb) {/* vga ram (bar 0) */
qapi-schema.json +45 -2
70 lines not on this page · raw message
ui/qemu-spice.h +5 -0
@@ -47,6 +47,11 @@ void do_info_spice(Monitor *mon, QObject **ret_data);CharDriverState *qemu_chr_open_spice (QemuOpts *opts); +/* implemented in hw/qxl.c */ +int qxl_get_guest_bug (DeviceState *dev); +int qxl_get_mode (DeviceState *dev); +int qxl_get_id (DeviceState *dev); +#else /* CONFIG_SPICE */ #include "monitor.h"
ui/spice-core.c +47 -1
72 lines not on this page · raw message
Signature · 1 line
1.7.10.1
Re: [Qemu-devel] [PATCH 3/4] hmp/qxl: info spice: add qxl info
Quoted 1 line · Alon Levy
For all devices print id, mode and
guest_bugstatus.
Queued up 1+2+4
For this one I wanna have an additional ack from qmp camp. Also a nit:
qapi-schema.json line 727
Quoted 11 lines
# @SpiceInfo
#
# Information about the SPICE session.qapi-schema.json +4
-0@@ -683,12 +721,17 @@ # # @channels: a list of @SpiceChannel for each active spice channel # +# @qxl0_mode: Mode of the primary qxl device. +# +# @qxl0_guest_bug: Guest bug status of primary qxl device. +#
Code changed, but docs didn't ...
Otherwise looks fine to me.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 3/4] hmp/qxl: info spice: add qxl info
Quoted 4 lines · Gerd Hoffmann
Quoted 1 line · Alon Levy
For all devices print id, mode and
guest_bugstatus.Queued up 1+2+4
Please unqueue "qxl: stop dirty loging when not in vga mode" and I'll send it again with the separate patch "hw/qxl: ignore guest from guestbug until reset" that accidentally got squashed into it.
Quoted 23 lines
For this one I wanna have an additional ack from qmp camp. Also a nit:
qapi-schema.json line 727
Quoted 11 lines
# @SpiceInfo
#
# Information about the SPICE session.qapi-schema.json +4
-0@@ -683,12 +721,17 @@ # # @channels: a list of @SpiceChannel for each active spice channel # +# @qxl0_mode: Mode of the primary qxl device. +# +# @qxl0_guest_bug: Guest bug status of primary qxl device. +#Code changed, but docs didn't ...
Otherwise looks fine to me.
cheers,
Gerd
PATCH 1/2 qxl: stop dirty loging when not in vga mode
In reply to Gerd HoffmannTested with linux guest. Not sure how to check actual performance affect of this. Checked with the previously send traceevent that the kvm ioctl to start/stop dirty logging is being called. (KVM_SET_USER_MEMORY_REGION).
---
These are the two patches to queue instead of the previously squashed patch.
hw/qxl.c | 2 ++ 1 file changed, 2 insertions(+)
hw/qxl.c +2 -0
@@ -932,6 +932,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)qemu_spice_create_host_primary (&d->ssd); d->mode =QXL_MODE_VGA ;memset (&d->ssd.dirty,0 ,sizeof (d->ssd.dirty)); +vga_dirty_log_start (&d->vga); }static void qxl_exit_vga_mode (PCIQXLDevice *d)
@@ -940,6 +941,7 @@ static void qxl_exit_vga_mode(PCIQXLDevice *d)return ; }trace_qxl_exit_vga_mode (d->id); +vga_dirty_log_stop (&d->vga);qxl_destroy_primary (d,QXL_SYNC ); }
Signature · 1 line
1.7.10.1
PATCH 2/2 hw/qxl: ignore guest from guestbug until reset
soft_reset is called from any of:
* QXL_IO_RESET
* vga io
* pci reset handler
--- hw/qxl.c | 13 ++++++++++++- hw/qxl.h | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-)
hw/qxl.c +12 -1
@@ -141,6 +141,7 @@ static void qxl_ring_set_dirty(PCIQXLDevice *qxl);void qxl_set_guest_bug (PCIQXLDevice *qxl,const char *msg, ...) {qxl_send_events (qxl,QXL_INTERRUPT_ERROR ); + qxl->guest_bug =1 ;if (qxl->guestdebug) {va_list ap;va_start (ap, msg);
@@ -151,6 +152,10 @@ void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...) } } +static void qxl_clear_guest_bug (PCIQXLDevice *qxl) +{ + qxl->guest_bug =0 ; +} void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id, struct QXLRect *area, struct QXLRect *dirty_rects,
@@ -572,7 +577,7 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)case QXL_MODE_NATIVE :case QXL_MODE_UNDEFINED : ring = &qxl->ram->cmd_ring; -if (SPICE_RING_IS_EMPTY (ring)) { +if (qxl->guest_bug ||SPICE_RING_IS_EMPTY (ring)) {return false; }SPICE_RING_CONS_ITEM (qxl, ring, cmd);
@@ -980,6 +985,7 @@ static void qxl_soft_reset(PCIQXLDevice *d) {trace_qxl_soft_reset (d->id);qxl_check_state (d); +qxl_clear_guest_bug (d);if (d->id ==0 ) {qxl_enter_vga_mode (d);
@@ -1297,6 +1303,10 @@ static void ioport_write(void *opaque, target_phys_addr_t addr,qxl_async_io async =QXL_SYNC ;uint32_t orig_io_port = io_port; +if (d->guest_bug && !io_port ==QXL_IO_RESET ) { +return ; + } +switch (io_port) {case QXL_IO_RESET :case QXL_IO_SET_MODE :
@@ -1749,6 +1759,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)qemu_mutex_init (&qxl->track_lock);qemu_mutex_init (&qxl->async_lock); qxl->current_async =QXL_UNDEFINED_IO ; + qxl->guest_bug =0 ;switch (qxl->revision) {case 1 :/* spice 0.4 -- qxl-1 */
hw/qxl.h +3 -0
@@ -31,6 +31,9 @@ typedef struct PCIQXLDevice {uint32_t debug;uint32_t guestdebug;uint32_t cmdlog; + +uint32_t guest_bug; +enum qxl_mode mode;uint32_t cmdflags;int generation;
Signature · 1 line
1.7.10.1
PATCH 4/4 qxl: stop dirty loging when not in vga mode
In reply to Alon LevyTested with linux guest. Not sure how to check actual performance affect of this. Checked with the previously send traceevent that the kvm ioctl to start/stop dirty logging is being called. (KVM_SET_USER_MEMORY_REGION).
--- hw/qxl.c | 2 ++ 1 file changed, 2 insertions(+)
hw/qxl.c +2 -0
@@ -932,6 +932,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)qemu_spice_create_host_primary (&d->ssd); d->mode =QXL_MODE_VGA ;memset (&d->ssd.dirty,0 ,sizeof (d->ssd.dirty)); +vga_dirty_log_start (&d->vga); }static void qxl_exit_vga_mode (PCIQXLDevice *d)
@@ -940,6 +941,7 @@ static void qxl_exit_vga_mode(PCIQXLDevice *d)return ; }trace_qxl_exit_vga_mode (d->id); +vga_dirty_log_stop (&d->vga);qxl_destroy_primary (d,QXL_SYNC ); }
Signature · 1 line
1.7.10.1
Quoted 3 lines · Alon Levy
We can't initialize QXLDevSurfaceCreate field by field because it has a pa hole, and so 4 bytes remain uninitialized when building on x86-64, so just memset.
This was supposed to be in reply to "<[email protected]>", rebased on just pulled master, so should apply cleanly.
Quoted 23 lines
Signed-off-by Alon Levy <[email protected]>--- ui/spice-display.c | 2 ++ 1 file changed, 2 insertions(+)ui/spice-display.c +2
-0@@ -244,6 +244,8 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd) {QXLDevSurfaceCreate surface; +memset (&surface,0 ,sizeof (surface)); +dprint (1 ,"%s: %dx%d\n" , __FUNCTION__,ds_get_width (ssd->ds),ds_get_height (ssd->ds));Signature · 1 line
1.7.10.1