Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libvirt doesn't show errors when deploying a virtual machine on standalone. #378

Open
eroussy opened this issue Feb 12, 2024 · 0 comments
Open
Labels
bug Something isn't working Yocto

Comments

@eroussy
Copy link
Member

eroussy commented Feb 12, 2024

Describe the bug
When deploying a virtual machine with ansible, if an error occured in libvirt, the error message is not shown by ansible. Instead, it say msg: '''libvirtError'' object has no attribute ''message'''

To Reproduce
Steps to reproduce the behavior:

  1. On a Yocto machine (standalone)
  2. Create the inventory vm.yml (see below)
  3. Launch the playbook deploy_vm_standalone.yaml to deploy the vm.
  4. An error occured during the step "Create VMs"
  5. The log of the error is incorrect : "msg: '''libvirtError'' object has no attribute ''message'''"

Expected behavior
In such situation, the correct libvirt error is visible when running journalctl -u libvirtd on the hypervisor :
libvirtd[627]: missing target information for device /var/lib/libvirt/images/guest.qcow2
This error should be visible in ansible logs.

I think I already see that also on a debian version, but I wasn't able to reproduce.
In cluster mode, it seems that a check is applied on xml before creating the virtual machines and this check catch the bug.
See if it is possible to run the check on a standalone machine too ?

The inventory vm.yaml

all:
  children:
    VMs:
      hosts:
        guest:
          ansible_host: 192.168.213.130
          vm_template: "../guest_false.xml"
          vm_disk: "../vm_images/guest.qcow2"
          vm_features: []

The associated xml "guest_false.xml" :

<?xml version="1.0" encoding="UTF-8"?>
<domain type="kvm">
    <name>{{ vm.inventory_hostname }}</name>
    <vcpu placement="static">1</vcpu>
    <memory unit="MiB">2048</memory>
    <currentMemory unit="MiB">2048</currentMemory>
    <os firmware="efi">
        <type arch="x86_64" machine="pc-i440fx-4.1">hvm</type>
        <boot dev="hd" />
        <bootmenu enable="no" />
        <bios useserial="yes" rebootTimeout="0" />
        <smbios mode="emulate" />
    </os>
    <features>
        <acpi />
        <apic />
        <vmport state="off" />
    </features>
    <cputune>
    </cputune>
    <cpu mode="custom" match="exact" check="none">
        <model fallback="allow">kvm64</model>
    </cpu>
    <clock offset="utc">
        <timer name="rtc" tickpolicy="catchup" />
        <timer name="pit" tickpolicy="delay" />
        <timer name="hpet" present="no" />
    </clock>
    <on_poweroff>destroy</on_poweroff>
    <on_reboot>restart</on_reboot>
    <on_crash>destroy</on_crash>
    <pm>
        <suspend-to-mem enabled="no" />
        <suspend-to-disk enabled="no" />
    </pm>
    <devices>
        <emulator>/usr/bin/qemu-system-x86_64</emulator>
        <disk type="file" device="disk">
           <driver name="qemu" type="qcow2"/>
           <source file="/var/lib/libvirt/images/guest.qcow2"/>
   <!--
           <target dev="vda" bus="virtio"/>
           When the target line is missing, libvirt will fail to find the disk
   -->
        </disk>
        <controller type="pci" index="0" model="pci-root" />
        <serial type="pty">
            <target type="isa-serial" port="0">
                <model name="isa-serial" />
            </target>
        </serial>
        <console type="pty">
            <target type="serial" port="0" />
        </console>
        <memballoon model="none" />
        <watchdog model="ib700" action="poweroff" />
    </devices>
</domain>

The error I injected is the missing target info in the disk part.

@eroussy eroussy added bug Something isn't working Yocto labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Yocto
Projects
Status: Todo
Development

No branches or pull requests

1 participant