mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-05 05:01:33 +00:00
kvm tools: Add a wrapper function to initialize all virtio block devices
The patch moves the code for initialization of all of the virtio block devices to virtio subsystem. Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
9df47d0069
commit
bcb6aaca07
@@ -33,6 +33,7 @@ struct kvm {
|
||||
|
||||
const char *vmlinux;
|
||||
struct disk_image **disks;
|
||||
int nr_disks;
|
||||
};
|
||||
|
||||
struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size);
|
||||
|
||||
@@ -6,5 +6,6 @@
|
||||
struct kvm;
|
||||
|
||||
void virtio_blk__init(struct kvm *kvm, struct disk_image *disk);
|
||||
void virtio_blk__init_all(struct kvm *kvm);
|
||||
|
||||
#endif /* KVM__BLK_VIRTIO_H */
|
||||
|
||||
@@ -530,12 +530,12 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
|
||||
strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline));
|
||||
|
||||
if (image_count) {
|
||||
kvm->disks = disk_image__open_all(image_filename, readonly_image, image_count);
|
||||
kvm->nr_disks = image_count;
|
||||
kvm->disks = disk_image__open_all(image_filename, readonly_image, image_count);
|
||||
if (!kvm->disks)
|
||||
die("Unable to load all disk images.");
|
||||
|
||||
for (i = 0; i < image_count; i++)
|
||||
virtio_blk__init(kvm, kvm->disks[i]);
|
||||
virtio_blk__init_all(kvm);
|
||||
}
|
||||
|
||||
free(hi);
|
||||
|
||||
@@ -320,3 +320,11 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk)
|
||||
|
||||
ioport__register(blk_dev_base_addr, &virtio_blk_io_ops, IOPORT_VIRTIO_BLK_SIZE);
|
||||
}
|
||||
|
||||
void virtio_blk__init_all(struct kvm *kvm)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < kvm->nr_disks; i++)
|
||||
virtio_blk__init(kvm, kvm->disks[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user