uint32_t dst_len;
uint8_t *status;
void *dst;
+ int err;
queue_index = ioport__read16(data);
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++;
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);
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;
} 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)
early_printk__init();
pci__init();
- if (enable_virtio)
- blk_virtio__init(kvm);
+ blk_virtio__init(kvm);
for (;;) {
kvm__run(kvm);