[英]Possible to call virConnectDomainXMLToNative in libvirt-python?
我需要能够使用libvirt-python将域的XML配置导出为libvirt下的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 API绑定页面 ,以virConnect
开头的virConnect
被映射到Python中virConnect
对象的方法。 因此,您应该创建一个virConnect
对象,然后调用其domainXMLToNative
方法。
如果仍然不起作用,则可以使用ctypes模块从共享库中调用函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.