1

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構成に変換する方法はありますか?

4

1 に答える 1

0

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

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

于 2012-03-31T22:04:17.800 に答える