Revision 6d74ca5a
b/hw/syborg_virtio.c | ||
---|---|---|
87 | 87 |
break; |
88 | 88 |
case SYBORG_VIRTIO_HOST_FEATURES: |
89 | 89 |
ret = vdev->get_features(vdev); |
90 |
ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY);
|
|
90 |
ret |= vdev->binding->get_features(s);
|
|
91 | 91 |
break; |
92 | 92 |
case SYBORG_VIRTIO_GUEST_FEATURES: |
93 | 93 |
ret = vdev->features; |
... | ... | |
242 | 242 |
qemu_set_irq(proxy->irq, level != 0); |
243 | 243 |
} |
244 | 244 |
|
245 |
static unsigned syborg_virtio_get_features(void *opaque) |
|
246 |
{ |
|
247 |
unsigned ret = 0; |
|
248 |
ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); |
|
249 |
return ret; |
|
250 |
} |
|
251 |
|
|
245 | 252 |
static VirtIOBindings syborg_virtio_bindings = { |
246 |
.notify = syborg_virtio_update_irq |
|
253 |
.notify = syborg_virtio_update_irq, |
|
254 |
.get_features = syborg_virtio_get_features, |
|
247 | 255 |
}; |
248 | 256 |
|
249 | 257 |
static int syborg_virtio_init(SyborgVirtIOProxy *proxy, VirtIODevice *vdev) |
b/hw/virtio-pci.c | ||
---|---|---|
236 | 236 |
switch (addr) { |
237 | 237 |
case VIRTIO_PCI_HOST_FEATURES: |
238 | 238 |
ret = vdev->get_features(vdev); |
239 |
ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); |
|
240 |
ret |= (1 << VIRTIO_RING_F_INDIRECT_DESC); |
|
241 |
ret |= (1 << VIRTIO_F_BAD_FEATURE); |
|
239 |
ret |= vdev->binding->get_features(proxy); |
|
242 | 240 |
break; |
243 | 241 |
case VIRTIO_PCI_GUEST_FEATURES: |
244 | 242 |
ret = vdev->features; |
... | ... | |
382 | 380 |
msix_write_config(pci_dev, address, val, len); |
383 | 381 |
} |
384 | 382 |
|
383 |
static unsigned virtio_pci_get_features(void *opaque) |
|
384 |
{ |
|
385 |
unsigned ret = 0; |
|
386 |
ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); |
|
387 |
ret |= (1 << VIRTIO_RING_F_INDIRECT_DESC); |
|
388 |
ret |= (1 << VIRTIO_F_BAD_FEATURE); |
|
389 |
return ret; |
|
390 |
} |
|
391 |
|
|
385 | 392 |
static const VirtIOBindings virtio_pci_bindings = { |
386 | 393 |
.notify = virtio_pci_notify, |
387 | 394 |
.save_config = virtio_pci_save_config, |
388 | 395 |
.load_config = virtio_pci_load_config, |
389 | 396 |
.save_queue = virtio_pci_save_queue, |
390 | 397 |
.load_queue = virtio_pci_load_queue, |
398 |
.get_features = virtio_pci_get_features, |
|
391 | 399 |
}; |
392 | 400 |
|
393 | 401 |
static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, |
b/hw/virtio.c | ||
---|---|---|
651 | 651 |
int virtio_load(VirtIODevice *vdev, QEMUFile *f) |
652 | 652 |
{ |
653 | 653 |
int num, i, ret; |
654 |
uint32_t features; |
|
655 |
uint32_t supported_features = vdev->get_features(vdev) | |
|
656 |
vdev->binding->get_features(vdev->binding_opaque); |
|
654 | 657 |
|
655 | 658 |
if (vdev->binding->load_config) { |
656 | 659 |
ret = vdev->binding->load_config(vdev->binding_opaque, f); |
... | ... | |
661 | 664 |
qemu_get_8s(f, &vdev->status); |
662 | 665 |
qemu_get_8s(f, &vdev->isr); |
663 | 666 |
qemu_get_be16s(f, &vdev->queue_sel); |
664 |
qemu_get_be32s(f, &vdev->features); |
|
667 |
qemu_get_be32s(f, &features); |
|
668 |
if (features & ~supported_features) { |
|
669 |
fprintf(stderr, "Features 0x%x unsupported. Allowed features: 0x%x\n", |
|
670 |
features, supported_features); |
|
671 |
return -1; |
|
672 |
} |
|
673 |
vdev->features = features; |
|
665 | 674 |
vdev->config_len = qemu_get_be32(f); |
666 | 675 |
qemu_get_buffer(f, vdev->config, vdev->config_len); |
667 | 676 |
|
b/hw/virtio.h | ||
---|---|---|
31 | 31 |
/* We've given up on this device. */ |
32 | 32 |
#define VIRTIO_CONFIG_S_FAILED 0x80 |
33 | 33 |
|
34 |
/* Some virtio feature bits (currently bits 28 through 31) are reserved for the |
|
35 |
* transport being used (eg. virtio_ring), the rest are per-device feature bits. */ |
|
36 |
#define VIRTIO_TRANSPORT_F_START 28 |
|
37 |
#define VIRTIO_TRANSPORT_F_END 32 |
|
38 |
|
|
34 | 39 |
/* We notify when the ring is completely used, even if the guest is suppressing |
35 | 40 |
* callbacks */ |
36 | 41 |
#define VIRTIO_F_NOTIFY_ON_EMPTY 24 |
... | ... | |
82 | 87 |
void (*save_queue)(void * opaque, int n, QEMUFile *f); |
83 | 88 |
int (*load_config)(void * opaque, QEMUFile *f); |
84 | 89 |
int (*load_queue)(void * opaque, int n, QEMUFile *f); |
90 |
unsigned (*get_features)(void * opaque); |
|
85 | 91 |
} VirtIOBindings; |
86 | 92 |
|
87 | 93 |
#define VIRTIO_PCI_QUEUE_MAX 16 |
Also available in: Unified diff