我要评分
获取效率
正确性
完整性
易理解

How Do I Customize Properties When Creating a VM on oVirt?

Symptom

During VM creation, a custom property qemu:commandline is desired, but this custom property is not included in the list of recognized keywords.

Key Process and Cause Analysis

The XML configuration of an oVirt-based VM cannot be manually modified. To enable various VM configurations, oVirt allows property customization. The official built-in custom properties do not contain qemu:commandline. However, the vdsm-hook-qemucmdline extension package is provided, which requires manual installation and configuration.

Conclusion and Solution

  • Currently, vdsm-hook-qemucmdline supports only the qemu:arg subtag. If you want to enable other qemucmdline property tags, you can modify the /usr/libexec/vdsm/hooks/before_vm_start/50_qemucmdline script to customize the property configuration.
  • If you want to enable other custom properties, create and add custom attributes and hook scripts by referring to the official document.
  1. Install the extension package.
    1
    yum install vdsm-hook-qemucmdline.noarch
    
  2. Add customized properties.
    1
    engine-config -s "UserDefinedVMProperties=qemu_cmdline=^.*$" --cver=4.4
    
  3. Restart the ovirt-engine service.
    1
    service ovirt-engine restart
    

The following is an example.

  1. Access the oVirt web page, choose New Virtual Machine > Custom Properties > qemu_cmdline, and enter the following content:
    ["-chardev","socket,path=/tmp/vm_sock0,server=on,wait=off,id=vm_sock","-device","virtio-serial","-device","virtserialport,chardev=vm_sock,name=serialport0"]

  2. After the VM is created and started, run the virsh dumpxml command to check the VM configuration. The following content is added to the VM configuration.
    <qemu:commandline>
      <qemu:arg value='-chardev'/>
      <qemu:arg value='socket,path=/tmp/vm_sock0,server=on,wait=off,id=vm_sock'/>
      <qemu:arg value='-device'/>
      <qemu:arg value='virtio-serial'/>
      <qemu:arg value='-device'/>
      <qemu:arg value='virtserialport,chardev=vm_sock,name=serialport0'/>
    </qemu:commandline>