【问题标题】:Python - libvirtPython - libvirt
【发布时间】:2015-02-11 16:50:43
【问题描述】:

是否可以使用 libvirt-python API 从 KVM 管理程序创建 VM? 我有一个直接从云端下载的iso。我在互联网上找不到任何示例。

干杯

【问题讨论】:

    标签: python qemu kvm libvirt


    【解决方案1】:

    确定 libvirt-python 就是为此而设计的。您只需要打开一个连接并使用格式良好的 XML 调用 defineXML()。

    import libvirt
    conn = libvirt.open('qemu+ssh://root@yourhost/system')
    conn.defineXML(imagine_a_well_formated_domain_xml_here)
    

    现在域已经定义好了,你可以启动它了:

    dom = conn.lookupByName(the_domain_name)
    dom.create() # start the domain
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多