CentOS 7 虚拟机创建失败解决

Openstack版本: Kilo

OS:CentOS 7 Gnome桌面版

问题:CentOS 7 计算节点上虚拟机创建失败

日志记录:/var/log/nova/nova-compute.log

2015-08-10 22:06:41.282 707 INFO nova.compute.manager [req-c4498aca-20cc-4950-8484-2ea9da8670c9 a9ba5e68a0db48fdbf5ab664f6f25ca0 a506166979e641dd9f44a25351515014 - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Starting instance...

2015-08-10 22:06:41.544 707 INFO nova.compute.claims [-] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Attempting claim: memory 2048 MB, disk 20 GB

2015-08-10 22:06:41.544 707 INFO nova.compute.claims [-] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Total memory: 16049 MB, used: 2560.00 MB

2015-08-10 22:06:41.545 707 INFO nova.compute.claims [-] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] memory limit: 24073.50 MB, free: 21513.50 MB

2015-08-10 22:06:41.545 707 INFO nova.compute.claims [-] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Total disk: 49 GB, used: 20.00 GB

2015-08-10 22:06:41.546 707 INFO nova.compute.claims [-] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] disk limit not specified, defaulting to unlimited

2015-08-10 22:06:41.621 707 INFO nova.compute.claims [-] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Claim successful

2015-08-10 22:06:41.874 707 INFO nova.scheduler.client.report [-] Compute_service record updated for ('localhost.localdomain', 'localhost.localdomain')

2015-08-10 22:06:42.253 707 INFO nova.scheduler.client.report [-] Compute_service record updated for ('localhost.localdomain', 'localhost.localdomain')

2015-08-10 22:06:42.835 707 INFO nova.virt.libvirt.driver [req-5028a584-b5fb-4260-b3f8-cb145d6a2088 - - - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Creating image

2015-08-10 22:06:44.116 707 INFO nova.scheduler.client.report [-] Compute_service record updated for ('localhost.localdomain', 'localhost.localdomain')

2015-08-10 22:06:57.048 707 INFO nova.virt.libvirt.firewall [req-5028a584-b5fb-4260-b3f8-cb145d6a2088 - - - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Called setup_basic_filtering in nwfilter

2015-08-10 22:06:57.049 707 INFO nova.virt.libvirt.firewall [req-5028a584-b5fb-4260-b3f8-cb145d6a2088 - - - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Ensuring static filters

2015-08-10 22:06:57.468 707 ERROR nova.virt.libvirt.driver [req-5028a584-b5fb-4260-b3f8-cb145d6a2088 - - - - -] Error launching a defined domain with XML: <domain type='kvm'>

  <name>instance-00000006</name>

  <uuid>e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c</uuid>

  <metadata>

    <nova:instance xmlns:nova="http://openstack.org/xmlns/libvirt/nova/1.0">

      <nova:package version="2015.1.0-3.el7"/>

      <nova:name>ffd</nova:name>

      <nova:creationTime>2015-08-11 02:06:57</nova:creationTime>

      <nova:flavor name="m1.small">

        <nova:memory>2048</nova:memory>

        <nova:disk>20</nova:disk>

        <nova:swap>0</nova:swap>

        <nova:ephemeral>0</nova:ephemeral>

        <nova:vcpus>1</nova:vcpus>

      </nova:flavor>

      <nova:owner>

        <nova:user uuid="a9ba5e68a0db48fdbf5ab664f6f25ca0">admin</nova:user>

        <nova:project uuid="a506166979e641dd9f44a25351515014">adminTenant</nova:project>

      </nova:owner>

      <nova:root type="image" uuid="7cf6891d-e1b1-433c-8ac3-9047c251c368"/>

    </nova:instance>

  </metadata>

  <memory unit='KiB'>2097152</memory>

  <currentMemory unit='KiB'>2097152</currentMemory>

  <vcpu placement='static' cpuset='0-3'>1</vcpu>

  <cputune>

    <shares>1024</shares>

  </cputune>

    <sysinfo type='smbios'>

      <system>

        <entry name='manufacturer'>Fedora Project</entry>

        <entry name='product'>OpenStack Nova</entry>

        <entry name='version'>2015.1.0-3.el7</entry>

        <entry name='serial'>bc3c4917-1c83-4aff-b58f-d860f485625a</entry>

        <entry name='uuid'>e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c</entry>

      </system>

    </sysinfo>

  <os>

    <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>

    <boot dev='hd'/>

    <smbios mode='sysinfo'/>

  </os>

  <features>

    <acpi/>

    <apic/>

  </features>

  <cpu mode='host-model'>

    <model fallback='allow'/>

    <topology sockets='1' cores='1' threads='1'/>

  </cpu>

  <clock offset='utc'>

    <timer name='pit' tickpolicy='delay'/>

    <timer name='rtc' tickpolicy='catchup'/>

    <timer name='hpet' present='no'/>

  </clock>

  <on_poweroff>destroy</on_poweroff>

  <on_reboot>restart</on_reboot>

  <on_crash>destroy</on_crash>

  <devices>

    <emulator>/usr/libexec/qemu-kvm</emulator>

    <disk type='file' device='disk'>

      <driver name='qemu' type='qcow2' cache='none'/>

      <source file='/var/lib/nova/instances/e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c/disk'/>

      <target dev='vda' bus='virtio'/>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>

    </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='virtio-serial' index='0'>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>

    </controller>

    <interface type='bridge'>

      <mac address='fa:16:3e:dd:a0:44'/>

      <source bridge='br100'/>

      <model type='virtio'/>

      <filterref filter='nova-instance-instance-00000006-fa163edda044'/>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>

    </interface>

    <serial type='file'>

      <source path='/var/lib/nova/instances/e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c/console.log'/>

      <target port='0'/>

    </serial>

    <serial type='pty'>

      <target port='1'/>

    </serial>

    <console type='file'>

      <source path='/var/lib/nova/instances/e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c/console.log'/>

      <target type='serial' port='0'/>

    </console>

    <channel type='pty'>

      <target type='virtio' name='com.RedHat.spice.0'/>

      <address type='virtio-serial' controller='0' bus='0' port='1'/>

    </channel>

    <input type='tablet' bus='usb'/>

    <input type='mouse' bus='ps2'/>

    <input type='keyboard' bus='ps2'/>

    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='en-us'>

      <listen type='address' address='0.0.0.0'/>

    </graphics>

    <graphics type='spice' autoport='yes' listen='0.0.0.0' keymap='en-us'>

      <listen type='address' address='0.0.0.0'/>

    </graphics>

    <video>

      <model type='qxl' ram='65536' vram='65536' vgamem='16384' 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'/>

      <stats period='10'/>

    </memballoon>

  </devices>

</domain>

2015-08-10 22:06:57.469 707 ERROR nova.compute.manager [req-5028a584-b5fb-4260-b3f8-cb145d6a2088 - - - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Instance failed to spawn

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Traceback (most recent call last):

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/Python2.7/site-packages/nova/compute/manager.py", line 2442, in _build_resources

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    yield resources

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2314, in _build_and_run_instance

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    block_device_info=block_device_info)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 2354, in spawn

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    block_device_info=block_device_info)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4391, in _create_domain_and_network

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    power_on=power_on)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4322, in _create_domain

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    LOG.error(err)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    six.reraise(self.type_, self.value, self.tb)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4312, in _create_domain

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    domain.createWithFlags(launch_flags)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 183, in doit

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    result = proxy_call(self._autowrap, f, *args, **kwargs)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 141, in proxy_call

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    rv = execute(f, *args, **kwargs)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 122, in execute

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    six.reraise(c, e, tb)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib/python2.7/site-packages/eventlet/tpool.py", line 80, in tworker

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    rv = meth(*args, **kwargs)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 996, in createWithFlags

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]    if ret == -1: raise libvirtError ('virDomainCreateWithFlags() failed', dom=self)

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] libvirtError: internal error: referenced filter 'no-mac-spoofing' is missing

2015-08-10 22:06:57.469 707 TRACE nova.compute.manager [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c]

2015-08-10 22:06:57.472 707 INFO nova.compute.manager [req-c4498aca-20cc-4950-8484-2ea9da8670c9 a9ba5e68a0db48fdbf5ab664f6f25ca0 a506166979e641dd9f44a25351515014 - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Terminating instance

2015-08-10 22:06:57.480 707 INFO nova.virt.libvirt.driver [-] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Instance destroyed successfully.

2015-08-10 22:06:57.715 707 INFO nova.virt.libvirt.driver [req-5028a584-b5fb-4260-b3f8-cb145d6a2088 - - - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Deleting instance files /var/lib/nova/instances/e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c_del

2015-08-10 22:06:57.716 707 INFO nova.virt.libvirt.driver [req-5028a584-b5fb-4260-b3f8-cb145d6a2088 - - - - -] [instance: e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c] Deletion of /var/lib/nova/instances/e8b32dc2-4dd1-4956-9cab-a6c6c0d5655c_del complete

根据日志记录,发现错误关键字:

libvirtError: internal error: referenced filter 'no-mac-spoofing' is missing

经过上网搜索以后,发现问题与libvirt的nwfilter功能相关。

查看计算节点libvirt 相关的nwfilter信息

root@localhost ~]# virsh nwfilter-list

 UUID                                  Name

------------------------------------------------------------------

 4e221669-6d5a-43a9-b5eb-98dd70e3a157  nova-allow-dhcp-server

 0f103d9e-20fb-4533-a3b5-edcaad5c2137  nova-base

 ad6f6e51-5981-49d0-892a-3409f1da58cf  nova-instance-instance-00000005-fa163e28d503

 fda64645-7a74-4b44-9949-c4c126672466  nova-instance-instance-00000006-fa163edda044

 c7a96409-7c16-4e18-bdef-29980aaa8c8f  nova-instance-instance-00000007-fa163eb3fb99

 500220cc-3738-4076-a71f-79aa9dc59802  nova-no-nd-reflection

 de0e1a3a-94df-4331-8cd4-e5a8e143e6d8  nova-nodhcp

 dab8b452-098e-4019-a5d2-b053d46d0091  nova-vpn

发现nwfilter缺少no-mac-spoofing信息。

解决:安装nwfilter软件包

yum install libvirt-daemon-config-nwfilter

软件包安装后,重启libvirtd服务:

service libvirtd restart

再次查看libvirt的network filter

[root@localhost ~]# virsh nwfilter-list

 UUID                                  Name

------------------------------------------------------------------

 7d26d9b6-1c05-4875-9d3c-d4ddc3e7157c  allow-arp

 5fd0997d-978a-42cb-bb55-83b195a1ee02  allow-dhcp

 26412da7-4cc1-47ad-a8bd-1ece211ac451  allow-dhcp-server

 cf070932-efdd-4647-b517-e31b08d5b27d  allow-incoming-ipv4

 59937e6f-d676-49c0-98c8-28313f54fbc7  allow-ipv4

 3f558bed-627e-4ae7-b245-7662476673c9  clean-traffic

 6350f1ca-d24a-4097-abee-04d04456d0bc  no-arp-ip-spoofing

 29337093-9041-4765-bd54-b0225e3d373c  no-arp-mac-spoofing

 8c508085-3af2-4355-84d9-7c0ed9baa97d  no-arp-spoofing

 6dd04710-0d3f-48ff-ace0-04ff4c540dac  no-ip-multicast

 b1f0c2ce-320e-41fd-9985-53c3fa27d226  no-ip-spoofing

 8cdd6e3d-35e2-4958-87e6-aa17ee04ea7e  no-mac-broadcast

 5aab9582-e0ac-4eb8-9b6f-e4a20eced81e  no-mac-spoofing

 19bb746c-2062-4128-a2d1-93e3177d967c  no-other-l2-traffic

 afe58c32-67e0-4f15-a31d-bb722344b89f  no-other-rarp-traffic

 4e221669-6d5a-43a9-b5eb-98dd70e3a157  nova-allow-dhcp-server

 0f103d9e-20fb-4533-a3b5-edcaad5c2137  nova-base

 ad6f6e51-5981-49d0-892a-3409f1da58cf  nova-instance-instance-00000005-fa163e28d503

 fda64645-7a74-4b44-9949-c4c126672466  nova-instance-instance-00000006-fa163edda044

 c7a96409-7c16-4e18-bdef-29980aaa8c8f  nova-instance-instance-00000007-fa163eb3fb99

 500220cc-3738-4076-a71f-79aa9dc59802  nova-no-nd-reflection

 de0e1a3a-94df-4331-8cd4-e5a8e143e6d8  nova-nodhcp

 dab8b452-098e-4019-a5d2-b053d46d0091  nova-vpn

 b81a5aa6-0045-49ec-b5fb-d5ae62245ef9  qemu-announce-self

 2dbff157-d88d-42fd-ae93-052efdd27af7  qemu-announce-self-rarp

此时创建虚拟机即可成功。

相关推荐