Hyper-V: VM Generation 2 Deep Dive

Windows Server

Hyper-V in Windows Server 2012 R2 supporta un nuovo virtual hardware model per la creazione di machine virtuali (VM) denominato Generation 2. Le principali novità delle VM Generation2 sono il supporto all’ Unified Extensible Firmware Interface (UEFI) firmware che sostituisce il BIOS-based firmware e la rimozione della maggior parte dei device legacy dal virtual hardware model.

Vantaggi delle VM Generation 2

I principali vantaggi offerti dalla Generation 2 sono principalmente legati alla fase di boot che risulta più flessibile, rapido e sicuro grazie alle seguenti funzionalità:

  • Boot PXE boot tramite network adapter sintetici con supporto a IPv4 e IPv6
  • Boot da SCSI virtual hard disk
  • Boot da SCSI virtual DVD
  • Secure Boot (abilitato per default)
  • Supporto a firmware UEFI

Tali funzionalità si traducono anche in un aumento della rapidità d’installazione del sistema operativo, mentre non vengono riportate differenze di performance nell’uso normale delle VM. La Generation 2 può quindi portare vantaggi in scenari VDI in termini di rapidità di deploy, avvio delle VM e sicurezza.

Virtual Hardware Model nella Generation 2

Per rendere il virtual hardware model più snello e adatto a supportare i nuovi e futuri sistemi operativi sono state operate una serie di modifiche ai device hardware virtuali. Come illustrato nella seguente tabella comparativa sono stati dismessi una serie di device, mentre quelli emulati sono stati rimpiazzati dal corrispondente sintetico.

2014_03_28_HyperV-01

Figura 1 – Gen1 vs Gen2

Guest OS nella Generation 2

Per quanto riguarda i sistemi operativi supportati al momento è possibile creare VM Generation 2 con i seguenti Guest OS:

  • Windows Server 2012 o superiore
  • Windows 8 64 Bit o superiore
  • Ubuntu 15.04 o superiore
  • CentOS 7 o superiore
  • Debian 7 o superiore
  • SUSE 11 o superiore

Sono supportati esclusivamente OS a 64 Bit in quanto l’implementazione del firmware UEFI in W8.1/WS2012 R2 al momento non ha il CSM (Compatibility Support Module) come indicato in Hyper-V generation 2 virtual machines – part 1 da John Howard (Senior Program Manager Hyper-V team):

“Our UEFI firmware in Windows 8.1 does not have a CSM (Compatibility Support Module). In terms of how the UEFI forum defines platform types, this makes our implementation “Class 3”. We do not have a 32-bit implementation, which means that only 64-bit Guest Operating systems would be able to run in this environment. I will cover what operating systems are actually supported later.”

Per quanto riguarda Windows 7 a 64 Bit e Windows Server 2008 R2 nonostante supportino UEFI non sono supportati come Guest OS in VM Generation 2 perché hanno una dipendenza nei confronti del Programmable Interrupt Controller (PIC) che non è presente nel nuovo virtual hardware model come indicato in Hyper-V generation 2 virtual machines – part 7:

“Q: Why don’t we support 64-bit Windows 7 or Windows Server 2008 R2 as a guest operating system in generation 2 virtual machines?
A: Certainly it is true that Windows 7 support UEFI, the first requirement for generation 2 virtual machines. However, Windows 7 has a hardware dependency on a Programmable Interrupt Controller (PIC) which is not present in generation 2 virtual machines. Even if Secure Boot is disabled, an attempt to install Windows 7 will result in an apparent hang at “Starting Windows” shortly after boot, consuming 100% VP utilisation. A similar effect to this will be seen if attempting a network install from a WDS server which has a Windows 7 era boot PE image – network boot will appear to hang as well. For that reason (along with the keyboard issue in Windows 8 PE) I strongly recommend any WDS server are upgraded to the Windows 8.1 PE boot image.”

Per quanto riguarda OS Linux al momento non sono supportati su VM Generation 2, ma si sta lavorando per fornire il supporto in futuro come indicato in Hyper-V generation 2 virtual machines – part 7:

“Q: When is Linux going to be supported in a generation 2 virtual machine
A: Linux support is being worked on as of writing. Currently, 64-bit versions of Windows 8 and 8.1, or Windows Server 2012 and Windows Server 2012 R2 are supported guest operating systems.”

Limitazioni nella Generation 2

I CD, DVD, Floppy virtuali non sono più supportati, vengono supportate esclusivamente le immagini ISO. Ciò è dovuto alla rimozione del controller IDE e del Floppy e DMA controller che sono stati sostituiti dal un software-based DVD device. A riguardo si veda quanto riportato in Hyper-V generation 2 virtual machines – part 1:

“Given that both IDE and Legacy NIC are no longer present, we had to introduce alternate boot mechanisms, and a new DVD device. We extended the UEFI firmware to be aware of software based devices (ie those using VMBus), and support booting from our software-based SCSI and Network controllers, plus the new software-based DVD device.”

RemoteFX non è supportata nelle VM Generation 2, questo è dovuto alla dipendenza dello stack RemoteFX dal PCI Bus rimosso nel virtual hardware model della Generation 2 come riportato in Hyper-V generation 2 virtual machines – part 7:

“Q: Is RemoteFX supported by generation 2 virtual machines?
A: No. The reason is that there is a dependency on PCI in the RemoteFX stack. PCI is not present in generation 2 virtual machines, and it was not possible to remove this dependency in the timeframe and resources available for the Windows 8.1 release cycle.”

I device legacy i8042 keyboard controller, PS/2 keyboard, PS/2 mouse, S3 e sono stati da software based device, questo comporta alcuni problemi nel boot di WinPE/WinRE per Windows 8 o Windows Server 2012, infatti in questa versione di PE il software based keyboard driver non è presente. Per ulteriori informazioni e workaround per gestire il boot di PE W8/WS2012 si veda il post Hyper-V generation 2 virtual machines – part 4. Nella versione di PE di Windows 8.1/WS2012 R2 il software based keyboard driver è invece presente.

I dischi virtuali con formato VHD non sono più supportati, sulle VM Generation 2 è possibile connettere esclusivamente dischi virtuali con formato VHDX. Anche se è possibile convertire i VHD in VHDX la conversione è supportata solo per dischi virtuali che contengono dati. Non è infatti supportato convertire dischi virtuali VHD di boot in VHDX, ma occorre eseguire una reinstallazione del sistema come indicato in Generation 2 Virtual Machine Overview:

“Q: Can a VHDX file that was converted from a VHD file be used to boot a generation 2 virtual machine?
A: No. A clean installation of the operating system is required.

Q: Can I create a VHDX file that can be used to boot both generation 1 and generation 2 virtual machines?
A: Although this is technically possible, it is possible that unexpected errors can occur. Therefore, a VHDX file that is bootable to both generation 1 and generation 2 virtual machines is not supported or recommended.”

Questo significa che le VM con W8 64 Bit o WS2012 devono essere reinstallate se si vuole che i sistemi vengano eseguiti in VM Generation 2. A tal proposito John Howard ha sviluppato uno script PowerShell per la migrazione di VM da Generation 1 a Generation2 disponibile al seguente Hyper-V generation 2 VM conversion utility, va comunque precisato che l’utility non è ufficialmente supportata.

Il boot da iSCSI o virtual Fiber Channel non è supportato, ma è supportato esclusivamente il boot tramite iso, SCSI e tramite rete (sia IPv4 che IPv6) come riportato in Hyper-V generation 2 virtual machines – part 7:

“Q: Can I iSCSI boot a generation 2 virtual machine?
A: No, you can only boot from SCSI-attached disk, .ISO attached to a CD/DVD device, or from network

Q: Can I boot a generation 2 virtual machine from a virtual FC adapter?
A: No, you can only boot from SCSI-attached disk, .ISO attached to a CD/DVD device, or from network

Q: Can I perform a network installation in a generation 2 virtual machine using IPv6?
A: Absolutely. In an elevated PowerShell prompt, run Set-VMFirmware –VMName <Name of VM> -IPProtocolPreference IPv6. Note that this will change the protocol for ALL network adapters in the VM – you cannot for example have the VM attempt an IPv4 boot from the first network adapter, and IPv6 on the second network adapter.”

Il Measured Boot non è supportato in quanto dipende da un TPM (Trusted Platform Module) che non è presente nel virtual hardware model nella Generation 2 (e neppure nel virtual hardware model della Generation 1) come riportato in Hyper-V generation 2 virtual machines – part 7:

“Q: Do generation 2 virtual machines support Measured Boot?
A: No. But they support the closely related Secure Boot capability. Measured Boot has a dependency on a TPM (Trusted Platform Module) which is not present in a generation 2 (or generation 1 for that matter) virtual machine.”

La modifica della generazione della VM non è supporta come riportato in Hyper-V generation 2 virtual machines – part 7:

“Q: How can I change the generation of an existing virtual machine
A: This is not possible (at least inbox). Generally a clean install and application migration is required. This topic will be covered in a lot more detail in part eight.”

Vantaggi della Generation 2

Una delle principali novità delle VM Generation 2 è il supporto al Secure Boot che offre un meccanismo di controllo delle firma durante l’avvio dell’OS per assicurarsi che solo i componenti approvati possano essere eseguiti. Secure Boot fa parte delle specifiche UEFI e nello specifico Hyper-V in WS2012 R2 implementa un subset delle specifiche UEFI che permette avviare nelle VM Generation 2 W8/W8.1 con il Secure Boot abilitato. Per maggiori informazioni riguardo si veda Hyper-V generation 2 virtual machines – part 6.

Il supporto a UEFI offerto dal virtual hardware model nella Generation 2 non ha alcuna correlazione col firmware fisico dell’host di virtualizzazione. In altre parole non vi sono requisiti specifici riguardanti il firmware dell’host per il supporto a UEFI e al Secure Boot delle VM Generation 2 come riportato in Hyper-V generation 2 virtual machines – part 7:

“Q: What is the dependency between UEFI in a generation 2 virtual machine and the physical platform firmware?
A: None. The firmware exposed in a Hyper-V virtual machine (mostly) has no correlation to the firmware on the physical platform. Hence there is no requirement for the physical server to have UEFI firmware or support Secure Boot to support both of these features in a generation 2 virtual machine.”

In caso di necessità è possibile eseguire il kernel debugging tramite porta COM anche se le porte di comunicazione seriale non sono più disponibili nel virtual hardware model della Generation 2. Infatti tramite PowerShell è comunque possibile assegnare una pipe ad una porta COM tramite il cmdlet Set-VMCOMPort ed eseguire il kernel debuggin dopo aver disabilitato il Secure Boot come descritto in Hyper-V generation 2 virtual machines – part 5.

Gestione Tramite PowerShell delle VM Generation 2

Per supportare la creazione e la configurazioe delle VM Generation 2 sono stati aggiornati i cmdlet PowerShell disponibili per la gestione di Hyper-V introdotti con Windows Server 2012.

Per quando riguarda la creazione delle VM Generation 2 al cmdlet New-VM è stata aggiunta l’opzione -Generation:

#Creazione VM Generation 2
New-VM –Name “VMG2” -Generation 2

Il fimware UEFI può invece essere gestito tramite i cmdlet Set-VMFirmware e Get-VMFirmware:

#Abilitazione Secure Boot
New-VM –Name “VMG2” -Generation 2

#Recupero informazioni sulle impostazioni del firmware UEFI
Get-VMFirmware -VMName “VMG2”

#Modifica Boot Order
$vmFimware = Get-VMFirmware -VMName “VM2012R2”
$bootFile = $ VMFimware.BootOrder[0] $bootNet = $ VMFimware.BootOrder[3] $bootHD = $ VMFimware.BootOrder[1] $bootDVD = $ VMFimware.BootOrder[2] Set-VMFirmware -VMName “VMG2” -BootOrder $bootNet,$ bootFile,$ bootHD,$ bootDVD

Conclusioni

Le VM Generation 2 sono da prendere in considerazione in scenari in cui si desidera adottare le utime versioni di sistema operativo W8/W8.1 in architettura a 64 Bit sfruttando le funzionlaità di rapidita e sicurezza al boot. Inoltre grazie all’utilizzo del controller virtuale SCSI le VM Generation 2 garantiscono anche una maggior flessibilità per quanto riguarda la gestione dello storage grazie alla possibilità del resize on line di VHDX e partizioni online anche sui dischi virtuali del sistema operativo.

Sebbene al momento le modifiche all’interno del virtual hardware model comportino al momento alcuni limitazioni, John Howard (Senior Program Manager Hyper-V team) nella serie di post che ha dedicato alla Generation 2 del VM ha lasciato intendere che il team sta continuando a lavorare per risolvere le problematiche in futuro, in particolare per il supporto di RemoteFX.

Link Utili