2016-02-19 4 views
1

Я пытаюсь создать бродячую коробку libvirt с нуля.Как построить коробку для libvirt с нуля

Я insttalled Ubuntu 14.04 и используется this руководство для подготовки машины для бродяги с помощью, а затем я использовал команду virsh domblklist test, чтобы найти мой файл изображения, так что я нашел его здесь /var/lib/libvirt/images/test.img, а затем копируется в место, где я собираюсь упаковать мой бродяга коробка. Затем я преобразовал свой файл необработанного изображения в формат qcow2 (beacause this страница говорит, что поддерживается только формат qcow2) с командой sudo qemu-img convert -f raw -O qcow2 test.img test.qcow2. Наконец, чтобы получить вещи сделано я выполнил vagrant init test и создал metadata.json файл с этим в нем

{ 
    "provider"  : "libvirt", 
    "format"  : "qcow2", 
    "virtual_size" : 8 
} 

И тогда я использовал команду tar cvzf vltest.box ./metadata.json ./Vagrantfile ./box.img, чтобы получить вещи вместе в одной коробке. Затем я добавил бокс для бродяг с vagrant box add test.img test.

Затем я попытался запустить машину с

vagrant init test 
vagrant up --provider=libvirt 

Но он застрял здесь:

... 
==> default: -- Video VRAM:  9216 
==> default: -- Keymap:   en-us 
==> default: -- INPUT:    type=mouse, bus=ps2 
==> default: -- Command line : 
==> default: Creating shared folders metadata... 
==> default: Starting domain. 
==> default: Waiting for domain to get an IP address... 

Тогда я решил открыть машину, и это было то, что я видел:

enter image description here

Здесь исходные конфигурации машины:

<domain type='kvm'> 
    <name>test</name> 
    <uuid>50c605f7-c06c-4288-bd03-f17575345171</uuid> 
    <memory unit='KiB'>1048576</memory> 
    <currentMemory unit='KiB'>1048576</currentMemory> 
    <vcpu placement='static'>1</vcpu> 
    <os> 
    <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type> 
    <boot dev='hd'/> 
    </os> 
    <features> 
    <acpi/> 
    <apic/> 
    <pae/> 
    </features> 
    <clock offset='utc'/> 
    <on_poweroff>destroy</on_poweroff> 
    <on_reboot>restart</on_reboot> 
    <on_crash>restart</on_crash> 
    <devices> 
    <emulator>/usr/bin/kvm-spice</emulator> 
    <disk type='file' device='disk'> 
     <driver name='qemu' type='raw'/> 
     <source file='/var/lib/libvirt/images/test.img'/> 
     <target dev='vda' bus='virtio'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> 
    </disk> 
    <disk type='block' device='cdrom'> 
     <driver name='qemu' type='raw'/> 
     <target dev='hdc' bus='ide'/> 
     <readonly/> 
     <address type='drive' controller='0' bus='1' target='0' unit='0'/> 
    </disk> 
    <controller type='usb' index='0'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> 
    </controller> 
    <controller type='pci' index='0' model='pci-root'/> 
    <controller type='ide' index='0'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> 
    </controller> 
    <interface type='network'> 
     <mac address='52:54:00:6c:05:1b'/> 
     <source network='default'/> 
     <model type='virtio'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> 
    </interface> 
    <serial type='pty'> 
     <target port='0'/> 
    </serial> 
    <console type='pty'> 
     <target type='serial' port='0'/> 
    </console> 
    <input type='mouse' bus='ps2'/> 
    <input type='keyboard' bus='ps2'/> 
    <graphics type='vnc' port='-1' autoport='yes'/> 
    <sound model='ich6'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> 
    </sound> 
    <video> 
     <model type='cirrus' vram='9216' heads='1'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> 
    </video> 
    <memballoon model='virtio'> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> 
    </memballoon> 
    </devices> 
</domain> 

Вот конфигурация вновь образованная бродячей коробка:

<domain type='kvm' id='8'> 
    <name>testLibvirt_default</name> 
    <uuid>00069068-f4bc-41fa-b316-870e78fbe393</uuid> 
    <memory unit='KiB'>524288</memory> 
    <currentMemory unit='KiB'>524288</currentMemory> 
    <vcpu placement='static'>1</vcpu> 
    <resource> 
    <partition>/machine</partition> 
    </resource> 
    <os> 
    <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type> 
    <boot dev='hd'/> 
    </os> 
    <features> 
    <acpi/> 
    <apic/> 
    <pae/> 
    </features> 
    <cpu mode='host-model'> 
    <model fallback='allow'/> 
    </cpu> 
    <clock offset='utc'/> 
    <on_poweroff>destroy</on_poweroff> 
    <on_reboot>restart</on_reboot> 
    <on_crash>destroy</on_crash> 
    <devices> 
    <emulator>/usr/bin/kvm-spice</emulator> 
    <disk type='file' device='disk'> 
     <driver name='qemu' type='qcow2'/> 
     <source file='/var/lib/libvirt/images/testLibvirt_default.img'/> 
     <target dev='vda' bus='virtio'/> 
     <alias name='virtio-disk0'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> 
    </disk> 
    <controller type='usb' index='0'> 
     <alias name='usb0'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> 
    </controller> 
    <controller type='pci' index='0' model='pci-root'> 
     <alias name='pci.0'/> 
    </controller> 
    <interface type='network'> 
     <mac address='52:54:00:91:b2:63'/> 
     <source network='vagrant-libvirt'/> 
     <target dev='vnet0'/> 
     <model type='virtio'/> 
     <alias name='net0'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> 
    </interface> 
    <serial type='pty'> 
     <source path='/dev/pts/8'/> 
     <target port='0'/> 
     <alias name='serial0'/> 
    </serial> 
    <console type='pty' tty='/dev/pts/8'> 
     <source path='/dev/pts/8'/> 
     <target type='serial' port='0'/> 
     <alias name='serial0'/> 
    </console> 
    <input type='mouse' bus='ps2'/> 
    <input type='keyboard' bus='ps2'/> 
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1' keymap='en-us'> 
     <listen type='address' address='127.0.0.1'/> 
    </graphics> 
    <video> 
     <model type='cirrus' vram='9216' heads='1'/> 
     <alias name='video0'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> 
    </video> 
    <memballoon model='virtio'> 
     <alias name='balloon0'/> 
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> 
    </memballoon> 
    </devices> 
    <seclabel type='dynamic' model='apparmor' relabel='yes'> 
    <label>libvirt-00069068-f4bc-41fa-b316-870e78fbe393</label> 
    <imagelabel>libvirt-00069068-f4bc-41fa-b316-870e78fbe393</imagelabel> 
    </seclabel> 
</domain> 

Update: Также я попытался packer но получить ту же ошибку, когда личинка показывает вверх. Вот мой шаблон для упаковщика:

{ 
    "builders": 
    [ 
     { 
     "type": "qemu", 
     "iso_url": "/home/galiaf95/Downloads/ubuntu-14.04.3-desktop-amd64.iso", 
     "iso_checksum": "cab6dd5ee6d649ed1b24e807c877c0ae", 
     "iso_checksum_type": "md5", 
     "output_directory": "output_centos_tdhtest", 
     "shutdown_command": "shutdown -P now", 
     "disk_size": 8000, 
     "format": "qcow2", 
     "headless": false, 
     "accelerator": "kvm", 
     "http_port_min": 10082, 
     "http_port_max": 10089, 
     "ssh_host_port_min": 2222, 
     "ssh_host_port_max": 2229, 
     "ssh_username": "vagrant", 
     "ssh_password": "vagrant", 
     "ssh_port": 22, 
     "ssh_wait_timeout": "7200s", 
     "vm_name": "tdhtest", 
     "net_device": "virtio-net", 
     "disk_interface": "virtio" 
     } 
    ], 
    "post-processors": [ 
     { 
      "keep_input_artifact": false, 
      "output": "box/ubuntu-1404-server.box", 
      "type": "vagrant" 
     } 
    ] 
} 

ISO файл убунт 14.04 я скачал с сайта Ubuntu.

Так что мои вопросы:

  1. Что я сделал не так и как решить, что
  2. Есть более правильный способ построения бродячих коробков Libvirt с нуля

ответ

0

Что я сделал неправильно и как решить это

не может реально помочь от моего язь

Есть более правильный способ строительства бродячие коробки Libvirt с нуля

Я бы рекомендовал использовать packer, как от [v 0,7.2] ( https://www.polibyte.com/blog/packer_supports_vagrant-libvirt) Пакерные опоры для бродяг-libvirt

+0

Привет, Я только что попробовал это, но получаю ту же ошибку, когда появляется спасение grub. Возможно, я сделал что-то не так. Не могли бы вы посмотреть мой шаблон для упаковщика, я добавил его для публикации. – GALIAF95

 Смежные вопросы

  • Нет связанных вопросов^_^