QEmu’s `-nodefaults` not working as expected to me - qemu

I expected QEmu’s -nodefaults to prevent the creation of default devices, but either I don’t use it correctly or it does not work as I expected.
I get this message, using the stripped down command line below, with QEmu 3.0.
The message:
qemu-system-i386: warning: multiple floppy disk controllers
with iobase=0x3f0 have been found
the one being picked for CMOS setup might not reflect your intent
Additional message in the VM’s terminal:
could not read the boot disk
The command line:
qemu-system-i386 \
-machine type=isapc,usb=no \
-nodefaults \
-device isa-vga \
-blockdev driver=file,node-name=fda-img,filename=fda.img \
-blockdev driver=raw,node-name=fda,file=fda-img \
-device isa-fdc,driveA=fda,fdtypeA=144,fdtypeB=none,bootindexA=0
I tried removing -machine type=isapc, but it changed nothing.
This is so, although the documentation says this:
-nodefaults
Don’t create default devices. Normally, QEMU sets the default devices
like serial port, parallel port, virtual console, monitor device, VGA
adapter, floppy and CD-ROM drive and others. The -nodefaults option will
disable all those default devices.
I tried to add a --verbose option to the command line, with the hope it will request a dump of the full configuration QEmu creates, but such an option unfortunately does not exist.
My naive feeling is that it’s broken, but I must also consider I may be missing something … (hence this naive question).
— Update for more details —
Although there is no way to dump the created machine from the commande line, I found there is a info qtree in the monitor, which dumps the devices tree. Below, what it says:
[…]
dev: isa-fdc, id ""
iobase = 1008 (0x3f0)
irq = 6 (0x6)
dma = 2 (0x2)
driveA = ""
driveB = ""
check_media_rate = true
fdtypeA = "144"
fdtypeB = "none"
fallback = "288"
isa irq 6
bus: floppy-bus.1
type floppy-bus
dev: floppy, id ""
unit = 0 (0x0)
drive = "fda"
logical_block_size = 512 (0x200)
physical_block_size = 512 (0x200)
min_io_size = 0 (0x0)
opt_io_size = 0 (0x0)
discard_granularity = 4294967295 (0xffffffff)
write-cache = "auto"
share-rw = false
drive-type = "144"
[…]
dev: isa-fdc, id ""
iobase = 1008 (0x3f0)
irq = 6 (0x6)
dma = 2 (0x2)
driveA = ""
driveB = ""
check_media_rate = true
fdtypeA = "auto"
fdtypeB = "auto"
fallback = "288"
isa irq 6
bus: floppy-bus.0
type floppy-bus
[…]
It creates two floppy controllers, ignoring -nodefaults. Am I still missing something?
Also, surprisingly, for the first controller, which is the one I create, driveA and driveB are empty strings while driveA is assigned in the command line.

I finally believe the documentation is unclear and that’s rather -machine none which does not create any device. However, doing so, there is no way to add a bus which would be required to attach any device. I guess in this particular case, the isapc cannot be created without some device and it must be used as‑is, as a starting point. Then, the backends are to be attached without creating the frontends (if the wording is correct).
Here is an example command line snippet:
[…]
-blockdev driver=file,node-name=fda-img,filename=dos-6-22/Dos622-1.img \
-blockdev driver=raw,node-name=fda,file=fda-img \
-global isa-fdc.driveA=fda \
[…]
Note the -global isa-fdc.driveA=fda, which the important part in this snippet ; this is how the backend is attached to the forcefully created frontend.
Update:
Devices created by -machine <model> seems to be a special case not taken into account by -nodefaults ; this is what the actual documentation forget to mention.
Update 2:
Submitted as a documentation bug, here: https://bugs.launchpad.net/qemu/+bug/1799768

Related

Bazel: Run a command without an output

I am using bazel for building bare metal programs. I would like to run the unit tests generated by bazel on qemu.
qemu-system-* -some_args -kernel bazel-bin/whatever/generated.elf
I've tried to run those by creating my own rule in a '.bzl'-file, but it seems that outputs are mandatory on all the rule actions. Note, that I need to invoke different qemu commands with different arguments depending on the target architecture. I would like to pass those to the rule.
Is there a way to invoke a shell command without any outputs?
If needed, this is what I have so far (yet I'm not sure which parts are correct as bazel stops in the analysis phase):
# run_tests.bzl
===============
def _impl(ctx):
qemu = ctx.attr.qemu
machine = ctx.attr.machine
cpu = ctx.attr.cpu
target = ctx.attr.target
# The command may only access files declared in inputs.
ctx.actions.run_shell(
arguments = [qemu, machine, cpu, target],
command="$1 -M $2 -cpu $3 -nographic -monitor null -serial null -semihosting -kernel $4")
run_tests = rule(
implementation=_impl,
attrs = {"qemu" : attr.string(),
"machine" : attr.string(),
"cpu" : attr.string(),
"target" : attr.string(),},
executable = True
)
And my BUILD-File:
# BUILD
=======
load("//make:run_tests.bzl", "run_tests")
run_tests(
name = "portos",
qemu = "qemu-system-arm",
machine = "realview-pbx-a9",
cpu = "cortex-a9",
target = ":test_portos.elf"
)
cc_binary(
name = "test_portos.elf",
srcs = glob(["*.cc"]),
deps = ["//src:portos",
"#unity//:unity"],
copts = ["-Isrc",
"-Iexternal/unity/src",
"-Iexternal/unity/extras/fixture/src"]
)
You are almost there: yes, you need outputs, otherwise bazel has nothing to do. For the rule output, you probably want the test logs or tests results.
Skylark has support for writing test rules. Basically instead of setting executable = True, you would set test = True, and then your rule would create an executable that is the test, then you set ctx.outputs.executable to that executable. Then you can use the bazel test command with your rule.
See:
docs: https://docs.bazel.build/versions/master/skylark/rules.html#test-rules
example: https://github.com/bazelbuild/examples/tree/master/rules/test_rule
rule.test: https://docs.bazel.build/versions/master/skylark/lib/globals.html#rule.test

How to use BoxCutter to take screenshot by using command line options in Actionscript 3?

I was looking for a way to take screenshot by using command line options of buxcutter.exe but i have no knowledge what are the arguments to pass for taking a screenshot. And i mostly want to take screenshots from different monitors.
I am using following codes to start process:
var cmdScreenCaputeLocation:File = File.applicationDirectory.resolvePath("assets\\boxcutter.exe");
var nativeProcessStartInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartInfo.executable = cmdScreenCaputeLocation;
var nativeProcess:NativeProcess = new NativeProcess();
nativeProcess.addEventListener(NativeProcessExitEvent.EXIT,screenCaptureNativeProcessComplated);
nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA,screenCapturOonErrorS);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR,screenCaptureOnError);
nativeProcess.start(nativeProcessStartInfo);
If anybody know what are the arguments i have to pass so that i can take screenshots from different monitors, please help me to solve this problem ?
Directly from the boxcutter main page http://keepnote.org/boxcutter/:
usage: boxcutter [OPTIONS] [OUTPUT_FILENAME]
Saves a screenshot to 'OUTPUT_FILENAME' if given. Only output formats
"*.bmp" and "*.png" are supported. If no file name is given,
screenshot is stored on clipboard by default.
OPTIONS
-c, --coords X1,Y1,X2,Y2 capture the rectange (X1,Y1)-(X2,Y2)
-f, --fullscreen fullscreen screenshot
-v, --version display version information
-h, --help display help message
Usage : boxcutter [OPTIONS] [OUTPUT_FILENAME]
OPTIONS
-c, = coords X1,Y1,X2,Y2 capture the rectangle (X1,Y1)-(X2,Y2).
-f, = to capture the full screen screenshot.
-v, = to display version information.
-h, = to display help message.
For Full Screen : boxcutter -f testgrab.png
By Coordinate : boxcutter -c X1,Y1,X2,Y2 testgrab.png
(Where X1 = Starting X Coordinate,X2 = Ending X Coordinate,Y1 = Starting Y Coordinate,Y2 = Ending Y Coordinate)

How to create a iso file by grub-mkrescue and assign its label?

I'm trying to create a iso bootable file by grub-mkrescue. But I require to assign the iso's label.
After read the man page, I guess here is a correct command line, but failed.
grub-mkrescue -o "my_arch.iso" -- -volid=MY_ARCH my_iso_dir
It will show error as:
xorriso 1.4.2 : RockRidge filesystem manipulator, libburnia project.
Drive current: -outdev 'stdio:my_arch.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 19.1g free
Added to ISO image: directory '/'='/tmp/grub.ZoYEzy'
xorriso : UPDATE : 613 files added in 1 seconds
xorriso : FAILURE : -as mkisofs: Unrecognized option '-volid=MY_ARCH'
xorriso : UPDATE : 613 files added in 1 seconds
xorriso : aborting : -abort_on 'FAILURE' encountered 'FAILURE'
According the 'info grub-mkrescue' document:
All arguments not explicitly listed as 'grub-mkrescue' options are
passed on directly to 'xorriso' in 'mkisofs' emulation mode. Options
passed to 'xorriso' will normally be interpreted as 'mkisofs' options;
if the option '--' is used, then anything after that will be interpreted
as native 'xorriso' options.
Non-option arguments specify additional source directories. This is
commonly used to add extra files to the image:
The -as mkisofs emulation of xorriso understands
-V MY_ARCH
or
-volid MY_ARCH
but not
-volid=MY_ARCH
Further be aware that you obviously use the intermediate C version of
grub-mkrescue which does not comply to the documentation you quoted.
This version demands '--' as delimiter between grub-mkrescue options
and xorriso -as mkisofs options.
But if you have '--' among the arguments of old grub-mkrescue shell script
or of current grub-mkrescue C program, then you will drop out of mkisofs
emulation. This will earn you an error message
xorriso : FAILURE : Not a known command: 'my_iso_dir'

wpa_supplicant Association Failed

I would like to connect my linux board to an access point (i.e mobile phone) by using wpa_supplicant.
My mobile phone ap is configured with WPA (AES) security.
I modified the wpa_supplicant.conf as follow :
ctrl_interface=DIR=/var/run/wpa_supplicant
network={
ssid="HTC"
psk="mypasswd"
scan_ssid=1
proto=WPA2
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
priority=5
}
I set to up the mlan0 and launch wpa_supplicant as follow
root#root:~# wpa_supplicant -i mlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
root#root:~# rfkill: Cannot open RFKILL control device
[ 2113.867283] IPv6: ADDRCONF(NETDEV_UP): mlan0: link is not ready
[ 2113.999385] wlan: mlan0 START SCAN
mlan0: CTRL-EVENT-SCAN-STARTED
[ 2116.924881] wlan: SCAN COMPLETED: scanned AP count=9
mlan0: Trying to associate with 84:7a:88:50:b0:a7 (SSID='HTC' freq=2437 MHz)
[ 2116.954134] ASSOC_RESP: Association Failed, status code = 17, error = 0x411, a_id = 0x0
[ 2116.962280] IOCTL failed: 9a8db800 id=0x20000, sub_id=0x20001 action=1, status_code=0x4110011
mlan0: CTRL-EVENT-ASSOC-REJECT status_code=1
[ 2117.073403] wlan: mlan0 START SCAN
mlan0: CTRL-EVENT-SCAN-STARTED
...
But connection is never established.
Just from looking at the wpa_supplicant output, it is clear that there are no problems with your interfaces mlan/wlan or your IP, as suggested by other responders.
Just to explain the output:
[ 2113.999385] wlan: mlan0 START SCAN
mlan0: CTRL-EVENT-SCAN-STARTED
[ 2116.924881] wlan: SCAN COMPLETED: scanned AP count=9
mlan0: Trying to associate with 84:7a:88:50:b0:a7 (SSID='HTC' freq=2437 MHz)
The above means that:
wpa_supplicant launched successfully.
wpa_supplicant started a wireless scan of nearby BSS's (Basic Service Set).
wpa_supplicant found 9 nearby BSS's, one of them is 'HTC'.
wpa_supplicant started an association sequence with 'HTC' on 2437 Mhz frequency i.e. channel 6.
So, what went wrong???
[ 2116.954134] ASSOC_RESP: Association Failed, status code = 17, error = 0x411, a_id = 0x0
You got error code 17 - Association denied because AP is unable to handle additional associated stations. Will happen if you run out of AIDs on the AP(Access Point).
One of the bellow is probably true:
Your AP is a Hotspot with limited number of stations or you are using an inferior AP that doesn't support enough stations.
You tried to connect to very busy Access Point
So, my solutions are:
Try to configure your AP to enable larger number of stations.
Try to connect to different network to see if the problem reproduces.
If your AP configurations are OK and it is not very busy (low number of associated stations), this might be indicative of a problem. You won't be able to connect any new station. I'd suggest AP reboot.
try to give static IP to your board on the same subnet as your phone having.
rfkill: Cannot open RFKILL control device
I got the same error message when
forgot to plug in the WiFi dongle
the interface specified in -i flag does not exist.
(And maybe it's not "mlan0", it's "wlan0"?)
In the second case, try to modify your command from
wpa_supplicant -i mlan0 -c /etc/wpa_supplicant.conf
to
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf

Next free device option for qemu-nbd

Is there an option for the qemu-nbd command to get the next free, i.e. unused NBD like losetup -f does? The manpage of 0.0.1 (which is version of the currently stable release 1.7.0 of qemu) doesn't mention anything.
You can query attributes about nbd devices in sysfs.
For example:
cat /sys/class/block/nbd0/size
Will return 0, or the size of the mapped image file otherwise, if /dev/ndb0 is in use.
So you could iterate each device until you find one with 0 and attempt to try that with qemu-nbd.
Something like this should do it:
for x in /sys/class/block/nbd* ; do
S=`cat $x/size`
if [ "$S" == "0" ] ; then
qemu-nbd -c /dev/`basename $x` some_file.img
break
fi
done