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?

4
  • Huh? What ID are you referring to? May 15, 2016 at 17:43
  • The domain-id as referred to: centos.org/docs/5/html/5.2/Virtualization/…
    – OwN
    May 15, 2016 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. May 15, 2016 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, 2016 at 17:49

1 Answer 1

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.

1
  • Awesom ? Nah, I just read the documentation after using google.
    – user9517
    May 20, 2016 at 5:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .