2 * Inter-VM Shared Memory PCI device.
7 * Based On: cirrus_vga.c
8 * Copyright (c) 2004 Fabrice Bellard
9 * Copyright (c) 2004 Makoto Suzuki (suzu)
12 * Copyright (c) 2006 Igor Kovalenko
14 * This code is licensed under the GNU GPL v2.
16 * Contributions after 2012-01-13 are licensed under the terms of the
17 * GNU GPL, version 2 or (at your option) any later version.
20 #include "hw/i386/pc.h"
21 #include "hw/pci/pci.h"
22 #include "hw/pci/msix.h"
23 #include "sysemu/kvm.h"
24 #include "migration/migration.h"
25 #include "qapi/qmp/qerror.h"
26 #include "qemu/event_notifier.h"
27 #include "qemu/fifo8.h"
28 #include "sysemu/char.h"
31 #include <sys/types.h>
34 #define PCI_VENDOR_ID_IVSHMEM PCI_VENDOR_ID_REDHAT_QUMRANET
35 #define PCI_DEVICE_ID_IVSHMEM 0x1110
37 #define IVSHMEM_IOEVENTFD 0
40 #define IVSHMEM_PEER 0
41 #define IVSHMEM_MASTER 1
43 #define IVSHMEM_REG_BAR_SIZE 0x100
45 //#define DEBUG_IVSHMEM
47 #define IVSHMEM_DPRINTF(fmt, ...) \
48 do {printf("IVSHMEM: " fmt, ## __VA_ARGS__); } while (0)
50 #define IVSHMEM_DPRINTF(fmt, ...)
53 #define TYPE_IVSHMEM "ivshmem"
54 #define IVSHMEM(obj) \
55 OBJECT_CHECK(IVShmemState, (obj), TYPE_IVSHMEM)
59 EventNotifier *eventfds;
62 typedef struct EventfdEntry {
67 typedef struct IVShmemState {
76 CharDriverState **eventfd_chr;
77 CharDriverState *server_chr;
79 MemoryRegion ivshmem_mmio;
81 /* We might need to register the BAR before we actually have the memory.
82 * So prepare a container MemoryRegion for the BAR immediately and
83 * add a subregion when we have the memory.
87 uint64_t ivshmem_size; /* size of shared memory region */
88 uint32_t ivshmem_attr;
89 uint32_t ivshmem_64bit;
90 int shm_fd; /* shared memory file descriptor */
93 int nb_peers; /* how many guests we have space for */
94 int max_peer; /* maximum numbered peer */
99 EventfdEntry *eventfd_table;
101 Error *migration_blocker;
106 int role_val; /* scalar to avoid multiple string comparisons */
109 /* registers for the Inter-VM shared memory device */
110 enum ivshmem_registers {
117 static inline uint32_t ivshmem_has_feature(IVShmemState *ivs,
118 unsigned int feature) {
119 return (ivs->features & (1 << feature));
122 static inline bool is_power_of_two(uint64_t x) {
123 return (x & (x - 1)) == 0;
126 /* accessing registers - based on rtl8139 */
127 static void ivshmem_update_irq(IVShmemState *s, int val)
129 PCIDevice *d = PCI_DEVICE(s);
131 isr = (s->intrstatus & s->intrmask) & 0xffffffff;
133 /* don't print ISR resets */
135 IVSHMEM_DPRINTF("Set IRQ to %d (%04x %04x)\n",
136 isr ? 1 : 0, s->intrstatus, s->intrmask);
139 pci_set_irq(d, (isr != 0));
142 static void ivshmem_IntrMask_write(IVShmemState *s, uint32_t val)
144 IVSHMEM_DPRINTF("IntrMask write(w) val = 0x%04x\n", val);
148 ivshmem_update_irq(s, val);
151 static uint32_t ivshmem_IntrMask_read(IVShmemState *s)
153 uint32_t ret = s->intrmask;
155 IVSHMEM_DPRINTF("intrmask read(w) val = 0x%04x\n", ret);
160 static void ivshmem_IntrStatus_write(IVShmemState *s, uint32_t val)
162 IVSHMEM_DPRINTF("IntrStatus write(w) val = 0x%04x\n", val);
166 ivshmem_update_irq(s, val);
169 static uint32_t ivshmem_IntrStatus_read(IVShmemState *s)
171 uint32_t ret = s->intrstatus;
173 /* reading ISR clears all interrupts */
176 ivshmem_update_irq(s, 0);
181 static void ivshmem_io_write(void *opaque, hwaddr addr,
182 uint64_t val, unsigned size)
184 IVShmemState *s = opaque;
186 uint16_t dest = val >> 16;
187 uint16_t vector = val & 0xff;
191 IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr);
195 ivshmem_IntrMask_write(s, val);
199 ivshmem_IntrStatus_write(s, val);
203 /* check that dest VM ID is reasonable */
204 if (dest > s->max_peer) {
205 IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);
209 /* check doorbell range */
210 if (vector < s->peers[dest].nb_eventfds) {
211 IVSHMEM_DPRINTF("Notifying VM %d on vector %d\n", dest, vector);
212 event_notifier_set(&s->peers[dest].eventfds[vector]);
216 IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);
220 static uint64_t ivshmem_io_read(void *opaque, hwaddr addr,
224 IVShmemState *s = opaque;
230 ret = ivshmem_IntrMask_read(s);
234 ret = ivshmem_IntrStatus_read(s);
238 /* return my VM ID if the memory is mapped */
247 IVSHMEM_DPRINTF("why are we reading " TARGET_FMT_plx "\n", addr);
254 static const MemoryRegionOps ivshmem_mmio_ops = {
255 .read = ivshmem_io_read,
256 .write = ivshmem_io_write,
257 .endianness = DEVICE_NATIVE_ENDIAN,
259 .min_access_size = 4,
260 .max_access_size = 4,
264 static void ivshmem_receive(void *opaque, const uint8_t *buf, int size)
266 IVShmemState *s = opaque;
268 ivshmem_IntrStatus_write(s, *buf);
270 IVSHMEM_DPRINTF("ivshmem_receive 0x%02x\n", *buf);
273 static int ivshmem_can_receive(void * opaque)
278 static void ivshmem_event(void *opaque, int event)
280 IVSHMEM_DPRINTF("ivshmem_event %d\n", event);
283 static void fake_irqfd(void *opaque, const uint8_t *buf, int size) {
285 EventfdEntry *entry = opaque;
286 PCIDevice *pdev = entry->pdev;
288 IVSHMEM_DPRINTF("interrupt on vector %p %d\n", pdev, entry->vector);
289 msix_notify(pdev, entry->vector);
292 static CharDriverState* create_eventfd_chr_device(void * opaque, EventNotifier *n,
295 /* create a event character device based on the passed eventfd */
296 IVShmemState *s = opaque;
297 CharDriverState * chr;
298 int eventfd = event_notifier_get_fd(n);
300 chr = qemu_chr_open_eventfd(eventfd);
303 fprintf(stderr, "creating eventfd for eventfd %d failed\n", eventfd);
306 qemu_chr_fe_claim_no_fail(chr);
308 /* if MSI is supported we need multiple interrupts */
309 if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
310 s->eventfd_table[vector].pdev = PCI_DEVICE(s);
311 s->eventfd_table[vector].vector = vector;
313 qemu_chr_add_handlers(chr, ivshmem_can_receive, fake_irqfd,
314 ivshmem_event, &s->eventfd_table[vector]);
316 qemu_chr_add_handlers(chr, ivshmem_can_receive, ivshmem_receive,
324 static int check_shm_size(IVShmemState *s, int fd) {
325 /* check that the guest isn't going to try and map more memory than the
326 * the object has allocated return -1 to indicate error */
330 if (fstat(fd, &buf) < 0) {
331 fprintf(stderr, "ivshmem: exiting: fstat on fd %d failed: %s\n",
332 fd, strerror(errno));
336 if (s->ivshmem_size > buf.st_size) {
338 "IVSHMEM ERROR: Requested memory size greater"
339 " than shared object size (%" PRIu64 " > %" PRIu64")\n",
340 s->ivshmem_size, (uint64_t)buf.st_size);
347 /* create the shared memory BAR when we are not using the server, so we can
348 * create the BAR and map the memory immediately */
349 static void create_shared_memory_BAR(IVShmemState *s, int fd) {
355 ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
357 memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s), "ivshmem.bar2",
358 s->ivshmem_size, ptr);
359 vmstate_register_ram(&s->ivshmem, DEVICE(s));
360 memory_region_add_subregion(&s->bar, 0, &s->ivshmem);
362 /* region for shared memory */
363 pci_register_bar(PCI_DEVICE(s), 2, s->ivshmem_attr, &s->bar);
366 static void ivshmem_add_eventfd(IVShmemState *s, int posn, int i)
368 memory_region_add_eventfd(&s->ivshmem_mmio,
373 &s->peers[posn].eventfds[i]);
376 static void ivshmem_del_eventfd(IVShmemState *s, int posn, int i)
378 memory_region_del_eventfd(&s->ivshmem_mmio,
383 &s->peers[posn].eventfds[i]);
386 static void close_guest_eventfds(IVShmemState *s, int posn)
388 int i, guest_curr_max;
390 if (!ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
393 if (posn < 0 || posn >= s->nb_peers) {
397 guest_curr_max = s->peers[posn].nb_eventfds;
399 memory_region_transaction_begin();
400 for (i = 0; i < guest_curr_max; i++) {
401 ivshmem_del_eventfd(s, posn, i);
403 memory_region_transaction_commit();
404 for (i = 0; i < guest_curr_max; i++) {
405 event_notifier_cleanup(&s->peers[posn].eventfds[i]);
408 g_free(s->peers[posn].eventfds);
409 s->peers[posn].nb_eventfds = 0;
412 /* this function increase the dynamic storage need to store data about other
414 static int increase_dynamic_storage(IVShmemState *s, int new_min_size)
419 /* check for integer overflow */
420 if (new_min_size >= INT_MAX / sizeof(Peer) - 1 || new_min_size <= 0) {
424 old_nb_alloc = s->nb_peers;
426 if (new_min_size >= s->nb_peers) {
427 /* +1 because #new_min_size is used as last array index */
428 s->nb_peers = new_min_size + 1;
433 IVSHMEM_DPRINTF("bumping storage to %d guests\n", s->nb_peers);
434 s->peers = g_realloc(s->peers, s->nb_peers * sizeof(Peer));
436 /* zero out new pointers */
437 for (j = old_nb_alloc; j < s->nb_peers; j++) {
438 s->peers[j].eventfds = NULL;
439 s->peers[j].nb_eventfds = 0;
445 static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
447 IVShmemState *s = opaque;
448 int incoming_fd, tmp_fd;
449 int guest_max_eventfd;
452 if (fifo8_is_empty(&s->incoming_fifo) && size == sizeof(incoming_posn)) {
453 memcpy(&incoming_posn, buf, size);
458 IVSHMEM_DPRINTF("short read of %d bytes\n", size);
459 num = MAX(size, sizeof(long) - fifo8_num_used(&s->incoming_fifo));
460 fifo8_push_all(&s->incoming_fifo, buf, num);
461 if (fifo8_num_used(&s->incoming_fifo) < sizeof(incoming_posn)) {
466 p = fifo8_pop_buf(&s->incoming_fifo, sizeof(incoming_posn), &num);
467 g_assert(num == sizeof(incoming_posn));
468 memcpy(&incoming_posn, p, sizeof(incoming_posn));
470 fifo8_push_all(&s->incoming_fifo, buf, size);
474 if (incoming_posn < -1) {
475 IVSHMEM_DPRINTF("invalid incoming_posn %ld\n", incoming_posn);
479 /* pick off s->server_chr->msgfd and store it, posn should accompany msg */
480 tmp_fd = qemu_chr_fe_get_msgfd(s->server_chr);
481 IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn, tmp_fd);
483 /* make sure we have enough space for this guest */
484 if (incoming_posn >= s->nb_peers) {
485 if (increase_dynamic_storage(s, incoming_posn) < 0) {
486 error_report("increase_dynamic_storage() failed");
495 /* if posn is positive and unseen before then this is our posn*/
496 if ((incoming_posn >= 0) &&
497 (s->peers[incoming_posn].eventfds == NULL)) {
498 /* receive our posn */
499 s->vm_id = incoming_posn;
502 /* otherwise an fd == -1 means an existing guest has gone away */
503 IVSHMEM_DPRINTF("posn %ld has gone away\n", incoming_posn);
504 close_guest_eventfds(s, incoming_posn);
509 /* because of the implementation of get_msgfd, we need a dup */
510 incoming_fd = dup(tmp_fd);
512 if (incoming_fd == -1) {
513 fprintf(stderr, "could not allocate file descriptor %s\n",
519 /* if the position is -1, then it's shared memory region fd */
520 if (incoming_posn == -1) {
526 if (check_shm_size(s, incoming_fd) == -1) {
530 /* mmap the region and map into the BAR2 */
531 map_ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED,
533 memory_region_init_ram_ptr(&s->ivshmem, OBJECT(s),
534 "ivshmem.bar2", s->ivshmem_size, map_ptr);
535 vmstate_register_ram(&s->ivshmem, DEVICE(s));
537 IVSHMEM_DPRINTF("guest h/w addr = %p, size = %" PRIu64 "\n",
538 map_ptr, s->ivshmem_size);
540 memory_region_add_subregion(&s->bar, 0, &s->ivshmem);
542 /* only store the fd if it is successfully mapped */
543 s->shm_fd = incoming_fd;
548 /* each guest has an array of eventfds, and we keep track of how many
549 * guests for each VM */
550 guest_max_eventfd = s->peers[incoming_posn].nb_eventfds;
552 if (guest_max_eventfd == 0) {
553 /* one eventfd per MSI vector */
554 s->peers[incoming_posn].eventfds = g_new(EventNotifier, s->vectors);
557 /* this is an eventfd for a particular guest VM */
558 IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn,
559 guest_max_eventfd, incoming_fd);
560 event_notifier_init_fd(&s->peers[incoming_posn].eventfds[guest_max_eventfd],
563 /* increment count for particular guest */
564 s->peers[incoming_posn].nb_eventfds++;
566 /* keep track of the maximum VM ID */
567 if (incoming_posn > s->max_peer) {
568 s->max_peer = incoming_posn;
571 if (incoming_posn == s->vm_id) {
572 s->eventfd_chr[guest_max_eventfd] = create_eventfd_chr_device(s,
573 &s->peers[s->vm_id].eventfds[guest_max_eventfd],
577 if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
578 ivshmem_add_eventfd(s, incoming_posn, guest_max_eventfd);
582 /* Select the MSI-X vectors used by device.
583 * ivshmem maps events to vectors statically, so
584 * we just enable all vectors on init and after reset. */
585 static void ivshmem_use_msix(IVShmemState * s)
587 PCIDevice *d = PCI_DEVICE(s);
590 if (!msix_present(d)) {
594 for (i = 0; i < s->vectors; i++) {
595 msix_vector_use(d, i);
599 static void ivshmem_reset(DeviceState *d)
601 IVShmemState *s = IVSHMEM(d);
607 static uint64_t ivshmem_get_size(IVShmemState * s) {
612 value = strtoull(s->sizearg, &ptr, 10);
614 case 0: case 'M': case 'm':
621 fprintf(stderr, "qemu: invalid ram size: %s\n", s->sizearg);
625 /* BARs must be a power of 2 */
626 if (!is_power_of_two(value)) {
627 fprintf(stderr, "ivshmem: size must be power of 2\n");
634 static void ivshmem_setup_msi(IVShmemState * s)
636 if (msix_init_exclusive_bar(PCI_DEVICE(s), s->vectors, 1)) {
637 IVSHMEM_DPRINTF("msix initialization failed\n");
641 IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
643 /* allocate QEMU char devices for receiving interrupts */
644 s->eventfd_table = g_malloc0(s->vectors * sizeof(EventfdEntry));
649 static void ivshmem_save(QEMUFile* f, void *opaque)
651 IVShmemState *proxy = opaque;
652 PCIDevice *pci_dev = PCI_DEVICE(proxy);
654 IVSHMEM_DPRINTF("ivshmem_save\n");
655 pci_device_save(pci_dev, f);
657 if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
658 msix_save(pci_dev, f);
660 qemu_put_be32(f, proxy->intrstatus);
661 qemu_put_be32(f, proxy->intrmask);
666 static int ivshmem_load(QEMUFile* f, void *opaque, int version_id)
668 IVSHMEM_DPRINTF("ivshmem_load\n");
670 IVShmemState *proxy = opaque;
671 PCIDevice *pci_dev = PCI_DEVICE(proxy);
674 if (version_id > 0) {
678 if (proxy->role_val == IVSHMEM_PEER) {
679 fprintf(stderr, "ivshmem: 'peer' devices are not migratable\n");
683 ret = pci_device_load(pci_dev, f);
688 if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
689 msix_load(pci_dev, f);
690 ivshmem_use_msix(proxy);
692 proxy->intrstatus = qemu_get_be32(f);
693 proxy->intrmask = qemu_get_be32(f);
699 static void ivshmem_write_config(PCIDevice *pci_dev, uint32_t address,
700 uint32_t val, int len)
702 pci_default_write_config(pci_dev, address, val, len);
703 msix_write_config(pci_dev, address, val, len);
706 static int pci_ivshmem_init(PCIDevice *dev)
708 IVShmemState *s = IVSHMEM(dev);
711 if (s->sizearg == NULL)
712 s->ivshmem_size = 4 << 20; /* 4 MB default */
714 s->ivshmem_size = ivshmem_get_size(s);
717 fifo8_create(&s->incoming_fifo, sizeof(long));
719 register_savevm(DEVICE(dev), "ivshmem", 0, 0, ivshmem_save, ivshmem_load,
722 /* IRQFD requires MSI */
723 if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) &&
724 !ivshmem_has_feature(s, IVSHMEM_MSI)) {
725 fprintf(stderr, "ivshmem: ioeventfd/irqfd requires MSI\n");
729 /* check that role is reasonable */
731 if (strncmp(s->role, "peer", 5) == 0) {
732 s->role_val = IVSHMEM_PEER;
733 } else if (strncmp(s->role, "master", 7) == 0) {
734 s->role_val = IVSHMEM_MASTER;
736 fprintf(stderr, "ivshmem: 'role' must be 'peer' or 'master'\n");
740 s->role_val = IVSHMEM_MASTER; /* default */
743 if (s->role_val == IVSHMEM_PEER) {
744 error_setg(&s->migration_blocker,
745 "Migration is disabled when using feature 'peer mode' in device 'ivshmem'");
746 migrate_add_blocker(s->migration_blocker);
749 pci_conf = dev->config;
750 pci_conf[PCI_COMMAND] = PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
752 pci_config_set_interrupt_pin(pci_conf, 1);
756 memory_region_init_io(&s->ivshmem_mmio, OBJECT(s), &ivshmem_mmio_ops, s,
757 "ivshmem-mmio", IVSHMEM_REG_BAR_SIZE);
759 /* region for registers*/
760 pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY,
763 memory_region_init(&s->bar, OBJECT(s), "ivshmem-bar2-container", s->ivshmem_size);
764 s->ivshmem_attr = PCI_BASE_ADDRESS_SPACE_MEMORY |
765 PCI_BASE_ADDRESS_MEM_PREFETCH;
766 if (s->ivshmem_64bit) {
767 s->ivshmem_attr |= PCI_BASE_ADDRESS_MEM_TYPE_64;
770 if ((s->server_chr != NULL) &&
771 (strncmp(s->server_chr->filename, "unix:", 5) == 0)) {
772 /* if we get a UNIX socket as the parameter we will talk
773 * to the ivshmem server to receive the memory region */
775 if (s->shmobj != NULL) {
776 fprintf(stderr, "WARNING: do not specify both 'chardev' "
777 "and 'shm' with ivshmem\n");
780 IVSHMEM_DPRINTF("using shared memory server (socket = %s)\n",
781 s->server_chr->filename);
783 if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
784 ivshmem_setup_msi(s);
787 /* we allocate enough space for 16 guests and grow as needed */
791 /* allocate/initialize space for interrupt handling */
792 s->peers = g_malloc0(s->nb_peers * sizeof(Peer));
794 pci_register_bar(dev, 2, s->ivshmem_attr, &s->bar);
796 s->eventfd_chr = g_malloc0(s->vectors * sizeof(CharDriverState *));
798 qemu_chr_add_handlers(s->server_chr, ivshmem_can_receive, ivshmem_read,
801 /* just map the file immediately, we're not using a server */
804 if (s->shmobj == NULL) {
805 fprintf(stderr, "Must specify 'chardev' or 'shm' to ivshmem\n");
809 IVSHMEM_DPRINTF("using shm_open (shm object = %s)\n", s->shmobj);
811 /* try opening with O_EXCL and if it succeeds zero the memory
812 * by truncating to 0 */
813 if ((fd = shm_open(s->shmobj, O_CREAT|O_RDWR|O_EXCL,
814 S_IRWXU|S_IRWXG|S_IRWXO)) > 0) {
815 /* truncate file to length PCI device's memory */
816 if (ftruncate(fd, s->ivshmem_size) != 0) {
817 fprintf(stderr, "ivshmem: could not truncate shared file\n");
820 } else if ((fd = shm_open(s->shmobj, O_CREAT|O_RDWR,
821 S_IRWXU|S_IRWXG|S_IRWXO)) < 0) {
822 fprintf(stderr, "ivshmem: could not open shared file\n");
827 if (check_shm_size(s, fd) == -1) {
831 create_shared_memory_BAR(s, fd);
835 dev->config_write = ivshmem_write_config;
840 static void pci_ivshmem_uninit(PCIDevice *dev)
842 IVShmemState *s = IVSHMEM(dev);
844 if (s->migration_blocker) {
845 migrate_del_blocker(s->migration_blocker);
846 error_free(s->migration_blocker);
849 memory_region_del_subregion(&s->bar, &s->ivshmem);
850 vmstate_unregister_ram(&s->ivshmem, DEVICE(dev));
851 unregister_savevm(DEVICE(dev), "ivshmem", s);
852 fifo8_destroy(&s->incoming_fifo);
855 static Property ivshmem_properties[] = {
856 DEFINE_PROP_CHR("chardev", IVShmemState, server_chr),
857 DEFINE_PROP_STRING("size", IVShmemState, sizearg),
858 DEFINE_PROP_UINT32("vectors", IVShmemState, vectors, 1),
859 DEFINE_PROP_BIT("ioeventfd", IVShmemState, features, IVSHMEM_IOEVENTFD, false),
860 DEFINE_PROP_BIT("msi", IVShmemState, features, IVSHMEM_MSI, true),
861 DEFINE_PROP_STRING("shm", IVShmemState, shmobj),
862 DEFINE_PROP_STRING("role", IVShmemState, role),
863 DEFINE_PROP_UINT32("use64", IVShmemState, ivshmem_64bit, 1),
864 DEFINE_PROP_END_OF_LIST(),
867 static void ivshmem_class_init(ObjectClass *klass, void *data)
869 DeviceClass *dc = DEVICE_CLASS(klass);
870 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
872 k->init = pci_ivshmem_init;
873 k->exit = pci_ivshmem_uninit;
874 k->vendor_id = PCI_VENDOR_ID_IVSHMEM;
875 k->device_id = PCI_DEVICE_ID_IVSHMEM;
876 k->class_id = PCI_CLASS_MEMORY_RAM;
877 dc->reset = ivshmem_reset;
878 dc->props = ivshmem_properties;
879 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
882 static const TypeInfo ivshmem_info = {
883 .name = TYPE_IVSHMEM,
884 .parent = TYPE_PCI_DEVICE,
885 .instance_size = sizeof(IVShmemState),
886 .class_init = ivshmem_class_init,
889 static void ivshmem_register_types(void)
891 type_register_static(&ivshmem_info);
894 type_init(ivshmem_register_types)