How to create Windows VM?


(Dan) #1

Hi guys!
I am brand new to OpenNebula. Today is going to be filled with a bunch of reading!

I have my test environment setup running on Unbuntu with OpenNebula and KVM. Can anyone point me in the right direction on some documentation of guidance on how to create a windows VM? I have been able to spin up a CentOS VM, but for the life of me I cant figure out a Windows one.

Thanks in advance!
Dan


How create a windows xp
(Roland) #2

welcome!

these are the basic steps I used to get a Windows 7 VM running:

  • upload a windows installation iso to opennebula
  • create a new image to use (recommend ~50 GB or larger)
  • create or clone a template for windows and setup the basics (image/network/boot sequence)
    make sure to set the network card type to “virtio” and make sure the disk-image is setup to be mounted as “vdX”, or make sure the image has a prefix as “vd”.
  • download the virtio driver iso from Red Hat (win-drivers need to be digitally signed, red hat can sign them)
  • add the win-iso, virtio-iso and the win-image to the template, make sure to set boot sequence to cdrom first.
  • instantiate VM, install windows, use drivers from virtio-iso during installation (install driver for virtio network interface and virtio disk controller)

Here is the raw content of a template I use. (Make sure to update all fields with “SOME” to your situation)

CONTEXT=[NETWORK="YES"]
CPU="2"
DESCRIPTION="Default Windows Template"
DISK=[IMAGE="SOME_IMAGE_NAME_HERE.qcow2",IMAGE_UNAME="oneadmin"]
DISK=[IMAGE="virtio-win.iso",IMAGE_UNAME="oneadmin"]
DISK=[IMAGE="SOME_Windows7-Installation.iso",IMAGE_UNAME="oneadmin"]
FEATURES=[ACPI="yes",APIC="yes",LOCALTIME="yes"]
GRAPHICS=[LISTEN="0.0.0.0",RANDOM_PASSWD="YES",TYPE="VNC"]
HYPERVISOR="kvm"
INPUT=[BUS="usb",TYPE="tablet"]
LOGO="images/logos/windows8.png"
MEMORY="4096"
NIC=[NETWORK="SOME_NETWORK"]
NIC_DEFAULT=[MODEL="virtio"]
OS=[ARCH="x86_64",BOOT="cdrom,hd"]
SUNSTONE_CAPACITY_SELECT="YES"
SUNSTONE_NETWORK_SELECT="NO"
VCPU="4"

Hope this helps!


Template to install Win7 (cannot find target hard-disk)
Windows VM template build up?
(César Eduardo) #3

Hi. Please you took issue with Windows 7 instances presenting two hands (pointers) on the screen? I created the KVM image on one machine and then imported into the OpenNebula.


(Pavel Pokorny) #4

Hello,
when I try to install Windows inside VM, installation is all the times stucked at Win logo screen.


Is there any solution for this?
Thanks, Pavel


(Jamesarems) #5

Hi Pavel,

Make sure your windows iso is not a corrupted one and please show your template content .


(em) #6

Hi,

I’m having the same issue trying to install windows10 on opennebula.
I’m using ISO downloaded from MS site, virtio-win.iso and a 100GB qcow2 disk.
here is the template:

TEMPLATE CONTENTS CONTEXT=[ NETWORK="YES", SSH_PUBLIC_KEY="$USER[SSH_PUBLIC_KEY]" ] CPU="1" DESCRIPTION="Windows 10 64bits Disk 100gb network staging" DISK=[ IMAGE="ocfs2-win-disk-100gb", IMAGE_UNAME="oneadmin" ] DISK=[ IMAGE="win10-eng-x64", IMAGE_UNAME="oneadmin" ] DISK=[ IMAGE="virtio-win-drivers", IMAGE_UNAME="oneadmin" ] FEATURES=[ ACPI="yes", APIC="yes", LOCALTIME="yes" ] GRAPHICS=[ LISTEN="0.0.0.0", TYPE="VNC" ] HYPERVISOR="kvm" INPUT=[ BUS="usb", TYPE="tablet" ] LOGO="images/logos/windows8.png" MEMORY="16384" NIC=[ MODEL="virtio", NETWORK="test", NETWORK_UNAME="oneadmin" ] OS=[ ARCH="x86_64", BOOT="cdrom,hd" ] SCHED_REQUIREMENTS="CLUSTER_ID=\"100\"" VCPU="4"

thanks!


Migrating Windows Server 2012 from VMDK to Opennebula
(Pavel Pokorny) #7

Hi,
I used the same ISO to install Win inside Hyper-V and without problem. So, ISO is OK.
The same “stuck” happens when installing Win 2013 and also Win 2016.
This is my template:

TEMPLATE 32 INFORMATION
ID : 32
NAME : Windows-2012-R2-from-ISO
USER : oneadmin
GROUP : oneadmin
REGISTER TIME : 05/06 13:34:24

PERMISSIONS
OWNER : um-
GROUP : —
OTHER : —

TEMPLATE CONTENTS
CONTEXT=[
NETWORK=“YES”,
SET_HOSTNAME="$NAME" ]
CPU="2"
DISK=[
IMAGE=“WINDOWS-2016-TP5-ISO”,
IMAGE_UNAME=“oneadmin” ]
DISK=[
IMAGE=“Virtio-WIN-0.1.117.ISO”,
IMAGE_UNAME=“oneadmin” ]
DISK=[
IMAGE=“Windows-Server-2012-R2-OS”,
IMAGE_UNAME=“oneadmin” ]
GRAPHICS=[
LISTEN=“0.0.0.0”,
TYPE=“VNC” ]
HYPERVISOR="kvm"
LOGO=“images/logos/windows8.png"
MEMORY=“10240"
NIC=[
NETWORK=“DEV-public”,
NETWORK_UNAME=“oneadmin” ]
NIC_DEFAULT=[
MODEL=“virtio” ]
OS=[
ARCH=“x86_64”,
BOOT=“cdrom” ]
RAW=[
DATA=””,
TYPE=“kvm” ]


(Pavel Pokorny) #8

Looks like problem is in VirtIO in image, image should be defined with DEV_PREFIX=“sd”.


(em) #9

So I was able to start the machine by changing the kvm’s cpu parameter from virsh, installation went fine, but after stopping the vm, I was not able to start it again.

steps:

  • use that template to deploy a new vm
  • vm starts but hangs with the windows logo
  • from that ONE backend, in virsh:
  1. poweroff the vm
  2. edit the vm xml
  3. add:
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>core2duo</model>
    <feature policy='require' name='nx'/>
  </cpu>
  1. start vm and install

Stopping the vm and restarting it gives me:
Could not create domain from /var/lib/one//datastores/101/163/deployment.4


How install windows vm?
(Roland) #10

besides the info I posted earlier in this thread, for windows 10 I had to do the following extra things:

  • get a windows disk image and make to mount it with prefix “sd”, so it will be mounted as something like “sda”. Use this way during the initial installation with the windows install cd.
  • also, mount this iso during installation: https://fedoraproject.org/wiki/Windows_Virtio_Drivers
    install drivers during installation, or if possible, after installation.
  • after install completes, make sure the template/image show device prefix as “vd” so the disk will be mounted as “vda”

Windows should boot normally now


(em) #11

Still not working.
I tried mounting the following options with no luck:

  • qcow2 disk as sd
  • installation ISO disk as sd
  • without VirtIO disk
  • without any disk, only the installation ISO

Always the same error and after reboot, shows the windows logo:


(Roland) #12

there is a thread here: http://ubuntuforums.org/showthread.php?t=2289210
with some tips about windows 10 and KVM. (changing cpu type)

Another option could be to install windows 10 using virtualbox, then convert the image using qemu-img and import it to opennebula. Workaround, yes, but get you where you want to go.


#13

Hi,

I’m currently trying to create a Windows Server 2016 vm. I’m still stuck at boot process and get the same error like emot.

Im working with a proconfigured image that I created with virtualbox. So the VirtIo drivers are already installed and I enabled remote control.
After creating the image I converted it to the qcow2 format using qemu-img.

This is my OpenNebula template:

CONTEXT=[NETWORK=“YES”]
CPU="2"
DISK=[DRIVER=“qcow2”,IMAGE=“winserv16”,IMAGE_UNAME=“oneadmin”,READONLY=“no”,TARGET=“vda”]
FEATURES=[ACPI=“yes”,APIC=“yes”,LOCALTIME=“yes”]
GRAPHICS=[LISTEN=“0.0.0.0”,RANDOM_PASSWD=“YES”,TYPE=“VNC”]
HYPERVISOR="kvm"
INPUT=[BUS=“usb”,TYPE=“tablet”]
MEMORY="16384"
NIC=[NETWORK=“TestNetz”,NETWORK_UNAME=“oneadmin”]
NIC_DEFAULT=[MODEL=“virtio”]
OS=[ARCH=“x86_64”,BOOT=“cdrom,hd”]
PCI=[CLASS=“0300”,DEVICE=“6798”,VENDOR=“1002”]
SUNSTONE_NETWORK_SELECT="NO"
VCPU=“2”

The previous post references http://ubuntuforums.org/showthread.php?t=2289210.
This is their conclusion:

Summary is to change the CPU type to (core2duo), add a feature flag (nx) and to hide KVM from the guest, then complete the upgrade...once finished you can revert the changes.
QEMU: -cpu core2duo,+nx,kvm=off
Libvirt:
Code:
<features>
  <acpi/>
  <kvm>
    <hidden state='on'/>
  </kvm>
</features>
<cpu mode='custom' match='exact'>
  <model fallback='allow'>core2duo</model>
  <feature policy='require' name='nx'/>
</cpu>

How can I add the needed Qemu options to my template? Same for the libvirt changes?
Has anyone tried it so far and was successful?

Sorry if some of the questions are obvious im pretty new to OpenNebula…


(Paul Batchelor) #14

I’ve successfully booted Windows 10 by adding this section to my template:

RAW=[
  DATA="<cpu><model fallback='allow'>core2duo</model></cpu>",
  TYPE="kvm" ]

This will add the required options to the libvirt XML that is generated from the template. You may need to ensure that the RAW template attribute is not restricted in oned.conf.


(em) #15

Thanks @Paul_Batchelor! I can run windows 10 now.


(Oscar) #16

Hi,

I have set this RAW data value in my Windows 10 template but it cannot deploy the virtual machine:

[oneadmin@vdicone01 100]$ cat /var/log/one/17.log
Sun Feb 5 01:06:13 2017 [Z0][VM][I]: New state is ACTIVE
Sun Feb 5 01:06:13 2017 [Z0][VM][I]: New LCM state is PROLOG
Sun Feb 5 01:07:18 2017 [Z0][VM][I]: New LCM state is BOOT
Sun Feb 5 01:07:18 2017 [Z0][VMM][I]: Generating deployment file: /var/lib/one/vms/17/deployment.0
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: Successfully execute transfer manager driver operation: tm_context.
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: ExitCode: 0
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: Successfully execute network driver operation: pre.
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: Command execution fail: cat << EOT | /var/tmp/one/vmm/kvm/deploy ‘/var/lib/one//datastores/0/17/deployment.0’ ‘vdicnode01-priv’ 17 vdicnode01-priv
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: error: Failed to create domain from /var/lib/one//datastores/0/17/deployment.0
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: error: unsupported configuration: guest and host CPU are not compatible: Host CPU does not provide required features: monitor
Sun Feb 5 01:07:19 2017 [Z0][VMM][E]: Could not create domain from /var/lib/one//datastores/0/17/deployment.0
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: ExitCode: 255
Sun Feb 5 01:07:19 2017 [Z0][VMM][I]: Failed to execute virtualization driver operation: deploy.
Sun Feb 5 01:07:19 2017 [Z0][VMM][E]: Error deploying virtual machine: Could not create domain from /var/lib/one//datastores/0/17/deployment.0
Sun Feb 5 01:07:19 2017 [Z0][VM][I]: New LCM state is BOOT_FAILURE

Anybody has eperienced the same issue?

My template:

CONTEXT = [
NETWORK = “YES”,
SSH_PUBLIC_KEY = “$USER[SSH_PUBLIC_KEY]” ]
CPU = "1"
DISK = [
DRIVER = “qcow2”,
IMAGE = “Windows10-BaseImage”,
IMAGE_UNAME = “oneadmin” ]
FEATURES = [
ACPI = “yes”,
APIC = “yes”,
LOCALTIME = “yes” ]
GRAPHICS = [
KEYMAP = “es”,
LISTEN = “0.0.0.0”,
TYPE = “SPICE” ]
INPUT = [
BUS = “usb”,
TYPE = “mouse” ]
INPUT = [
BUS = “usb”,
TYPE = “tablet” ]
LOGO = "images/logos/windows8.png"
MEMORY = "1024"
NIC = [
NETWORK = “VDI”,
NETWORK_UNAME = “oneadmin” ]
OS = [
ARCH = “x86_64”,
ROOT = “hd” ]
RAW = [
DATA = “core2duo”,
TYPE = “kvm” ]
USER_INPUTS = [
MEMORY = “O|fixed|| |1024” ]
VCPU = “2”


(Paul Batchelor) #17

Hi Oscar,

You need to set the data section exactly as I have it in the previous example -

RAW=[
  DATA="<cpu><model fallback='allow'>core2duo</model></cpu>",
  TYPE="kvm" ]

“core2duo” by itself isn’t valid XML and libvirt is failing to create the VM on the hypervisor as the domain xml is corrupted.


(Oscar) #18

Hi,

Sorry for the delay, I have had a heavy problem in my enviroment and I have not been able to fix it until now!

I attache the template of the VM where one can see that I have set it exactly as you suggest:

http://paste.fedoraproject.org/555403/69261501/

RAW = [
DATA = “core2duo”,
TYPE = “kvm” ]

But I’m getting the following errors:

Sun Feb 12 20:04:49 2017 [Z0][ReM][D]: Req:8976 UID:0 VirtualMachineAction invoked , “resume”, 17
Sun Feb 12 20:04:49 2017 [Z0][DiM][D]: Resuming VM 17
Sun Feb 12 20:04:49 2017 [Z0][ReM][D]: Req:8976 UID:0 VirtualMachineAction result SUCCESS, 17
Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 Successfully execute transfer manager driver operation: tm_context.

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 ExitCode: 0

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 Successfully execute network driver operation: pre.

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 Command execution fail: cat << EOT | /var/tmp/one/vmm/kvm/deploy ‘/var/lib/one//datastores/0/17/deployment.3’ ‘vdicnode01-priv’ 17 vdicnode01-priv

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 error: Failed to create domain from /var/lib/one//datastores/0/17/deployment.3

> Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 error: unsupported configuration: guest and host CPU are not compatible: Host CPU does not provide required features: monitor

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG E 17 Could not create domain from /var/lib/one//datastores/0/17/deployment.3

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 ExitCode: 255

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: LOG I 17 Failed to execute virtualization driver operation: deploy.

Sun Feb 12 20:04:50 2017 [Z0][VMM][D]: Message received: DEPLOY FAILURE 17 Could not create domain from /var/lib/one//datastores/0/17/deployment.3

Thanks a lot


(Paul Batchelor) #19

Hi Oscar

The only obvious issue I see in your template is that you have two INPUT sections. I’d suggest removing one of them. (you should keep the type=“TABLET” one as that won’t offset the mouse pointer in VNC (not sure about spice as we don’t use it)

Cheers


(Oscar) #20

Hi,

I have removed one of the INPUT sections:

https://paste.fedoraproject.org/paste/EDnRzNockeFEtTcdpRJPPV5M1UNdIGYhyRLivL9gydE=

But I still get the same error… :frowning:

Thanks a lot.