如何使用python libvirt并行创建kvm桥接口?

时间:2019-03-08 18:16:37

标签: python virtual-machine kvm libvirt hypervisor

我想使用python libvirt库并行创建多个kvm桥接口。

我尝试使用python线程创建多个kvm桥接口,但是libvirt引发错误:'libvirt.libvirtError:创建桥接口virbr4时出错:文件存在'。

这是我的线程代码:

thread_count = 10
threads = list()
for xml_file in network_xml_files:
    thread = threading.Thread(target=conn.networkCreateXML,
                              args(xml_file))
    threads.append(thread)
    thread.start()
    if len(threads) >= thread_count:
        for thread in threads:
            thread.join()
        threads = list()

if threads:
    for thread in threads:
        thread.join()

0 个答案:

没有答案