How does qemu-kvm interact with kvm module? - qemu

I'm trying to read qemu-kvm and kvm modules and it is quite hard to understand the following:
How does qemu-kvm interact with kvm kernel module?
Any explanations or pointers would be appreciated.

qemu-kvm interacts with KVM via ioctls. The KVM_CREATE_VM ioctl, sent to a file descriptor for /dev/kvm, creates a VM file descriptor. The KVM_CREATE_VCPU, sent to a VM file descriptor, creates a VCPU file descriptor. The KVM_SET_REGS ioctl, sent to a VCPU file descriptor, initializes the registers. More information is passed between QEMU and KVM by mmap-ing the VCPU file descriptor. Finally, the guest runs with the KVM_RUN ioctl sent to a VCPU file descriptor, until the kernel needs QEMU to do something (typically emulate some piece of virtual hardware).

It uses ioctl(), more detail about the ioctl types on here

Related

How to open a configuration file through CAPL script

I have created a configuration that has a panel with options to open another configuration. When an option is selected from the panel, the corresponding configuration should open in Canoe. Is there any way to do this through CAPL scripting?
Are there any built-in functions available in CAPL?
CAPL API offers a way to start RT configurations, if they were previously download to an RT device. For instance:
dword StandaloneConfigOpen(CHAR rtcfgFileName[], dword stopCurrentMeasurement, dword startNewMeasurement, dword returnToActiveConfig)
Opens the RTCFG file with the given name as
standalone configuration.
The given standalone configuration file must have been downloaded to the device before.
The command is only allowed while standalone mode is activated.
If standalone measurement is currently running the command is deferred until end of measurement (unless overwritten by another
subsequent open command).
If standalone measurement is not running but standalone mode is activated the file is loaded (and indicated in the Standalone Manager
GUI) but measurement is not started automatically.
If you need to execute more complex operations, or open a non-RT configuration, you'll have to rely on COM components or write your own routines.

QEMU riscv32 virt machine, how to access the screen?

I want to use QEMU to setup a bare metal riscv32 machine and so assume I need to use the '-machine virt' option. How do I setup so I can output to a screen? Either a console style output where I provide strings to be output, or a VGA device where I set memory addresses to cause the output to be defined?
You can use uart device to output to the host console. You can check the device mmio base address in hw/riscv/virt.cc
I don’t think qemu riscv virt implemented a vga device.
As it defines PCIe and virtio, I suppose you could dynamically add PCIe video device or virtio device accordingly.

Force TCPDump to write in PCAP instead of PCAP-NG format

I'm running tcpdump on Mac OS and I've noticed it saves files in PCAP-NG format (the first 4 bytes are 0A 0D 0D 0A). Is there a way to force it to use the old PCAP instead?
Software version:
tcpdump version 4.3.0 -- Apple version 56
libpcap version 1.3.0 - Apple version 41
ps.
I'm not sure is that related to TCPDump or libpcap.
The tcpdump man page on Mavericks says:
-i Listen on interface.
If the -D flag is supported, an interface number as printed by
that flag can be used as the interface argument.
On Darwin systems version 13 or later, when the interface is
unspecified, tcpdump will use a pseudo interface to capture
packets on a set of interfaces determined by the kernel
(excludes by default loopback and tunnel interfaces).
Alternatively, to capture on more than one interface at a time,
one may use "pktap" as the interface parameter followed by an
optional list of comma separated interface names to include.
For example, to capture on the loopback and en0 interface:
tcpdump -i pktap,lo0,en0
An interface argument of "all" or "pktap,all" can be used to
capture packets from all interfaces, including loopback and tun-
nel interfaces.
A pktap pseudo interface provides for packet metadata using the
default PKTAP data link type and files are written in the Pcap-
ng file format. The RAW data link type must be used to force to
use the legacy pcap-savefile(5) file format with a ptkap pseudo
interface. Note that captures on a ptkap pseudo interface will
not be done in promiscuous mode.
An interface argument of "iptap" can be used to capture packets
from at the IP layer. This capture packets as they are passed
to the input and output routines of the IPv4 and IPv6 protocol
handlers of the networking stack. Note that captures will not
be done in promiscuous mode.
so you need to specify an interface on which to capture.
Note that versions of OS X dating back to Lion, newer versions of FreeBSD/NetBSD/DragonFly BSD, and newer versions of many Linux distributions include libpcap 1.1.1 or later, which means that programs using libpcap to read capture files can read many pcap-ng files. Wireshark has also been able to read them for several releases.
There is also an app, CocoaPacketAnalyzer, which reads pcap files, but not pcap-NG files. There is a web page, https://pcapng.com, that will convert a small pcap-NG file to the older format. However, if you are capturing password or web server interactions, or generally care about security, beware about posting packet captures on the internet!

KVM install and QEMU install

I try to install qemu, but I should intall the kvm first, and I have checked my cpu supporting the visualization, so I don't know why. Here is the error, when I input kvm.
open /dev/kvm: No such file or directory
Could not initialize KVM, will disable KVM support
And a new window for qemu comes out, but there are
boot failed....could not read the boot disk, could not read from CDROM(code 0003)
What can I do. I searched the methods for a long time. Thanks!
when I use mobprobe, the problem is here, (I checked my CPU, it supports VMX.)
FATAL: Error inserting kvm_intel (/lib/modules/2.6.38-8-generic/kernel/arch/x86/kvm/kvm-intel.ko): Operation not supported
When I use:~$ kvm -cdrom img.iso -hda disk.img -boot d
open /dev/kvm: No such file or directory Could not initialize KVM, will disable KVM support kvm: -cdrom img.iso: could not open disk image img.iso: No such file or directory
I don't know why..... Thanks!
The "could not open disk image img.iso" problem is the easier of the two errors: that file does not exist. That argument means "mount the disk image in the file img.iso as the CD-ROM"; that file must exist (and should be a valid ISO). Try downloading a ISO of any Linux flavor, for example.
disk.img must also exist (that argument means "use the disk image contained in the file disk.img as the hard disk"). You can create it using dd, e.g.:
dd if=/dev/zero of=images/disk.img bs=512M count=20
That will create a 10GB disk image in a file called disk.img. Adjust the block size and # of blocks (bs and count) to increase or decrease the size; bs cannot be larger than available memory.
For the second problem, Could not initialize KVM, will disable KVM, there are a number of possible causes:
disabled in BIOS
you are not running as root (i.e. using sudo) and your user cannot access /dev/kvm
the machine you are on is already virtualized (e.g. you are using Amazon EC2). These CPUs may have the VMX flag (because they are paravirtualized) but cannot be virtualized (because the hypervisor won't allow it.)
Note that this is NOT a fatal error; qemu can run without KVM support, it just runs in emulation mode and is quite slow.
The first problem will probably produce some output, examine the output of dmesg (dmesg | grep kvm). It can be solved by enabling it in BIOS.
The second problem can be diagnosed easily by running the commands as root instead of as a user. If that works, you have identified the problem.
The third problem is more difficult to resolve. XEN-blanket may help.
Pasting the output of "sudo kvm-ok" might be allow someone to offer more insight.
The instructions given in here would be translatable to other platforms:
https://help.ubuntu.com/community/KVM/Installation
If you provide more information about the machines you are using and your desired goals, we can be more helpful.
Did you check your BIOS-Settings? Some BIOS let you choose wether you want to activate VT / VMX or not.
Furthermore, I've found following, pretty similiar thread:
http://ubuntuforums.org/archive/index.php/t-755122.html
Hope this helps
Your problem is your system does not have KVM modules inserted. Please check your BIOS setting regarding VT is enabled, and also your KVM module matches your specific Linux distribution. An unmatched version of KVM module and Linux cannot be inserted.
Check the VM xml CD-ROM is set as 'file' not 'block'.
try to load kvm-intel or kvm-amd kernel modules, then take a look at dmesg, if loaded successfully you should be good to go

smb.conf file location on different flavors of Solaris

Ok I am a total beginner with the Solaris Operating system and I need to install and configure samba on 3 boxes each has a different version of Solaris (8,9,10).
What I want to know location of samba configuration file i.e., smb.conf files in each version? So far all I have found is
Solaris 8
/usr/local/samba/lib/smb.conf
Solaris 9 and Solaris 10
/etc/sfw/samba/smb.conf
Is this right? I need to know where these files go by default when samba is installed.
Samba configuration files can be set anywhere your administrator want you to have them.
/usr/local/samba/ is the path where samba can be installed.
smb.conf is one of the configuration files, along with private/secrets.tdb or username.map
You can launch your samba with a:
smbd -D -s /myPath/smb.conf
The two locations (samba installation and samba configuration paths) can be completely separate.
-D If specified, this parameter causes the server to operate as a daemon. That is, it detaches itself and runs in the background, fielding requests on the appropriate port. Operating the server as a daemon is the recommended way of running smbd for servers that provide more than casual use file and print services. This switch is assumed if smbd is executed on the command line of a shell.
-s <configuration file>
The file specified contains the configuration details required by the server. The information in this file includes server-specific information such as what printcap file to use, as well as descriptions of all the services that the server is to provide.
The FILES section of the manpage for `smbd' may give some hints. I don't have any Solaris box handy, so cannot unfortunately confirm.
you can do also the test parameter commands like this # testparm /etc/samba/smb.conf