[英]Possible to call virConnectDomainXMLToNative in libvirt-python?
I need to be able to export the domain's XML configs to XEN config format under libvirt using libvirt-python. 我需要能够使用libvirt-python将域的XML配置导出为libvirt下的XEN配置格式。 Apparently to make that call, you use the following in C:
显然,要进行该调用,请在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.
However, there is no equivalent function in Python. 但是,Python中没有等效功能。
I noticed you can call certain C functions in libvirt-python. 我注意到您可以在libvirt-python中调用某些C函数。 I don't see that in the current list of calls, though, when I use help(libvirt).
但是,当我使用help(libvirt)时,在当前的呼叫列表中没有看到该消息。 (I am using the libvirt-python package that is available with CentOS 5, BTW).
(我使用的是CentOS 5附带的libvirt-python软件包)。
Is there a way to make that call anyway within Python and convert the domain .xml to xen config? 有没有办法在Python中进行该调用并将域.xml转换为xen config?
According to the Python API bindings page , functions starting with virConnect
are mapped to methods of a virConnect
object in Python. 根据Python API绑定页面 ,以
virConnect
开头的virConnect
被映射到Python中virConnect
对象的方法。 So you should create a virConnect
object and then call its domainXMLToNative
method. 因此,您应该创建一个
virConnect
对象,然后调用其domainXMLToNative
方法。
If that still doesn't work, you can use the ctypes module to call functions from a shared library. 如果仍然不起作用,则可以使用ctypes模块从共享库中调用函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.