[tip:tools/kvm] kvm tools: Add a wrapper function to initialize all virtio block devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  4f84f6724f7866e57e782db7dd0d05b654753afe
Gitweb:     http://git.kernel.org/tip/4f84f6724f7866e57e782db7dd0d05b654753afe
Author:     Prasad Joshi <prasadjoshi124@xxxxxxxxx>
AuthorDate: Sun, 22 May 2011 17:24:06 +0100
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Sun, 22 May 2011 23:06:34 +0300

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@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/include/kvm/kvm.h        |    1 +
 tools/kvm/include/kvm/virtio-blk.h |    1 +
 tools/kvm/kvm-run.c                |    6 +++---
 tools/kvm/virtio/blk.c             |    8 ++++++++
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index f419634..08c6fda 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -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);
diff --git a/tools/kvm/include/kvm/virtio-blk.h b/tools/kvm/include/kvm/virtio-blk.h
index 22983e8..72f6491 100644
--- a/tools/kvm/include/kvm/virtio-blk.h
+++ b/tools/kvm/include/kvm/virtio-blk.h
@@ -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 */
diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
index 8cd003b..eacde81 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -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);
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index c5d1bb8..224e14c 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -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]);
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux