]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm: Enable virtio block device if disk image specified
authorPekka Enberg <penberg@kernel.org>
Fri, 7 Jan 2011 19:06:27 +0000 (21:06 +0200)
committerPekka Enberg <penberg@kernel.org>
Fri, 7 Jan 2011 19:06:27 +0000 (21:06 +0200)
This patch removes the "--enable-virtion" command line option and enable virtio
block device when a disk image is specified.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/blk-virtio.c
tools/kvm/main.c

index 1995a404bf5dd0522d8d0c08017cb1b530a54423..3b4f6412ffc46872157063bf0e3ce5a693177557 100644 (file)
@@ -146,6 +146,7 @@ static bool blk_virtio_out(struct kvm *self, uint16_t port, void *data, int size
                uint32_t dst_len;
                uint8_t *status;
                void *dst;
+               int err;
 
                queue_index             = ioport__read16(data);
 
@@ -177,17 +178,12 @@ static bool blk_virtio_out(struct kvm *self, uint16_t port, void *data, int size
 
                status                  = guest_flat_to_host(self, desc->addr);
 
-               if (self->disk_image) {
-                       int err;
+               err = disk_image__read_sector(self->disk_image, req->sector, dst, dst_len);
 
-                       err = disk_image__read_sector(self->disk_image, req->sector, dst, dst_len);
-
-                       if (err)
-                               *status                 = VIRTIO_BLK_S_IOERR;
-                       else
-                               *status                 = VIRTIO_BLK_S_OK;
-               } else
+               if (err)
                        *status                 = VIRTIO_BLK_S_IOERR;
+               else
+                       *status                 = VIRTIO_BLK_S_OK;
 
                queue->vring.used->idx++;
 
@@ -235,8 +231,10 @@ static struct pci_device_header blk_virtio_pci_device = {
 
 void blk_virtio__init(struct kvm *self)
 {
-       if (self->disk_image)
-               device.blk_config.capacity = self->disk_image->size;
+       if (!self->disk_image)
+               return;
+
+       device.blk_config.capacity = self->disk_image->size;
 
        pci__register(&blk_virtio_pci_device, 1);
 
index 09c17c6878a4a9f54ba0ae46867c19acd12bed86..69977b3cbfe6016e80bcb680f0722d5887c8d7e6 100644 (file)
@@ -53,7 +53,6 @@ int main(int argc, char *argv[])
        const char *kernel_cmdline = NULL;
        const char *kvm_dev = "/dev/kvm";
        unsigned long ram_size = 64UL << 20;
-       bool enable_virtio = false;
        bool single_step = false;
        int i;
 
@@ -78,9 +77,6 @@ int main(int argc, char *argv[])
                } else if (option_matches(argv[i], "--single-step")) {
                        single_step     = true;
                        continue;
-               } else if (option_matches(argv[i], "--enable-virtio")) {
-                       enable_virtio   = true;
-                       continue;
                } else if (option_matches(argv[i], "--mem=")) {
                        unsigned long val = atol(&argv[i][6]) << 20;
                        if (val < ram_size)
@@ -133,8 +129,7 @@ int main(int argc, char *argv[])
        early_printk__init();
        pci__init();
 
-       if (enable_virtio)
-               blk_virtio__init(kvm);
+       blk_virtio__init(kvm);
 
        for (;;) {
                kvm__run(kvm);