From af2cd7175cdf9d459b04532b9a1f0fd07c2a6688 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 30 Mar 2015 18:00:43 +0200 Subject: [PATCH] vbox: enable video acceleration (VBVA) This commit enables the VirtualBox graphics adapter, provides guest mouse pointer integration with Nitpicker using the 'vbox_pointer' application and enhances the VirtualBox run scripts with the configuration of Nitpicker, input merger and network driver. Fixes #1474 --- .../include/vbox_pointer/dither_painter.h | 75 ++ .../ports/include/vbox_pointer/shape_report.h | 38 + repos/ports/ports/virtualbox.hash | 2 +- repos/ports/ports/virtualbox.port | 2 +- repos/ports/run/vbox_auto_win7.run | 2 +- repos/ports/run/vbox_auto_win7_share.run | 10 +- repos/ports/run/vbox_auto_win8.run | 2 +- repos/ports/run/vbox_win.inc | 116 +- repos/ports/run/virtualbox_auto.inc | 4 +- repos/ports/src/app/vbox_pointer/big_mouse.h | 36 + repos/ports/src/app/vbox_pointer/main.cc | 410 +++++++ repos/ports/src/app/vbox_pointer/target.mk | 3 + .../ports/src/virtualbox/frontend/console.cc | 5 +- repos/ports/src/virtualbox/frontend/console.h | 92 +- repos/ports/src/virtualbox/frontend/fb.h | 8 +- .../virtualbox/patches/fake_pci_vendor.patch | 10 - .../src/virtualbox/patches/vbox_main.patch | 1010 +++++++++-------- 17 files changed, 1344 insertions(+), 481 deletions(-) create mode 100644 repos/ports/include/vbox_pointer/dither_painter.h create mode 100644 repos/ports/include/vbox_pointer/shape_report.h create mode 100644 repos/ports/src/app/vbox_pointer/big_mouse.h create mode 100644 repos/ports/src/app/vbox_pointer/main.cc create mode 100644 repos/ports/src/app/vbox_pointer/target.mk delete mode 100644 repos/ports/src/virtualbox/patches/fake_pci_vendor.patch diff --git a/repos/ports/include/vbox_pointer/dither_painter.h b/repos/ports/include/vbox_pointer/dither_painter.h new file mode 100644 index 000000000..655e7da2c --- /dev/null +++ b/repos/ports/include/vbox_pointer/dither_painter.h @@ -0,0 +1,75 @@ +/* + * \brief Functor for converting pixel formats by applying dithering + * \author Norman Feske + * \date 2014-09-10 + */ + +/* + * Copyright (C) 2014 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _DITHER_PAINTER_H_ +#define _DITHER_PAINTER_H_ + +#include +#include + + +struct Dither_painter +{ + /* + * Surface and texture must have the same size + */ + template + static inline void paint(Genode::Surface &surface, + Genode::Texture const &texture) + { + if (surface.size() != texture.size()) return; + + Genode::Surface_base::Rect const clipped = surface.clip(); + + if (!clipped.valid()) return; + + unsigned const offset = surface.size().w()*clipped.y1() + clipped.x1(); + + DST_PT *dst, *dst_line = surface.addr() + offset; + SRC_PT const *src_pixel, *src_pixel_line = texture.pixel() + offset; + unsigned char const *src_alpha, *src_alpha_line = texture.alpha() + offset; + + unsigned const line_len = surface.size().w(); + + for (int y = clipped.y1(), h = clipped.h() ; h--; y++) { + + src_pixel = src_pixel_line; + src_alpha = src_alpha_line; + dst = dst_line; + + for (int x = clipped.x1(), w = clipped.w(); w--; x++) { + + int const v = Genode::Dither_matrix::value(x, y) >> 4; + + SRC_PT const pixel = *src_pixel++; + unsigned char const alpha = *src_alpha++; + + int const r = pixel.r() - v; + int const g = pixel.g() - v; + int const b = pixel.b() - v; + int const a = alpha ? (int)alpha - v : 0; + + using Genode::min; + using Genode::max; + + *dst++ = DST_PT(max(0, r), max(0, g), max(0, b), max(0, a)); + } + + src_pixel_line += line_len; + src_alpha_line += line_len; + dst_line += line_len; + } + } +}; + +#endif /* _DITHER_PAINTER_H_ */ diff --git a/repos/ports/include/vbox_pointer/shape_report.h b/repos/ports/include/vbox_pointer/shape_report.h new file mode 100644 index 000000000..5d44e2ec6 --- /dev/null +++ b/repos/ports/include/vbox_pointer/shape_report.h @@ -0,0 +1,38 @@ +/* + * \brief shape report + * \author Christian Prochaska + * \date 2015-03-20 + */ + +/* + * Copyright (C) 2015 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__VBOX_POINTER__SHAPE_REPORT_H_ +#define _INCLUDE__VBOX_POINTER__SHAPE_REPORT_H_ + +namespace Vbox_pointer { + + enum { + MAX_WIDTH = 100, + MAX_HEIGHT = 100, + MAX_SHAPE_SIZE = MAX_WIDTH*MAX_HEIGHT*4 + }; + + struct Shape_report; +} + +struct Vbox_pointer::Shape_report +{ + bool visible; + unsigned int x_hot; + unsigned int y_hot; + unsigned int width; + unsigned int height; + unsigned char shape[MAX_SHAPE_SIZE]; +}; + +#endif /* _INCLUDE__VBOX_POINTER__SHAPE_REPORT_H_ */ diff --git a/repos/ports/ports/virtualbox.hash b/repos/ports/ports/virtualbox.hash index 17c905d69..0ea336889 100644 --- a/repos/ports/ports/virtualbox.hash +++ b/repos/ports/ports/virtualbox.hash @@ -1 +1 @@ -7e0d7dd26169ee60eea603a22fd068bd0b879a79 +1e49158411c029263f5b29b890ec3f212b2caf29 diff --git a/repos/ports/ports/virtualbox.port b/repos/ports/ports/virtualbox.port index e8ec1d42a..fbf55f2f3 100644 --- a/repos/ports/ports/virtualbox.port +++ b/repos/ports/ports/virtualbox.port @@ -8,7 +8,7 @@ URL(virtualbox) := http://download.virtualbox.org/virtualbox/$(VERSION)/$(VIRTUA DIR(virtualbox) := src/app/virtualbox SHA(virtualbox) := e4c23b713e8715b8e0172fa066f2197756e901fe -PATCHES_LIST := acpi_drv dev_e1000 eminternal fake_pci_vendor iconv mouse +PATCHES_LIST := acpi_drv dev_e1000 eminternal iconv mouse PATCHES_LIST += pdm_driver poke sharedfolder_pagelist PATCHES_LIST += time-log-deadlock tm_retries vbox_inc vbox_main network PATCHES_LIST += vga_fb vga_vbva vmdk vmmdev avoid_yield serial rem_irq usb diff --git a/repos/ports/run/vbox_auto_win7.run b/repos/ports/run/vbox_auto_win7.run index c48282f72..9445c37ef 100644 --- a/repos/ports/run/vbox_auto_win7.run +++ b/repos/ports/run/vbox_auto_win7.run @@ -7,7 +7,7 @@ set flavor "win7" # Write overlay back to harddisk if set to 0 set use_ram_fs 0 -set use_usb 0 +set use_usb 1 set use_ps2 [have_spec ps2] source ${genode_dir}/repos/ports/run/vbox_win.inc diff --git a/repos/ports/run/vbox_auto_win7_share.run b/repos/ports/run/vbox_auto_win7_share.run index f6b6a1aeb..1db4adbf0 100644 --- a/repos/ports/run/vbox_auto_win7_share.run +++ b/repos/ports/run/vbox_auto_win7_share.run @@ -102,7 +102,7 @@ catch { exec dd if=/dev/urandom of=bin/test.bin bs=4096 count=8160 } # Step 1: prepare and start the actual VM # set build_components { - server/ram_fs + server/ram_fs server/report_rom server/tcp_terminal drivers/nic lib/libc_noux noux/minimal @@ -117,7 +117,7 @@ foreach pkg {bash coreutils} { set boot_modules { ram_fs noux libc_noux.lib.so bash.tar coreutils.tar - tcp_terminal lwip.lib.so nic_drv + tcp_terminal lwip.lib.so nic_drv report_rom test.bin template.bat vm_auto_share.vbox } @@ -189,6 +189,12 @@ set config_of_app { + + + + + + diff --git a/repos/ports/run/vbox_auto_win8.run b/repos/ports/run/vbox_auto_win8.run index bf945c75c..dfac76b8d 100644 --- a/repos/ports/run/vbox_auto_win8.run +++ b/repos/ports/run/vbox_auto_win8.run @@ -9,7 +9,7 @@ set flavor "win8" # Write overlay back to harddisk if set to 0 set use_ram_fs 0 -set use_usb 0 +set use_usb 1 set use_ps2 [have_spec ps2] source ${genode_dir}/repos/ports/run/vbox_win.inc diff --git a/repos/ports/run/vbox_win.inc b/repos/ports/run/vbox_win.inc index 898e36028..9c3e9b861 100644 --- a/repos/ports/run/vbox_win.inc +++ b/repos/ports/run/vbox_win.inc @@ -10,10 +10,120 @@ set vdi_image "${flavor}.vdi" set vbox_file "vm_${flavor}.vbox" set overlay_image "overlay_${flavor}.vdi" -set build_components { } -set boot_modules { } +set build_components { + server/input_merger + drivers/nic + server/nitpicker + app/vbox_pointer + server/nit_fb + server/report_rom +} + +set boot_modules { + input_merger + nic_drv + nitpicker + vbox_pointer + nit_fb + report_rom +} set config_of_app { + + + + + + + } +append_if [expr $use_ps2] config_of_app { + } +append_if [expr $use_usb] config_of_app { + } +append config_of_app { + + } +append_if [expr $use_ps2] config_of_app { + + + } +append_if [expr $use_usb] config_of_app { + + + } +append config_of_app { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } @@ -44,6 +154,8 @@ append_if [expr $use_ram_fs] config_of_app { append config_of_app { + + diff --git a/repos/ports/run/virtualbox_auto.inc b/repos/ports/run/virtualbox_auto.inc index 2f8637441..086f41341 100644 --- a/repos/ports/run/virtualbox_auto.inc +++ b/repos/ports/run/virtualbox_auto.inc @@ -41,7 +41,7 @@ set config { - + @@ -139,7 +139,7 @@ append_if [have_spec framebuffer] config { - + } append_if [have_spec x86] config { diff --git a/repos/ports/src/app/vbox_pointer/big_mouse.h b/repos/ports/src/app/vbox_pointer/big_mouse.h new file mode 100644 index 000000000..8a2921286 --- /dev/null +++ b/repos/ports/src/app/vbox_pointer/big_mouse.h @@ -0,0 +1,36 @@ +/* + * \brief Mouse cursor pixel data + * \author Norman Feske + * \date 2006-08-09 + */ + +/* + * Copyright (C) 2006-2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +static struct { + unsigned short w, h, pixels[16][16]; +} big_mouse = { + 16,16, + { + {0x738E,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x94B2,0x7BCF,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x630C,0xC638,0xC638,0x6B4D,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x738E,0x8C71,0xFFFF,0xB5B6,0x6B4D,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x630C,0x4A49,0x630C,0xB5B6,0xFFFF,0xB5B6,0x630C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x528A,0x528A,0x630C,0x9492,0xB5B6,0xFFFF,0xB5B6,0x630C,0x0000,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x528A,0x39C7,0x4208,0x630C,0x7BCF,0xB5B6,0xFFFF,0xFFFF,0xB5B6,0x630C,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x4208,0x39C7,0x4208,0x630C,0x7BCF,0xB5B6,0xDEFB,0xFFFF,0xFFFF,0xB5B6,0x630C,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x4A49,0x1082,0x39C7,0x4208,0x5ACB,0x7BCF,0x8C71,0xAD75,0x630C,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x0000,0x4208,0x1082,0x39C7,0x5ACB,0x630C,0xB5B6,0x0000,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x0000,0x4A49,0x1082,0x1082,0x39C7,0x4A49,0x630C,0xAD75,0x0000,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4208,0x1082,0x4A49,0x0000,0x4A49,0x630C,0x8C71,0x0000,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4A49,0x39C7,0x4A49,0x0000,0x0000,0x4A49,0x630C,0x8C71,0x0000,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4A49,0x0000,0x0000,0x0000,0x0000,0x4A49,0x630C,0x8C71,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4A49,0x0000,0x0000,0x0000,0x0000,0x0000,0x4A49,0x4A49,0x0000}, + {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000}, + } +}; diff --git a/repos/ports/src/app/vbox_pointer/main.cc b/repos/ports/src/app/vbox_pointer/main.cc new file mode 100644 index 000000000..59aef95e6 --- /dev/null +++ b/repos/ports/src/app/vbox_pointer/main.cc @@ -0,0 +1,410 @@ +/* + * \brief Nitpicker pointer with support for VirtualBox-defined shapes + * \author Norman Feske + * \author Christian Helmuth + * \author Christian Prochaska + * \date 2014-07-02 + */ + +/* + * Copyright (C) 2014-2015 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* local includes */ +#include "big_mouse.h" + +/* exception */ +struct Pointer_shape_too_large { }; + +template +void convert_default_cursor_data_to_pixels(PT *pixel, Nitpicker::Area size) +{ + unsigned char *alpha = (unsigned char *)(pixel + size.count()); + + for (unsigned y = 0; y < size.h(); y++) { + for (unsigned x = 0; x < size.w(); x++) { + + /* the source is known to be in RGB565 format */ + Genode::Pixel_rgb565 src = + *(Genode::Pixel_rgb565 *)(&big_mouse.pixels[y][x]); + + unsigned const i = y*size.w() + x; + pixel[i] = PT(src.r(), src.g(), src.b()); + alpha[i] = src.r() ? 255 : 0; + } + } +} + +template +void convert_vbox_cursor_data_to_pixels(PT *pixel, unsigned char *shape, + Nitpicker::Area size) +{ + Genode::Attached_ram_dataspace texture_pixel_ds { Genode::env()->ram_session(), + size.count() * + sizeof(Genode::Pixel_rgb888) }; + + Genode::Attached_ram_dataspace texture_alpha_ds { Genode::env()->ram_session(), + size.count() }; + + Genode::Texture + texture(texture_pixel_ds.local_addr(), + texture_alpha_ds.local_addr(), + size); + + for (unsigned int y = 0; y < size.h(); y++) { + + /* convert the shape data from BGRA encoding to RGBA encoding */ + unsigned char *bgra_line = &shape[y * size.w() * 4]; + unsigned char rgba_line[size.w() * 4]; + for (unsigned int i = 0; i < size.w() * 4; i += 4) { + rgba_line[i + 0] = bgra_line[i + 2]; + rgba_line[i + 1] = bgra_line[i + 1]; + rgba_line[i + 2] = bgra_line[i + 0]; + rgba_line[i + 3] = bgra_line[i + 3]; + } + + /* import the RGBA-encoded line into the texture */ + texture.rgba(rgba_line, size.w(), y); + } + + Genode::Pixel_alpha8 *alpha = + reinterpret_cast(pixel + size.count()); + + Genode::Surface pixel_surface(pixel, size); + Genode::Surface alpha_surface(alpha, size); + + Dither_painter::paint(pixel_surface, texture); + Dither_painter::paint(alpha_surface, texture); +} + +//struct Log { Log(char const *msg) { PINF("Log: %s", msg); } }; + + +typedef Genode::String<64> Domain_name; + +class Domain : public Genode::List::Element +{ + public: + + struct Name_too_long { }; + + private: + + Domain_name _name; + + public: + + Domain(char const *name) : _name(name) + { + if (Genode::strlen(name) + 1 > _name.capacity()) + throw Name_too_long(); + } + + Domain_name const & name() { return _name; } +}; + + +struct Domain_list : private Genode::List +{ + void add(char const *name) + { + Domain *d = new (Genode::env()->heap()) Domain(name); + insert(d); + } + + bool contains(Domain_name const &name) + { + for (Domain *d = first(); d; d = d->next()) + if (d->name() == name) + return true; + + return false; + } +}; + + +struct Main +{ + Genode::Attached_rom_dataspace hover_ds { "hover" }; + Genode::Attached_rom_dataspace xray_ds { "xray" }; + Genode::Attached_rom_dataspace shape_ds { "shape" }; + + Genode::Signal_receiver sig_rec; + + void handle_hover(unsigned num = 0); + void handle_xray(unsigned num = 0); + void handle_shape(unsigned num = 0); + + Genode::Signal_dispatcher
hover_signal_dispatcher { + sig_rec, *this, &Main::handle_hover }; + Genode::Signal_dispatcher
xray_signal_dispatcher { + sig_rec, *this, &Main::handle_xray }; + Genode::Signal_dispatcher
shape_signal_dispatcher { + sig_rec, *this, &Main::handle_shape }; + + Nitpicker::Connection nitpicker; + + Nitpicker::Session::View_handle view = nitpicker.create_view(); + + Domain_list vbox_domains; + Domain_name current_domain; + + bool xray = false; + bool default_pointer_visible = false; + bool vbox_pointer_visible = false; + bool vbox_pointer_shape_changed = false; + + Nitpicker::Area current_cursor_size; + Genode::Dataspace_capability pointer_ds; + + void resize_nitpicker_buffer_if_needed(Nitpicker::Area cursor_size) + { + if (cursor_size != current_cursor_size) { + + Framebuffer::Mode const mode { (int)cursor_size.w(), (int)cursor_size.h(), + Framebuffer::Mode::RGB565 }; + + nitpicker.buffer(mode, true /* use alpha */); + + pointer_ds = nitpicker.framebuffer()->dataspace(); + + current_cursor_size = cursor_size; + } + } + + void show_default_pointer() + { + if (!default_pointer_visible) { + + Nitpicker::Area const cursor_size { big_mouse.w, big_mouse.h }; + + try { + resize_nitpicker_buffer_if_needed(cursor_size); + } catch (...) { + PERR("%s: could not resize the pointer buffer for %u x %u pixels", + __func__, cursor_size.w(), cursor_size.h()); + return; + } + + Genode::Attached_dataspace ds { pointer_ds }; + + convert_default_cursor_data_to_pixels(ds.local_addr(), + cursor_size); + nitpicker.framebuffer()->refresh(0, 0, cursor_size.w(), cursor_size.h()); + + Nitpicker::Rect geometry(Nitpicker::Point(0, 0), cursor_size); + nitpicker.enqueue(view, geometry); + nitpicker.execute(); + + default_pointer_visible = true; + vbox_pointer_visible = false; + } + } + + void show_vbox_pointer() + { + if (!vbox_pointer_visible || vbox_pointer_shape_changed) { + + try { + + Vbox_pointer::Shape_report *shape_report = + shape_ds.local_addr(); + + if (shape_report->visible) { + + if ((shape_report->width == 0) || (shape_report->height == 0)) + return; + + if ((shape_report->width > Vbox_pointer::MAX_WIDTH) || + (shape_report->height > Vbox_pointer::MAX_HEIGHT)) + throw Pointer_shape_too_large(); + + Nitpicker::Area const cursor_size { shape_report->width, + shape_report->height }; + + resize_nitpicker_buffer_if_needed(cursor_size); + + Genode::Attached_dataspace ds { pointer_ds }; + + convert_vbox_cursor_data_to_pixels(ds.local_addr(), + shape_report->shape, + cursor_size); + nitpicker.framebuffer()->refresh(0, 0, cursor_size.w(), cursor_size.h()); + + Nitpicker::Rect geometry(Nitpicker::Point(-shape_report->x_hot, -shape_report->y_hot), cursor_size); + nitpicker.enqueue(view, geometry); + + } else { + + Nitpicker::Rect geometry(Nitpicker::Point(0, 0), Nitpicker::Area(0, 0)); + nitpicker.enqueue(view, geometry); + + } + + } catch (Genode::Volatile_object::Deref_unconstructed_object) { + /* no shape has been reported, yet */ + Nitpicker::Rect geometry(Nitpicker::Point(0, 0), Nitpicker::Area(0, 0)); + nitpicker.enqueue(view, geometry); + } + + nitpicker.execute(); + + vbox_pointer_visible = true; + vbox_pointer_shape_changed = false; + default_pointer_visible = false; + } + } + + void update_pointer() + { + if (xray || !vbox_domains.contains(current_domain)) + show_default_pointer(); + else + try { + show_vbox_pointer(); + } catch (Pointer_shape_too_large) { + PERR("%s: the pointer shape is larger than the maximum supported size of %u x %u", + __func__, Vbox_pointer::MAX_WIDTH, Vbox_pointer::MAX_HEIGHT); + show_default_pointer(); + } catch (...) { + PERR("%s: an unhandled exception occurred while trying to show \ + the VirtualBox pointer", __func__); + show_default_pointer(); + } + } + + Main() + { + /* + * Try to allocate the Nitpicker buffer for the maximum supported + * pointer size to let the user know right from the start if the + * RAM quota is too low. + */ + Framebuffer::Mode const mode { Vbox_pointer::MAX_WIDTH, Vbox_pointer::MAX_HEIGHT, + Framebuffer::Mode::RGB565 }; + + nitpicker.buffer(mode, true /* use alpha */); + + /* TODO should be read from config */ + vbox_domains.add("vbox"); + + /* register signal handlers */ + hover_ds.sigh(hover_signal_dispatcher); + xray_ds.sigh(xray_signal_dispatcher); + shape_ds.sigh(shape_signal_dispatcher); + + nitpicker.enqueue(view); + nitpicker.execute(); + + /* import initial state */ + handle_hover(); + handle_xray(); + handle_shape(); + } +}; + + +static Domain_name read_string_attribute(Genode::Xml_node const &node, + char const *attr, + Domain_name const &default_value) +{ + try { + char buf[Domain_name::capacity()]; + node.attribute(attr).value(buf, sizeof(buf)); + return Domain_name(buf); + } + catch (...) { + return default_value; } +} + + +void Main::handle_hover(unsigned) +{ + hover_ds.update(); + if (!hover_ds.is_valid()) + return; + + /* read new hover information from nitpicker's hover report */ + try { + Genode::Xml_node node(hover_ds.local_addr()); + + current_domain = read_string_attribute(node, "domain", Domain_name()); + } + catch (...) { + PWRN("could not parse hover report"); + } + + update_pointer(); +} + + +void Main::handle_xray(unsigned) +{ + xray_ds.update(); + if (!xray_ds.is_valid()) + return; + + try { + Genode::Xml_node node(xray_ds.local_addr()); + + xray = node.has_attribute("enabled") + && node.attribute("enabled").has_value("yes"); + } + catch (...) { + PWRN("could not parse xray report"); + } + + update_pointer(); +} + + +void Main::handle_shape(unsigned) +{ + shape_ds.update(); + + if (!shape_ds.is_valid()) + return; + + if (shape_ds.size() < sizeof(Vbox_pointer::Shape_report)) + return; + + vbox_pointer_shape_changed = true; + + update_pointer(); +} + + +int main() +{ + static Main main; + + /* dispatch signals */ + for (;;) { + + Genode::Signal sig = main.sig_rec.wait_for_signal(); + Genode::Signal_dispatcher_base *dispatcher = + dynamic_cast(sig.context()); + + if (dispatcher) + dispatcher->dispatch(sig.num()); + } +} diff --git a/repos/ports/src/app/vbox_pointer/target.mk b/repos/ports/src/app/vbox_pointer/target.mk new file mode 100644 index 000000000..2280cd9f7 --- /dev/null +++ b/repos/ports/src/app/vbox_pointer/target.mk @@ -0,0 +1,3 @@ +TARGET = vbox_pointer +SRC_CC = main.cc +LIBS += base diff --git a/repos/ports/src/virtualbox/frontend/console.cc b/repos/ports/src/virtualbox/frontend/console.cc index 6a1575912..e92023b93 100644 --- a/repos/ports/src/virtualbox/frontend/console.cc +++ b/repos/ports/src/virtualbox/frontend/console.cc @@ -86,12 +86,9 @@ HRESULT Console::Teleport(unsigned short*, unsigned int, unsigned short*, unsigned int, Progress**) DUMMY(E_FAIL) HRESULT Console::setDiskEncryptionKeys(const Utf8Str &strCfg) DUMMY(E_FAIL) -void Console::onMouseCapabilityChange(BOOL, BOOL, BOOL, BOOL) TRACE() void Console::onAdditionsStateChange() TRACE() void Console::onAdditionsOutdated() DUMMY() -void Console::onMousePointerShapeChange(bool, bool, uint32_t, uint32_t, - uint32_t, uint32_t, - ComSafeArrayIn(uint8_t, aShape)) DUMMY() + void Console::onKeyboardLedsChange(bool, bool, bool) TRACE() HRESULT Console::onVideoCaptureChange() DUMMY(E_FAIL) HRESULT Console::onSharedFolderChange(BOOL aGlobal) DUMMY(E_FAIL) diff --git a/repos/ports/src/virtualbox/frontend/console.h b/repos/ports/src/virtualbox/frontend/console.h index d57925f99..4457c1701 100644 --- a/repos/ports/src/virtualbox/frontend/console.h +++ b/repos/ports/src/virtualbox/frontend/console.h @@ -24,6 +24,9 @@ /* VirtualBox includes */ #include "ConsoleImpl.h" #include +#include +#include +#include class Scan_code @@ -104,12 +107,15 @@ class GenodeConsole : public Console { private: - Input::Connection _input; - Genode::Signal_receiver _receiver; - Genode::Signal_context _context; - Input::Event *_ev_buf; - unsigned _ax, _ay; - bool _last_received_motion_event_was_absolute; + Input::Connection _input; + Genode::Signal_receiver _receiver; + Genode::Signal_context _context; + Input::Event *_ev_buf; + unsigned _ax, _ay; + bool _last_received_motion_event_was_absolute; + Report::Connection _shape_report_connection; + Genode::Attached_dataspace _shape_report_ds; + Vbox_pointer::Shape_report *_shape_report; bool _key_status[Input::KEY_MAX + 1]; @@ -127,7 +133,10 @@ class GenodeConsole : public Console { Console(), _ev_buf(static_cast(Genode::env()->rm_session()->attach(_input.dataspace()))), _ax(0), _ay(0), - _last_received_motion_event_was_absolute(false) + _last_received_motion_event_was_absolute(false), + _shape_report_connection("shape", sizeof(Vbox_pointer::Shape_report)), + _shape_report_ds(_shape_report_connection.dataspace()), + _shape_report(_shape_report_ds.local_addr()) { for (unsigned i = 0; i <= Input::KEY_MAX; i++) _key_status[i] = 0; @@ -284,4 +293,73 @@ class GenodeConsole : public Console { gMouse->PutEventMultiTouch(mt_number, mt_number, mt_events, RTTimeMilliTS()); } + + void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, + BOOL supportsMT, BOOL needsHostCursor) + { + if (supportsAbsolute) { + /* let the guest hide the software cursor */ + Mouse *gMouse = getMouse(); + gMouse->PutMouseEventAbsolute(-1, -1, 0, 0, 0); + } + } + + void onMousePointerShapeChange(bool fVisible, bool fAlpha, + uint32_t xHot, uint32_t yHot, + uint32_t width, uint32_t height, + ComSafeArrayIn(BYTE,pShape)) + { + com::SafeArray shape_array(ComSafeArrayInArg(pShape)); + + if (fVisible && ((width == 0) || (height == 0))) + return; + + _shape_report->visible = fVisible; + _shape_report->x_hot = xHot; + _shape_report->y_hot = yHot; + _shape_report->width = width; + _shape_report->height = height; + + unsigned int and_mask_size = (_shape_report->width + 7) / 8 * + _shape_report->height; + + unsigned char *and_mask = shape_array.raw(); + + unsigned char *shape = and_mask + ((and_mask_size + 3) & ~3); + + size_t shape_size = shape_array.size() - (shape - and_mask); + + if (shape_size > Vbox_pointer::MAX_SHAPE_SIZE) { + PERR("%s: shape data buffer is too small for %zu bytes", + __func__, shape_size); + return; + } + + Genode::memcpy(_shape_report->shape, + shape, + shape_size); + + if (fVisible && !fAlpha) { + + for (unsigned int i = 0; i < width * height; i++) { + + unsigned int *color = + &((unsigned int*)_shape_report->shape)[i]; + + /* heuristic from VBoxSDL.cpp */ + + if (and_mask[i / 8] & (1 << (7 - (i % 8)))) { + + if (*color & 0x00ffffff) + *color = 0xff000000; + else + *color = 0x00000000; + + } else + *color |= 0xff000000; + } + } + + _shape_report_connection.submit(sizeof(Vbox_pointer::Shape_report)); + } }; diff --git a/repos/ports/src/virtualbox/frontend/fb.h b/repos/ports/src/virtualbox/frontend/fb.h index 6f8a31f4e..e1a0b8a95 100644 --- a/repos/ports/src/virtualbox/frontend/fb.h +++ b/repos/ports/src/virtualbox/frontend/fb.h @@ -166,7 +166,13 @@ class Genodefb : public Framebuffer STDMETHODIMP VideoModeSupported(ULONG width, ULONG height, ULONG bpp, BOOL *supported) { - Assert(!"FixMe"); + if (!supported) + return E_POINTER; + + *supported = ((width <= (ULONG)_fb_mode.width()) && + (height <= (ULONG)_fb_mode.height()) && + (bpp == _fb_mode.bytes_per_pixel() * 8)); + return S_OK; } diff --git a/repos/ports/src/virtualbox/patches/fake_pci_vendor.patch b/repos/ports/src/virtualbox/patches/fake_pci_vendor.patch deleted file mode 100644 index 867dd5fca..000000000 --- a/repos/ports/src/virtualbox/patches/fake_pci_vendor.patch +++ /dev/null @@ -1,10 +0,0 @@ -+++ src/app/virtualbox/src/VBox/Devices/Graphics/DevVGA.cpp -@@ -5946,7 +5946,7 @@ - else - { - #endif /* VBOX_WITH_VMSVGA */ -- PCIDevSetVendorId( &pThis->Dev, 0x80ee); /* PCI vendor, just a free bogus value */ -+ PCIDevSetVendorId( &pThis->Dev, 0x80ef); /* PCI vendor, just a free bogus value */ - PCIDevSetDeviceId( &pThis->Dev, 0xbeef); - #ifdef VBOX_WITH_VMSVGA - } diff --git a/repos/ports/src/virtualbox/patches/vbox_main.patch b/repos/ports/src/virtualbox/patches/vbox_main.patch index 583a28c12..e059ca93f 100644 --- a/repos/ports/src/virtualbox/patches/vbox_main.patch +++ b/repos/ports/src/virtualbox/patches/vbox_main.patch @@ -1,5 +1,8 @@ +diff --git src/app/virtualbox/src/VBox/Main/include/ConsoleImpl.h src/app/virtualbox/src/VBox/Main/include/ConsoleImpl.h +index 030a601..fe6cb1c 100644 +--- src/app/virtualbox/src/VBox/Main/include/ConsoleImpl.h +++ src/app/virtualbox/src/VBox/Main/include/ConsoleImpl.h -@@ -50,7 +50,9 @@ +@@ -50,7 +50,9 @@ class VMMDevMouseInterface; class DisplayMouseInterface; #include @@ -9,7 +12,7 @@ #include #ifdef VBOX_WITH_GUEST_PROPS # include /* For the property notification callback */ -@@ -261,10 +263,12 @@ +@@ -261,10 +263,12 @@ public: ULONG aBalloonedVMM, ULONG aSharedVMM, ULONG aVmNetRx, ULONG aVmNetTx) { @@ -22,8 +25,30 @@ } void enableVMMStatistics(BOOL aEnable); +@@ -274,12 +278,12 @@ public: + + // callback callers (partly; for some events console callbacks are notified + // directly from IInternalSessionControl event handlers declared above) +- void onMousePointerShapeChange(bool fVisible, bool fAlpha, +- uint32_t xHot, uint32_t yHot, +- uint32_t width, uint32_t height, +- ComSafeArrayIn(uint8_t, aShape)); +- void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, +- BOOL supportsMT, BOOL needsHostCursor); ++ virtual void onMousePointerShapeChange(bool fVisible, bool fAlpha, ++ uint32_t xHot, uint32_t yHot, ++ uint32_t width, uint32_t height, ++ ComSafeArrayIn(uint8_t, aShape)) = 0; ++ virtual void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, ++ BOOL supportsMT, BOOL needsHostCursor) = 0; + void onStateChange(MachineState_T aMachineState); + void onAdditionsStateChange(); + void onAdditionsOutdated(); +diff --git src/app/virtualbox/src/VBox/Main/include/DisplayImpl.h src/app/virtualbox/src/VBox/Main/include/DisplayImpl.h +index 585f6b2..368453c 100644 +--- src/app/virtualbox/src/VBox/Main/include/DisplayImpl.h +++ src/app/virtualbox/src/VBox/Main/include/DisplayImpl.h -@@ -122,7 +122,7 @@ +@@ -122,7 +122,7 @@ typedef struct _DISPLAYFBINFO class DisplayMouseInterface { public: @@ -32,7 +57,7 @@ ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin) = 0; virtual void getFramebufferDimensions(int32_t *px1, int32_t *py1, int32_t *px2, int32_t *py2) = 0; -@@ -132,6 +132,7 @@ +@@ -132,6 +132,7 @@ class VMMDev; class ATL_NO_VTABLE Display : public VirtualBoxBase, @@ -40,7 +65,7 @@ VBOX_SCRIPTABLE_IMPL(IEventListener), VBOX_SCRIPTABLE_IMPL(IDisplay), public DisplayMouseInterface -@@ -192,7 +193,7 @@ +@@ -192,7 +193,7 @@ public: return maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer; } void getFramebufferDimensions(int32_t *px1, int32_t *py1, int32_t *px2, int32_t *py2); @@ -49,7 +74,7 @@ ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin) { return GetScreenResolution(cScreen, pcx, pcy, pcBPP, pXOrigin, pYOrigin); -@@ -232,6 +233,8 @@ +@@ -232,6 +233,8 @@ public: static const PDMDRVREG DrvReg; @@ -58,8 +83,11 @@ private: int updateDisplayData(void); +diff --git src/app/virtualbox/src/VBox/Main/include/FramebufferImpl.h src/app/virtualbox/src/VBox/Main/include/FramebufferImpl.h +index feebfcd..4136d6d 100644 +--- src/app/virtualbox/src/VBox/Main/include/FramebufferImpl.h +++ src/app/virtualbox/src/VBox/Main/include/FramebufferImpl.h -@@ -70,6 +70,7 @@ +@@ -70,6 +70,7 @@ public: STDMETHOD(SetVisibleRegion)(BYTE *aRectangles, ULONG aCount) = 0; STDMETHOD(ProcessVHWACommand)(BYTE *pCommand) = 0; @@ -67,8 +95,11 @@ }; #endif // ____H_H_FRAMEBUFFERIMPL +diff --git src/app/virtualbox/src/VBox/Main/include/MachineImpl.h src/app/virtualbox/src/VBox/Main/include/MachineImpl.h +index bb91290..d3c6d85 100644 +--- src/app/virtualbox/src/VBox/Main/include/MachineImpl.h +++ src/app/virtualbox/src/VBox/Main/include/MachineImpl.h -@@ -1213,7 +1213,7 @@ +@@ -1213,7 +1213,7 @@ private: HRESULT setMachineState(MachineState_T aMachineState); HRESULT updateMachineStateOnClient(); @@ -77,8 +108,11 @@ ConsoleTaskData mConsoleTaskData; +diff --git src/app/virtualbox/src/VBox/Main/include/MediumFormatImpl.h src/app/virtualbox/src/VBox/Main/include/MediumFormatImpl.h +index 2acdc6e..88ac27c 100644 +--- src/app/virtualbox/src/VBox/Main/include/MediumFormatImpl.h +++ src/app/virtualbox/src/VBox/Main/include/MediumFormatImpl.h -@@ -72,6 +72,8 @@ +@@ -72,6 +72,8 @@ public: /** Const, no need to lock */ const PropertyArray &i_getProperties() const { return m.maProperties; } @@ -87,6 +121,9 @@ private: // wrapped IMediumFormat properties +diff --git src/app/virtualbox/src/VBox/Main/include/NetworkServiceRunner.h src/app/virtualbox/src/VBox/Main/include/NetworkServiceRunner.h +index f0ec275..78a390e 100644 +--- src/app/virtualbox/src/VBox/Main/include/NetworkServiceRunner.h +++ src/app/virtualbox/src/VBox/Main/include/NetworkServiceRunner.h @@ -15,6 +15,9 @@ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. @@ -98,14 +135,17 @@ #include #include #include -@@ -55,3 +58,5 @@ +@@ -55,3 +58,5 @@ private: struct Data; Data *m; }; + +#endif /* ____H_H_NetworkServiceRunner */ +diff --git src/app/virtualbox/src/VBox/Main/include/ProgressImpl.h src/app/virtualbox/src/VBox/Main/include/ProgressImpl.h +index 6b01274..70aca28 100644 +--- src/app/virtualbox/src/VBox/Main/include/ProgressImpl.h +++ src/app/virtualbox/src/VBox/Main/include/ProgressImpl.h -@@ -103,7 +103,7 @@ +@@ -103,7 +103,7 @@ public: #if !defined (VBOX_COM_INPROC) VirtualBox *aParent, #endif @@ -114,7 +154,7 @@ CBSTR aDescription, BOOL aCancelable, OUT_GUID aId = NULL) -@@ -138,7 +138,7 @@ +@@ -138,7 +138,7 @@ public: #if !defined (VBOX_COM_INPROC) VirtualBox *aParent, #endif @@ -123,7 +163,7 @@ CBSTR aDescription, BOOL aCancelable, ULONG cOperations, CBSTR bstrFirstOperationDescription, -@@ -162,7 +162,7 @@ +@@ -162,7 +162,7 @@ public: #if !defined (VBOX_COM_INPROC) VirtualBox *aParent, #endif @@ -132,7 +172,7 @@ CBSTR aDescription, BOOL aCancelable, ULONG cOperations, -@@ -180,7 +180,7 @@ +@@ -180,7 +180,7 @@ public: #if !defined (VBOX_COM_INPROC) VirtualBox *aParent, #endif @@ -141,8 +181,11 @@ CBSTR aDescription, OUT_GUID aId = NULL); HRESULT init(AutoInitSpan &aAutoInitSpan); void init(AutoUninitSpan &aAutoUninitSpan); +diff --git src/app/virtualbox/src/VBox/Main/include/ProgressProxyImpl.h src/app/virtualbox/src/VBox/Main/include/ProgressProxyImpl.h +index 66f2b31..0ac7ab8 100644 +--- src/app/virtualbox/src/VBox/Main/include/ProgressProxyImpl.h +++ src/app/virtualbox/src/VBox/Main/include/ProgressProxyImpl.h -@@ -52,7 +52,7 @@ +@@ -52,7 +52,7 @@ public: #if !defined (VBOX_COM_INPROC) VirtualBox *pParent, #endif @@ -151,8 +194,11 @@ CBSTR bstrDescription, BOOL fCancelable, ULONG uTotalOperationsWeight, +diff --git src/app/virtualbox/src/VBox/Main/include/SessionImpl.h src/app/virtualbox/src/VBox/Main/include/SessionImpl.h +index b0f600e..4ee298c 100644 +--- src/app/virtualbox/src/VBox/Main/include/SessionImpl.h +++ src/app/virtualbox/src/VBox/Main/include/SessionImpl.h -@@ -135,5 +135,7 @@ +@@ -135,5 +135,7 @@ private: ClientTokenHolder *mClientTokenHolder; }; @@ -160,8 +206,11 @@ + #endif // !____H_SESSIONIMPL /* vi: set tabstop=4 shiftwidth=4 expandtab: */ +diff --git src/app/virtualbox/src/VBox/Main/src-all/EventImpl.cpp src/app/virtualbox/src/VBox/Main/src-all/EventImpl.cpp +index 182f267..90b8716 100644 +--- src/app/virtualbox/src/VBox/Main/src-all/EventImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-all/EventImpl.cpp -@@ -1263,7 +1263,8 @@ +@@ -1263,7 +1263,8 @@ STDMETHODIMP EventSource::EventProcessed(IEventListener *aListener, */ class ATL_NO_VTABLE PassiveEventListener : public VirtualBoxBase, @@ -171,7 +220,7 @@ { public: -@@ -1302,7 +1303,8 @@ +@@ -1302,7 +1303,8 @@ public: /* Proxy listener class, used to aggregate multiple event sources into one */ class ATL_NO_VTABLE ProxyEventListener : public VirtualBoxBase, @@ -181,7 +230,7 @@ { ComPtr mSource; public: -@@ -1349,8 +1351,9 @@ +@@ -1349,8 +1351,9 @@ public: }; class ATL_NO_VTABLE EventSourceAggregator : @@ -193,7 +242,7 @@ { typedef std::list > EventSourceList; /* key is weak reference */ -@@ -1417,6 +1420,7 @@ +@@ -1417,6 +1420,7 @@ public: HRESULT removeProxyListener(IEventListener *aListener); }; @@ -201,7 +250,7 @@ #ifdef VBOX_WITH_XPCOM NS_DECL_CLASSINFO(ProxyEventListener) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(ProxyEventListener, IEventListener) -@@ -1431,6 +1435,7 @@ +@@ -1431,6 +1435,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1_CI(EventSource, IEventSource) NS_DECL_CLASSINFO(EventSourceAggregator) NS_IMPL_THREADSAFE_ISUPPORTS1_CI(EventSourceAggregator, IEventSource) #endif @@ -209,8 +258,11 @@ STDMETHODIMP EventSource::CreateListener(IEventListener **aListener) +diff --git src/app/virtualbox/src/VBox/Main/src-all/PCIDeviceAttachmentImpl.cpp src/app/virtualbox/src/VBox/Main/src-all/PCIDeviceAttachmentImpl.cpp +index e984238..b02cb45 100644 +--- src/app/virtualbox/src/VBox/Main/src-all/PCIDeviceAttachmentImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-all/PCIDeviceAttachmentImpl.cpp -@@ -131,6 +131,6 @@ +@@ -131,6 +131,6 @@ STDMETHODIMP PCIDeviceAttachment::COMGETTER(GuestAddress)(LONG * aGuestAddress) } #ifdef VBOX_WITH_XPCOM @@ -219,6 +271,9 @@ +//NS_DECL_CLASSINFO(PCIDeviceAttachment) +//NS_IMPL_THREADSAFE_ISUPPORTS1_CI(PCIDeviceAttachment, IPCIDeviceAttachment) #endif +diff --git src/app/virtualbox/src/VBox/Main/src-all/ProgressImpl.cpp src/app/virtualbox/src/VBox/Main/src-all/ProgressImpl.cpp +index fa3ecea..f372edc 100644 +--- src/app/virtualbox/src/VBox/Main/src-all/ProgressImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-all/ProgressImpl.cpp @@ -20,9 +20,9 @@ @@ -233,7 +288,7 @@ #endif /* defined(VBOX_WITH_XPCOM) */ #include "ProgressImpl.h" -@@ -98,7 +98,7 @@ +@@ -98,7 +98,7 @@ STDMETHODIMP Progress::COMGETTER(Initiator)(IUnknown **aInitiator) else { ComObjPtr pVirtualBox(mParent); @@ -242,7 +297,7 @@ } #else mInitiator.queryInterfaceTo(aInitiator); -@@ -514,7 +514,7 @@ +@@ -514,7 +514,7 @@ HRESULT Progress::init( #if !defined(VBOX_COM_INPROC) VirtualBox *aParent, #endif @@ -251,7 +306,7 @@ CBSTR aDescription, BOOL aCancelable, ULONG cOperations, -@@ -573,8 +573,10 @@ +@@ -573,8 +573,10 @@ HRESULT Progress::init( #endif unconst(mId).create(); @@ -262,7 +317,7 @@ #if !defined(VBOX_COM_INPROC) /* add to the global collection of progress operations (note: after -@@ -1057,7 +1059,7 @@ +@@ -1057,7 +1059,7 @@ HRESULT Progress::setResultCode(HRESULT aResultCode) } #else /* !defined(VBOX_WITH_XPCOM) */ @@ -271,7 +326,7 @@ nsCOMPtr es; es = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID, &rc); if (NS_SUCCEEDED(rc)) -@@ -1076,6 +1078,7 @@ +@@ -1076,6 +1078,7 @@ HRESULT Progress::setResultCode(HRESULT aResultCode) } } } @@ -279,6 +334,9 @@ #endif /* !defined(VBOX_WITH_XPCOM) */ AssertMsg(rc == S_OK, ("Couldn't get error info (rc=%08X) while trying to set a failed result (%08X)!\n", +diff --git src/app/virtualbox/src/VBox/Main/src-all/VirtualBoxBase.cpp src/app/virtualbox/src/VBox/Main/src-all/VirtualBoxBase.cpp +index b43f5a6..6aef9df 100644 +--- src/app/virtualbox/src/VBox/Main/src-all/VirtualBoxBase.cpp +++ src/app/virtualbox/src/VBox/Main/src-all/VirtualBoxBase.cpp @@ -23,6 +23,7 @@ @@ -296,7 +354,7 @@ #include "VirtualBoxBase.h" #include "AutoCaller.h" -@@ -296,6 +298,7 @@ +@@ -296,6 +298,7 @@ void VirtualBoxBase::releaseCaller() AssertMsgFailed (("mState = %d!", mState)); } @@ -304,7 +362,7 @@ /** * Handles unexpected exceptions by turning them into COM errors in release * builds or by hitting a breakpoint in the release builds. -@@ -770,6 +773,7 @@ +@@ -770,6 +773,7 @@ void VirtualBoxBase::clearError(void) #endif } @@ -312,174 +370,9 @@ //////////////////////////////////////////////////////////////////////////////// // -+++ src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl2.cpp -@@ -27,6 +27,7 @@ - #include "VBox/com/ptr.h" - - #include "ConsoleImpl.h" -+#include "MachineImpl.h" - #include "DisplayImpl.h" - #ifdef VBOX_WITH_GUEST_CONTROL - # include "GuestImpl.h" -@@ -129,6 +130,7 @@ - *******************************************************************************/ - static Utf8Str *GetExtraDataBoth(IVirtualBox *pVirtualBox, IMachine *pMachine, const char *pszName, Utf8Str *pStrValue); - -+#if 0 - - - #if defined(RT_OS_DARWIN) -@@ -202,6 +204,7 @@ - /* Comment out the following line to remove VMWare compatibility hack. */ - #define VMWARE_NET_IN_SLOT_11 - -+#endif - /** - * Translate IDE StorageControllerType_T to string representation. - */ -@@ -522,12 +525,12 @@ - - #define MAX_BIOS_LUN_COUNT 4 - --static int SetBiosDiskInfo(ComPtr pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg, -+static HRESULT SetBiosDiskInfo(ComPtr pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg, - Bstr controllerName, const char * const s_apszBiosConfig[4]) - { - HRESULT hrc; - #define MAX_DEVICES 30 --#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_GENERAL_FAILURE) -+#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), E_FAIL) - - LONG lPortLUN[MAX_BIOS_LUN_COUNT]; - LONG lPortUsed[MAX_DEVICES]; -@@ -599,9 +602,11 @@ - LogFlowFunc(("Top %d HBA ports = %s, %d\n", j, s_apszBiosConfig[j], lPortLUN[j])); - } - } -- return VINF_SUCCESS; -+#undef H -+ return S_OK; - } - -+#if 0 - #ifdef VBOX_WITH_PCI_PASSTHROUGH - HRESULT Console::attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *pBusMgr, PCFGMNODE pDevices) - { -@@ -741,6 +746,7 @@ - } - #endif - -+#endif /* if 0 */ - - void Console::attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds, - uint64_t uFirst, uint64_t uLast, -@@ -2070,6 +2076,8 @@ - case NetworkAdapterType_I82545EM: - InsertConfigInteger(pCfg, "AdapterType", 2); - break; -+ default: -+ break; - } - - /* -@@ -2225,6 +2233,7 @@ - /* - * Parallel (LPT) Ports - */ -+#if 0 - InsertConfigNode(pDevices, "parallel", &pDev); - for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ++ulInstance) - { -@@ -2254,6 +2263,7 @@ - InsertConfigString(pLunL1, "DevicePath", bstr); - } - -+#endif - /* - * VMM Device - */ -@@ -2286,6 +2296,7 @@ - /* - * Audio Sniffer Device - */ -+#if 0 - InsertConfigNode(pDevices, "AudioSniffer", &pDev); - InsertConfigNode(pDev, "0", &pInst); - InsertConfigNode(pInst, "Config", &pCfg); -@@ -2300,9 +2311,12 @@ - /* - * AC'97 ICH / SoundBlaster16 audio / Intel HD Audio - */ -+#endif - BOOL fAudioEnabled = FALSE; - ComPtr audioAdapter; -+#if 0 - hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H(); -+#endif - if (audioAdapter) - hrc = audioAdapter->COMGETTER(Enabled)(&fAudioEnabled); H(); - -@@ -2421,6 +2435,8 @@ - break; - } - #endif -+ default: -+ break; - } - hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H(); - InsertConfigString(pCfg, "StreamName", bstr); -@@ -3533,6 +3551,8 @@ - ComPtr pMedium; - hrc = pMediumAtt->COMGETTER(Medium)(pMedium.asOutParam()); H(); - -+#if 0 -+ - /* - * 1. Only check this for hard disk images. - * 2. Only check during VM creation and not later, especially not during -@@ -3717,6 +3737,8 @@ - } - } - -+#endif /* if 0 */ -+ - if (pMedium) - { - BOOL fHostDrive; -@@ -3810,7 +3832,7 @@ - // InsertConfig* throws - try - { -- int rc = VINF_SUCCESS; -+// int rc = VINF_SUCCESS; - HRESULT hrc; - Bstr bstr; - PCFGMNODE pLunL1 = NULL; -@@ -4414,7 +4436,7 @@ - { - switch (hrc) - { -- case VERR_ACCESS_DENIED: -+ case E_ACCESSDENIED: - return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_( - "Failed to open '/dev/net/tun' for read/write access. Please check the " - "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or " -@@ -4428,12 +4450,12 @@ - } - } - -- Assert((int)maTapFD[uInstance] >= 0); -- if ((int)maTapFD[uInstance] >= 0) -+ Assert((long)maTapFD[uInstance] >= 0); -+ if ((long)maTapFD[uInstance] >= 0) - { - InsertConfigString(pLunL0, "Driver", "HostInterface"); - InsertConfigNode(pLunL0, "Config", &pCfg); -- InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]); -+ InsertConfigInteger(pCfg, "FileHandle", (long)maTapFD[uInstance]); - } - - #elif defined(VBOX_WITH_NETFLT) +diff --git src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp +index 69e3109..289e7f3 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl.cpp @@ -51,10 +51,14 @@ #include "KeyboardImpl.h" @@ -531,7 +424,7 @@ #include #include #include // for auto_ptr -@@ -278,6 +288,8 @@ +@@ -278,6 +288,8 @@ struct VMSaveTask : public VMTask Reason_T mReason; }; @@ -540,7 +433,7 @@ // Handler for global events //////////////////////////////////////////////////////////////////////////////// inline static const char *networkAdapterTypeToName(NetworkAdapterType_T adapterType); -@@ -383,6 +395,7 @@ +@@ -383,6 +395,7 @@ typedef ListenerImpl VmEventListenerImpl; VBOX_LISTENER_DECLARE(VmEventListenerImpl) @@ -548,7 +441,7 @@ // constructor / destructor ///////////////////////////////////////////////////////////////////////////// -@@ -530,6 +543,7 @@ +@@ -530,6 +543,7 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc rc = mDisplay->init(this); AssertComRCReturnRC(rc); @@ -556,7 +449,7 @@ unconst(mVRDEServerInfo).createObject(); rc = mVRDEServerInfo->init(this); AssertComRCReturnRC(rc); -@@ -538,6 +552,7 @@ +@@ -538,6 +552,7 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc rc = mEmulatedUSB->init(this); AssertComRCReturnRC(rc); @@ -564,7 +457,7 @@ /* Grab global and machine shared folder lists */ rc = fetchSharedFolders(true /* aGlobal */); -@@ -545,10 +560,12 @@ +@@ -545,10 +560,12 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc rc = fetchSharedFolders(false /* aGlobal */); AssertComRCReturnRC(rc); @@ -577,7 +470,7 @@ /* Figure out size of meAttachmentType vector */ ComPtr pVirtualBox; -@@ -574,9 +591,11 @@ +@@ -574,9 +591,11 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc // unconst(m_pVMMDev) = new VMMDev(this); // AssertReturn(mVMMDev, E_FAIL); @@ -589,7 +482,7 @@ FirmwareType_T enmFirmwareType; mMachine->COMGETTER(FirmwareType)(&enmFirmwareType); if ( enmFirmwareType == FirmwareType_EFI -@@ -584,8 +603,10 @@ +@@ -584,8 +603,10 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc || enmFirmwareType == FirmwareType_EFI64 || enmFirmwareType == FirmwareType_EFIDUAL) { @@ -600,7 +493,7 @@ } #ifdef VBOX_WITH_USB_CARDREADER -@@ -593,6 +614,7 @@ +@@ -593,6 +614,7 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc AssertReturn(mUsbCardReader, E_FAIL); #endif @@ -608,7 +501,7 @@ /* VirtualBox events registration. */ { ComPtr pES; -@@ -609,6 +631,7 @@ +@@ -609,6 +631,7 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc rc = pES->RegisterListener(aVmListener, ComSafeArrayAsInParam(eventTypes), true); AssertComRC(rc); } @@ -616,7 +509,7 @@ } /* Confirm a successful initialization when it's the case */ -@@ -625,6 +648,7 @@ +@@ -625,6 +648,7 @@ HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, Loc return S_OK; } @@ -624,7 +517,7 @@ /** * Uninitializes the Console object. */ -@@ -1035,6 +1059,8 @@ +@@ -1035,6 +1059,8 @@ void Console::guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId) #endif /* VBOX_WITH_GUEST_PROPS */ @@ -633,7 +526,7 @@ bool Console::isResetTurnedIntoPowerOff(void) { Bstr value; -@@ -1046,6 +1072,8 @@ +@@ -1046,6 +1072,8 @@ bool Console::isResetTurnedIntoPowerOff(void) return false; } @@ -642,7 +535,7 @@ #ifdef VBOX_WITH_EXTPACK /** * Used by VRDEServer and others to talke to the extension pack manager. -@@ -1505,6 +1533,7 @@ +@@ -1505,6 +1533,7 @@ void Console::VRDPInterceptClipboard(uint32_t u32ClientId) return; } @@ -650,7 +543,7 @@ //static const char *Console::sSSMConsoleUnit = "ConsoleData"; -@@ -1970,6 +1999,8 @@ +@@ -1970,6 +1999,8 @@ STDMETHODIMP Console::COMGETTER(Display)(IDisplay **aDisplay) return S_OK; } @@ -659,7 +552,7 @@ STDMETHODIMP Console::COMGETTER(Debugger)(IMachineDebugger **aDebugger) { CheckComArgOutPointerValid(aDebugger); -@@ -2069,6 +2100,7 @@ +@@ -2069,6 +2100,7 @@ Console::COMGETTER(SharedFolders)(ComSafeArrayOut(ISharedFolder *, aSharedFolder return S_OK; } @@ -667,7 +560,7 @@ STDMETHODIMP Console::COMGETTER(EventSource)(IEventSource ** aEventSource) { -@@ -2085,6 +2117,8 @@ +@@ -2085,6 +2117,8 @@ STDMETHODIMP Console::COMGETTER(EventSource)(IEventSource ** aEventSource) return hrc; } @@ -676,7 +569,7 @@ STDMETHODIMP Console::COMGETTER(AttachedPCIDevices)(ComSafeArrayOut(IPCIDeviceAttachment *, aAttachments)) { CheckComArgOutSafeArrayPointerValid(aAttachments); -@@ -2134,6 +2168,7 @@ +@@ -2134,6 +2168,7 @@ STDMETHODIMP Console::COMSETTER(UseHostClipboard)(BOOL aUseHostClipboard) // IConsole methods ///////////////////////////////////////////////////////////////////////////// @@ -684,7 +577,7 @@ STDMETHODIMP Console::PowerUp(IProgress **aProgress) { -@@ -2291,6 +2326,8 @@ +@@ -2291,6 +2326,8 @@ STDMETHODIMP Console::PowerDown(IProgress **aProgress) return rc; } @@ -693,7 +586,7 @@ STDMETHODIMP Console::Reset() { LogFlowThisFuncEnter(); -@@ -3451,6 +3488,8 @@ +@@ -3451,6 +3488,8 @@ STDMETHODIMP Console::RestoreSnapshot(ISnapshot *aSnapshot, IProgress **aProgres return S_OK; } @@ -702,7 +595,7 @@ // Non-interface public methods ///////////////////////////////////////////////////////////////////////////// -@@ -3526,6 +3565,8 @@ +@@ -3526,6 +3565,8 @@ HRESULT Console::convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG } } @@ -711,7 +604,7 @@ // private methods ///////////////////////////////////////////////////////////////////////////// -@@ -4388,6 +4429,8 @@ +@@ -4388,6 +4429,8 @@ HRESULT Console::onNATRedirectRuleChange(ULONG ulInstance, BOOL aNatRuleRemove, return rc; } @@ -720,7 +613,7 @@ VMMDevMouseInterface *Console::getVMMDevMouseInterface() { return m_pVMMDev; -@@ -4398,6 +4441,8 @@ +@@ -4398,6 +4441,8 @@ DisplayMouseInterface *Console::getDisplayMouseInterface() return mDisplay; } @@ -729,7 +622,7 @@ /** * Parses one key value pair. * -@@ -6490,6 +6535,8 @@ +@@ -6490,6 +6535,8 @@ void Console::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelati fireMouseCapabilityChangedEvent(mEventSource, supportsAbsolute, supportsRelative, supportsMT, needsHostCursor); } @@ -738,7 +631,7 @@ void Console::onStateChange(MachineState_T machineState) { AutoCaller autoCaller(this); -@@ -6497,6 +6544,8 @@ +@@ -6497,6 +6544,8 @@ void Console::onStateChange(MachineState_T machineState) fireStateChangedEvent(mEventSource, machineState); } @@ -747,7 +640,7 @@ void Console::onAdditionsStateChange() { AutoCaller autoCaller(this); -@@ -6555,6 +6604,8 @@ +@@ -6555,6 +6604,8 @@ void Console::onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached, fireUSBDeviceStateChangedEvent(mEventSource, aDevice, aAttached, aError); } @@ -756,7 +649,7 @@ void Console::onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage) { AutoCaller autoCaller(this); -@@ -6563,6 +6614,8 @@ +@@ -6563,6 +6614,8 @@ void Console::onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage) fireRuntimeErrorEvent(mEventSource, aFatal, aErrorID, aMessage); } @@ -765,7 +658,7 @@ HRESULT Console::onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId) { AssertReturn(aCanShow, E_POINTER); -@@ -6626,6 +6679,8 @@ +@@ -6626,6 +6679,8 @@ HRESULT Console::onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId) return S_OK; } @@ -774,7 +667,7 @@ // private methods //////////////////////////////////////////////////////////////////////////////// -@@ -6819,6 +6874,8 @@ +@@ -6819,6 +6874,8 @@ HRESULT Console::consoleInitReleaseLog(const ComPtr aMachine) } } @@ -783,7 +676,7 @@ char szError[RTPATH_MAX + 128]; int vrc = com::VBoxLogRelCreate("VM", logFile.c_str(), RTLOGFLAGS_PREFIX_TIME_PROG | RTLOGFLAGS_RESTRICT_GROUPS, -@@ -6839,6 +6896,8 @@ +@@ -6839,6 +6896,8 @@ HRESULT Console::consoleInitReleaseLog(const ComPtr aMachine) if (SUCCEEDED(hrc) || cHistoryFiles) RTDirFlush(logDir.c_str()); @@ -792,7 +685,7 @@ return hrc; } -@@ -7113,6 +7172,8 @@ +@@ -7113,6 +7172,8 @@ HRESULT Console::powerUp(IProgress **aProgress, bool aPaused) } #endif @@ -801,7 +694,7 @@ // If there is immutable drive the process that. VMPowerUpTask::ProgressList progresses(task->hardDiskProgresses); -@@ -7123,7 +7184,8 @@ +@@ -7123,7 +7184,8 @@ HRESULT Console::powerUp(IProgress **aProgress, bool aPaused) ++cOperations; ulTotalOperationsWeight += 1; } @@ -811,7 +704,7 @@ progressDesc.raw(), TRUE, // Cancelable cOperations, -@@ -7136,13 +7198,15 @@ +@@ -7136,13 +7198,15 @@ HRESULT Console::powerUp(IProgress **aProgress, bool aPaused) else if ( mMachineState == MachineState_Saved || (!fTeleporterEnabled && !fFaultToleranceSyncEnabled)) { @@ -829,7 +722,7 @@ progressDesc.raw(), TRUE /* aCancelable */, 3 /* cOperations */, -@@ -7153,7 +7217,8 @@ +@@ -7153,7 +7217,8 @@ HRESULT Console::powerUp(IProgress **aProgress, bool aPaused) } else if (fFaultToleranceSyncEnabled) { @@ -839,7 +732,7 @@ progressDesc.raw(), TRUE /* aCancelable */, 3 /* cOperations */, -@@ -7649,6 +7714,8 @@ +@@ -7649,6 +7714,8 @@ HRESULT Console::setMachineState(MachineState_T aMachineState, return rc; } @@ -848,7 +741,7 @@ /** * Searches for a shared folder with the given logical name * in the collection of shared folders. -@@ -7684,6 +7751,8 @@ +@@ -7684,6 +7751,8 @@ HRESULT Console::findSharedFolder(const Utf8Str &strName, return VBOX_E_FILE_ERROR; } @@ -857,7 +750,7 @@ /** * Fetches the list of global or machine shared folders from the server. * -@@ -8353,6 +8422,8 @@ +@@ -8353,6 +8422,8 @@ DECLCALLBACK(void) Console::vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, V } } @@ -866,7 +759,7 @@ /** * Changes the clipboard mode. * -@@ -8875,6 +8946,8 @@ +@@ -8875,6 +8946,8 @@ HRESULT Console::detachFromTapInterface(INetworkAdapter *networkAdapter) } #endif /* (RT_OS_LINUX || RT_OS_FREEBSD) && !VBOX_WITH_NETFLT */ @@ -875,7 +768,7 @@ /** * Called at power down to terminate host interface networking. * -@@ -9077,6 +9150,8 @@ +@@ -9077,6 +9150,8 @@ void Console::detachAllUSBDevices(bool aDone) mControl->DetachAllUSBDevices(aDone); } @@ -884,7 +777,7 @@ /** * @note Locks this object for writing. */ -@@ -9249,6 +9324,8 @@ +@@ -9249,6 +9324,8 @@ void Console::processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *p LogFlowThisFuncLeave(); } @@ -893,7 +786,7 @@ /** * Progress cancelation callback for fault tolerance VM poweron */ -@@ -9346,6 +9423,7 @@ +@@ -9346,6 +9423,7 @@ DECLCALLBACK(int) Console::powerUpThread(RTTHREAD Thread, void *pvUser) /* Create the VRDP server. In case of headless operation, this will * also create the framebuffer, required at VM creation. */ @@ -901,7 +794,7 @@ ConsoleVRDPServer *server = pConsole->consoleVRDPServer(); Assert(server); -@@ -9392,6 +9470,7 @@ +@@ -9392,6 +9470,7 @@ DECLCALLBACK(int) Console::powerUpThread(RTTHREAD Thread, void *pvUser) vrc, errMsg.c_str())); throw setErrorStatic(E_FAIL, errMsg.c_str()); } @@ -909,7 +802,7 @@ ComPtr pMachine = pConsole->machine(); ULONG cCpus = 1; -@@ -9416,8 +9495,10 @@ +@@ -9416,8 +9495,10 @@ DECLCALLBACK(int) Console::powerUpThread(RTTHREAD Thread, void *pvUser) alock.acquire(); @@ -920,7 +813,7 @@ if (RT_SUCCESS(vrc)) { -@@ -9441,9 +9522,11 @@ +@@ -9441,9 +9522,11 @@ DECLCALLBACK(int) Console::powerUpThread(RTTHREAD Thread, void *pvUser) /* * Synchronize debugger settings */ @@ -932,7 +825,7 @@ /* * Shared Folders -@@ -9719,6 +9802,7 @@ +@@ -9719,6 +9802,7 @@ DECLCALLBACK(int) Console::powerUpThread(RTTHREAD Thread, void *pvUser) return VINF_SUCCESS; } @@ -940,7 +833,7 @@ /** * Reconfigures a medium attachment (part of taking or deleting an online snapshot). -@@ -10209,6 +10293,8 @@ +@@ -10209,6 +10293,8 @@ DECLCALLBACK(int) Console::saveStateThread(RTTHREAD Thread, void *pvUser) return VINF_SUCCESS; } @@ -949,7 +842,7 @@ /** * Thread for powering down the Console. * -@@ -10252,6 +10338,7 @@ +@@ -10252,6 +10338,7 @@ DECLCALLBACK(int) Console::powerDownThread(RTTHREAD Thread, void *pvUser) return VINF_SUCCESS; } @@ -957,7 +850,7 @@ /** * @interface_method_impl{VMM2USERMETHODS,pfnSaveState} -@@ -10367,6 +10454,7 @@ +@@ -10367,6 +10454,7 @@ Console::i_pdmIfSecKey_KeyRelease(PPDMISECKEY pInterface, const char *pszId) } @@ -965,7 +858,7 @@ /** -@@ -10461,9 +10549,11 @@ +@@ -10461,9 +10549,11 @@ DECLCALLBACK(int) Console::drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, alock.release(); ComPtr pNewMediumAtt; @@ -977,6 +870,180 @@ alock.acquire(); if (pNewMediumAtt != pMediumAtt) +diff --git src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl2.cpp src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl2.cpp +index caed4be..6d02496 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl2.cpp ++++ src/app/virtualbox/src/VBox/Main/src-client/ConsoleImpl2.cpp +@@ -27,6 +27,7 @@ + #include "VBox/com/ptr.h" + + #include "ConsoleImpl.h" ++#include "MachineImpl.h" + #include "DisplayImpl.h" + #ifdef VBOX_WITH_GUEST_CONTROL + # include "GuestImpl.h" +@@ -129,6 +130,7 @@ + *******************************************************************************/ + static Utf8Str *GetExtraDataBoth(IVirtualBox *pVirtualBox, IMachine *pMachine, const char *pszName, Utf8Str *pStrValue); + ++#if 0 + + + #if defined(RT_OS_DARWIN) +@@ -202,6 +204,7 @@ static int DarwinSmcKey(char *pabKey, uint32_t cbKey) + /* Comment out the following line to remove VMWare compatibility hack. */ + #define VMWARE_NET_IN_SLOT_11 + ++#endif + /** + * Translate IDE StorageControllerType_T to string representation. + */ +@@ -522,12 +525,12 @@ static LONG GetNextUsedPort(LONG aPortUsed[30], LONG lBaseVal, uint32_t u32Size) + + #define MAX_BIOS_LUN_COUNT 4 + +-static int SetBiosDiskInfo(ComPtr pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg, ++static HRESULT SetBiosDiskInfo(ComPtr pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg, + Bstr controllerName, const char * const s_apszBiosConfig[4]) + { + HRESULT hrc; + #define MAX_DEVICES 30 +-#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_GENERAL_FAILURE) ++#define H() AssertMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), E_FAIL) + + LONG lPortLUN[MAX_BIOS_LUN_COUNT]; + LONG lPortUsed[MAX_DEVICES]; +@@ -599,9 +602,11 @@ static int SetBiosDiskInfo(ComPtr pMachine, PCFGMNODE pCfg, PCFGMNODE + LogFlowFunc(("Top %d HBA ports = %s, %d\n", j, s_apszBiosConfig[j], lPortLUN[j])); + } + } +- return VINF_SUCCESS; ++#undef H ++ return S_OK; + } + ++#if 0 + #ifdef VBOX_WITH_PCI_PASSTHROUGH + HRESULT Console::attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *pBusMgr, PCFGMNODE pDevices) + { +@@ -741,6 +746,7 @@ HRESULT Console::attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *pBusMgr, P + } + #endif + ++#endif /* if 0 */ + + void Console::attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds, + uint64_t uFirst, uint64_t uLast, +@@ -2070,6 +2076,8 @@ int Console::configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock) + case NetworkAdapterType_I82545EM: + InsertConfigInteger(pCfg, "AdapterType", 2); + break; ++ default: ++ break; + } + + /* +@@ -2225,6 +2233,7 @@ int Console::configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock) + /* + * Parallel (LPT) Ports + */ ++#if 0 + InsertConfigNode(pDevices, "parallel", &pDev); + for (ULONG ulInstance = 0; ulInstance < SchemaDefs::ParallelPortCount; ++ulInstance) + { +@@ -2254,6 +2263,7 @@ int Console::configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock) + InsertConfigString(pLunL1, "DevicePath", bstr); + } + ++#endif + /* + * VMM Device + */ +@@ -2286,6 +2296,7 @@ int Console::configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock) + /* + * Audio Sniffer Device + */ ++#if 0 + InsertConfigNode(pDevices, "AudioSniffer", &pDev); + InsertConfigNode(pDev, "0", &pInst); + InsertConfigNode(pInst, "Config", &pCfg); +@@ -2300,9 +2311,12 @@ int Console::configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock) + /* + * AC'97 ICH / SoundBlaster16 audio / Intel HD Audio + */ ++#endif + BOOL fAudioEnabled = FALSE; + ComPtr audioAdapter; ++#if 0 + hrc = pMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); H(); ++#endif + if (audioAdapter) + hrc = audioAdapter->COMGETTER(Enabled)(&fAudioEnabled); H(); + +@@ -2421,6 +2435,8 @@ int Console::configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock) + break; + } + #endif ++ default: ++ break; + } + hrc = pMachine->COMGETTER(Name)(bstr.asOutParam()); H(); + InsertConfigString(pCfg, "StreamName", bstr); +@@ -3533,6 +3549,8 @@ int Console::configMediumAttachment(PCFGMNODE pCtlInst, + ComPtr pMedium; + hrc = pMediumAtt->COMGETTER(Medium)(pMedium.asOutParam()); H(); + ++#if 0 ++ + /* + * 1. Only check this for hard disk images. + * 2. Only check during VM creation and not later, especially not during +@@ -3717,6 +3735,8 @@ int Console::configMediumAttachment(PCFGMNODE pCtlInst, + } + } + ++#endif /* if 0 */ ++ + if (pMedium) + { + BOOL fHostDrive; +@@ -3810,7 +3830,7 @@ int Console::configMedium(PCFGMNODE pLunL0, + // InsertConfig* throws + try + { +- int rc = VINF_SUCCESS; ++// int rc = VINF_SUCCESS; + HRESULT hrc; + Bstr bstr; + PCFGMNODE pLunL1 = NULL; +@@ -4414,7 +4434,7 @@ int Console::configNetwork(const char *pszDevice, + { + switch (hrc) + { +- case VERR_ACCESS_DENIED: ++ case E_ACCESSDENIED: + return VMSetError(VMR3GetVM(mpUVM), VERR_HOSTIF_INIT_FAILED, RT_SRC_POS, N_( + "Failed to open '/dev/net/tun' for read/write access. Please check the " + "permissions of that node. Either run 'chmod 0666 /dev/net/tun' or " +@@ -4428,12 +4448,12 @@ int Console::configNetwork(const char *pszDevice, + } + } + +- Assert((int)maTapFD[uInstance] >= 0); +- if ((int)maTapFD[uInstance] >= 0) ++ Assert((long)maTapFD[uInstance] >= 0); ++ if ((long)maTapFD[uInstance] >= 0) + { + InsertConfigString(pLunL0, "Driver", "HostInterface"); + InsertConfigNode(pLunL0, "Config", &pCfg); +- InsertConfigInteger(pCfg, "FileHandle", maTapFD[uInstance]); ++ InsertConfigInteger(pCfg, "FileHandle", (long)maTapFD[uInstance]); + } + + #elif defined(VBOX_WITH_NETFLT) +diff --git src/app/virtualbox/src/VBox/Main/src-client/DisplayImpl.cpp src/app/virtualbox/src/VBox/Main/src-client/DisplayImpl.cpp +index fed0ac3..bc3c334 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/DisplayImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-client/DisplayImpl.cpp @@ -16,9 +16,12 @@ */ @@ -991,7 +1058,7 @@ #include "VMMDev.h" #include "AutoCaller.h" -@@ -1067,7 +1070,9 @@ +@@ -1067,7 +1070,9 @@ void Display::handleResizeCompletedEMT(BOOL fResizeContext) * Must be done before calling NotifyUpdate below. */ LogRelFlowFunc(("Calling VRDP\n")); @@ -1001,7 +1068,7 @@ /* @todo Merge these two 'if's within one 'if (!pFBInfo->pFramebuffer.isNull())' */ if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN && !pFBInfo->pFramebuffer.isNull()) -@@ -1266,8 +1271,10 @@ +@@ -1266,8 +1271,10 @@ void Display::handleDisplayUpdate (unsigned uScreenId, int x, int y, int w, int /* When VBVA is enabled, the VRDP server is informed in the VideoAccelFlush. * Inform the server here only if VBVA is disabled. */ @@ -1012,7 +1079,7 @@ } } -@@ -2260,7 +2267,9 @@ +@@ -2260,7 +2267,9 @@ void Display::videoAccelFlush (void) vbvaRgnDirtyRect (&rgn, uScreenId, phdr); /* Forward the command to VRDP server. */ @@ -1022,7 +1089,7 @@ *phdr = hdrSaved; } -@@ -3248,9 +3257,11 @@ +@@ -3248,9 +3257,11 @@ int Display::drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, rc = VERR_INVALID_PARAMETER; } @@ -1034,7 +1101,7 @@ pDisplay->vbvaUnlock(); return rc; -@@ -3701,7 +3712,9 @@ +@@ -3701,7 +3712,9 @@ DECLCALLBACK(int) Display::changeFramebuffer (Display *that, IFramebuffer *aFB, DISPLAYFBINFO *pDisplayFBInfo = &that->maFramebuffers[uScreenId]; pDisplayFBInfo->pFramebuffer = aFB; @@ -1044,7 +1111,7 @@ /* The driver might not have been constructed yet */ if (that->mpDrv) -@@ -3877,8 +3890,10 @@ +@@ -3877,8 +3890,10 @@ DECLCALLBACK(void) Display::displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterf if (!pFBInfo->pFramebuffer.isNull() && pFBInfo->u32ResizeStatus == ResizeStatus_Void) { @@ -1055,7 +1122,7 @@ } } } -@@ -4758,7 +4773,9 @@ +@@ -4758,7 +4773,9 @@ DECLCALLBACK(void) Display::displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInte pHdrUnconst->y -= (int16_t)pFBInfo->yOrigin; /* @todo new SendUpdate entry which can get a separate cmd header or coords. */ @@ -1065,7 +1132,7 @@ *pHdrUnconst = hdrSaved; } -@@ -5004,7 +5021,9 @@ +@@ -5004,7 +5021,9 @@ DECLCALLBACK(int) Display::displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, c { /* VRDP server still need this notification. */ LogRelFlowFunc(("Calling VRDP\n")); @@ -1075,6 +1142,9 @@ } return VINF_SUCCESS; } +diff --git src/app/virtualbox/src/VBox/Main/src-client/GuestImpl.cpp src/app/virtualbox/src/VBox/Main/src-client/GuestImpl.cpp +index b438f9d..2b9755e 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/GuestImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-client/GuestImpl.cpp @@ -16,6 +16,7 @@ */ @@ -1084,7 +1154,7 @@ #include "GuestSessionImpl.h" #include "Global.h" -@@ -104,11 +105,11 @@ +@@ -104,11 +105,11 @@ HRESULT Guest::init(Console *aParent) mVmValidStats = pm::VMSTATMASK_NONE; mMagic = GUEST_MAGIC; @@ -1097,7 +1167,7 @@ hr = unconst(mEventSource).createObject(); if (SUCCEEDED(hr)) hr = mEventSource->init(); -@@ -183,6 +184,7 @@ +@@ -183,6 +184,7 @@ void Guest::uninit() LogFlowFuncLeave(); } @@ -1105,7 +1175,7 @@ /* static */ DECLCALLBACK(void) Guest::staticUpdateStats(RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick) { -@@ -194,6 +196,7 @@ +@@ -194,6 +196,7 @@ DECLCALLBACK(void) Guest::staticUpdateStats(RTTIMERLR hTimerLR, void *pvUser, ui NOREF(hTimerLR); } @@ -1113,7 +1183,7 @@ /* static */ int Guest::staticEnumStatsCallback(const char *pszName, STAMTYPE enmType, void *pvSample, STAMUNIT enmUnit, -@@ -1177,8 +1180,11 @@ +@@ -1177,8 +1180,11 @@ void Guest::onUserStateChange(Bstr aUser, Bstr aDomain, VBoxGuestUserState enmSt Bstr strDetails; /** @todo Implement state details here. */ @@ -1125,6 +1195,26 @@ LogFlowFuncLeave(); } +diff --git src/app/virtualbox/src/VBox/Main/src-client/MouseImpl.cpp src/app/virtualbox/src/VBox/Main/src-client/MouseImpl.cpp +index 652f2df..877b775 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/MouseImpl.cpp ++++ src/app/virtualbox/src/VBox/Main/src-client/MouseImpl.cpp +@@ -816,7 +816,11 @@ HRESULT Mouse::putEventMultiTouch(LONG aCount, + } + } + +- if (SUCCEEDED(rc)) ++ /* ++ * Contrary to the comment of the previous if clause, the usb model ++ * triggers various assertions if 0 contacts are propagated. ++ */ ++ if (SUCCEEDED(rc) && cContacts) + { + rc = reportMultiTouchEventToDevice(cContacts, cContacts? pau64Contacts: NULL, (uint32_t)aScanTime); + +diff --git src/app/virtualbox/src/VBox/Main/src-client/SessionImpl.cpp src/app/virtualbox/src/VBox/Main/src-client/SessionImpl.cpp +index 6ea10d3..c8ce931 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/SessionImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-client/SessionImpl.cpp @@ -17,8 +17,11 @@ @@ -1138,7 +1228,7 @@ #include "AutoCaller.h" #include "Logging.h" -@@ -329,7 +332,9 @@ +@@ -329,7 +332,9 @@ STDMETHODIMP Session::AssignMachine(IMachine *aMachine, LockType_T aLockType, /* query IInternalMachineControl interface */ mControl = aMachine; @@ -1148,7 +1238,7 @@ #ifndef VBOX_COM_INPROC_API_CLIENT HRESULT rc = mConsole.createObject(); -@@ -349,6 +354,7 @@ +@@ -349,6 +354,7 @@ STDMETHODIMP Session::AssignMachine(IMachine *aMachine, LockType_T aLockType, AssertPtr(aToken); #endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */ /* create the machine client token */ @@ -1156,7 +1246,7 @@ try { #ifndef VBOX_WITH_GENERIC_SESSION_WATCHER -@@ -367,6 +373,7 @@ +@@ -367,6 +373,7 @@ STDMETHODIMP Session::AssignMachine(IMachine *aMachine, LockType_T aLockType, { rc = E_OUTOFMEMORY; } @@ -1164,7 +1254,7 @@ /* * Reference the VirtualBox object to ensure the server is up -@@ -1217,12 +1224,14 @@ +@@ -1217,12 +1224,14 @@ HRESULT Session::unlockMachine(bool aFinalRelease, bool aFromServer, AutoWriteLo if (mType == SessionType_WriteLock) { @@ -1179,6 +1269,9 @@ if (!aFinalRelease && !aFromServer) { /* +diff --git src/app/virtualbox/src/VBox/Main/src-client/VBoxDriversRegister.cpp src/app/virtualbox/src/VBox/Main/src-client/VBoxDriversRegister.cpp +index 7fa0f99..d85976d 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/VBoxDriversRegister.cpp +++ src/app/virtualbox/src/VBox/Main/src-client/VBoxDriversRegister.cpp @@ -25,7 +25,9 @@ #include "VMMDev.h" @@ -1199,7 +1292,7 @@ { LogFlow(("VBoxDriversRegister: u32Version=%#x\n", u32Version)); AssertReleaseMsg(u32Version == VBOX_VERSION, ("u32Version=%#x VBOX_VERSION=%#x\n", u32Version, VBOX_VERSION)); -@@ -67,6 +69,7 @@ +@@ -67,6 +69,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRegister(PCPDMDRVREGCB pCallbacks, uint32_ if (RT_FAILURE(rc)) return rc; @@ -1207,7 +1300,7 @@ rc = pCallbacks->pfnRegister(pCallbacks, &AudioSniffer::DrvReg); if (RT_FAILURE(rc)) return rc; -@@ -78,6 +81,7 @@ +@@ -78,6 +81,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRegister(PCPDMDRVREGCB pCallbacks, uint32_ rc = pCallbacks->pfnRegister(pCallbacks, &EmWebcam::DrvReg); if (RT_FAILURE(rc)) return rc; @@ -1215,8 +1308,11 @@ #ifdef VBOX_WITH_USB_CARDREADER rc = pCallbacks->pfnRegister(pCallbacks, &UsbCardReader::DrvReg); +diff --git src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp +index b4f4da4..a341e45 100644 +--- src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp +++ src/app/virtualbox/src/VBox/Main/src-client/VMMDevInterface.cpp -@@ -553,7 +553,9 @@ +@@ -553,7 +553,9 @@ DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, boo { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); @@ -1226,6 +1322,9 @@ if (!pfPageFusionEnabled) return VERR_INVALID_POINTER; +diff --git src/app/virtualbox/src/VBox/Main/src-server/DHCPServerImpl.cpp src/app/virtualbox/src/VBox/Main/src-server/DHCPServerImpl.cpp +index 1cd7ce7..366d693 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/DHCPServerImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-server/DHCPServerImpl.cpp @@ -20,6 +20,7 @@ #include @@ -1235,159 +1334,11 @@ #include "AutoCaller.h" #include "Logging.h" -+++ src/app/virtualbox/src/VBox/Main/src-server/MachineImplCloneVM.cpp -@@ -889,7 +889,7 @@ - rc = d->pProgress.createObject(); - if (FAILED(rc)) throw rc; - rc = d->pProgress->init(p->getVirtualBox(), -- static_cast(d->pSrcMachine) /* aInitiator */, -+ nullptr /* aInitiator */, - Bstr(p->tr("Cloning Machine")).raw(), - true /* fCancellable */, - uCount, -+++ src/app/virtualbox/src/VBox/Main/src-server/MediumLock.cpp -@@ -18,7 +18,7 @@ - #include "MediumLock.h" - #include "MediumImpl.h" - #include "MediumAttachmentImpl.h" -- -+#include "TokenImpl.h" - - MediumLock::MediumLock() - : mMedium(NULL), mMediumCaller(NULL), mLockWrite(false), -+++ src/app/virtualbox/src/VBox/Main/src-server/NetworkAdapterImpl.cpp -@@ -1332,7 +1332,7 @@ - bool NetworkAdapter::isModified() { - AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); - bool fChanged = m_fModified; -- fChanged |= (mData->mAdapterType == NetworkAttachmentType_NAT? mNATEngine->isModified() : false); -+ fChanged |= (mData->mAttachmentType == NetworkAttachmentType_NAT? mNATEngine->isModified() : false); - return fChanged; - } - -+++ src/app/virtualbox/src/VBox/Main/src-server/SnapshotImpl.cpp -@@ -24,6 +24,7 @@ - #include "MediumFormatImpl.h" - #include "Global.h" - #include "ProgressImpl.h" -+#include "TokenImpl.h" - - // @todo these three includes are required for about one or two lines, try - // to remove them and put that code in shared code in MachineImplcpp -@@ -2863,7 +2864,7 @@ - ComObjPtr pChildSnapshot = aTask.pSnapshot->getFirstChild(); - if (pChildSnapshot) - { -- pMachine = pChildSnapshot->getSnapshotMachine(); -+ pMachine = &*pChildSnapshot->getSnapshotMachine(); - childSnapshotId = pChildSnapshot->getId(); - } - pAtt = findAttachment(pMachine->mMediaData->mAttachments, it->mpSource); -+++ src/app/virtualbox/src/VBox/Main/src-server/VirtualBoxImpl.cpp -@@ -42,7 +42,9 @@ - #include - #include - -+#if 0 - #include -+#endif - - #include - #include -@@ -1367,7 +1369,7 @@ - RTPATH_DELIMITER, - firmwareDesc[i].fileName); - int rc = calculateFullPath(shortName, fullName); -- AssertRCReturn(rc, rc); -+ AssertRCReturn(rc, Global::vboxStatusCodeToCOM(rc)); - if (RTFileExists(fullName.c_str())) - { - *aResult = TRUE; -@@ -1378,7 +1380,7 @@ - - char pszVBoxPath[RTPATH_MAX]; - rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); -- AssertRCReturn(rc, rc); -+ AssertRCReturn(rc, Global::vboxStatusCodeToCOM(rc)); - fullName = Utf8StrFmt("%s%c%s", - pszVBoxPath, - RTPATH_DELIMITER, -@@ -4368,8 +4370,10 @@ - /* add to the collection of registered machines */ - m->allMachines.addChild(aMachine); - -+#if 0 - if (autoCaller.state() != InInit) - rc = saveSettings(); -+#endif - - return rc; - } -+++ src/app/virtualbox/src/VBox/Main/src-server/VRDEServerImpl.cpp -@@ -31,7 +31,7 @@ - #include - #include - --#include -+//#include - - #include "AutoStateDep.h" - #include "AutoCaller.h" -@@ -486,6 +486,7 @@ - return S_OK; - } - -+#if 0 - static int loadVRDELibrary(const char *pszLibraryName, RTLDRMOD *phmod, PFNVRDESUPPORTEDPROPERTIES *ppfn) - { - int rc = VINF_SUCCESS; -@@ -530,6 +531,7 @@ - - return rc; - } -+#endif - - STDMETHODIMP VRDEServer::COMGETTER(VRDEProperties)(ComSafeArrayOut(BSTR, aProperties)) - { -@@ -584,13 +586,14 @@ - /* - * Load the VRDE library and start the server, if it is enabled. - */ -- PFNVRDESUPPORTEDPROPERTIES pfn = NULL; -+// PFNVRDESUPPORTEDPROPERTIES pfn = NULL; - RTLDRMOD hmod = NIL_RTLDRMOD; -- vrc = loadVRDELibrary(strVrdeLibrary.c_str(), &hmod, &pfn); -+// vrc = loadVRDELibrary(strVrdeLibrary.c_str(), &hmod, &pfn); -+ vrc = !vrc; - Log(("VRDEPROP: load library [%s] rc %Rrc\n", strVrdeLibrary.c_str(), vrc)); - if (RT_SUCCESS(vrc)) - { -- const char * const *papszNames = pfn(); -+ const char * const *papszNames = nullptr; //pfn(); - - if (papszNames) - { -+++ src/app/virtualbox/src/VBox/Main/xml/Settings.cpp -@@ -4922,6 +4922,8 @@ - case DeviceType_Floppy: - pcszType = "Floppy"; - break; -+ default: -+ break; - } - - pelmDevice->setAttribute("type", pcszType); -@@ -5273,6 +5275,8 @@ - case AudioDriverType_MMPM: - #endif - return true; -+ default: -+ break; - } - - return false; +diff --git src/app/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp src/app/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp +index 3889a01..a4df732 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp -@@ -3522,7 +3522,7 @@ +@@ -3522,7 +3522,7 @@ STDMETHODIMP Machine::LockMachine(ISession *aSession, tr("The given session is busy")); // get the client's IInternalSessionControl interface @@ -1396,7 +1347,7 @@ ComAssertMsgRet(!!pSessionControl, ("No IInternalSessionControl interface"), E_INVALIDARG); -@@ -3826,8 +3826,10 @@ +@@ -3826,8 +3826,10 @@ STDMETHODIMP Machine::LockMachine(ISession *aSession, /* request an IUnknown pointer early from the remote party for later * identity checks (it will be internally cached within mDirectControl * at least on XPCOM) */ @@ -1407,7 +1358,7 @@ } /* Release the lock since SessionMachine::uninit() locks VirtualBox which -@@ -3933,7 +3935,7 @@ +@@ -3933,7 +3935,7 @@ STDMETHODIMP Machine::LaunchVMProcess(ISession *aSession, ComObjPtr progress; progress.createObject(); rc = progress->init(mParent, @@ -1416,7 +1367,7 @@ Bstr(tr("Starting VM")).raw(), TRUE /* aCancelable */, fTeleporterEnabled ? 20 : 10 /* uTotalOperationsWeight */, -@@ -4920,7 +4922,7 @@ +@@ -4920,7 +4922,7 @@ STDMETHODIMP Machine::SetHotPluggableForDevice(IN_BSTR aControllerName, LONG aCo STDMETHODIMP Machine::SetNoBandwidthGroupForDevice(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice) { @@ -1425,7 +1376,7 @@ LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d\n", aControllerName, aControllerPort, aDevice)); -@@ -5014,7 +5016,7 @@ +@@ -5014,7 +5016,7 @@ STDMETHODIMP Machine::UnmountMedium(IN_BSTR aControllerName, LONG aDevice, BOOL aForce) { @@ -1434,7 +1385,7 @@ LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d", aControllerName, aControllerPort, aForce)); -@@ -5029,7 +5031,7 @@ +@@ -5029,7 +5031,7 @@ STDMETHODIMP Machine::MountMedium(IN_BSTR aControllerName, IMedium *aMedium, BOOL aForce) { @@ -1443,7 +1394,7 @@ LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d aForce=%d\n", aControllerName, aControllerPort, aDevice, aForce)); -@@ -5610,7 +5612,7 @@ +@@ -5610,7 +5612,7 @@ STDMETHODIMP Machine::DeleteConfig(ComSafeArrayIn(IMedium*, aMedia), IProgress * pTask->pProgress.createObject(); pTask->pProgress->init(getVirtualBox(), @@ -1452,7 +1403,7 @@ Bstr(tr("Deleting files")).raw(), true /* fCancellable */, pTask->llFilesToDelete.size() + pTask->llMediums.size() + 1, // cOperations -@@ -8025,7 +8027,9 @@ +@@ -8025,7 +8027,9 @@ HRESULT Machine::launchVMProcess(IInternalSessionControl *aControl, size_t cchBufLeft = strlen(szPath); szPath[cchBufLeft++] = RTPATH_DELIMITER; szPath[cchBufLeft] = 0; @@ -1462,7 +1413,7 @@ cchBufLeft = sizeof(szPath) - cchBufLeft; int vrc = VINF_SUCCESS; -@@ -8096,10 +8100,14 @@ +@@ -8096,10 +8100,14 @@ HRESULT Machine::launchVMProcess(IInternalSessionControl *aControl, } strSupStartLogArg.append(strStartupLogFile); } @@ -1477,7 +1428,7 @@ #ifdef VBOX_WITH_QTGUI -@@ -8500,6 +8508,7 @@ +@@ -8500,6 +8508,7 @@ HRESULT Machine::prepareRegister() // Ensure the settings are saved. If we are going to be registered and // no config file exists yet, create it by calling saveSettings() too. @@ -1485,7 +1436,7 @@ if ( (mData->flModifications) || (!mData->pMachineConfigFile->fileExists()) ) -@@ -8509,6 +8518,7 @@ +@@ -8509,6 +8518,7 @@ HRESULT Machine::prepareRegister() // we can't have a machine XML file rename pending if (FAILED(rc)) return rc; } @@ -1493,7 +1444,7 @@ /* more config checking goes here */ -@@ -8740,9 +8750,8 @@ +@@ -8740,9 +8750,8 @@ HRESULT Machine::initDataAndChildObjects() { AutoCaller autoCaller(this); AssertComRCReturnRC(autoCaller.rc()); @@ -1504,7 +1455,7 @@ AssertReturn(!mData->mAccessible, E_FAIL); /* allocate data structures */ -@@ -9097,7 +9106,7 @@ +@@ -9097,7 +9106,7 @@ HRESULT Machine::loadMachineDataFromSettings(const settings::MachineConfigFile & cbOut, DECODE_STR_MAX); com::SafeArray iconByte(cbOut); @@ -1513,7 +1464,7 @@ if (FAILED(rc)) return setError(E_FAIL, tr("Failure to Decode Icon Data. '%s' (%d)"), -@@ -12844,7 +12853,9 @@ +@@ -12844,7 +12853,9 @@ HRESULT SessionMachine::init(Machine *aMachine) AssertReturn(aMachine, E_INVALIDARG); @@ -1523,7 +1474,7 @@ /* Enclose the state transition NotReady->InInit->Ready */ AutoInitSpan autoInitSpan(this); -@@ -12975,7 +12986,7 @@ +@@ -12975,7 +12986,7 @@ void SessionMachine::uninit(Uninit::Reason aReason) * accessing any members (and before AutoUninitSpan that does it as well). * This self reference will be released as the very last step on return. */ @@ -1532,7 +1483,7 @@ /* Enclose the state transition Ready->InUninit->NotReady */ AutoUninitSpan autoUninitSpan(this); -@@ -13464,12 +13475,12 @@ +@@ -13464,12 +13475,12 @@ STDMETHODIMP SessionMachine::EndPoweringDown(LONG iResult, IN_BSTR aErrMsg) { Utf8Str strErrMsg(aErrMsg); if (strErrMsg.length()) @@ -1547,7 +1498,7 @@ } /* clear out the temporary saved state data */ -@@ -13679,8 +13690,8 @@ +@@ -13679,8 +13690,8 @@ STDMETHODIMP SessionMachine::OnSessionEnd(ISession *aSession, Assert(mData->mSession.mProgress.isNull()); ComObjPtr progress; progress.createObject(); @@ -1558,7 +1509,7 @@ Bstr(tr("Closing session")).raw(), FALSE /* aCancelable */); progress.queryInterfaceTo(aProgress); -@@ -13787,7 +13798,7 @@ +@@ -13787,7 +13798,7 @@ STDMETHODIMP SessionMachine::EndSavingState(LONG iResult, IN_BSTR aErrMsg) if (FAILED(iResult)) setMachineState(mConsoleTaskData.mLastState); @@ -1567,6 +1518,22 @@ } /** +diff --git src/app/virtualbox/src/VBox/Main/src-server/MachineImplCloneVM.cpp src/app/virtualbox/src/VBox/Main/src-server/MachineImplCloneVM.cpp +index 3a7507d..ce9a2b3 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/MachineImplCloneVM.cpp ++++ src/app/virtualbox/src/VBox/Main/src-server/MachineImplCloneVM.cpp +@@ -889,7 +889,7 @@ HRESULT MachineCloneVM::start(IProgress **pProgress) + rc = d->pProgress.createObject(); + if (FAILED(rc)) throw rc; + rc = d->pProgress->init(p->getVirtualBox(), +- static_cast(d->pSrcMachine) /* aInitiator */, ++ nullptr /* aInitiator */, + Bstr(p->tr("Cloning Machine")).raw(), + true /* fCancellable */, + uCount, +diff --git src/app/virtualbox/src/VBox/Main/src-server/MediumImpl.cpp src/app/virtualbox/src/VBox/Main/src-server/MediumImpl.cpp +index c61ea6f..893ac88 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/MediumImpl.cpp +++ src/app/virtualbox/src/VBox/Main/src-server/MediumImpl.cpp @@ -20,6 +20,7 @@ #include "ProgressImpl.h" @@ -1576,7 +1543,7 @@ #include "AutoCaller.h" #include "Logging.h" -@@ -679,16 +680,21 @@ +@@ -679,16 +680,21 @@ DECLCALLBACK(int) Medium::Task::fntMediumTask(RTTHREAD aThread, void *pvUser) HRESULT rc = pTask->handler(); @@ -1599,7 +1566,7 @@ LogFlowFunc(("rc=%Rhrc\n", rc)); LogFlowFuncLeave(); -@@ -1231,7 +1237,7 @@ +@@ -1231,7 +1237,7 @@ HRESULT Medium::init(VirtualBox *aVirtualBox, else { // Otherwise use the old VirtualBox "make absolute path" logic: @@ -1608,7 +1575,7 @@ if (FAILED(rc)) return rc; } } -@@ -2578,7 +2584,7 @@ +@@ -2578,7 +2584,7 @@ STDMETHODIMP Medium::CreateBaseStorage(LONG64 aLogicalSize, pProgress.createObject(); rc = pProgress->init(m->pVirtualBox, @@ -1617,7 +1584,7 @@ (mediumVariantFlags & MediumVariant_Fixed) ? BstrFmt(tr("Creating fixed medium storage unit '%s'"), m->strLocationFull.c_str()).raw() : BstrFmt(tr("Creating dynamic medium storage unit '%s'"), m->strLocationFull.c_str()).raw(), -@@ -2758,7 +2764,7 @@ +@@ -2758,7 +2764,7 @@ STDMETHODIMP Medium::CloneToBase(IMedium *aTarget, ComSafeArrayIn(MediumVariant_T, aVariant), IProgress **aProgress) { @@ -1626,17 +1593,162 @@ CheckComArgNotNull(aTarget); CheckComArgOutPointerValid(aProgress); CheckComArgSafeArrayNotNull(aVariant); -+++ src/app/virtualbox/src/VBox/Main/src-client/MouseImpl.cpp -@@ -816,7 +818,11 @@ - } +diff --git src/app/virtualbox/src/VBox/Main/src-server/MediumLock.cpp src/app/virtualbox/src/VBox/Main/src-server/MediumLock.cpp +index 567973d..2cda8b2 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/MediumLock.cpp ++++ src/app/virtualbox/src/VBox/Main/src-server/MediumLock.cpp +@@ -18,7 +18,7 @@ + #include "MediumLock.h" + #include "MediumImpl.h" + #include "MediumAttachmentImpl.h" +- ++#include "TokenImpl.h" + + MediumLock::MediumLock() + : mMedium(NULL), mMediumCaller(NULL), mLockWrite(false), +diff --git src/app/virtualbox/src/VBox/Main/src-server/NetworkAdapterImpl.cpp src/app/virtualbox/src/VBox/Main/src-server/NetworkAdapterImpl.cpp +index e3908bb..c5cee5c 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/NetworkAdapterImpl.cpp ++++ src/app/virtualbox/src/VBox/Main/src-server/NetworkAdapterImpl.cpp +@@ -1332,7 +1332,7 @@ HRESULT NetworkAdapter::saveSettings(settings::NetworkAdapter &data) + bool NetworkAdapter::isModified() { + AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); + bool fChanged = m_fModified; +- fChanged |= (mData->mAdapterType == NetworkAttachmentType_NAT? mNATEngine->isModified() : false); ++ fChanged |= (mData->mAttachmentType == NetworkAttachmentType_NAT? mNATEngine->isModified() : false); + return fChanged; + } + +diff --git src/app/virtualbox/src/VBox/Main/src-server/SnapshotImpl.cpp src/app/virtualbox/src/VBox/Main/src-server/SnapshotImpl.cpp +index ddce18b..55065d2 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/SnapshotImpl.cpp ++++ src/app/virtualbox/src/VBox/Main/src-server/SnapshotImpl.cpp +@@ -24,6 +24,7 @@ + #include "MediumFormatImpl.h" + #include "Global.h" + #include "ProgressImpl.h" ++#include "TokenImpl.h" + + // @todo these three includes are required for about one or two lines, try + // to remove them and put that code in shared code in MachineImplcpp +@@ -2863,7 +2864,7 @@ void SessionMachine::deleteSnapshotHandler(DeleteSnapshotTask &aTask) + ComObjPtr pChildSnapshot = aTask.pSnapshot->getFirstChild(); + if (pChildSnapshot) + { +- pMachine = pChildSnapshot->getSnapshotMachine(); ++ pMachine = &*pChildSnapshot->getSnapshotMachine(); + childSnapshotId = pChildSnapshot->getId(); + } + pAtt = findAttachment(pMachine->mMediaData->mAttachments, it->mpSource); +diff --git src/app/virtualbox/src/VBox/Main/src-server/VRDEServerImpl.cpp src/app/virtualbox/src/VBox/Main/src-server/VRDEServerImpl.cpp +index a717aff..3d52b9f 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/VRDEServerImpl.cpp ++++ src/app/virtualbox/src/VBox/Main/src-server/VRDEServerImpl.cpp +@@ -31,7 +31,7 @@ + #include + #include + +-#include ++//#include + + #include "AutoStateDep.h" + #include "AutoCaller.h" +@@ -486,6 +486,7 @@ STDMETHODIMP VRDEServer::GetVRDEProperty(IN_BSTR aKey, BSTR *aValue) + return S_OK; + } + ++#if 0 + static int loadVRDELibrary(const char *pszLibraryName, RTLDRMOD *phmod, PFNVRDESUPPORTEDPROPERTIES *ppfn) + { + int rc = VINF_SUCCESS; +@@ -530,6 +531,7 @@ static int loadVRDELibrary(const char *pszLibraryName, RTLDRMOD *phmod, PFNVRDES + + return rc; + } ++#endif + + STDMETHODIMP VRDEServer::COMGETTER(VRDEProperties)(ComSafeArrayOut(BSTR, aProperties)) + { +@@ -584,13 +586,14 @@ STDMETHODIMP VRDEServer::COMGETTER(VRDEProperties)(ComSafeArrayOut(BSTR, aProper + /* + * Load the VRDE library and start the server, if it is enabled. + */ +- PFNVRDESUPPORTEDPROPERTIES pfn = NULL; ++// PFNVRDESUPPORTEDPROPERTIES pfn = NULL; + RTLDRMOD hmod = NIL_RTLDRMOD; +- vrc = loadVRDELibrary(strVrdeLibrary.c_str(), &hmod, &pfn); ++// vrc = loadVRDELibrary(strVrdeLibrary.c_str(), &hmod, &pfn); ++ vrc = !vrc; + Log(("VRDEPROP: load library [%s] rc %Rrc\n", strVrdeLibrary.c_str(), vrc)); + if (RT_SUCCESS(vrc)) + { +- const char * const *papszNames = pfn(); ++ const char * const *papszNames = nullptr; //pfn(); + + if (papszNames) + { +diff --git src/app/virtualbox/src/VBox/Main/src-server/VirtualBoxImpl.cpp src/app/virtualbox/src/VBox/Main/src-server/VirtualBoxImpl.cpp +index 9ce039a..2e6ac11 100644 +--- src/app/virtualbox/src/VBox/Main/src-server/VirtualBoxImpl.cpp ++++ src/app/virtualbox/src/VBox/Main/src-server/VirtualBoxImpl.cpp +@@ -42,7 +42,9 @@ + #include + #include + ++#if 0 + #include ++#endif + + #include + #include +@@ -1367,7 +1369,7 @@ VirtualBox::CheckFirmwarePresent(FirmwareType_T aFirmwareType, + RTPATH_DELIMITER, + firmwareDesc[i].fileName); + int rc = calculateFullPath(shortName, fullName); +- AssertRCReturn(rc, rc); ++ AssertRCReturn(rc, Global::vboxStatusCodeToCOM(rc)); + if (RTFileExists(fullName.c_str())) + { + *aResult = TRUE; +@@ -1378,7 +1380,7 @@ VirtualBox::CheckFirmwarePresent(FirmwareType_T aFirmwareType, + + char pszVBoxPath[RTPATH_MAX]; + rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); +- AssertRCReturn(rc, rc); ++ AssertRCReturn(rc, Global::vboxStatusCodeToCOM(rc)); + fullName = Utf8StrFmt("%s%c%s", + pszVBoxPath, + RTPATH_DELIMITER, +@@ -4368,8 +4370,10 @@ HRESULT VirtualBox::registerMachine(Machine *aMachine) + /* add to the collection of registered machines */ + m->allMachines.addChild(aMachine); + ++#if 0 + if (autoCaller.state() != InInit) + rc = saveSettings(); ++#endif + + return rc; + } +diff --git src/app/virtualbox/src/VBox/Main/xml/Settings.cpp src/app/virtualbox/src/VBox/Main/xml/Settings.cpp +index 3520c9c..e3288af 100644 +--- src/app/virtualbox/src/VBox/Main/xml/Settings.cpp ++++ src/app/virtualbox/src/VBox/Main/xml/Settings.cpp +@@ -4922,6 +4922,8 @@ void MachineConfigFile::buildStorageControllersXML(xml::ElementNode &elmParent, + case DeviceType_Floppy: + pcszType = "Floppy"; + break; ++ default: ++ break; + } + + pelmDevice->setAttribute("type", pcszType); +@@ -5273,6 +5275,8 @@ bool MachineConfigFile::isAudioDriverAllowedOnThisHost(AudioDriverType_T drv) + case AudioDriverType_MMPM: + #endif + return true; ++ default: ++ break; } -- if (SUCCEEDED(rc)) -+ /* -+ * Contrary to the comment of the previous if clause, the usb model -+ * triggers various assertions if 0 contacts are propagated. -+ */ -+ if (SUCCEEDED(rc) && cContacts) - { - rc = reportMultiTouchEventToDevice(cContacts, cContacts? pau64Contacts: NULL, (uint32_t)aScanTime); - + return false;