第 18 章 生成自定义 libvirt 脚本
这部分将为旨在使用 libvirt
编写自定义脚本的程序员和系统管理员提供一些有用信息。
第 17 章 提示及陷阱 is recommended reading for programmers thinking of writing new applications which use libvirt
.
18.1. 使用带 virsh 的 XML 配置文件
virsh
can handle XML configuration files. You may want to use this to your advantage for scripting large deployments with special options. You can add devices defined in an XML file to a running para-virtualized guest. For example, to add a ISO file as hdc
to a running guest create an XML file:
# cat satelliteiso.xml
<disk type="file" device="disk">
<driver name="file"/>
<source file="/var/lib/libvirt/images/rhn-satellite-5.0.1-11-redhat-linux-as-i386-4-embedded-oracle.iso"/>
<target dev="hdc"/>
<readonly/>
</disk>
Run virsh attach-device
to attach the ISO as hdc
to a guest called “satellite” :
# virsh attach-device satellite satelliteiso.xml
当前内容版权归 fedoraproject 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 fedoraproject .