From: Prasad Joshi <prasadjoshi124@gmail.com>
To: prasadjoshi124@gmail.com
Cc: mingo@elte.hu, kvm@vger.kernel.org, penberg@kernel.org,
asias.hejun@gmail.com, gorcunov@gmail.com,
levinsasha928@gmail.com, chaitanyakulkarni15@gmail.com,
ashwini.kulkarni@gmail.com
Subject: [PATCH v2 3/4] kvm tools: Add a wrapper function to initialize all virtio block devices
Date: Fri, 20 May 2011 16:02:39 +0100 [thread overview]
Message-ID: <1305903760-7804-3-git-send-email-prasadjoshi124@gmail.com> (raw)
In-Reply-To: <1305903760-7804-1-git-send-email-prasadjoshi124@gmail.com>
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>
---
tools/kvm/include/kvm/kvm.h | 1 +
tools/kvm/include/kvm/virtio-blk.h | 1 +
tools/kvm/kvm-run.c | 4 ++--
tools/kvm/virtio/blk.c | 8 ++++++++
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index f419634..9592ce7 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 ndisks;
};
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 9bfe8fe..6b0c1fd 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -529,14 +529,14 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
if (!strstr(real_cmdline, "root="))
strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline));
+ kvm->ndisks = image_count;
kvm->disks = disk_image__open_all(image_filename, readonly_image, image_count);
if (!kvm->disks)
die("unable to load disk image");
free(hi);
- for (i = 0; i < image_count; i++)
- virtio_blk__init(kvm, kvm->disks[i]);
+ virtio_blk__init_all(kvm);
printf(" # kvm run -k %s -m %Lu -c %d\n", kernel_filename, ram_size / 1024 / 1024, nrcpus);
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index c5d1bb8..2ee5854 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->ndisks; i++)
+ virtio_blk__init(kvm, kvm->disks[i]);
+}
--
1.7.4.1
next prev parent reply other threads:[~2011-05-20 15:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-20 15:02 [PATCH v2 1/4] kvm tools: Add a wrapper function to open disk images Prasad Joshi
2011-05-20 15:02 ` [PATCH v2 2/4] kvm tools: Close the disk images after the guest shuts down Prasad Joshi
2011-05-20 15:29 ` Sasha Levin
2011-05-20 15:02 ` Prasad Joshi [this message]
2011-05-20 15:02 ` [PATCH v2 4/4] kvm tools: Release memory allocated during virtio block initialization Prasad Joshi
2011-05-20 15:28 ` [PATCH v2 1/4] kvm tools: Add a wrapper function to open disk images Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1305903760-7804-3-git-send-email-prasadjoshi124@gmail.com \
--to=prasadjoshi124@gmail.com \
--cc=ashwini.kulkarni@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=chaitanyakulkarni15@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox