How to resolve “Specify the 'raw' format explicitly to remove the restrictions.” in qemu?

妖精的绣舞 提交于 2020-08-27 04:29:20

问题


I am trying to run helloos.img on MACBOOK Pro, and even program works fine, it is showing

Specify the 'raw' format explicitly to remove the restrictions.

How to deal with this? Is this important?


回答1:


The reason for this warning is that QEMU is automatically guessing the format of your disk image as raw. The problem with doing that is that if your guest was able to write to the whole of the raw image it could maliciously write (say) a QCOW2 disk header to the start of the raw image, which would mean that when the VM was restarted QEMU would guess the image type wrongly, possibly with bad results. To prevent this, QEMU refuses to allow the guest to write to the start of a probed raw format image. Mostly that won't hurt but if you try to for instance repartition the disk from within the guest it will fail.

To fix this you need to explicitly tell QEMU that the image is in raw format, but you can't do that with the convenience short options or with the "just pass a disk image filename which is assumed to be the harddisk" approach you're using. You need to use the 'long format' options to specify your disk image so that you can pass it format=raw. In this case that would be
-drive file=helloos.img,format=raw,index=0,media=disk
(This is documented in the QEMU manpage where it has "Instead of -hda, -hdb, -hdc, -hdd you can use:" and long format equivalents for the short options.)

See also https://unix.stackexchange.com/questions/276480/booting-a-raw-disk-image-in-qemu which is a similar query.

PS: your question would be easier to answer if you gave the command line you're running and the full error message in the text of the question, rather than just in a screenshot where the windows are overlapping.



来源:https://stackoverflow.com/questions/47235461/how-to-resolve-specify-the-raw-format-explicitly-to-remove-the-restrictions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!