return -1;
}
+static size_t alsa_buffer_get_free(HWVoiceOut *hw)
+{
+ ALSAVoiceOut *alsa = (ALSAVoiceOut *)hw;
+ snd_pcm_sframes_t avail;
+ size_t alsa_free, generic_free, generic_in_use;
+
+ avail = snd_pcm_avail_update(alsa->handle);
+ if (avail < 0) {
+ if (avail == -EPIPE) {
+ if (!alsa_recover(alsa->handle)) {
+ avail = snd_pcm_avail_update(alsa->handle);
+ }
+ }
+ if (avail < 0) {
+ alsa_logerr(avail,
+ "Could not obtain number of available frames\n");
+ avail = 0;
+ }
+ }
+
+ alsa_free = avail * hw->info.bytes_per_frame;
+ generic_free = audio_generic_buffer_get_free(hw);
+ generic_in_use = hw->samples * hw->info.bytes_per_frame - generic_free;
+ if (generic_in_use) {
+ /*
+ * This code can only be reached in the unlikely case that
+ * snd_pcm_avail_update() returned a larger number of frames
+ * than snd_pcm_writei() could write. Make sure that all
+ * remaining bytes in the generic buffer can be written.
+ */
+ alsa_free = alsa_free > generic_in_use ? alsa_free - generic_in_use : 0;
+ }
+
+ return alsa_free;
+}
+
static size_t alsa_write(HWVoiceOut *hw, void *buf, size_t len)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
.init_out = alsa_init_out,
.fini_out = alsa_fini_out,
.write = alsa_write,
- .buffer_get_free = audio_generic_buffer_get_free,
+ .buffer_get_free = alsa_buffer_get_free,
.run_buffer_out = audio_generic_run_buffer_out,
.enable_out = alsa_enable_out,
}
}
+/**
+ * audio_frontend_frames_in() - returns the number of frames the resampling
+ * code generates from frames_in frames
+ *
+ * @sw: audio recording frontend
+ * @frames_in: number of frames
+ */
+static size_t audio_frontend_frames_in(SWVoiceIn *sw, size_t frames_in)
+{
+ return (int64_t)frames_in * sw->ratio >> 32;
+}
+
static size_t audio_get_avail (SWVoiceIn *sw)
{
size_t live;
}
ldebug (
- "%s: get_avail live %zu ret %" PRId64 "\n",
+ "%s: get_avail live %zu frontend frames %zu\n",
SW_NAME (sw),
- live, (((int64_t) live << 32) / sw->ratio) * sw->info.bytes_per_frame
+ live, audio_frontend_frames_in(sw, live)
);
- return (((int64_t) live << 32) / sw->ratio) * sw->info.bytes_per_frame;
+ return live;
}
-static size_t audio_sw_bytes_free(SWVoiceOut *sw, size_t free)
+/**
+ * audio_frontend_frames_out() - returns the number of frames needed to
+ * get frames_out frames after resampling
+ *
+ * @sw: audio playback frontend
+ * @frames_out: number of frames
+ */
+static size_t audio_frontend_frames_out(SWVoiceOut *sw, size_t frames_out)
{
- return (((int64_t)free << 32) / sw->ratio) * sw->info.bytes_per_frame;
+ return ((int64_t)frames_out << 32) / sw->ratio;
}
static size_t audio_get_free(SWVoiceOut *sw)
dead = sw->hw->mix_buf->size - live;
#ifdef DEBUG_OUT
- dolog("%s: get_free live %zu dead %zu sw_bytes %zu\n",
- SW_NAME(sw), live, dead, audio_sw_bytes_free(sw, dead));
+ dolog("%s: get_free live %zu dead %zu frontend frames %zu\n",
+ SW_NAME(sw), live, dead, audio_frontend_frames_out(sw, dead));
#endif
return dead;
HWVoiceOut *hw = NULL;
SWVoiceOut *sw;
- if (!audio_get_pdo_out(s->dev)->mixing_engine) {
- while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
+ while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
+ size_t played, live, prev_rpos;
+ size_t hw_free = audio_pcm_hw_get_free(hw);
+ int nb_live;
+
+ if (!audio_get_pdo_out(s->dev)->mixing_engine) {
/* there is exactly 1 sw for each hw with no mixeng */
sw = hw->sw_head.lh_first;
}
if (sw->active) {
- sw->callback.fn(sw->callback.opaque, INT_MAX);
+ sw->callback.fn(sw->callback.opaque,
+ hw_free * sw->info.bytes_per_frame);
}
- }
- return;
- }
- while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
- size_t played, live, prev_rpos;
- size_t hw_free = audio_pcm_hw_get_free(hw);
- int nb_live;
+ if (hw->pcm_ops->run_buffer_out) {
+ hw->pcm_ops->run_buffer_out(hw);
+ }
+
+ continue;
+ }
for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
if (sw->active) {
size_t free;
if (hw_free > sw->total_hw_samples_mixed) {
- free = audio_sw_bytes_free(sw,
+ free = audio_frontend_frames_out(sw,
MIN(sw_free, hw_free - sw->total_hw_samples_mixed));
} else {
free = 0;
}
if (free > 0) {
- sw->callback.fn(sw->callback.opaque, free);
+ sw->callback.fn(sw->callback.opaque,
+ free * sw->info.bytes_per_frame);
}
}
}
sw->total_hw_samples_acquired -= min;
if (sw->active) {
+ size_t sw_avail = audio_get_avail(sw);
size_t avail;
- avail = audio_get_avail (sw);
+ avail = audio_frontend_frames_in(sw, sw_avail);
if (avail > 0) {
- sw->callback.fn (sw->callback.opaque, avail);
+ sw->callback.fn(sw->callback.opaque,
+ avail * sw->info.bytes_per_frame);
}
}
}
}
}
- if (hw->pcm_ops->run_buffer_out) {
- hw->pcm_ops->run_buffer_out(hw);
- }
-
return total;
}
s->nb_hw_voices_out = audio_get_pdo_out(dev)->voices;
s->nb_hw_voices_in = audio_get_pdo_in(dev)->voices;
- if (s->nb_hw_voices_out <= 0) {
+ if (s->nb_hw_voices_out < 1) {
dolog ("Bogus number of playback voices %d, setting to 1\n",
s->nb_hw_voices_out);
s->nb_hw_voices_out = 1;
}
- if (s->nb_hw_voices_in <= 0) {
+ if (s->nb_hw_voices_in < 0) {
dolog ("Bogus number of capture voices %d, setting to 0\n",
s->nb_hw_voices_in);
s->nb_hw_voices_in = 0;
rate->start_ticks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
}
-size_t audio_rate_get_bytes(struct audio_pcm_info *info, RateCtl *rate,
- size_t bytes_avail)
+size_t audio_rate_peek_bytes(RateCtl *rate, struct audio_pcm_info *info)
{
int64_t now;
int64_t ticks;
int64_t bytes;
- int64_t samples;
- size_t ret;
+ int64_t frames;
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ticks = now - rate->start_ticks;
bytes = muldiv64(ticks, info->bytes_per_second, NANOSECONDS_PER_SECOND);
- samples = (bytes - rate->bytes_sent) / info->bytes_per_frame;
- if (samples < 0 || samples > 65536) {
- AUD_log(NULL, "Resetting rate control (%" PRId64 " samples)\n", samples);
+ frames = (bytes - rate->bytes_sent) / info->bytes_per_frame;
+ if (frames < 0 || frames > 65536) {
+ AUD_log(NULL, "Resetting rate control (%" PRId64 " frames)\n", frames);
audio_rate_start(rate);
- samples = 0;
+ frames = 0;
}
- ret = MIN(samples * info->bytes_per_frame, bytes_avail);
- rate->bytes_sent += ret;
- return ret;
+ return frames * info->bytes_per_frame;
+}
+
+void audio_rate_add_bytes(RateCtl *rate, size_t bytes_used)
+{
+ rate->bytes_sent += bytes_used;
+}
+
+size_t audio_rate_get_bytes(RateCtl *rate, struct audio_pcm_info *info,
+ size_t bytes_avail)
+{
+ size_t bytes;
+
+ bytes = audio_rate_peek_bytes(rate, info);
+ bytes = MIN(bytes, bytes_avail);
+ audio_rate_add_bytes(rate, bytes);
+
+ return bytes;
}
} RateCtl;
void audio_rate_start(RateCtl *rate);
-size_t audio_rate_get_bytes(struct audio_pcm_info *info, RateCtl *rate,
+size_t audio_rate_peek_bytes(RateCtl *rate, struct audio_pcm_info *info);
+void audio_rate_add_bytes(RateCtl *rate, size_t bytes_used);
+size_t audio_rate_get_bytes(RateCtl *rate, struct audio_pcm_info *info,
size_t bytes_avail);
static inline size_t audio_ring_dist(size_t dst, size_t src, size_t len)
return 0;
}
+#ifdef DAC
samples = ((int64_t) sw->HWBUF->size << 32) / sw->ratio;
+#else
+ samples = (int64_t)sw->HWBUF->size * sw->ratio >> 32;
+#endif
sw->buf = audio_calloc(__func__, samples, sizeof(struct st_sample));
if (!sw->buf) {
}
*size = MIN(vo->buf_size - vo->buf_pos, *size);
- *size = audio_rate_get_bytes(&hw->info, &vo->rate, *size);
+ *size = audio_rate_get_bytes(&vo->rate, &hw->info, *size);
return vo->buf + vo->buf_pos;
trace_dbus_audio_read(size);
- /* size = audio_rate_get_bytes(&hw->info, &vo->rate, size); */
+ /* size = audio_rate_get_bytes(&vo->rate, &hw->info, size); */
g_hash_table_iter_init(&iter, da->in_listeners);
while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) {
static size_t no_write(HWVoiceOut *hw, void *buf, size_t len)
{
NoVoiceOut *no = (NoVoiceOut *) hw;
- return audio_rate_get_bytes(&hw->info, &no->rate, len);
+ return audio_rate_get_bytes(&no->rate, &hw->info, len);
}
static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
static size_t no_read(HWVoiceIn *hw, void *buf, size_t size)
{
NoVoiceIn *no = (NoVoiceIn *) hw;
- int64_t bytes = audio_rate_get_bytes(&hw->info, &no->rate, size);
+ int64_t bytes = audio_rate_get_bytes(&no->rate, &hw->info, size);
audio_pcm_info_clear_buf(&hw->info, buf, bytes / hw->info.bytes_per_frame);
return bytes;
ilast = *ibuf++;
rate->ipos++;
- /* if ipos overflow, there is a infinite loop */
- if (rate->ipos == 0xffffffff) {
- rate->ipos = 1;
- rate->opos = rate->opos & 0xffffffff;
- }
/* See if we finished the input buffer yet */
if (ibuf >= iend) {
goto the_end;
icur = *ibuf;
+ /* wrap ipos and opos around long before they overflow */
+ if (rate->ipos >= 0x10001) {
+ rate->ipos = 1;
+ rate->opos &= 0xffffffff;
+ }
+
/* interpolate */
#ifdef FLOAT_MIXENG
#ifdef RECIPROCAL
spice_server_remove_interface (&out->sin.base);
}
+static size_t line_out_get_free(HWVoiceOut *hw)
+{
+ SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
+
+ return audio_rate_peek_bytes(&out->rate, &hw->info);
+}
+
static void *line_out_get_buffer(HWVoiceOut *hw, size_t *size)
{
SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
*size = MIN((out->fsize - out->fpos) << 2, *size);
}
- *size = audio_rate_get_bytes(&hw->info, &out->rate, *size);
-
return out->frame + out->fpos;
}
{
SpiceVoiceOut *out = container_of(hw, SpiceVoiceOut, hw);
+ audio_rate_add_bytes(&out->rate, size);
+
if (buf) {
assert(buf == out->frame + out->fpos && out->fpos <= out->fsize);
out->fpos += size >> 2;
static size_t line_in_read(HWVoiceIn *hw, void *buf, size_t len)
{
SpiceVoiceIn *in = container_of (hw, SpiceVoiceIn, hw);
- uint64_t to_read = audio_rate_get_bytes(&hw->info, &in->rate, len) >> 2;
+ uint64_t to_read = audio_rate_get_bytes(&in->rate, &hw->info, len) >> 2;
size_t ready = spice_server_record_get_samples(&in->sin, buf, to_read);
- /* XXX: do we need this? */
+ /*
+ * If the client didn't send new frames, it most likely disconnected.
+ * Generate silence in this case to avoid a stalled audio stream.
+ */
if (ready == 0) {
memset(buf, 0, to_read << 2);
ready = to_read;
.init_out = line_out_init,
.fini_out = line_out_fini,
.write = audio_generic_write,
+ .buffer_get_free = line_out_get_free,
.get_buffer_out = line_out_get_buffer,
.put_buffer_out = line_out_put_buffer,
.enable_out = line_out_enable,
static size_t wav_write_out(HWVoiceOut *hw, void *buf, size_t len)
{
WAVVoiceOut *wav = (WAVVoiceOut *) hw;
- int64_t bytes = audio_rate_get_bytes(&hw->info, &wav->rate, len);
+ int64_t bytes = audio_rate_get_bytes(&wav->rate, &hw->info, len);
assert(bytes % hw->info.bytes_per_frame == 0);
if (bytes && fwrite(buf, bytes, 1, wav->f) != 1) {
# Virtualization, as specified in the AMD64 Architecture
# Programmer's Manual. QEMU command line options related to
# this feature are documented in
-# "docs/amd-memory-encryption.txt".
+# "docs/system/i386/amd-memory-encryption.rst".
#
# @amd-sev-es: The firmware supports running under AMD Secure Encrypted
# Virtualization - Encrypted State, as specified in the AMD64
# Architecture Programmer's Manual. QEMU command line options
# related to this feature are documented in
-# "docs/amd-memory-encryption.txt".
+# "docs/system/i386/amd-memory-encryption.rst".
+#
+# @amd-sev-snp: The firmware supports running under AMD Secure Encrypted
+# Virtualization - Secure Nested Paging, as specified in the
+# AMD64 Architecture Programmer's Manual. QEMU command line
+# options related to this feature are documented in
+# "docs/system/i386/amd-memory-encryption.rst".
+#
+# @intel-tdx: The firmware supports running under Intel Trust Domain
+# Extensions (TDX).
#
# @enrolled-keys: The variable store (NVRAM) template associated with
# the firmware binary has the UEFI Secure Boot
# Since: 3.0
##
{ 'enum' : 'FirmwareFeature',
- 'data' : [ 'acpi-s3', 'acpi-s4', 'amd-sev', 'amd-sev-es', 'enrolled-keys',
- 'requires-smm', 'secure-boot', 'verbose-dynamic',
- 'verbose-static' ] }
+ 'data' : [ 'acpi-s3', 'acpi-s4',
+ 'amd-sev', 'amd-sev-es', 'amd-sev-snp',
+ 'intel-tdx',
+ 'enrolled-keys', 'requires-smm', 'secure-boot',
+ 'verbose-dynamic', 'verbose-static' ] }
##
# @FirmwareFlashFile:
1af4:1004 SCSI host bus adapter device (legacy)
1af4:1005 entropy generator device (legacy)
1af4:1009 9p filesystem device (legacy)
-
-1af4:1041 network device (modern)
-1af4:1042 block device (modern)
-1af4:1043 console device (modern)
-1af4:1044 entropy generator device (modern)
-1af4:1045 balloon device (modern)
-1af4:1048 SCSI host bus adapter device (modern)
-1af4:1049 9p filesystem device (modern)
-1af4:1050 virtio gpu device (modern)
-1af4:1052 virtio input device (modern)
+1af4:1012 vsock device (bug compatibility)
+
+1af4:1040 Start of ID range for modern virtio devices. The PCI device
+ to ID is calculated from the virtio device ID by adding the
+1af4:10ef 0x1040 offset. The virtio IDs are defined in the virtio
+ specification. The Linux kernel has a header file with
+ defines for all virtio IDs (linux/virtio_ids.h), qemu has a
+ copy in include/standard-headers/.
1af4:10f0 Available for experimental usage without registration. Must get
to official ID when the code leaves the test lab (i.e. when seeking
word alignment, so we keep them for the next line */
/* XXX: keep alignment to speed up transfer */
end_ptr = s->cirrus_bltbuf + s->cirrus_blt_srcpitch;
- copy_count = s->cirrus_srcptr_end - end_ptr;
+ copy_count = MIN(s->cirrus_srcptr_end - end_ptr, CIRRUS_BLTBUFSIZE);
memmove(s->cirrus_bltbuf, end_ptr, copy_count);
s->cirrus_srcptr = s->cirrus_bltbuf + copy_count;
s->cirrus_srcptr_end = s->cirrus_bltbuf + s->cirrus_blt_srcpitch;
k->realize = virtio_iommu_pci_realize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
device_class_set_props(dc, virtio_iommu_pci_properties);
- pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
- pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_IOMMU;
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
pcidev_k->class_id = PCI_CLASS_OTHERS;
dc->hotpluggable = false;
}
static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = {
- .generic_name = TYPE_VIRTIO_IOMMU_PCI,
+ .generic_name = TYPE_VIRTIO_IOMMU_PCI,
.instance_size = sizeof(VirtIOIOMMUPCI),
.instance_init = virtio_iommu_pci_instance_init,
.class_init = virtio_iommu_pci_class_init,
k->realize = virtio_mem_pci_realize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
- pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
- pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_MEM;
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
pcidev_k->class_id = PCI_CLASS_OTHERS;
pci_set_word(config + PCI_VENDOR_ID,
PCI_VENDOR_ID_REDHAT_QUMRANET);
pci_set_word(config + PCI_DEVICE_ID,
- 0x1040 + virtio_bus_get_vdev_id(bus));
+ PCI_DEVICE_ID_VIRTIO_10_BASE + virtio_bus_get_vdev_id(bus));
pci_config_set_revision(config, 1);
}
config[PCI_INTERRUPT_PIN] = 1;
k->realize = virtio_pmem_pci_realize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
- pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
- pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_PMEM;
pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
pcidev_k->class_id = PCI_CLASS_OTHERS;
#define PCI_SUBVENDOR_ID_REDHAT_QUMRANET 0x1af4
#define PCI_SUBDEVICE_ID_QEMU 0x1100
+/* legacy virtio-pci devices */
#define PCI_DEVICE_ID_VIRTIO_NET 0x1000
#define PCI_DEVICE_ID_VIRTIO_BLOCK 0x1001
#define PCI_DEVICE_ID_VIRTIO_BALLOON 0x1002
#define PCI_DEVICE_ID_VIRTIO_RNG 0x1005
#define PCI_DEVICE_ID_VIRTIO_9P 0x1009
#define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012
-#define PCI_DEVICE_ID_VIRTIO_PMEM 0x1013
-#define PCI_DEVICE_ID_VIRTIO_IOMMU 0x1014
-#define PCI_DEVICE_ID_VIRTIO_MEM 0x1015
+
+/*
+ * modern virtio-pci devices get their id assigned automatically,
+ * there is no need to add #defines here. It gets calculated as
+ *
+ * PCI_DEVICE_ID = PCI_DEVICE_ID_VIRTIO_10_BASE +
+ * virtio_bus_get_vdev_id(bus)
+ */
+#define PCI_DEVICE_ID_VIRTIO_10_BASE 0x1040
#define PCI_VENDOR_ID_REDHAT 0x1b36
#define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001
# interfaces (e.g. VGA and virtual console character devices)
# by default.
# Since 7.1
+# @show-menubar: Display the main window menubar. Defaults to "on".
+# Since 8.0
#
# Since: 2.12
##
{ 'struct' : 'DisplayGTK',
'data' : { '*grab-on-hover' : 'bool',
'*zoom-to-fit' : 'bool',
- '*show-tabs' : 'bool' } }
+ '*show-tabs' : 'bool',
+ '*show-menubar' : 'bool' } }
##
# @DisplayEGLHeadless:
fprintf(stderr, "not a number: %s\n", optarg);
exit(1);
}
+ if (dpi == 0) {
+ fprintf(stderr, "cannot be zero: %s\n", optarg);
+ exit(1);
+ }
break;
case 'v':
info.vendor = optarg;
#if defined(CONFIG_GTK)
"-display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off]\n"
" [,show-tabs=on|off][,show-cursor=on|off][,window-close=on|off]\n"
+ " [,show-menubar=on|off]\n"
#endif
#if defined(CONFIG_VNC)
"-display vnc=<display>[,<optargs>]\n"
``window-close=on|off`` : Allow to quit qemu with window close button
+ ``show-menubar=on|off`` : Display the main window menubar, defaults to "on"
+
``curses[,charset=<encoding>]``
Display video output via curses. For graphics device models
which support a text mode, QEMU can display this output using a
if (resized) {
gd_update_windowsize(vc);
}
+
+ eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
+ EGL_NO_CONTEXT);
}
QEMUGLContext gd_egl_create_context(DisplayGLCtx *dgc,
s = container_of(notify, GtkDisplayState, mouse_mode_notifier);
/* release the grab at switching to absolute mode */
- if (qemu_input_is_absolute() && gd_is_grab_active(s)) {
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
- FALSE);
+ if (qemu_input_is_absolute() && s->ptr_owner) {
+ if (!s->ptr_owner->window) {
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
+ FALSE);
+ } else {
+ gd_ungrab_pointer(s);
+ }
}
for (i = 0; i < s->nb_vcs; i++) {
VirtualConsole *vc = &s->vc[i];
return group;
}
-static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
+static GtkWidget *gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts)
{
GSList *group = NULL;
GtkWidget *view_menu;
s->show_menubar_item = gtk_check_menu_item_new_with_mnemonic(
_("Show Menubar"));
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->show_menubar_item),
- TRUE);
+ !opts->u.gtk.has_show_menubar ||
+ opts->u.gtk.show_menubar);
gtk_accel_group_connect(s->accel_group, GDK_KEY_m, HOTKEY_MODIFIERS, 0,
g_cclosure_new_swap(G_CALLBACK(gd_accel_show_menubar), s, NULL));
gtk_accel_label_set_accel(
return view_menu;
}
-static void gd_create_menus(GtkDisplayState *s)
+static void gd_create_menus(GtkDisplayState *s, DisplayOptions *opts)
{
GtkSettings *settings;
s->accel_group = gtk_accel_group_new();
s->machine_menu = gd_create_menu_machine(s);
- s->view_menu = gd_create_menu_view(s);
+ s->view_menu = gd_create_menu_view(s, opts);
s->machine_menu_item = gtk_menu_item_new_with_mnemonic(_("_Machine"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(s->machine_menu_item),
gtk_window_set_icon_name(GTK_WINDOW(s->window), "qemu");
- gd_create_menus(s);
+ gd_create_menus(s, opts);
gd_connect_signals(s);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
+ if (opts->u.gtk.has_show_menubar &&
+ !opts->u.gtk.show_menubar) {
+ gtk_widget_hide(s->menu_bar);
+ }
vc = gd_vc_find_current(s);
gtk_widget_set_sensitive(s->view_menu, vc != NULL);
if (len == 1) {
return 8;
}
+ uint32_t dlen = abs(read_s32(data, 4));
if (len == 8) {
- uint32_t dlen = abs(read_s32(data, 4));
if (dlen > (1 << 20)) {
error_report("vnc: client_cut_text msg payload has %u bytes"
" which exceeds our limit of 1MB.", dlen);
}
if (read_s32(data, 4) < 0) {
- vnc_client_cut_text_ext(vs, abs(read_s32(data, 4)),
- read_u32(data, 8), data + 12);
+ if (dlen < 4) {
+ error_report("vnc: malformed payload (header less than 4 bytes)"
+ " in extended clipboard pseudo-encoding.");
+ vnc_client_error(vs);
+ break;
+ }
+ vnc_client_cut_text_ext(vs, dlen, read_u32(data, 8), data + 12);
break;
}
vnc_client_cut_text(vs, read_u32(data, 4), data + 8);