2

I am currently using the qemu command line arguments to launch a VM.

My command line is:

/home/gnayan/QEMU-devel/qemu-ubuntu/qemu/x86_64-softmmu/qemu-system-x86_64
 -trace events=/home/gnayan/qemu_events 
-drive file=/home/gnayan/CUSTOM_QEMU_SYSTEM/UBUNTU/ubuntu.img,if=virtio,format=raw
-drive file=/home/gnayan/CUSTOM_QEMU_SYSTEM/UBUNTU/u1.img,if=virtio,format=raw 
-m 1G -net nic,model=virtio -net user -redir tcp:2222::22 -enable-kvm &

I would like to launch the same VM using libvirt tools like virsh or virt-install etc, however I am having a hard time getting this done.

I created my domain xml:

<domain type="kvm">
        <name>first</name>
        <currentMemory unit="MB">1024</currentMemory>
        <memory unit="MB">1024</memory>
        <os>
                <type arch='x86_64'>hvm</type>
        </os>
        <devices>
                <emulator>/home/gnayan/QEMU-devel/qemu-ubuntu/qemu/x86_64-softmmu/qemu-system-x86_64</emulator>
                <disk type='file' device='disk'>
                        <source file='/home/gnayan/CUSTOM_QEMU_SYSTEM/UBUNTU/ubuntu.img'/>
                        <driver name='qemu' type='raw'/>
                        <target dev='vda' bus='virtio'/>
                </disk>
        </devices>
</domain>

THen tried to create VM using virsh define first.xml I get following error:

error: Failed to define domain from first.xml
error: internal error: Child process (LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /home/gnayan/QEMU-devel/qemu-ubuntu/qemu/x86_64-softmmu/qemu-system-x86_64 -help) unexpected exit status 126: libvirt:  error : cannot execute binary /home/gnayan/QEMU-devel/qemu-ubuntu/qemu/x86_64-softmmu/qemu-system-x86_64: Permission denied

What may be wrong in my ubuntu settings.

I have install qemu from source.

The path /home/gnayan/QEMU-devel/qemu-ubuntu/qemu/x86_64-softmmu/ has not been exported, will libvirt require this path ?

I also get the following message in dmesg

type=1400 audit(1470991545.250:44): apparmor="DENIED" operation="exec" profile="/usr/sbin/libvirtd" name="/home/gnayan/QEMU-devel/qemu-ubuntu/qemu/x86_64-softmmu/qemu-system-x86_64" pid=21287 comm="libvirtd" requested_mask="x" denied_mask="x" fsuid=0 ouid=0
[19990.781774] audit: type=1400 audit(1470991545.258:45): apparmor="DENIED" operation="exec" profile="/usr/sbin/libvirtd" name="/home/gnayan/QEMU-devel/qemu-ubuntu/qemu/x86_64-softmmu/qemu-system-x86_64" pid=21288 comm="libvirtd" requested_mask="x" denied_mask="x" fsuid=0 ouid=0

1 Answer 1

2

I would do this

virt-install --quiet --network bridge=bridge-name,model=virtio --name first  --ram=1024 \
--vcpus=1 --disk path=/home/gnayan/CUSTOM_QEMU_SYSTEM/UBUNTU/ubuntu.img,format=raw\
--disk path=/home/gnayan/CUSTOM_QEMU_SYSTEM/UBUNTU/u1.img,format=raw \
--graphics none --os-type=linux --import --autostart & \
  • bridge-name, in order to link it to the bridge you must have configured in your system(and physical external port added to allow vm access to external network)
  • The --import option is because I assume that the Ubuntu OS is already installed.

  • For the port redirection I would use iptables instead of doing it in a Vagrant style. But just an opinion. Not sure if it is possible in KVM.

My permisions for images in /var/lib/libvirtd/images/ -rw-r--r-- 1 qemu qemu

Sign up to request clarification or add additional context in comments.

3 Comments

Hi Thanks, any ideas how to add the trace argument in virt-install or virsh?
You can redirect the standard output to a specified file if you want but in my view the proper acction would be using --debug and search in ~/.cache/virt-manager/virt-install.log file
I meant the trace events=/home/gnayan/qemu_events argument, here qemu_events is a text file describing what particular qemu events need to be traced, I did not get your comment, please explain. Qemu tracer will then fill the events information into ftrace trace-buffer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.