-
Notifications
You must be signed in to change notification settings - Fork 78
Add support for vng --blk-disk and appending disk I/O / topology options to either --*disk
#389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…sk options Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
The scsi-hd `serial=` parameter is used by QEMU as a default for the
`device_id=` parameter (which is what in fact ends up in the by-id
path).
The `serial=` parameter is set by `virtme-run` using the disk "name"
provided in the `--{,blk-}disk` argument, which is in turn set by `vng`
to the disk path, when not explicitly provided.
When all of this is chained, the full path to disk image ends up being
used as the SCSI device_id:
1. `vng --disk /path/to/disk` leads to
2. `virtme-run --disk /path/to/disk=/path/to/disk` leads to
3. `qemu -device scsi-hd,serial=/path/to/disk` leads to (internally)
4. `qemu -device scsi-hd,serial=/path/to/disk,device_id=/path/to/disk`
However, QEMU (or perhaps it is SCSI) limits the device_id to
20 characters:
```
qemu-system-x86_64: -device scsi-hd,drive=disk0,vendor=virtme,product=disk,serial=/long/path/to/image/file: The serial number can't be longer than 20 characters when it is also used as the default for device_id
```
This problem is indirectly exposed since the previous commit, because
`vng --disk` is now a shorthand for a SCSI disk, not a virtio-blk disk.
Fix this by truncating the SCSI serial manually and using the truncated
value as the SCSI device_id.
Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
This is a behavioral change (although one that brings the behavior _in line_ with the documentation). Previously, `vng --disk` was converted to `virtme-run --blk-disk` internally, contrary to the `vng` help which is saying that `--disk` adds a virtio-scsi disk. Support both `vng --disk` (which is converted to `virtme-run --disk`) and `vng --blk-disk` (which is converted to `virtme-run --blk-disk`). Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
Not specifying a disk image file format leads to QEMU issuing a warning
and write-protecting block 0. This is seldom desirable:
```
WARNING: Image format was not specified for '/path/to/file' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
```
To squelch the warning, specify `format=raw` explicitly. This will be
made configurable in the next commit.
Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
This implements support for various disk topology and I/O driver options for both `--disk` and `--blk-disk` arguments. Options are accepted as a comma-separated list after the image file path e.g., `--disk /path/to/file,format=qcow2,...`. In addition to general QEMU options (format=), I/O driver options (cache=, aio=, discard=, detect-zeroes=, queues=) and topology options (log-sec=, phy-sec=, min-io=, opt-io=, disc-gran=) a "topology=" metaoption is accepted to pass through host device queue limits. The names for these options were chosen to match `lsblk` columns rather than QEMU's own -drive/-device options, because the latter are underdocumented and non-uniform. Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
f0b6c10 to
c7f018f
Compare
marcosps
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me. (I saw that this commit is also present on your patchset to add blk-disk, but this one is easier merged here :) )
arighi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for working on this!!
Just one comment, it'd be nice to not change the behavior of --disk (BTW, with the new syntax how do we specify virtio-blk disks?).
Maybe adding a separate --scsi-disk would be nicer, because we don't break the current behavior, someone may currently use --disk expecting to create virtio-blk devices.
Like I wrote, I made
OK, so you want I did not do it this way because I thought that mapping A to B and B to C would be highly confusing, but I'll do whatever you decide on. |
Could we eventually use aliases not to change the behaviours? So having |
|
So, introduce and prominently document |
Ah alright, it makes sense as it is then, thanks for clarifying it. Also I think not many people are using --disk, so let's stick with this syntax, which seems more sane. Edit: I should read the whole thread before replying. This #389 (comment) would be the best, thanks! |
Expand
vng's capabilities for configuring emulated disk drives. This has two meaningful parts.First, this PR adds support to the
vngwrapper for connecting both types of emulated disks to the VM. Originally,vngonly accepted a--diskargument (which was internally translated tovng --blk-disk), with no option to attach a SCSI disk using thevngwrapper. This PR adds support for bothvng --diskandvng --blk-disk, which now map 1:1 tovirtme-ngoptions.(Note: this is a behavior change. If this is not desired, this can be done any other way around — like adding a
vng --scsi-diskfor SCSI disks and keepingvng --diskfor virtio-blk disks, or anything else. I don't feel strongly about it.)Second, this PR adds support to both
vngandvirtme-runfor passing extended options in both--diskand--blk-diskarguments. Each value is now treated as a comma-separated list with a number of I/O driver options and disk topology options available.There are several I/O driver options:
format=(raw|qcow2)cache=(...)corresponds to QEMU's-blockdev cache.*, or-drive cache=...aio=(...)corresponds to QEMU's-blockdev aio=..., or-drive aio=...discard=(on|off)corresponds to QEMU's-blockdev discard=(ignore|unmap)or-drive discard=...detect-zeroes=(on|off)corresponds to QEMU's-blockdev detect-zeroes=(on|off|unmap)or-drive detect-zeroes=...queues=(int)corresponds to QEMU's-device num_queues=...onvirtio-blk-deviceorvirtio-scsi-devicenodesThen, there are topology options which change the characteristics and limits of the disk reported to the guest OS:
log-sec=(bytes)sets the logical sector (LBA) size, e.g. to emulate 4Kn disksphy-sec=(bytes)sets the physical (underlying) sector sizemin-io=(bytes)sets the advisory minimum I/O sizeopt-io=(bytes)sets the advisory optimal I/O sizedisc-gran=(bytes)sets the advisory TRIM/UNMAP request granularityrota=(on|off)indicates whether the emulated drive is reported as rotational mediumFinally, there are two metaoptions:
iothread=(on|off)adds a dedicated I/O thread for the disk and/or SCSI controller, andtopology=(on|off)extracts host device topology data from sysfs and translates that into the values of the options above (naturally, this only works when the path points to a block device).