Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a transient domain in libvirt?

How can I create a transient domain using libvirt? (Using QEMU/KVM as back-end)

The documentation discusses the difference between transient and persistent domains at this link: http://wiki.libvirt.org/page/VM_lifecycle#Transient_guest_domains_vs_Persistent_guest_domains

Still, I haven't found any concrete example on how to create one.

The only pointer I found is in this email: https://www.redhat.com/archives/libvirt-users/2011-August/msg00057.html, where the maintainer suggests to add the <transient/> tag in the <disk> field of the XML's description.

When I tried, I got this disappointing answer: "libvirtError: unsupported configuration: transient disks not supported yet".

Is this feature really "not supported yet", or am I missing something? The documentation makes me think that this should be supported.

Any answer related to the C or Python binding, virsh, or virt-manager will be highly appreciated!

like image 845
reyammer Avatar asked Nov 30 '13 03:11

reyammer


People also ask

What is a domain in libvirt?

a domain is an instance of an operating system (or subsystem in the case of container virtualization) running on a virtualized machine provided by the hypervisor.

Does libvirt use KVM?

libvirt uses QEMU and KVM.

What is a Virsh domain?

The main command interface used to control both Solaris xVM and guest domains is the virsh command. virsh provides a generic and stable interface for controlling virtualized operating systems. Use virsh instead of xm wherever possible. Many virsh commands act asynchronously.


1 Answers

Using virsh

If you are using virsh, than there are commands:

  • define -- This command takes an XML file as it's parameter and makes the domain known to libvirt (you can reference that domain by using its name or UUID).

  • start -- This command takes the domain name or UUID as its parameter and starts (boots) the domain.

  • create -- This command takes an XML file as it's parameter and creates (starts) the domain with settings described in that file. Depending on whether the domain is known to libvirt (previously defined with that UUID) it may result in two things:

    • if it is already defined, the known domain is marked as started, it is persistent domain, but it is started with the settings supplied and not those it was defined with).

    • in case it is not defined, the domain started is now a transient domain (it disappears when it is destroyed, shuts down, etc.).

  • undefine -- This command takes a domain name or UUID (or ID if it's started) and makes it unknown to libvirt, but if that domain is running it doesn't destroy it, just marks it transient.

C functions

In C, the APIs that virsh is using for these commands are:

  • define -- virDomainDefineXML
  • start -- virDomainCreate
  • create -- virDomainCreateXML
  • undefine -- virDomainUndefine

Notes:

  • The names may be a little bit confusing, but due to backward compatibility it is kept from Xen times.

  • Most of those mention commands have parameters which may alter the behavior, these may cause using different C functions for the purpose.

like image 66
nert Avatar answered Oct 16 '22 21:10

nert