2

Is there a way to hard code the domain-id of a virtual machine kvm guest?

I tried adding an id attribute to the XML configuration via

virsh edit name

And I also tried to edit the XML directly stored in /etc/libvirt/qemu

Basically, I'd like all of my virtual machine domain-ids to stay the same forever and never change. As new virtual machines are added, they should increment in id. Is there a way to do this, or will an external program interfacing with the virtual machines be required to do so by a unique name for the virtual machine?

  • Huh? What ID are you referring to? – Michael Hampton May 15 '16 at 17:43
  • The domain-id as referred to: centos.org/docs/5/html/5.2/Virtualization/… – OwN May 15 '16 at 17:44
  • That ID only refers to running VMs and stopped VMs have no ID. If you need a unique identifier, use the UUID; that's what it's for. – Michael Hampton May 15 '16 at 17:47
  • Great, so it looks like you can manage a vm using the UUID, but how do you get a list of the name, id, and UUID? virsh list --all only returns the ID, name, and state. So, how is one to discover the UUID from making a generic list call? – OwN May 15 '16 at 17:49
1

The documentation is your friend.

The virsh sub-command domuuid will return the uuid of the provided domain-name or domian-id.

The sub-command domid returns the id when provided the domain-name or domain-uuid of a running machine.

The sub-command domname gives domain-name when provided with a domain-uuid or domain-id.

Note that the domid sub-command is only valid if a machine is running and that domain-id is similarly only available for a running machine.

  • Awesom ? Nah, I just read the documentation after using google. – Iain May 20 '16 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.