spice patch queue
Hi,
Here is the spice patch queue with a collection of little improvements and bugfixes. No major stuff. See individual patches for details.
please pull,
Gerd
The following changes since commit 99c7f87826337fa81f2f0f9baa9ca0a44faf90e9:
input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600)
are available in the git repository at:
git://anongit.freedesktop.org/spice/qemu spice.v48
Daniel P. Berrange (1):
Add SPICE support to add_client monitor command
Gerd Hoffmann (5):
qxl: fix warnings on 32bit
qxl: don't render stuff when the vm is stopped.
qxl: drop vram bar minimum size
qxl: move ram size init to new function
qxl: add user-friendly bar size properties
Yonit Halperin (3):
qxl: set only off-screen surfaces dirty instead of the whole vram
qxl: make sure primary surface is saved on migration also in compat mode
spice: support ipv6 channel address in monitor events and in spice info
hw/qxl-render.c | 12 +++---- hw/qxl.c | 109 +++++++++++++++++++++++++++++++++++++++---------------- hw/qxl.h | 4 ++ monitor.c | 9 ++++- qmp-commands.hx | 6 ++- ui/qemu-spice.h | 7 ++++ ui/spice-core.c | 50 +++++++++++++++++++++++--- 7 files changed, 150 insertions(+), 47 deletions(-)
PATCH 1/9 qxl: fix warnings on 32bit
--- hw/qxl.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
hw/qxl.c +4 -3
@@ -625,7 +625,7 @@ static void interface_release_resource(QXLInstance *sin,if (ext.group_id ==MEMSLOT_GROUP_HOST ) {/* host group -> vga mode update request */ -qemu_spice_destroy_update (&qxl->ssd, (void *)ext.info->id); +qemu_spice_destroy_update (&qxl->ssd, (void *)(intptr_t )ext.info->id);return ; }
@@ -748,7 +748,8 @@ static void interface_async_complete(QXLInstance *sin, uint64_t cookie) qxl->current_async =QXL_UNDEFINED_IO ;qemu_mutex_unlock (&qxl->async_lock); -dprint (qxl,2 ,"async_complete: %d (%ld) done\n" , current_async, cookie); +dprint (qxl,2 ,"async_complete: %d (%" PRId64") done\n" , + current_async, cookie);switch (current_async) {case QXL_IO_CREATE_PRIMARY_ASYNC :qxl_create_guest_primary_complete (qxl);
@@ -1015,7 +1016,7 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)switch (group_id) {case MEMSLOT_GROUP_HOST : -return (void *)offset; +return (void *)(intptr_t )offset;case MEMSLOT_GROUP_GUEST :PANIC_ON (slot >=NUM_MEMSLOTS );PANIC_ON (!qxl->guest_slots[slot].active);
Signature · 1 line
1.7.1
PATCH 2/9 qxl: don't render stuff when the vm is stopped.
In reply to Gerd HoffmannThis patch fixes the local qxl renderer to not kick spice-server in case the vm is stopped. First it is largely pointless because we ask spice-server to process all not-yet processed commands when the vm is stopped, so there isn't much do do anyway. Second we avoid triggering an assert in spice-server.
The patch makes sure we still honor redraw requests, even if we don't ask spice-server for updates. This is needed to handle displaysurface changes with a stopped vm correctly.
With this patch applied it is possible to take screen shots (via screendump monitor command) from a qxl gpu even in case the guest is stopped.
--- hw/qxl-render.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
hw/qxl-render.c +5 -7
@@ -121,19 +121,17 @@ void qxl_render_update(PCIQXLDevice *qxl)dpy_resize (vga->ds); } -if (!qxl->guest_primary.commands) { -return ; - } - qxl->guest_primary.commands =0 ; - update.left =0 ; update.right = qxl->guest_primary.surface.width; update.top =0 ; update.bottom = qxl->guest_primary.surface.height;memset (dirty,0 ,sizeof (dirty)); -qxl_spice_update_area (qxl,0 , &update, - dirty,ARRAY_SIZE (dirty),1 ,QXL_SYNC ); +if (runstate_is_running () && qxl->guest_primary.commands) { + qxl->guest_primary.commands =0 ; +qxl_spice_update_area (qxl,0 , &update, + dirty,ARRAY_SIZE (dirty),1 ,QXL_SYNC ); + }if (redraw) {memset (dirty,0 ,sizeof (dirty)); dirty[0 ] = update;
Signature · 1 line
1.7.1
PATCH 3/9 qxl: set only off-screen surfaces dirty instead of the whole vram
In reply to Gerd HoffmannFrom: Yonit Halperin <[email protected]>
We used to assure the guest surfaces were saved before migration by setting the whole vram dirty. This patch sets dirty only the areas that are actually used in the vram.
--- hw/qxl.c | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 44 insertions(+), 9 deletions(-)
hw/qxl.c +44 -9
@@ -1007,7 +1007,7 @@ static void qxl_reset_surfaces(PCIQXLDevice *d)qxl_spice_destroy_surfaces (d,QXL_SYNC ); } -/* called from spice server thread context only */ +/* can be also called from spice server thread context */ void *qxl_phys2virt (PCIQXLDevice *qxl,QXLPHYSICAL pqxl,int group_id) {uint64_t phys =le64_to_cpu (pqxl);
@@ -1466,6 +1466,46 @@ static void qxl_hw_text_update(void *opaque, console_ch_t *chardata) } } +static void qxl_dirty_surfaces (PCIQXLDevice *qxl) +{ +intptr_t vram_start; +int i; + +if (qxl->mode !=QXL_MODE_NATIVE ) { +return ; + } + +/* dirty the primary surface */ +qxl_set_dirty (&qxl->vga.vram, qxl->shadow_rom.draw_area_offset, + qxl->shadow_rom.surface0_area_size); + + vram_start = (intptr_t )memory_region_get_ram_ptr (&qxl->vram_bar); + +/* dirty the off-screen surfaces */ +for (i =0 ; i <NUM_SURFACES ; i++) { +QXLSurfaceCmd *cmd; +intptr_t surface_offset; +int surface_size; + +if (qxl->guest_surfaces.cmds[i] ==0 ) { +continue ; + } + + cmd =qxl_phys2virt (qxl, qxl->guest_surfaces.cmds[i], +MEMSLOT_GROUP_GUEST ); +assert (cmd->type ==QXL_SURFACE_CMD_CREATE ); + surface_offset = (intptr_t )qxl_phys2virt (qxl, + cmd->u.surface_create.data, +MEMSLOT_GROUP_GUEST ); + surface_offset -= vram_start; + surface_size = cmd->u.surface_create.height * +abs (cmd->u.surface_create.stride); +dprint (qxl,3 ,"%s: dirty surface %d, offset %d, size %d\n" , __func__, + i, (int )surface_offset, surface_size); +qxl_set_dirty (&qxl->vram_bar, surface_offset, surface_size); + } +} +static void qxl_vm_change_state_handler (void *opaque,int running,RunState state) {
@@ -1479,14 +1519,9 @@ static void qxl_vm_change_state_handler(void *opaque, int running,* called */ qxl_update_irq (qxl); - }else if (qxl->mode ==QXL_MODE_NATIVE ) { -/* dirty all vram (which holds surfaces) and devram (primary surface) -* to make sure they are saved */ -/* FIXME #1: should go out during "live" stage */ -/* FIXME #2: we only need to save the areas which are actually used */ -qxl_set_dirty (&qxl->vram_bar,0 , qxl->vram_size); -qxl_set_dirty (&qxl->vga.vram, qxl->shadow_rom.draw_area_offset, - qxl->shadow_rom.surface0_area_size); + }else { +/* make sure surfaces are saved before migration */ +qxl_dirty_surfaces (qxl); } }
Signature · 1 line
1.7.1
PATCH 4/9 qxl: make sure primary surface is saved on migration also in compat mode
In reply to Gerd HoffmannFrom: Yonit Halperin <[email protected]>
RHBZ #790083
--- hw/qxl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/qxl.c +1 -1
@@ -1471,7 +1471,7 @@ static void qxl_dirty_surfaces(PCIQXLDevice *qxl)intptr_t vram_start;int i; -if (qxl->mode !=QXL_MODE_NATIVE ) { +if (qxl->mode !=QXL_MODE_NATIVE && qxl->mode !=QXL_MODE_COMPAT ) {return ; }
Signature · 1 line
1.7.1
PATCH 5/9 Add SPICE support to add_client monitor command
In reply to Gerd HoffmannFrom: Daniel P. Berrange <[email protected]>
With the acceptance of some new APIs to libspice-server.so it is possible to add support for SPICE to the 'add_client' monitor command, bringing parity with VNC. Since SPICE can use TLS or plain connections, the command also gains a new 'tls' parameter to specify whether TLS should be attempted on the injected client sockets.
This new feature is only enabled if building against a libspice-server >= 0.10.1
* qmp-commands.hx: Add 'tls' parameter & missing doc for 'skipauth' parameter
* monitor.c: Wire up SPICE for 'add_client' command
* ui/qemu-spice.h, ui/spice-core.c: Add qemu_spice_display_add_client API to wire up from monitor
http://cgit.freedesktop.org/spice/spice/commit/server/spice.h?id=bd07dde530d9504e1cfe7ed5837fc00c26f36716
Changes in v3:
- Added 'optional' flag to new parameters documented
- Added no-op impl of qemu_spice_display_add_client when SPICE is disabled during build
--- monitor.c | 9 +++++++-- qmp-commands.hx | 6 ++++-- ui/qemu-spice.h | 7 +++++++ ui/spice-core.c | 13 +++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-)
monitor.c +7 -2
@@ -823,13 +823,18 @@ static int add_graphics_client(Monitor *mon, const QDict *qdict, QObject **ret_dCharDriverState *s;if (strcmp (protocol,"spice" ) ==0 ) { +int fd =monitor_get_fd (mon, fdname); +int skipauth =qdict_get_try_bool (qdict,"skipauth" ,0 ); +int tls =qdict_get_try_bool (qdict,"tls" ,0 );if (!using_spice) {/* correct one? spice isn't a device ,,, */ qerror_report (QERR_DEVICE_NOT_ACTIVE ,"spice" );return -1 ; } -qerror_report (QERR_ADD_CLIENT_FAILED ); -return -1 ; +if (qemu_spice_display_add_client (fd, skipauth, tls) <0 ) { +close (fd); + } +return 0 ; #ifdef CONFIG_VNC }else if (strcmp (protocol,"vnc" ) ==0 ) {int fd =monitor_get_fd (mon, fdname);
qmp-commands.hx +4 -2
@@ -910,8 +910,8 @@ EQMP { .name = "add_client", - .args_type = "protocol:s,fdname:s,skipauth:b?", - .params = "protocol fdname skipauth", + .args_type = "protocol:s,fdname:s,skipauth:b?,tls:b?", + .params = "protocol fdname skipauth tls", .help = "add a graphics client", .user_print = monitor_user_noop, .mhandler.cmd_new = add_graphics_client,
@@ -927,6 +927,8 @@ Arguments: - "protocol": protocol name (json-string) - "fdname": file descriptor name (json-string) +- "skipauth": whether to skip authentication (json-bool, optional) +- "tls": whether to perform TLS (json-bool, optional) Example:
ui/qemu-spice.h +7 -0
@@ -33,6 +33,7 @@ void qemu_spice_init(void);void qemu_spice_input_init (void );void qemu_spice_audio_init (void );void qemu_spice_display_init (DisplayState *ds); +int qemu_spice_display_add_client (int csock,int skipauth,int tls);int qemu_spice_add_interface (SpiceBaseInstance *sin);int qemu_spice_set_passwd (const char *passwd,bool fail_if_connected,bool disconnect_if_connected);
@@ -68,6 +69,12 @@ static inline int qemu_spice_migrate_info(const char *h, int p, int t,return -1 ; } +static inline int qemu_spice_display_add_client (int csock,int skipauth, +int tls) +{ +return -1 ; +} +#endif /* CONFIG_SPICE */ #endif /* QEMU_SPICE_H */
ui/spice-core.c +13 -0
@@ -747,6 +747,19 @@ int qemu_spice_set_pw_expire(time_t expires)return qemu_spice_set_ticket (false, false); } +int qemu_spice_display_add_client (int csock,int skipauth,int tls) +{ +#if SPICE_SERVER_VERSION >=0x000a01 +if (tls) { +return spice_server_add_ssl_client (spice_server, csock, skipauth); + }else { +return spice_server_add_client (spice_server, csock, skipauth); + } +#else +return -1 ; +#endif +} +static void spice_register_config (void ) {qemu_add_opts (&qemu_spice_opts);
Signature · 1 line
1.7.1
PATCH 6/9 spice: support ipv6 channel address in monitor events and in spice info
In reply to Gerd HoffmannFrom: Yonit Halperin <[email protected]>
RHBZ #788444
--- ui/spice-core.c | 37 ++++++++++++++++++++++++++++++++----- 1 files changed, 32 insertions(+), 5 deletions(-)
ui/spice-core.c +32 -5
@@ -220,10 +220,23 @@ static void channel_event(int event, SpiceChannelEventInfo *info) } client =qdict_new (); -add_addr_info (client, &info->paddr, info->plen); - server =qdict_new (); -add_addr_info (server, &info->laddr, info->llen); + +#ifdef SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT +if (info->flags &SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT ) { +add_addr_info (client, (struct sockaddr *)&info->paddr_ext, + info->plen_ext); +add_addr_info (server, (struct sockaddr *)&info->laddr_ext, + info->llen_ext); + }else { +fprintf (stderr,"spice: %s, extended address is expected\n" , + __func__); +#endif +add_addr_info (client, &info->paddr, info->plen); +add_addr_info (server, &info->laddr, info->llen); +#ifdef SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT + } +#endif if (event ==SPICE_CHANNEL_EVENT_INITIALIZED ) {qdict_put (server,"auth" ,qstring_from_str (auth));
@@ -376,16 +389,30 @@ static SpiceChannelList *qmp_query_spice_channels(void) QTAILQ_FOREACH(item, &channel_list, link) {SpiceChannelList *chan;char host[NI_MAXHOST ], port[NI_MAXSERV ]; +struct sockaddr *paddr; +socklen_t plen; chan =g_malloc0 (sizeof (*chan)); chan->value =g_malloc0 (sizeof (*chan->value)); -getnameinfo (&item->info->paddr, item->info->plen, +#ifdef SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT +if (item->info->flags &SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT ) { + paddr = (struct sockaddr *)&item->info->paddr_ext; + plen = item->info->plen_ext; + }else { +#endif + paddr = &item->info->paddr; + plen = item->info->plen; +#ifdef SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT + } +#endif + +getnameinfo (paddr, plen, host,sizeof (host), port,sizeof (port),NI_NUMERICHOST |NI_NUMERICSERV ); chan->value->host =g_strdup (host); chan->value->port =g_strdup (port); - chan->value->family =g_strdup (inet_strfamily (item->info->paddr.sa_family)); + chan->value->family =g_strdup (inet_strfamily (paddr->sa_family)); chan->value->connection_id = item->info->connection_id; chan->value->channel_type = item->info->type;
Signature · 1 line
1.7.1
PATCH 7/9 qxl: drop vram bar minimum size
In reply to Gerd HoffmannThere is no reason to require a minimum size of 16 MB for the vram. Lower the limit to 4096 (one page). Make it disapper completely would break guests.
--- hw/qxl.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/qxl.c +2 -2
@@ -1592,8 +1592,8 @@ static int qxl_init_common(PCIQXLDevice *qxl)init_qxl_rom (qxl);init_qxl_ram (qxl); -if (qxl->vram_size <16 *1024 *1024 ) { - qxl->vram_size =16 *1024 *1024 ; +if (qxl->vram_size <4096 ) { + qxl->vram_size =4096 ; }if (qxl->revision ==1 ) { qxl->vram_size =4096 ;
Signature · 1 line
1.7.1
PATCH 8/9 qxl: move ram size init to new function
In reply to Gerd HoffmannFactor memory bar sizing bits out to a separate function.
--- hw/qxl.c | 41 ++++++++++++++++++++++------------------- 1 files changed, 22 insertions(+), 19 deletions(-)
hw/qxl.c +22 -19
@@ -1554,6 +1554,25 @@ static DisplayChangeListener display_listener = { .dpy_refresh = display_refresh, }; +static void qxl_init_ramsize (PCIQXLDevice *qxl,uint32_t ram_min_mb) +{ +/* vga ram (bar 0) */ +if (qxl->vga.vram_size < ram_min_mb *1024 *1024 ) { + qxl->vga.vram_size = ram_min_mb *1024 *1024 ; + } + +/* vram (surfaces, bar 1) */ +if (qxl->vram_size <4096 ) { + qxl->vram_size =4096 ; + } +if (qxl->revision ==1 ) { + qxl->vram_size =4096 ; + } + + qxl->vga.vram_size =msb_mask (qxl->vga.vram_size *2 -1 ); + qxl->vram_size =msb_mask (qxl->vram_size *2 -1 ); +} +static int qxl_init_common (PCIQXLDevice *qxl) {uint8_t * config = qxl->pci.config;
@@ -1592,13 +1611,6 @@ static int qxl_init_common(PCIQXLDevice *qxl)init_qxl_rom (qxl);init_qxl_ram (qxl); -if (qxl->vram_size <4096 ) { - qxl->vram_size =4096 ; - } -if (qxl->revision ==1 ) { - qxl->vram_size =4096 ; - } - qxl->vram_size =msb_mask (qxl->vram_size *2 -1 );memory_region_init_ram (&qxl->vram_bar,"qxl.vram" , qxl->vram_size);vmstate_register_ram (&qxl->vram_bar, &qxl->pci.qdev);
@@ -1641,15 +1653,11 @@ static int qxl_init_primary(PCIDevice *dev) {PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci, dev);VGACommonState *vga = &qxl->vga; -ram_addr_t ram_size =msb_mask (qxl->vga.vram_size *2 -1 );PortioList *qxl_vga_port_list =g_new (PortioList,1 ); qxl->id =0 ; - -if (ram_size <32 *1024 *1024 ) { - ram_size =32 *1024 *1024 ; - } -vga_common_init (vga, ram_size); +qxl_init_ramsize (qxl,32 ); +vga_common_init (vga, qxl->vga.vram_size);vga_init (vga,pci_address_space (dev),pci_address_space_io (dev), false);portio_list_init (qxl_vga_port_list, qxl_vga_portio_list, vga,"vga" );portio_list_add (qxl_vga_port_list,pci_address_space_io (dev),0x3b0 );
@@ -1668,14 +1676,9 @@ static int qxl_init_secondary(PCIDevice *dev) {static int device_id =1 ;PCIQXLDevice *qxl =DO_UPCAST (PCIQXLDevice, pci, dev); -ram_addr_t ram_size =msb_mask (qxl->vga.vram_size *2 -1 ); qxl->id = device_id++; - -if (ram_size <16 *1024 *1024 ) { - ram_size =16 *1024 *1024 ; - } - qxl->vga.vram_size = ram_size; +qxl_init_ramsize (qxl,16 );memory_region_init_ram (&qxl->vga.vram,"qxl.vgavram" , qxl->vga.vram_size);vmstate_register_ram (&qxl->vga.vram, &qxl->pci.qdev); qxl->vga.vram_ptr =memory_region_get_ram_ptr (&qxl->vga.vram);
Signature · 1 line
1.7.1
PATCH 9/9 qxl: add user-friendly bar size properties
In reply to Gerd HoffmannAdd two properties to specify bar sizes in megabytes instead of bytes, which is alot more user-friendly.
--- hw/qxl.c | 8 ++++++++ hw/qxl.h | 4 ++++ 2 files changed, 12 insertions(+), 0 deletions(-)
hw/qxl.c +8 -0
@@ -1557,11 +1557,17 @@ static DisplayChangeListener display_listener = {static void qxl_init_ramsize (PCIQXLDevice *qxl,uint32_t ram_min_mb) {/* vga ram (bar 0) */ +if (qxl->ram_size_mb !=-1 ) { + qxl->vga.vram_size = qxl->ram_size_mb *1024 *1024 ; + }if (qxl->vga.vram_size < ram_min_mb *1024 *1024 ) { qxl->vga.vram_size = ram_min_mb *1024 *1024 ; }/* vram (surfaces, bar 1) */ +if (qxl->vram_size_mb !=-1 ) { + qxl->vram_size = qxl->vram_size_mb *1024 *1024 ; + }if (qxl->vram_size <4096 ) { qxl->vram_size =4096 ; }
@@ -1860,6 +1866,8 @@ static Property qxl_properties[] = {DEFINE_PROP_UINT32 ("debug" , PCIQXLDevice, debug,0 ),DEFINE_PROP_UINT32 ("guestdebug" , PCIQXLDevice, guestdebug,0 ),DEFINE_PROP_UINT32 ("cmdlog" , PCIQXLDevice, cmdlog,0 ), +DEFINE_PROP_UINT32 ("ram_size_mb" , PCIQXLDevice, ram_size_mb,-1 ), +DEFINE_PROP_UINT32 ("vram_size_mb" , PCIQXLDevice, vram_size_mb,-1 ), DEFINE_PROP_END_OF_LIST(), };
hw/qxl.h +4 -0
@@ -89,6 +89,10 @@ typedef struct PCIQXLDevice {/* io bar */ MemoryRegion io_bar; + +/* user-friendly properties (in megabytes) */ +uint32_t ram_size_mb; +uint32_t vram_size_mb; } PCIQXLDevice;#define PANIC_ON (x) if ((x)) { \
Signature · 1 line
1.7.1
Quoted 4 lines · Gerd Hoffmann
Hi,Here is the spice patch queue with a collection of little improvements and bugfixes. No major stuff. See individual patches for details.
Pulled. Thanks.
Regards,
Anthony Liguori
Quoted 35 lines
please pull,
GerdThe following changes since commit
99c7f87826337fa81f2f0f9baa9ca0a44faf90e9:input: send kbd+mouse events only to running guests. (2012-02-17 11:02:55 -0600)
are available in the git repository at:
git://anongit.freedesktop.org/spice/qemuspice.v48Daniel P. Berrange (1):
Add SPICE support toadd_clientmonitor commandGerd Hoffmann (5):
qxl: fix warnings on 32bit
qxl: don't render stuff when the vm is stopped.
qxl: drop vram bar minimum size
qxl: move ram size init to new function
qxl: add user-friendly bar size propertiesYonit Halperin (3):
qxl: set only off-screen surfaces dirty instead of the whole vram
qxl: make sure primary surface is saved on migration also in compat mode
spice: support ipv6 channel address in monitor events and in spice infohw/qxl-render.c | 12 +++---- hw/qxl.c | 109 +++++++++++++++++++++++++++++++++++++++---------------- hw/qxl.h | 4 ++ monitor.c | 9 ++++- qmp-commands.hx | 6 ++- ui/qemu-spice.h | 7 ++++ ui/spice-core.c | 50 +++++++++++++++++++++++--- 7 files changed, 150 insertions(+), 47 deletions(-)