Enabling virtio_blk_device for qemu - linux

I am using qemu 2.2.0 to emulate x86 Linux guest on x86 Linux host.
I want to use the existing dataplane mechanism in QEMU (implemented using virtqueue & IOThreads )for achieving parallel R/W operations in my device.
It requires enabling virtio-blk-device & verifying concurrency in existing framework before implementing the same for my device.
I use the following commnand to enable virtio block device & boot qemu:
./qemu-system-x86_64_exe -m 2048 -usbdevice mouse -usbdevice keyboard -usbdevice tablet -enable-kvm -drive if=none,id=drive1,file=debian_wheezy_i386_desktop.raw -object iothread,id=iothread2 -device virtio-blk-device,id=drv0,drive=drive1,iothread=iothread2 -smp 8
This command executes with error:
No 'virtio-bus' found for device 'virtio-blk-device' .
However, querying this device using " ./qemu-system-x86_64_exe -device help" displays following info for virtio-blk-device:
name virtio-blk-device, bus virtio-bus.
Is there something amiss in my Command line options ?

I hit the same problem and couldn't find informations for virtio-blk-device.
I swichted to virtio-blk-pci instead.

virtio-blk-device is a VirtIO device that relies solely on memory-mapped IO (MMIO) and not on the PCI-bus. This does not work with Qemu's default machine type pc-i440fx-X.Y, or at least not out of the box.
You can use the machine type microvm (https://qemu.readthedocs.io/en/latest/system/i386/microvm.html), a minimalistic machine type without PCI and ACPI. To do so you would add -machine microvm to your Qemu commandline. Then virtio-blk-device and also virtio-net-device should work out of the box. You won't be able to use any devices that rely on PCI however.
As already suggested switching to the PCI-variants is probably the best option in most usecases. As for the error message that no PCI bus is found, maybe your Qemu build defaults to some very weird machine type. Try setting it specifically to -machine pc.

Related

Vfio 0000:41:00.0: failed to open /dev/vfio/32: No such file or directory - QEMU

I have a NVME M.2 SSD that I would like to pass-through to my Virtual Machine as a boot, My SSD works fine with the Virtual Machine Manager, but when I attempt to the Qemu:Console, I get the following message Saying it is not a existing file?!
checked if it the pass-through worked!
This is the Qemu Console command I am using
-device vfio-pci,host=41:00.0
Reading on I found it was a QEMU Console Permission error. I can't find a way to set the vfio permission for manjaro, I heard something of setting a udev perms up, PCI Passthrough is working for other devices, Like my GT710 is working fine.
I then noticed that it was attached to the host and I could not find anyway to remove it, as seen here.
Please Help me!
You need bind your PCI device to the vfio-pci driver.
Unbind pci device from its previous driver
echo "0000:00:14.0" > /sys/devices/pci0000:00/0000:00:14.0/driver/unbind
Bind to vfio-pci driver
echo 8086 a36d > /sys/bus/pci/drivers/vfio-pci/new_id
Where 8086 is the vendor id of the PCI device, and a36d is device id of the PCI device
Check and vfio group should be present, and Qemu can run.
ls -l /dev/vfio/

QEMU Booting for kernel developement not working when using tcp 2222:22 to copy things

I am learning how to implement my own system call in linux kernel by following:
Syscall Guide
Custom Kernel Guide
for getting QEMU set up.
In the end, it tells us to run the following command to Redirect port 2222 on the host OS to the QEMU VM's port 22 which will let me copy files between QEMU and my linux:
qemu-system-x86_64 -m 64M -hda ../debian_squeeze_amd64_standard.qcow2 - append "root=/dev/sda1 console=tty0 console=ttyS0,115200n8" -kernel arch/ x86_64/boot/bzImage -nographic -net nic,vlan=1 -net user,vlan=1 -redir tcp: 2222::22
But I get the follwing error on my terminal when I run the code:
qemu-system-x86_64: -: invalid option
Help me out, I am a beginner. Thanks
In this part of your command line: "- append" -- you have an extra space between the "-" and the "append". QEMU command line options are generally of the form "-something". If you put a space in the middle then QEMU won't recognize what you've given it.
If you're following a tutorial and a command it gives you doesn't work then it's often a good idea to check it carefully for minor typos, or to copy-and-paste the command from the tutorial and try that.

Serial port unavaliable arduino

Trying to upload a code to arduino, but whether in the Arduino IDE or Arduino Create, both return this erro while uploading. Running on Linux Tara(mint 19 cinnamon).
./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:mega:cpu=atmega2560 -build-cache /tmp -build-path /tmp/716441957/build -verbose -libraries /tmp/716441957/custom -libraries /tmp/716441957/pinned /tmp/716441957/sketch_oct8a
Sketch uses 8280 bytes (3%) of program storage space. Maximum is 253952 bytes.
Global variables use 443 bytes (5%) of dynamic memory, leaving 7749 bytes for local variables. Maximum is 8192 bytes.
Programming with: Serial
Flashing with command:/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/bin/avrdude -C/home/jesus/.arduino-create/arduino/avrdude/6.3.0-arduino9/etc/avrdude.conf -q -q -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino-create-agent734074237/sketch_oct8a.hex:i
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device
ioctl("TIOCMGET"): Inappropriate ioctl for device
1#
First, check the port in your IDE. In Arduino tools->port
If the port is hidden or you can not move the cursor over this then run this commands in your terminal.If everything ok then skips this and follow the second part.
sudo apt-get install librxtx-java -y
sudo usermod -aG dialout $USER
sudo apt-get install gnome-system-tools
2#
After this again check the first method. If it is not working then run this commands
ls -l /dev/ttyACM*
sudo usermod -a -G dialout <username>
You probably have another program running which is already using this port.
You should close most other programs like putty or another serial monitor app.
Otherwise, try to reconnect the Arduino to the PC.
I know that these ideas below come from using a Teensy, but they may help you.
Sometimes there are the ACM* ports listed in the Arduino IDE. Try looking at the ser ports. I know when I am running my Teensy, sometimes I have them switched and need to select the correct one.
Also, from my experience with the Teensy, you might need to add a udev rule to allow permissions to access the port from non-root user. Here is the link that shows the udev file.
There is no direct way to solve this issue. In addition to it, you are not using an IDE. I will list the things you need to check, I am sure this will solve your problem.
I am not good at Linux environment so I will refer to applications names as window, you go the corresponding application in Linux.
Go to linux device manager and see for your arduino board. It should have proper naming like "arduino uno at port 3", then use the correct port in your command. If this name does not come properly then it means Driver is not available in your machine. So, go to step2.
Find the driver online and install it in your system, I am not sure about the support of linux with arduino, once it is done please repeat step1.
So, I conclude in short that you do not have the proper driver (which is strongly believe) or pointing the wrong port. I am not an expert with the udev rules, but it is definitely an issue you can experience with these kinds of micro-controllers.

virtual parallel port connector in QEMU

I have been reading Linux Device Drivers 3rd edition and have been running linux 2.6 in QEMU. However, I am at the point where it requires real hardware. I attempted to emulate a paralleport connector in QEMU with no luck. The host has no parallel port connector.
qemu-system-x86_64 -parallel file:outputfile --enable-kvm -smp 2 -initrd initramfs.igz -kernel arch/x86/boot/bzImage -m 1024 -append "console=ttyS0 loglevel=8" -nographic
I then wrote a module to access the parallel port connector via request_region(0x378,1,"parallelport");. However, whenever I attempt to write to the ioport region, none of the output is seen in the file "outputfile" in the working directory where QEMU was booted. I have also added the CONFIG_PARPORT option in the kernel and added some of its associated CONFIG's (i.e CONFIG_PARPORT_PC...) which seemed to only add the linux built-in driver or register an IRQ handler. With this, I was still unable to write to the parallelport "outputfile" on the host machine.
However, I can read and write to the ioport region (meaning whatever I do write with outb can be then read with inb. However, it is not written to the parallel port outfile, which leads me to believe something is still wrong.
I was wondering if I could get some suggestions as to what I might be doing wrong or how to start going about this? The only research I found was the different paralleport options for qemu (use host devices, over udp, etc...), which I tried with no luck. In addition, with using the outputfile option or any option that does not require a host machine parallel port, is it possible to simulate interrupts?
Update: After playing around a little more, it seems the operations of writing and reading from the ioport are working (still don't appear in the outputfile thought). This is because when I do -parallel none, I can obtain the ioport and write to it, but reading from it results in unprintable characters (not the ones I inputed). This doesn't happen by default (specifying no -parallel option or when -parallel file:outputfile.
Update2: From QEMU -device documentation I found that -parallel is legacy. So I changed my command to the following:
qemu-system-x86_64 -chardev file,path=./outputfile,id=parallel0 -device isa-parallel,chardev=parallel0,iobase=0x378,irq=7,index=0 --enable-kvm --smp 2 -initrd initramfs.igz -kernel arch/x86/boot/bzImage -m 1024 -append "console=ttyS0 loglevel=8" -nographic
and then loaded the driver and made a chardev /dev/parallel0. However, this still didn't work.

Linux vanilla kernel on QEMU and networking with eth0

I have downloaded and compiled vanilla linux kernel (3.7.1)
I used busybox for ramdisk then I booted it using QEMU.
This is my QEMU command line
qemu-system-i386 -kernel bzImage -initrd ramdisk.img -append "root=/dev/ram rw console=ttyS0 rdinit=/bin/ash" -nographic -net nic -net user
everything goes well.
However, I can't use networking on vanilla kernel with busybox.
'ifup eth0' tells me
/ # ifup eth0
ip: SIOCGIFFLAGS: No such device
I googled the Internet but can' get any clue...
some advice would be nice
thank you in advance.
Most probably there is no driver (in your example is should be e1000) loaded or the device has another name.
In /sys/class/net/ you should find a listing of all available net-devices.
If there is none (besides lo) the driver is not loaded.
In qemu monitor type "info pci" and it will show you the PCI-address of your ethernet card. It should look like this:
...
Bus 0, device 3, function 0:
Ethernet controller: PCI device 8086:100e
...
This device corresponds to /sys/devices/pci0000:00/0000:00:03.0/.
The files "vendor" and "device" must contain "0x8086" and "0x100e" which is the PCI-id from above and by which the kernel determines the driver to load.
Try to load it manually with "modprobe e1000" or insmod. If loaded there must be a symlink named "driver". If not "dmesg" should give you the reason why not.

Resources