Openstack官方描述:

问题

libvirtError: POST operation failed: xend_post: error from xen daemon: (xend.err 'Device /dev/xvdp (51952, tap) is already connected.')

修改后创建虚拟机时仍是err

[root@Dom0 ~(keystone_admin)]$ nova list+--------------------------------------+---------------+---------+----------+| ID                                   | Name          | Status  | Networks |+--------------------------------------+---------------+---------+----------+| 136c56da-c827-497b-b8b9-bc7b3f0592bf | cirros1       | ERROR   |          |

将p_w_picpath文件改成raw格式,并手工修改libvirt.xml后:

<domain type="xen">

<uuid>47c3dee4-4a0f-4e43-b3b2-360994c39eb6</uuid>

<name>instance-00000003</name>

<memory>131072</memory>

<vcpu>2</vcpu>

<os>

<type>xen</type>

<root>/dev/xvda</root>

<boot dev="hd"/>

</os>

<features>

<acpi/>

</features>

<clock offset="utc"/>

<devices>

<disk type="file" device="disk">

- <driver name="file" type="qcow2" cache="none"/>

+ <driver name="file" type="raw" cache="none"/>

<source file="/var/lib/nova/instances/instance-00000003/disk"/>

- <target bus="xen" dev="sda"/>

+ <target bus="xen" dev="xvda"/>

</disk>

<disk type="file" device="disk">

- <driver name="file" type="qcow2" cache="none"/>

+ <driver name="file" type="raw" cache="none"/>

<source file="/var/lib/nova/instances/instance-00000003/disk.swap"/>

- <target bus="xen" dev="sdb"/>

+ <target bus="xen" dev="xvdb"/>

</disk>

<console type="pty"/>

<graphics type="vnc" autoport="yes" keymap="en-us" listen="172.16.100.1"/>

</devices>

</domain>

[root@Dom0 ~(keystone_admin)]$ nova start cirros1

[root@Dom0 ~(keystone_admin)]$ nova list+--------------------------------------+---------------+---------+----------+| ID                                   | Name          | Status  | Networks |+--------------------------------------+---------------+---------+----------+| 136c56da-c827-497b-b8b9-bc7b3f0592bf | cirros1       | ACTIVE   |          |

[root@Dom0 instances]# virsh console instance-00000003

____               ____  ____ / __/ __ ____ ____ / __ \/ __// /__ / // __// __// /_/ /\ \\___//_//_/  /_/   \____/___/ http://launchpad.net/cirroslogin as 'cirros' user. default password: 'cubswin:)'. use 'sudo' for root.cirros login:

可是,总不能每次都手工修改吧,查阅官方文档后找到了问题的解决办法:

错误原因:

想要nova正确地生成xml配置文件,仅在nova配置文件(/etc/nova/nova.conf)中关于xen的配置使用下面几个参数是不够的,生成的配置文件在p_w_picpath文件格式(默认qcow2而openstack中Xen不支持)和磁盘名称(sdX)上都不对

# COMPUTElibvirt_type=xenconnection_type=libvirtcompute_driver=libvirt.LibvirtDriver

至少应该这样指定:

# COMPUTElibvirt_type=xenconnection_type=libvirtcompute_driver=libvirt.LibvirtDriverlibvirt_disk_prefix=xvdlibvirt_p_w_picpaths_type=raw

重启服务:

[root@Dom0 ~(keystone_admin)]$ for svc in api compute network cert console scheduler; do service openstack-nova-$svc restart; done

创建虚拟机实例:

[root@Dom0 ~(keystone_admin)]$ nova boot --flavor 6 --p_w_picpath `nova p_w_picpath-list | grep cirros-0.3.0-x86 | awk '{print $2}'` --key_name testkey --security_group default cirros1

虚拟机正常启动:

[root@Dom0 ~(keystone_admin)]$ nova list+--------------------------------------+---------+--------+----------------------+| ID                                   | Name    | Status | Networks             |+--------------------------------------+---------+--------+----------------------+| bfdab37b-5419-47c0-90cc-9112000ba4d1 | cirros1 | ACTIVE | private=172.16.200.4 |+--------------------------------------+---------+--------+----------------------+

ip及key都正常

[root@Dom0 ~(keystone_admin)]$ ssh cirros@172.16.200.4$ df -hFilesystem                Size      Used Available Use% Mounted on/dev                     51.9M         0     51.9M   0% /dev/dev/xvda1               23.2M     12.9M      9.1M  59% /tmpfs                    56.1M         0     56.1M   0% /dev/shmtmpfs                   200.0K     20.0K    180.0K  10% /run$ whoamicirros$

配置文件:

[root@Dom0 instances]# cat instance-00000002/libvirt.xml
bfdab37b-5419-47c0-90cc-9112000ba4d1
instance-00000002
131072
2
xen
/dev/xvda