2012-03-22 3 views
1

libvirt-pythonを使用して、libvirtの下でドメインのXML設定をXEN設定形式にエクスポートできる必要があります。その呼び出しを行うには、C言語で次のコードを使用してください:libvirt-pythonでvirConnectDomainXMLToNativeを呼び出すことはできますか?

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関数を呼び出すことができます。しかし、現在のコールリストでは、私がヘルプ(libvirt)を使用すると、それは表示されません。 (私はCentOS 5、BTWで利用可能なlibvirt-pythonパッケージを使用しています)。

とにかくPython内でその呼び出しを行い、domain .xmlをxen configに変換する方法はありますか?

答えて

0

Python API bindings pageによると、virConnectで始まる関数は、PythonのvirConnectオブジェクトのメソッドにマップされます。したがって、virConnectオブジェクトを作成し、そのdomainXMLToNativeメソッドを呼び出す必要があります。

これでも機能しない場合は、ctypesモジュールを使用して、共有ライブラリから関数を呼び出すことができます。

+0

少なくともlibvirtとlibvirt-python 0.7xにアップグレードする必要があるようです。私はそれが将来の道だと思う。 – Rilindo

関連する問題