Richard W.M. Jones
2016-Jun-10 15:03 UTC
Re: [Libguestfs] [PATCH 2/2] v2v: remove the 'graphicsmodedisabled' entry in ESP BCD
On Fri, Jun 10, 2016 at 05:07:03PM +0300, Pavel Butsykin wrote:> Guest tools for Windows in Parallels / Virtuozzo Server 6 contain a > paravirtualized video driver, which wants to take full control of the video > mode. To avoid excessive video mode switches in UEFI VMs it executes > "bcdedit /set {current} graphicsmodedisabled true". > > When such a VM is imported into a QEMU/KVM-based hypervisor, the > standard video drivers in Windows do not set the video mode as they > expect it to have already been configured by the bootloader. As a result, > the VM runs with black screen. > > So patch the BCD store (which is a Windows registry hive with a special > structure, located on the EFI system partition) to clear this setting. > > Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com> > --- > v2v/convert_windows.ml | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml > index 62bb536..8579240 100644 > --- a/v2v/convert_windows.ml > +++ b/v2v/convert_windows.ml > @@ -466,6 +466,45 @@ if errorlevel 3010 exit /b 0 > ignore (g#pwrite_device rootpart bytes 0x1a_L) > ) > ) > + > + and fix_win_esp () > + let fix_win_uefi_bcd esp_path > + try > + let bcd_path = "/EFI/Microsoft/Boot/BCD" in > + Windows.with_hive_write g (esp_path ^ bcd_path) ( > + (* Remove the 'graphicsmodedisabled' key in BCD *) > + fun root -> > + let path = ["Objects"; "{9dea862c-5cdd-4e70-acc1-f32b344d4795}"; > + "Elements"; "23000003"] in > + let boot_mgr_default_link > + match Windows.get_node g root path with > + | None -> raise Not_found > + | Some node -> node in > + let current_boot_entry = g#hivex_value_utf8 ( > + g#hivex_node_get_value boot_mgr_default_link "Element") in > + let path = ["Objects"; current_boot_entry; "Elements"; "16000046"] in > + match Windows.get_node g root path with > + | None -> raise Not_found > + | Some graphics_mode_disabled -> > + g#hivex_node_delete_child graphics_mode_disabled > + ); > + with > + Not_found -> () > + in > + > + let esp_temp_path = g#mkdtemp "/Windows/Temp/ESP_XXXXXX" in > + > + match inspect.i_uefi with > + | None -> () > + | Some uefi_list -> > + List.iter ( > + fun dev_path -> > + g#mount dev_path esp_temp_path; > + fix_win_uefi_bcd esp_temp_path; > + g#umount esp_temp_path; > + ) uefi_list; > + > + g#rmdir esp_temp_path; > in > > (* Firstboot configuration. *) > @@ -480,6 +519,8 @@ if errorlevel 3010 exit /b 0 > > fix_ntfs_heads (); > > + fix_win_esp (); > +This patch looks OK to me. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Reasonably Related Threads
- Re: [PATCH v2 2/2] v2v: remove the 'graphicsmodedisabled' entry in ESP BCD
- [PATCH 0/8] Miscellaneous cleanups to Windows registry code.
- Re: [PATCH 1/2] v2v: fill the list of the EFI system partitions
- [PATCH v12 04/11] New API: Deprecate hivex_value_utf8 and replace with hivex_value_string.
- [PATCH] v2v: Fix get_firmware_bootable_device.