kvm: Enable virtio block device if disk image specified

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>
This commit is contained in:
Pekka Enberg
2015-06-01 16:39:41 +01:00
committed by Will Deacon
parent 1ef2738d03
commit 1f84889767
2 changed files with 10 additions and 17 deletions
+9 -11
View 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);
+1 -6
View 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);