此内容没有您所选择的语言版本。

15.5. Methods


15.5.1. Creating a Virtual Machine

Creating a new virtual machine requires the name, template, and cluster elements. Identify the template and cluster elements with the id attribute or name element. Identify the CPU profile ID with the cpuprofiles attribute.

Example 15.4. Creating a virtual machine with 512 MB that boots from CD-ROM

POST /ovirt-engine/api/vms HTTP/1.1
Accept: application/xml
Content-type: application/xml

<vm>
    <name>vm2</name>
    <description>Virtual Machine 2</description>
    <type>desktop</type>
    <memory>536870912</memory>
    <cluster>
        <name>default</name>
    </cluster>
    <template>
        <name>Blank</name>
    </template>
    <os>
        <boot dev="cdrom"/>
    </os>
    <cdroms>
        <cdrom>
            <file id="example_windows_7_x64_dvd_u_677543.iso"/>
        </cdrom>
    </cdroms>
    <cpu_profile id="0000001a-001a-001a-001a-00000000035e"/>
</vm>
Copy to Clipboard Toggle word wrap

Example 15.5. Creating a virtual machine with 512 MB that boots from a virtual hard disk

POST /ovirt-engine/api/vms HTTP/1.1
Accept: application/xml
Content-type: application/xml

<vm>
    <name>vm2</name>
    <description>Virtual Machine 2</description>
    <type>desktop</type>
    <memory>536870912</memory>
    <cluster>
        <name>default</name>
    </cluster>
    <template>
        <name>Blank</name>
    </template>
    <os>
      <boot dev="hd"/>
    </os>
    <cpu_profile id="0000001a-001a-001a-001a-00000000035e"/>
</vm>
Copy to Clipboard Toggle word wrap

Note

Memory in the previous example is converted to bytes using the following formula:
512MB * 1024 2 = 536870912 bytes

15.5.2. Updating a Virtual Machine

The name, description, cluster, type, memory, cpu, os, high_availability, display, timezone, domain, stateless, placement_policy, memory_policy, usb, payloads, origin and custom_properties elements are updatable post-creation.

Example 15.6. Updating a virtual machine to contain 1 GB of memory

PUT /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<vm>
    <memory>1073741824</memory>
</vm>
Copy to Clipboard Toggle word wrap

Note

Memory in the previous example is converted to bytes using the following formula:
1024MB * 1024 2 = 1073741824 bytes

Note

Memory hot plug is supported in Red Hat Virtualization. If the virtual machine's operating system supports memory hot plug, you can use the example above to increase memory while the virtual machine is running.

Example 15.7. Hot plugging vCPUs

Add virtual CPUs to a running virtual machine without having to reboot it. In this example, the number of sockets is changed to 2.
PUT /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<vm>
    <cpu>
        <topology sockets="2" cores="1"/>
    </cpu>
</vm>
Copy to Clipboard Toggle word wrap

Note

CPU hot unplug is currently not supported in Red Hat Virtualization.

Example 15.8. Pinning a virtual machine to multiple hosts

A virtual machine that is pinned to multiple hosts cannot be live migrated, but in the event of a host failure, any virtual machine configured to be highly available is automatically restarted on one of the other hosts to which the virtual machine is pinned. Multi-host pinning can be used to restrict a virtual machine to hosts with, for example, the same hardware configuration.
PUT /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<vm>
    <high_availability>
        <enabled>true</enabled>
        <priority>1</priority>
    </high_availability>
    <placement_policy>
        <hosts>
            <host><name>Host1</name></host>
            <host><name>Host2</name></host>
        </hosts>
        <affinity>pinned</affinity>
    </placement_policy>
</vm>
Copy to Clipboard Toggle word wrap

15.5.3. Removing a Virtual Machine

Removal of a virtual machine requires a DELETE request.

Example 15.9. Removing a virtual machine

DELETE /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1

HTTP/1.1 204 No Content
Copy to Clipboard Toggle word wrap

15.5.4. Removing a Virtual Machine but not the Virtual Disk

Detach the virtual disk prior to removing the virtual machine. This preserves the virtual disk. Removal of a virtual machine requires a DELETE request.

Example 15.10. Removing a virtual machine

DELETE /ovirt-engine/api/vms/082c794b-771f-452f-83c9-b2b5a19c0399 HTTP/1.1
Accept: application/xml
Content-type: application/xml

<action>
    <vm>
        <disks>
            <detach_only>true</detach_only>
        </disks>
    </vm>
</action>
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat