summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd/vioqcow2.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* an alloca() snuck into the tree. We don't use alloca() in our tree unlessderaadt2019-01-101-2/+3
| | | | | | it is entirely unavoidable (for example libc/*/exec.c), because any erroneous size controlled by an attacker turns into a known-location object placement in a very dangerous region. So use malloc() instead.
* Move the {qcow2,raw} create functions from vmctl into vmd/vio{qcow2,raw}.creyk2018-11-261-2/+143
| | | | | | This way they are in the appropriate place and code can be shared with vmd. Ok ori@ mlarkin@ ccardenas@
* Improve error handling and logging in qcow2ori2018-11-241-116/+70
| | | | | | | This turns most warn + returns that should never happen into hard failures, and improves the user directed error messages. ok @mlarkin, @reyk
* Fix qcow2 disk images for data sizes greater than 4 gigs.ori2018-10-241-5/+5
| | | | | | | | | | | We used to truncate the disk end by anding it with a 32 bit value. The 32 bit value was not sign extended, which causes the disk size to wrap at 4 gigabytes: disk->end = (disk->end + disk->clustersz - 1) & ~(disk->clustersz - 1); This change converts the clustersz to an off_t in order to remove the class of errors by avoiding type conversions entirely.
* Add support to create and convert disk images from existing imagesreyk2018-10-191-10/+41
| | | | | | | | | | | | | | The -i option to vmctl create (eg. vmctl create output.qcow2 -i input.img) lets you create a new image from an input file and convert it if it is a different format. This allows to convert qcow2 images from raw images, raw from qcow2, or even qcow2 from qcow2 and raw from raw to re-optimize the disk. This re-uses Ori's vioqcow2.c from vmd by reaching into it and compiling it in. The API has been adjust to be used from both vmctl and vmd accordingly. OK mlarkin@
* Add support for qcow2 base images (external snapshots).reyk2018-10-081-34/+55
| | | | | | | | | | | | | | | | | | | | | This works is from Ori Bernstein, committing on his behalf: Add support to vmd for external snapshots. That is, snapshots that are derived from a base image. Data lookups start in the derived image, and if the derived image does not contain some data, the search proceeds ot the base image. Multiple derived images may exist off of a single base image. A limitation of this format is that modifying the base image will corrupt the derived image. This change also adds support for creating disk derived disk images to vmctl. To use it: vmctl create derived.qcow2 -s 16G -b base.qcow2 From Ori Bernstein OK mlarkin@ reyk@
* Fix potential double-free in error pathreyk2018-10-011-2/+1
| | | | | | qc2_open() calls qc2_close() on error which already frees diskp. OK ccardenas@
* Try to derive the qcow2 file format from an image file automatically.reyk2018-10-011-2/+3
| | | | | | | | | | | | | | This makes the "-d qcow2:" and "format qcow" arguments optional as vmctl and vmd will read the magic bytes at the beginning of a file to guess if it is a raw or a qcow image file. The "vmctl create" command has been changed by removing the -f qcow2 option and replacing it with the same syntax as -d: "vmctl create qcow2:foo.img". In a slightly ununixy but intended way, the create command now also considers the file extension for the format as "vmctl create foo.qcow2" creates a qcow2 disk and not a raw image file. Ok mlarkin@ (and ccardenas@ on an earlier version of the diff)
* Support vmd-internal's vmboot with qcow2 disk images.reyk2018-09-281-6/+7
| | | | OK mlarkin@
* Compress qcow2 open debug messages into a single linereyk2018-09-281-5/+8
| | | | | | | Please avoid tabs and excessive multi-line information with log_debug as it also goes to syslog. No functional change.
* Various clean up items for disks.ccardenas2018-09-191-22/+41
| | | | | | | | | | | - qcow2: general cleanup - vioraw: check malloc - virtio: add function to sync disks - vm: call virtio_shutdown to sync disks when vm is finished executing Thanks to Ori Bernstein. Ok miko@
* Fail fast when we are unable to determine disk format.ccardenas2018-09-111-13/+14
| | | | While here, minor cleanup on logging.
* Add initial qcow2 image support.ccardenas2018-09-091-0/+580
Users are able to declare disk images as 'raw' or 'qcow2' using either vmctl and vm.conf. The default disk image format is 'raw' if not specified. Examples of using disk format: vmctl start bsd -Lc -r cd64.iso -d qcow2:current.qc2 or vmctl start bsd -Lc -r cd64.iso -d raw:current.raw is equivalent to vmctl start bsd -Lc -r cd64.iso -d current.raw in vm.conf vm "current" { disable memory 2G disk "/home/user/vmm/current.qc2" format "qcow2" interface { switch "external" } } or vm "current" { disable memory 2G disk "/home/user/vmm/current.raw" format "raw" interface { switch "external" } } is equivlanet to vm "current" { disable memory 2G disk "/home/user/vmm/current.raw" interface { switch "external" } } Tested by many. Big Thanks to Ori Bernstein.