On Wed, May 02, 2018 at 04:05:05PM +0000, Stallard, Adam wrote:
Hi,
Hi Adam,
I'm wondering if there are any guides to connecting a qemu image
to libvirt without using any virt-manager tools. I wish to send poweroff / on signals to
the machine, and it seems all I need to do so is the libvirt library. I'm working on
building an embedded platform where the images are generated in a cross-compiled
environment. I'm hoping I can integrate them into libvirt's scope without the use
of virt-manager tools like virt-install.
As far as I can tell, I need to hand write /etc/libvirt/qemu/myimages.xml and
/etc/libvirt/qemu/networks/myimagenetworks.xml. Is this feasible?
First of all, never modify/delete/create these files manually, they are
libvirt internal files and you should use libvirt APIs or virsh.
You can easily achieve that by pre-creating guest and network XML
definitions by hand or generate guest XML on a different machine using
virt-install and store them somewhere on your host as a template.
The following steps will add that guest into libvirt:
- define new guest:
$ virsh define /path/to/guest.xml
- start existing guest:
$ virsh start guest
- to set the guest to start on host boot:
$ virsh autostart guest
To have the guests automatically handled on host reboot/poweroff
you can use libvirt-guests service. The configuration file is
</etc/sysconfig/libvirt-guests>.
There are also virsh commands to manipulate networks:
$ virsh help network
If the machines are started up at boot time using qemu-system-x86_64,
will these libvirt "profiles" provide a domain for libvirt visibility? I am
trying to avoid adding virt-manager / python as a dependency to our host image as working
with the dependency chain has been hellish so far.
libvirt has to be the one to start QEMU process in order to have it
managed by libvirt.
About avoiding python in the host, you will always have python installed
because it is required by yum and I'm kind of surprised that installing
virt-install package drags in some conflicting python dependencies. The
list of packages is quite small:
$ yum install virt-install
Installing:
virt-install
Installing for dependencies:
libarchive
libosinfo
libvirt-python
osinfo-db
osinfo-db-tools
python-backports
python-backports-ssl_match_hostname
python-ipaddr
python-requests
python-six
python-urllib3
virt-manager-common
You don't have to install virt-manager package, that's the GUI part of
virt-manager project and that one requires a lot of packages.
Pavel