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?

OwN
  • 177
  • 3
  • 13
  • Huh? What ID are you referring to? – Michael Hampton May 15 '16 at 17:43
  • The domain-id as referred to: https://www.centos.org/docs/5/html/5.2/Virtualization/chap-Virtualization-Managing_guests_with_virsh.html – 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 Answers1

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.

user9517
  • 114,104
  • 20
  • 206
  • 289