mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
hw/xen: automatically assign device index to block devices
There's no need to force the user to assign a vdev. We can automatically assign one, starting at xvda and searching until we find the first disk name that's unused. This means we can now allow '-drive if=xen,file=xxx' to work without an explicit separate -driver argument, just like if=virtio. Rip out the legacy handling from the xenpv machine, which was scribbling over any disks configured by the toolstack, and didn't work with anything but raw images. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Acked-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
parent
d388c9f53b
commit
d3256f88d9
5 changed files with 125 additions and 46 deletions
15
blockdev.c
15
blockdev.c
|
@ -255,13 +255,13 @@ void drive_check_orphaned(void)
|
|||
* Ignore default drives, because we create certain default
|
||||
* drives unconditionally, then leave them unclaimed. Not the
|
||||
* users fault.
|
||||
* Ignore IF_VIRTIO, because it gets desugared into -device,
|
||||
* so we can leave failing to -device.
|
||||
* Ignore IF_VIRTIO or IF_XEN, because it gets desugared into
|
||||
* -device, so we can leave failing to -device.
|
||||
* Ignore IF_NONE, because leaving unclaimed IF_NONE remains
|
||||
* available for device_add is a feature.
|
||||
*/
|
||||
if (dinfo->is_default || dinfo->type == IF_VIRTIO
|
||||
|| dinfo->type == IF_NONE) {
|
||||
|| dinfo->type == IF_XEN || dinfo->type == IF_NONE) {
|
||||
continue;
|
||||
}
|
||||
if (!blk_get_attached_dev(blk)) {
|
||||
|
@ -977,6 +977,15 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
|
|||
qemu_opt_set(devopts, "driver", "virtio-blk", &error_abort);
|
||||
qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
|
||||
&error_abort);
|
||||
} else if (type == IF_XEN) {
|
||||
QemuOpts *devopts;
|
||||
devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
|
||||
&error_abort);
|
||||
qemu_opt_set(devopts, "driver",
|
||||
(media == MEDIA_CDROM) ? "xen-cdrom" : "xen-disk",
|
||||
&error_abort);
|
||||
qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
|
||||
&error_abort);
|
||||
}
|
||||
|
||||
filename = qemu_opt_get(legacy_opts, "file");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue