【问题标题】:Possible to call virConnectDomainXMLToNative in libvirt-python?可以在 libvirt-python 中调用 virConnectDomainXMLToNative 吗?
【发布时间】:2012-03-22 17:56:45
【问题描述】:

我需要能够使用 libvirt-python 在 libvirt 下将域的 XML 配置导出为 XEN 配置格式。显然要进行该调用,您在 C 中使用以下内容:

virConnectDomainXMLToNative

Reads a domain XML configuration document, and generates a native configuration file describing the domain. The format of the native data is hypervisor dependant.

conn:   a connection object
nativeFormat:   configuration format exporting to
domainXml:  the domain configuration to export
flags:  extra flags; not used yet, so callers should always pass 0
Returns:    a 0 terminated UTF-8 encoded native config datafile, or NULL in case of error. the caller must free() the returned value.

但是,Python 中没有等效的函数。

我注意到您可以在 libvirt-python 中调用某些 C 函数。但是,当我使用 help(libvirt) 时,我在当前的调用列表中看不到这一点。 (我正在使用 CentOS 5 提供的 libvirt-python 包,顺便说一句)。

有没有办法在 Python 中进行调用并将域 .xml 转换为 xen config?

【问题讨论】:

    标签: python xen libvirt


    【解决方案1】:

    根据Python API bindings page,以virConnect开头的函数映射到Python中virConnect对象的方法。所以你应该创建一个virConnect 对象,然后调用它的domainXMLToNative 方法。

    如果还是不行,您可以使用ctypes 模块从共享库中调用函数。

    【讨论】:

    • 它看起来需要我至少升级到 libvirt 和 libvirt-python 0.7x。我想这就是前进的方向。
    猜你喜欢
    • 2012-02-04
    • 2020-10-02
    • 1970-01-01
    • 2012-02-06
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 2014-09-16
    相关资源
    最近更新 更多