Change VM name on node from one-# to system name

Currently when a KVM system is deployed to a node it shows up on “virsh list” as “one-##” where the number is the ID of the VM. I was hoping there is a way to change it so I can include the VM’s name as the name of the VM running on the KVM node.

virsh list
Id Name State

8 one-17 running

I would love to be able to have it called “licenseserver-17” or some variation of that so it can be identified locally on the node itself without needing to log into the frontend.

Is there a way?

there is a CLI for that already, like the ouput of "onevm list"
If you use opennebula to manage or deploy VMs, I’d move away from using virsh and start using one cli. As far as I know, VMs are numbered by opennebula and naming them is set with a different attribute in the opennebula database (mysql or sqlite). This way, you can manage them from the web interface or the opennebula CLI. If you manage VMs using virsh, the database will not get updated, so things will prob. go berserk.

@Anyone, please correct me if I’m wrong, this is based on my adventures so far :slight_smile:

Here is the documentation for CLI:

And here is the “onevm” info:


  onevm - manages OpenNebula virtual machines


onevm command [args] [options]


 -m, --multiple x          Instance multiple VMs
 --hold                    Creates the new VM on hold state instead of
 --name name               Name for the new VM
 --cpu cpu                 CPU percentage reserved for the VM (1=100% one
 --vcpu vcpu               Number of virtualized CPUs
 --arch arch               Architecture of the VM, e.g.: i386 or x86_64
 --memory memory           Memory amount given to the VM. By default the
                           unit is megabytes. To use gigabytes add a 'g',
                           floats can be used: 8g=8192, 0.5g=512
 --disk image0,image1      Disks to attach. To use an image owned by other
                           user use user[disk]. Add any additional
                           attributes separated by ':' and in the shape of
                           KEY=VALUE. For example, if the disk must be
                           resized, use image0:size=1000 . Or
 --nic network0,network1   Networks to attach. To use a network owned by
                           other user use user[network]. Additional
                           attributes are supported like with the --disk
 --raw string              Raw string to add to the template. Not to be
                           confused with the RAW attribute
 --vnc                     Add VNC server to the VM
 --vnc-password password   VNC password
 --vnc-listen ip           VNC IP where to listen for connections. By
                           default is (all interfaces).
 --vnc-keymap keymap       VNC keyboard layout
 --spice                   Add spice server to the VM
 --spice-password password spice password
 --spice-listen ip         spice IP where to listen for connections. By
                           default is (all interfaces).
 --spice-keymap keymap     spice keyboard layout
 --ssh [file]              Add an ssh public key to the context. If the file
                           is omited then the user variable SSH_PUBLIC_KEY
                           will be used.
 --net_context             Add network contextualization parameters
 --context line1,line2,line3 Lines to add to the context section
 --boot device_list        Set boot device list e.g. disk0,disk2,nic0
 --files_ds file1,file2    Add files to the contextualization CD from
                           thefiles datastore
 --init script1,script2    Script or scripts to start in context
 --startscript [file]      Start script to be executed
 --report_ready            Sends READY=YES to OneGate, useful for OneFlow
 --dry                     Just print the template
 -a, --append              Append new attributes to the current template
 --schedule TIME           Schedules this action to be executed afterthe
                           given time. For example: onevm resume 0
                           --schedule "09/23 14:15"
 -t, --type type           Type of the new Image
 -s, --snapshot snapshot   ID of the Snapshot to save.
 --hard                    Does not communicate with the guest OS
 -e, --enforce             Enforce that the host capacity is not exceeded
 --live                    Do the action with the VM running
 --success                 Recover a VM by succeeding the pending action
 --failure                 Recover a VM by failing the pending action
 --retry                   Recover a VM by retrying the last failed action
 --interactive             Enables interactive recovery. Only works
                           alongside the --retry option.
 --delete                  No recover action possible, delete the VM
 --recreate                No recover action possible, delete and recreate
                           the VM
 -f, --file file           Selects the template file
 -i, --image id|name       Selects the image
 -t, --target target       Device where the image will be attached
 --cache cache_mode        Hypervisor cache mode: default, none,
                           writethrough, writeback, directsync or unsafe.
                           (Only KVM driver)
 --discard discard_mode    Hypervisor discard mode: ignore or unmap. (Only
                           KVM driver)
 --prefix prefix           Overrides the DEV_PREFIX of the image
 -n, --network id|name     Selects the virtual network
 -i, --ip ip               IP address for the new NIC
 -l, --list x,y,z          Selects columns to display with list command
 -d, --delay x             Sets the delay in seconds for top command
 -f, --filter x,y,z        Filter data. An array is specified with
                           column=value pairs.
 --csv                     Write table in csv format
 -x, --xml                 Show the resource in xml format
 -n, --numeric             Do not translate user and group IDs
 -k, --kilobytes           Show units in kilobytes
 --describe                Describe list columns
 --all                     Show all template data
 --persistent              Make the new images persistent
 -v, --verbose             Verbose mode
 -h, --help                Show this message
 -V, --version             Show version and copyright information
 --user name               User name used to connect to OpenNebula
 --password password       Password to authenticate with OpenNebula
 --endpoint endpoint       URL of OpenNebula xmlrpc frontend

The onvm list command works, but it truncates the names and other information sometimes. I mean from a functionality standpoint its fine. I see it’s truncated and use onevm show # to find out the info I wanted. This is more for hands on troubleshooting of the local node. Because Open Nebula doesn’t always know what is going on with the VM running on the node (such as VM states/failure/recovery), I find myself having to virsh list to get a hands on real time view of things. It would just be nice to see what’s running without having to refer back to the frontend to double check. I just added another 6 VMs to my list and it started to get to the point I can’t remember what the IDs are.

Edit: Forgot to thank you for trying to help :slight_smile: Thanks!

There is section Other in VM template with “Raw data” section. You can add
Type: KVM
Data: <title>name of VM</title>

And “virsh list --title” will show you title.


Is there any way to include this “title” tag in the raw data in the “instantiate” moment? Or create a kind of substitution variable in the template in order to be automatically set on instantiate?

Thanks a lot


Anybody knows if this is possible?

thanks a lot.