wiki:TipAndDoc/VM/Xen

Version 17 (modified by mitty, 9 years ago) (diff)

--

Xen

Xen with Debian squeeze

  • $ sudo xen-create-image --hostname squeeze-ubuntu --dhcp --dir /var/lib/libvirt/images/
    • /var/log/xen-tools/squeeze-ubuntu.log にログが出来る
      Installation Summary
      ---------------------
      Hostname        :  squeeze-ubuntu
      Distribution    :  squeeze
      IP-Address(es)  :  dynamic
      RSA Fingerprint :  c7:4f:41:bb:27:df:fd:5a:54:6c:65:40:cf:4e:e5:1f
      Root Password   :  gP2zHhCR
      
      • root password が画面に出力される!
    • virt-managerにはDom-0のまま、作成したゲストは登録されない
  • $ sudo xm create /etc/xen/squeeze-ubuntu.cfg
    Using config file "/etc/xen/squeeze-ubuntu.cfg".
    Started domain squeeze-ubuntu (id=1)
    
    • 起動中のみ、ゲストが現れる

Xen with Ubuntu lucid

  • https://help.ubuntu.com/community/Xen
    • Maverick Notes (Xen 4.0.1 pvops on Ubuntu 10.10)

      The Xen packages that come with Ubuntu 10.10 ubuntu-xen-desktop and ubuntu-xen-server have broken dependencies. Therefore, we will have to download Xen source and build it.

force install ubuntu-xen-server

  • 結論としては「失敗」
  • $ sudo aptitude install -R ubuntu-xen-server
    The following packages are BROKEN:
      ubuntu-xen-server
    The following NEW packages will be installed:
      libc6-xen libsdl1.2debian{a} libsdl1.2debian-alsa{a} linux-generic-pae
      linux-image-2.6.32-27-generic-pae linux-image-generic-pae linux-server
      python-dev{a} python-xen-3.3 python2.6-dev{a} xen-docs-3.3
      xen-hypervisor-3.3 xen-utils-3.3
    The following packages are RECOMMENDED but will NOT be installed:
      libc6-dev
    0 packages upgraded, 14 newly installed, 0 to remove and 0 not upgraded.
    Need to get 39.3MB/39.5MB of archives. After unpacking 120MB will be used.
    The following packages have unmet dependencies:
      ubuntu-xen-server: Depends: xen-tools which is a virtual package.
    The following actions will resolve these dependencies:
    
    Keep the following packages at their current version:
    ubuntu-xen-server [Not Installed]
    
    Score is -9881
    
    Accept this solution? [Y/n/q/?] Y
    The following NEW packages will be installed:
      libc6-xen libsdl1.2debian{a} libsdl1.2debian-alsa{a} linux-generic-pae
      linux-image-2.6.32-27-generic-pae linux-image-generic-pae linux-server
      python-dev{a} python-xen-3.3 python2.6-dev{a} xen-docs-3.3
      xen-hypervisor-3.3 xen-utils-3.3
    The following packages are RECOMMENDED but will NOT be installed:
      libc6-dev
    0 packages upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
    Need to get 39.3MB/39.5MB of archives. After unpacking 120MB will be used.
    Do you want to continue? [Y/n/?]
    
    (snip)
    
    Processing triggers for python-central ...
    Setting up xen-utils-3.3 (3.3.0-1ubuntu11) ...
    update-rc.d: warning: xend stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (S 0 1 6)
    grep: /proc/xen/capabilities: No such file or directory
    update-rc.d: warning: xendomains start runlevel arguments (2 3 4 5) do not match LSB Default-Start values (3 4 5)
    update-rc.d: warning: xendomains stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (0 1 2 6)
    
    (snip)
    
  • $ uname -a
    Linux milly 2.6.32-27-generic-pae #49-Ubuntu SMP Thu Dec 2 00:07:52 UTC 2010 i686 GNU/Linux
    

cannot start xend

  • $ sudo service xend start
    grep: /proc/xen/capabilities: No such file or directory
    
  • $ sudo vim /etc/fstab
    xenfs /proc/xen xenfs defaults 0 0
    

    An error occured while mounting /proc/xen

remove xen 3.3

  • $ sudo aptitude remove -R \
    >   libc6-xen libsdl1.2debian libsdl1.2debian-alsa linux-generic-pae\
    >   linux-image-2.6.32-27-generic-pae linux-image-generic-pae linux-server\
    >   python-dev python-xen-3.3 python2.6-dev xen-docs-3.3\
    >   xen-hypervisor-3.3 xen-utils-3.3
    
    The following packages will be REMOVED:
      libc6-xen libsdl1.2debian libsdl1.2debian-alsa linux-generic-pae
      linux-image-2.6.32-27-generic-pae linux-image-generic-pae linux-server
      python-dev python-xen-3.3 python2.6-dev xen-docs-3.3 xen-hypervisor-3.3
      xen-utils-3.3
    0 packages upgraded, 0 newly installed, 13 to remove and 0 not upgraded.
    

build 4.0.1 from source

  • https://help.ubuntu.com/community/Xen

    The packages are: gettext, bin86, bcc, libc6-dev-i386, iasl, texinfo, git, uuid-dev.

    • これだけでは十分ではない => log
  • Xen4.0 with Ubuntu 10.04 LTS Server Install|Digital Lab
    • コンパイルに必要なパッケージの取得。

      #sudo apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev

    • イメージファイルを使うときは tap を有効にする。
      Backend driver support (XEN_BACKEND) [Y/n/?] y
      Block-device backend driver (XEN_BLKDEV_BACKEND) [Y/n/m/?] y
      Block-device tap backend driver (XEN_BLKDEV_TAP) [N/m/y/?] (NEW) y
      

cannot boot

  • 以下の手順ではXen Kernelの起動に成功していない

case 1

build kernel

  1. $ sudo aptitude install -R bcc bin86 build-essential gettext ghostscript git-core iasl libncurses5-dev libsdl1.2-dev libssl-dev python2.6-dev texinfo texlive-binaries texlive-fonts-recommended texlive-latex-base texlive-latex-recommended transfig uuid-dev x11proto-core-dev zlib1g-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Reading extended state information
    Initializing package states... Done
    The following NEW packages will be installed:
      bcc bin86 binutils{a} build-essential defoma{a} dpkg-dev{a}
      esound-common{a} fontconfig-config{a} g++{a} g++-4.4{a} gawk{a} gcc{a}
      gcc-4.4{a} gettext ghostscript git-core gsfonts{a} iasl libaa1{a}
      libaa1-dev{a} libasound2{a} libasound2-dev{a} libaudio-dev{a}
      libaudio2{a} libaudiofile-dev{a} libaudiofile0{a} libavahi-client-dev{a}
      libavahi-client3{a} libavahi-common-data{a} libavahi-common-dev{a}
      libavahi-common3{a} libc-dev-bin{a} libc6-dev{a} libcaca-dev{a}
      libcaca0{a} libcroco3{a} libcups2{a} libcupsimage2{a} libdbus-1-dev{a}
      libdigest-sha1-perl{a} libdirectfb-1.2-0{a} libdirectfb-dev{a}
      libdirectfb-extra{a} libdrm-dev{a} liberror-perl{a} libesd0{a}
      libesd0-dev{a} libflac8{a} libfontconfig1{a} libfreetype6-dev{a}
      libgl1-mesa-dev{a} libgl1-mesa-glx{a} libglib2.0-dev{a} libglu1-mesa{a}
      libglu1-mesa-dev{a} libgomp1{a} libgs8{a} libice-dev{a} libice6{a}
      libjpeg62{a} libjpeg62-dev{a} libkpathsea5{a} liblcms1{a} liblzma1{a}
      libncurses5-dev libogg0{a} libpaper1{a} libpng12-dev{a} libpoppler5{a}
      libpthread-stubs0{a} libpthread-stubs0-dev{a} libpulse-browse0{a}
      libpulse-dev{a} libpulse-mainloop-glib0{a} libpulse0{a} libpython2.6{a}
      libsdl1.2-dev libsdl1.2debian{a} libsdl1.2debian-alsa{a} libslang2-dev{a}
      libsm-dev{a} libsm6{a} libsndfile1{a} libssl-dev libstdc++6-4.4-dev{a}
      libsysfs-dev{a} libsysfs2{a} libtiff4{a} libts-0.0-0{a} libvorbis0a{a}
      libvorbisenc2{a} libx11-dev{a} libxau-dev{a} libxaw7{a} libxcb1-dev{a}
      libxdamage1{a} libxdmcp-dev{a} libxext-dev{a} libxfixes3{a} libxi6{a}
      libxmu6{a} libxpm4{a} libxt-dev{a} libxt6{a} libxtst6{a} libxxf86vm1{a}
      linux-libc-dev{a} luatex{a} mesa-common-dev{a} patch{a} pkg-config{a}
      python2.6-dev tex-common{a} texinfo texlive-base{a} texlive-binaries
      texlive-common{a} texlive-doc-base{a} texlive-fonts-recommended
      texlive-latex-base texlive-latex-recommended transfig tsconf{a}
      ttf-dejavu-core{a} uuid-dev x11-common{a} x11proto-core-dev
      x11proto-input-dev{a} x11proto-kb-dev{a} x11proto-xext-dev{a}
      xtrans-dev{a} xz-utils{a} zlib1g-dev
    The following packages are RECOMMENDED but will NOT be installed:
      cvs cvsnt elks-libc esound-clients fakeroot latex-beamer latex-xcolor
      libgl1-mesa-dri libpaper-utils lmodern manpages-dev netpbm prosper
      psfontmgr texlive-fonts-recommended-doc texlive-latex-base-doc
      texlive-latex-recommended-doc texlive-luatex tipa
    0 packages upgraded, 133 newly installed, 0 to remove and 0 not upgraded.
    Need to get 108MB of archives. After unpacking 310MB will be used.
    
  2. $ wget http://bits.xensource.com/oss-xen/release/4.0.1/xen-4.0.1.tar.gz
  3. ~/xen-4.0.1$ make world
    install -d -m0755 -p /home/mitty/xen-4.0.1/dist/check
    install -m0644 -p ./COPYING /home/mitty/xen-4.0.1/dist
    install -m0644 -p ./README /home/mitty/xen-4.0.1/dist
    install -m0755 -p ./install.sh /home/mitty/xen-4.0.1/dist
    install -m0755 -p tools/check/chk tools/check/check_* tools/check/funcs.sh /home/mitty/xen-4.0.1/dist/check
    make[1]: Leaving directory `/home/mitty/xen-4.0.1'
    
  4. ~/xen-4.0.1$ sudo make install
    install -d -m0755 -p //usr/share/man
    cp -dR man1 //usr/share/man
    cp -dR man5 //usr/share/man
    [ ! -d html ] || cp -dR html //usr/share/doc/xen
    make[1]: Leaving directory `/home/mitty/xen-4.0.1/docs'
    

edit GRUB conf

  1. $ sudo vim /etc/default/grub
    @@ -2,7 +2,7 @@
     # /boot/grub/grub.cfg.
    
     GRUB_DEFAULT=0
    -GRUB_HIDDEN_TIMEOUT=0
    +#GRUB_HIDDEN_TIMEOUT=0
     GRUB_HIDDEN_TIMEOUT_QUIET=true
     GRUB_TIMEOUT=10
     GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    
  2. $ sudo vim /etc/grub.d/40_custom
    @@ -3,3 +3,12 @@
     # This file provides an easy way to add custom menu entries.  Simply type the
     # menu entries you want to add after this comment.  Be careful not to change
     # the 'exec tail' line above.
    +menuentry "Xen 4.0.1  2.6.32-27 pvops" {
    +insmod part_msdos
    +insmod ext2
    +set root=(hd0,msdos1)
    +search --no-floppy --fs-uuid --set 95142d06-fa2c-4af5-ae7f-c237b109c320
    +multiboot /boot/xen.gz
    +module /boot//boot/initrd.img-2.6.32-27 root=/dev/sda1
    +module /boot/initrd.img-2.6.32-27
    +}
    
  3. $ sudo update-grub

case 2

  1. $ sudo aptitude install -R bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial build-essential make gcc libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev
    Note: selecting "libpci-dev" instead of the
          virtual package "pciutils-dev"
    The following NEW packages will be installed:
      bridge-utils comerr-dev{a} e2fslibs-dev krb5-multidev{a} libbz2-dev
      libcurl3 libcurl4-openssl-dev libgssrpc4{a} libidn11-dev{a}
      libkadm5clnt-mit7{a} libkadm5srv-mit7{a} libkdb5-4{a} libkrb5-dev{a}
      libldap2-dev{a} libpci-dev libvncserver-dev libvncserver0{a} mercurial
      mercurial-common{a} python-crypto{a} python-dev python-openssl{a}
      python-pkg-resources{a} python-pyasn1{a} python-twisted
      python-twisted-bin{a} python-twisted-conch{a} python-twisted-core{a}
      python-twisted-lore{a} python-twisted-mail{a} python-twisted-names{a}
      python-twisted-news{a} python-twisted-runner{a} python-twisted-web{a}
      python-twisted-words{a} python-zope.interface{a} texlive-fonts-extra tgif
    The following packages are RECOMMENDED but will NOT be installed:
      python-pam python-serial texlive-fonts-extra-doc
    0 packages upgraded, 38 newly installed, 0 to remove and 0 not upgraded.
    Need to get 92.6MB of archives. After unpacking 264MB will be used.
    
  2. ~/xen-4.0.1$ make world
      Block-device tap backend driver (XEN_BLKDEV_TAP) [N/m/y/?] (NEW) y
    
  3. ~/xen-4.0.1$ sudo make install
  4. $ sudo vi /etc/fstab
    xenfs /proc/xen xenfs defaults 0 0
    
  5. $ sudo mkinitramfs -o /boot/initrd.img-2.6.32.27 2.6.32.27
  6. $ sudo vi /etc/grub.d/40_custom
    menuentry "Xen 4.0.1  2.6.32-27 pvops" {
    insmod part_msdos
    insmod ext2
    set root=(hd0,msdos1)
    search --no-floppy --fs-uuid --set 96bc95f7-2de5-48a2-be1a-7bfd9d8ed206
    multiboot /boot/xen.gz
    module /boot/vmlinuz-2.6.32-27 root=/dev/sda1
    module /boot/initrd.img-2.6.32.27
    }
    
  7. $ sudo update-grub

how to boot

  • WORK IN PROGRESS

  • $ sudo mkinitramfs -o /boot/initrd.img-2.6.32-27-generic 2.6.32-27-generic
    • /etc/grub.d/40_custom を併せて修正したが効果なし

passthrough

primary VGA controller

  • spec
    • H/W -> wiki:TipAndDoc/VM/KVM#Windows7x64withvirtio と同じ
    • Ubuntu 14.04.2 LTS
    • Linux xen 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    • Package: xen-hypervisor-4.4-amd64
    • Version: 4.4.1-0ubuntu0.14.04.6

gfx_passthru=0

  • guest win7-xen.cfg
    builder='hvm'
    memory = 4096
    name = 'win7'
    vcpus=4
    #pae=1
    acpi=1
    apic=1
    on_xend_stop='shutdown'
    vif = [ 'mac=00:16:3e:68:e1:01,bridge=xenbr0' ]
    disk = [ 'file:/data/libvirt/images/win7-xen.img,hda,w' , 'file:/data/samba/iso/virtio-win-0.1.104.iso,hdc:cdrom,r' ]
    boot='dc'
    sdl=0
    spice=1
    spiceport=5900
    spicepasswd='password'
    stdvga=0
    serial='pty'
    viridian=1
    usb=1
    usbdevice='tablet'
    gfx_passthru=0
    pci=[ '00:02.0' ]
    localtime=1
    pci_power_mgmt=1
    
    1. mitty@xen:~$ lspci -nn
      00:02.0 VGA compatible controller [0300]: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [8086:0412] (rev 06)
      
    2. mitty@xen:~$ sudo modprobe xen-pciback
    3. mitty@xen:~$ sudo xl pci-assignable-list
    4. mitty@xen:~$ sudo xl pci-assignable-add 00:02.0
    5. mitty@xen:~$ sudo xl pci-assignable-list
      0000:00:02.0
      

gfx_passthru=1

  • mitty@xen:~$ vim win7-xen.cfg
    gfx_passthru=1
    
  • mitty@xen:~$ sudo xl create win7-xen.cfg
    Parsing config from win7-xen.cfg
    libxl: error: libxl_dm.c:1388:device_model_spawn_outcome: domain 5 device model: spawn failed (rc=-3)
    libxl: error: libxl_create.c:1186:domcreate_devmodel_started: device model did not start: -3
    libxl: error: libxl_dm.c:1492:kill_device_model: Device Model already exited
    

qemu-xen-traditional

  • mitty@xen:~$ vim win7-xen.cfg
    device_model_version="qemu-xen-traditional"
    gfx_passthru=1
    

Attachments (7)

Download all attachments as: .zip