ditto hw/xilinx_uartlite.c
[qemu/aliguori.git] / hw / ivshmem.c
blobb55f33c7a0d7a3e35748f6fc5c3b64d18cc7f089
1 /*
2 * Inter-VM Shared Memory PCI device.
4 * Author:
5 * Cam Macdonell <cam@cs.ualberta.ca>
7 * Based On: cirrus_vga.c
8 * Copyright (c) 2004 Fabrice Bellard
9 * Copyright (c) 2004 Makoto Suzuki (suzu)
11 * and rtl8139.c
12 * Copyright (c) 2006 Igor Kovalenko
14 * This code is licensed under the GNU GPL v2.
16 #include "hw.h"
17 #include "pc.h"
18 #include "pci.h"
19 #include "msix.h"
20 #include "kvm.h"
22 #include <sys/mman.h>
23 #include <sys/types.h>
25 #define IVSHMEM_IOEVENTFD 0
26 #define IVSHMEM_MSI 1
28 #define IVSHMEM_PEER 0
29 #define IVSHMEM_MASTER 1
31 #define IVSHMEM_REG_BAR_SIZE 0x100
33 //#define DEBUG_IVSHMEM
34 #ifdef DEBUG_IVSHMEM
35 #define IVSHMEM_DPRINTF(fmt, ...) \
36 do {printf("IVSHMEM: " fmt, ## __VA_ARGS__); } while (0)
37 #else
38 #define IVSHMEM_DPRINTF(fmt, ...)
39 #endif
41 typedef struct Peer {
42 int nb_eventfds;
43 int *eventfds;
44 } Peer;
46 typedef struct EventfdEntry {
47 PCIDevice *pdev;
48 int vector;
49 CharDriverState *chr;
50 } EventfdEntry;
52 typedef struct IVShmemState {
53 PCIDevice dev;
54 uint32_t intrmask;
55 uint32_t intrstatus;
56 uint32_t doorbell;
58 CharDriverState **eventfd_chr;
59 CharDriverState *server_chr;
60 MemoryRegion ivshmem_mmio;
62 pcibus_t mmio_addr;
63 /* We might need to register the BAR before we actually have the memory.
64 * So prepare a container MemoryRegion for the BAR immediately and
65 * add a subregion when we have the memory.
67 MemoryRegion bar;
68 MemoryRegion ivshmem;
69 MemoryRegion msix_bar;
70 uint64_t ivshmem_size; /* size of shared memory region */
71 int shm_fd; /* shared memory file descriptor */
73 Peer *peers;
74 int nb_peers; /* how many guests we have space for */
75 int max_peer; /* maximum numbered peer */
77 int vm_id;
78 uint32_t vectors;
79 uint32_t features;
80 EventfdEntry *eventfd_table;
82 char * shmobj;
83 char * sizearg;
84 char * role;
85 int role_val; /* scalar to avoid multiple string comparisons */
86 } IVShmemState;
88 /* registers for the Inter-VM shared memory device */
89 enum ivshmem_registers {
90 INTRMASK = 0,
91 INTRSTATUS = 4,
92 IVPOSITION = 8,
93 DOORBELL = 12,
96 static inline uint32_t ivshmem_has_feature(IVShmemState *ivs,
97 unsigned int feature) {
98 return (ivs->features & (1 << feature));
101 static inline bool is_power_of_two(uint64_t x) {
102 return (x & (x - 1)) == 0;
105 /* accessing registers - based on rtl8139 */
106 static void ivshmem_update_irq(IVShmemState *s, int val)
108 int isr;
109 isr = (s->intrstatus & s->intrmask) & 0xffffffff;
111 /* don't print ISR resets */
112 if (isr) {
113 IVSHMEM_DPRINTF("Set IRQ to %d (%04x %04x)\n",
114 isr ? 1 : 0, s->intrstatus, s->intrmask);
117 qemu_set_irq(s->dev.irq[0], (isr != 0));
120 static void ivshmem_IntrMask_write(IVShmemState *s, uint32_t val)
122 IVSHMEM_DPRINTF("IntrMask write(w) val = 0x%04x\n", val);
124 s->intrmask = val;
126 ivshmem_update_irq(s, val);
129 static uint32_t ivshmem_IntrMask_read(IVShmemState *s)
131 uint32_t ret = s->intrmask;
133 IVSHMEM_DPRINTF("intrmask read(w) val = 0x%04x\n", ret);
135 return ret;
138 static void ivshmem_IntrStatus_write(IVShmemState *s, uint32_t val)
140 IVSHMEM_DPRINTF("IntrStatus write(w) val = 0x%04x\n", val);
142 s->intrstatus = val;
144 ivshmem_update_irq(s, val);
145 return;
148 static uint32_t ivshmem_IntrStatus_read(IVShmemState *s)
150 uint32_t ret = s->intrstatus;
152 /* reading ISR clears all interrupts */
153 s->intrstatus = 0;
155 ivshmem_update_irq(s, 0);
157 return ret;
160 static void ivshmem_io_write(void *opaque, target_phys_addr_t addr,
161 uint64_t val, unsigned size)
163 IVShmemState *s = opaque;
165 uint64_t write_one = 1;
166 uint16_t dest = val >> 16;
167 uint16_t vector = val & 0xff;
169 addr &= 0xfc;
171 IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr);
172 switch (addr)
174 case INTRMASK:
175 ivshmem_IntrMask_write(s, val);
176 break;
178 case INTRSTATUS:
179 ivshmem_IntrStatus_write(s, val);
180 break;
182 case DOORBELL:
183 /* check that dest VM ID is reasonable */
184 if (dest > s->max_peer) {
185 IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);
186 break;
189 /* check doorbell range */
190 if (vector < s->peers[dest].nb_eventfds) {
191 IVSHMEM_DPRINTF("Writing %" PRId64 " to VM %d on vector %d\n",
192 write_one, dest, vector);
193 if (write(s->peers[dest].eventfds[vector],
194 &(write_one), 8) != 8) {
195 IVSHMEM_DPRINTF("error writing to eventfd\n");
198 break;
199 default:
200 IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);
204 static uint64_t ivshmem_io_read(void *opaque, target_phys_addr_t addr,
205 unsigned size)
208 IVShmemState *s = opaque;
209 uint32_t ret;
211 switch (addr)
213 case INTRMASK:
214 ret = ivshmem_IntrMask_read(s);
215 break;
217 case INTRSTATUS:
218 ret = ivshmem_IntrStatus_read(s);
219 break;
221 case IVPOSITION:
222 /* return my VM ID if the memory is mapped */
223 if (s->shm_fd > 0) {
224 ret = s->vm_id;
225 } else {
226 ret = -1;
228 break;
230 default:
231 IVSHMEM_DPRINTF("why are we reading " TARGET_FMT_plx "\n", addr);
232 ret = 0;
235 return ret;
238 static const MemoryRegionOps ivshmem_mmio_ops = {
239 .read = ivshmem_io_read,
240 .write = ivshmem_io_write,
241 .endianness = DEVICE_NATIVE_ENDIAN,
242 .impl = {
243 .min_access_size = 4,
244 .max_access_size = 4,
248 static void ivshmem_receive(void *opaque)
250 IVShmemState *s = opaque;
251 uint8_t buf[8];
253 qemu_chr_fe_read(s->server_chr, buf, sizeof(buf));
254 ivshmem_IntrStatus_write(s, *buf);
256 IVSHMEM_DPRINTF("ivshmem_receive 0x%02x\n", *buf);
259 static int ivshmem_event(void *opaque, int event, void *data)
261 IVSHMEM_DPRINTF("ivshmem_event %d\n", event);
262 return 0;
265 static void fake_irqfd(void *opaque)
268 EventfdEntry *entry = opaque;
269 PCIDevice *pdev = entry->pdev;
270 uint8_t buf[8];
272 IVSHMEM_DPRINTF("interrupt on vector %p %d\n", pdev, entry->vector);
273 qemu_chr_fe_read(entry->chr, buf, sizeof(buf));
274 msix_notify(pdev, entry->vector);
277 static CharDriverState* create_eventfd_chr_device(void * opaque, int eventfd,
278 int vector)
280 /* create a event character device based on the passed eventfd */
281 IVShmemState *s = opaque;
282 CharDriverState * chr;
284 chr = qemu_chr_open_eventfd(eventfd);
286 if (chr == NULL) {
287 fprintf(stderr, "creating eventfd for eventfd %d failed\n", eventfd);
288 exit(-1);
291 qemu_chr_fe_open(chr);
292 /* if MSI is supported we need multiple interrupts */
293 if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
294 s->eventfd_table[vector].pdev = &s->dev;
295 s->eventfd_table[vector].vector = vector;
296 s->eventfd_table[vector].chr = chr;
298 qemu_chr_fe_set_handlers(chr, fake_irqfd, NULL, ivshmem_event,
299 &s->eventfd_table[vector]);
300 } else {
301 qemu_chr_fe_set_handlers(chr, ivshmem_receive, NULL,
302 ivshmem_event, s);
305 return chr;
309 static int check_shm_size(IVShmemState *s, int fd) {
310 /* check that the guest isn't going to try and map more memory than the
311 * the object has allocated return -1 to indicate error */
313 struct stat buf;
315 fstat(fd, &buf);
317 if (s->ivshmem_size > buf.st_size) {
318 fprintf(stderr,
319 "IVSHMEM ERROR: Requested memory size greater"
320 " than shared object size (%" PRIu64 " > %" PRIu64")\n",
321 s->ivshmem_size, (uint64_t)buf.st_size);
322 return -1;
323 } else {
324 return 0;
328 /* create the shared memory BAR when we are not using the server, so we can
329 * create the BAR and map the memory immediately */
330 static void create_shared_memory_BAR(IVShmemState *s, int fd) {
332 void * ptr;
334 s->shm_fd = fd;
336 ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
338 memory_region_init_ram_ptr(&s->ivshmem, &s->dev.qdev, "ivshmem.bar2",
339 s->ivshmem_size, ptr);
340 memory_region_add_subregion(&s->bar, 0, &s->ivshmem);
342 /* region for shared memory */
343 pci_register_bar(&s->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar);
346 static void close_guest_eventfds(IVShmemState *s, int posn)
348 int i, guest_curr_max;
350 guest_curr_max = s->peers[posn].nb_eventfds;
352 for (i = 0; i < guest_curr_max; i++) {
353 kvm_set_ioeventfd_mmio_long(s->peers[posn].eventfds[i],
354 s->mmio_addr + DOORBELL, (posn << 16) | i, 0);
355 close(s->peers[posn].eventfds[i]);
358 qemu_free(s->peers[posn].eventfds);
359 s->peers[posn].nb_eventfds = 0;
362 static void setup_ioeventfds(IVShmemState *s) {
364 int i, j;
366 for (i = 0; i <= s->max_peer; i++) {
367 for (j = 0; j < s->peers[i].nb_eventfds; j++) {
368 memory_region_add_eventfd(&s->ivshmem_mmio,
369 DOORBELL,
371 true,
372 (i << 16) | j,
373 s->peers[i].eventfds[j]);
378 /* this function increase the dynamic storage need to store data about other
379 * guests */
380 static void increase_dynamic_storage(IVShmemState *s, int new_min_size) {
382 int j, old_nb_alloc;
384 old_nb_alloc = s->nb_peers;
386 while (new_min_size >= s->nb_peers)
387 s->nb_peers = s->nb_peers * 2;
389 IVSHMEM_DPRINTF("bumping storage to %d guests\n", s->nb_peers);
390 s->peers = qemu_realloc(s->peers, s->nb_peers * sizeof(Peer));
392 /* zero out new pointers */
393 for (j = old_nb_alloc; j < s->nb_peers; j++) {
394 s->peers[j].eventfds = NULL;
395 s->peers[j].nb_eventfds = 0;
399 static void ivshmem_read(void *opaque)
401 IVShmemState *s = opaque;
402 int incoming_fd, tmp_fd;
403 int guest_max_eventfd;
404 long incoming_posn;
405 uint8_t buf[8];
407 qemu_chr_fe_read(s->server_chr, buf, sizeof(buf));
409 memcpy(&incoming_posn, buf, sizeof(long));
410 /* pick off s->server_chr->msgfd and store it, posn should accompany msg */
411 tmp_fd = qemu_chr_fe_get_msgfd(s->server_chr);
412 IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn, tmp_fd);
414 /* make sure we have enough space for this guest */
415 if (incoming_posn >= s->nb_peers) {
416 increase_dynamic_storage(s, incoming_posn);
419 if (tmp_fd == -1) {
420 /* if posn is positive and unseen before then this is our posn*/
421 if ((incoming_posn >= 0) &&
422 (s->peers[incoming_posn].eventfds == NULL)) {
423 /* receive our posn */
424 s->vm_id = incoming_posn;
425 return;
426 } else {
427 /* otherwise an fd == -1 means an existing guest has gone away */
428 IVSHMEM_DPRINTF("posn %ld has gone away\n", incoming_posn);
429 close_guest_eventfds(s, incoming_posn);
430 return;
434 /* because of the implementation of get_msgfd, we need a dup */
435 incoming_fd = dup(tmp_fd);
437 if (incoming_fd == -1) {
438 fprintf(stderr, "could not allocate file descriptor %s\n",
439 strerror(errno));
440 return;
443 /* if the position is -1, then it's shared memory region fd */
444 if (incoming_posn == -1) {
446 void * map_ptr;
448 s->max_peer = 0;
450 if (check_shm_size(s, incoming_fd) == -1) {
451 exit(-1);
454 /* mmap the region and map into the BAR2 */
455 map_ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED,
456 incoming_fd, 0);
457 memory_region_init_ram_ptr(&s->ivshmem, &s->dev.qdev,
458 "ivshmem.bar2", s->ivshmem_size, map_ptr);
460 IVSHMEM_DPRINTF("guest h/w addr = %" PRIu64 ", size = %" PRIu64 "\n",
461 s->ivshmem_offset, s->ivshmem_size);
463 memory_region_add_subregion(&s->bar, 0, &s->ivshmem);
465 /* only store the fd if it is successfully mapped */
466 s->shm_fd = incoming_fd;
468 return;
471 /* each guest has an array of eventfds, and we keep track of how many
472 * guests for each VM */
473 guest_max_eventfd = s->peers[incoming_posn].nb_eventfds;
475 if (guest_max_eventfd == 0) {
476 /* one eventfd per MSI vector */
477 s->peers[incoming_posn].eventfds = (int *) qemu_malloc(s->vectors *
478 sizeof(int));
481 /* this is an eventfd for a particular guest VM */
482 IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn,
483 guest_max_eventfd, incoming_fd);
484 s->peers[incoming_posn].eventfds[guest_max_eventfd] = incoming_fd;
486 /* increment count for particular guest */
487 s->peers[incoming_posn].nb_eventfds++;
489 /* keep track of the maximum VM ID */
490 if (incoming_posn > s->max_peer) {
491 s->max_peer = incoming_posn;
494 if (incoming_posn == s->vm_id) {
495 s->eventfd_chr[guest_max_eventfd] = create_eventfd_chr_device(s,
496 s->peers[s->vm_id].eventfds[guest_max_eventfd],
497 guest_max_eventfd);
500 if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
501 if (kvm_set_ioeventfd_mmio_long(incoming_fd, s->mmio_addr + DOORBELL,
502 (incoming_posn << 16) | guest_max_eventfd, 1) < 0) {
503 fprintf(stderr, "ivshmem: ioeventfd not available\n");
507 return;
510 static void ivshmem_reset(DeviceState *d)
512 IVShmemState *s = DO_UPCAST(IVShmemState, dev.qdev, d);
514 s->intrstatus = 0;
515 return;
518 static uint64_t ivshmem_get_size(IVShmemState * s) {
520 uint64_t value;
521 char *ptr;
523 value = strtoull(s->sizearg, &ptr, 10);
524 switch (*ptr) {
525 case 0: case 'M': case 'm':
526 value <<= 20;
527 break;
528 case 'G': case 'g':
529 value <<= 30;
530 break;
531 default:
532 fprintf(stderr, "qemu: invalid ram size: %s\n", s->sizearg);
533 exit(1);
536 /* BARs must be a power of 2 */
537 if (!is_power_of_two(value)) {
538 fprintf(stderr, "ivshmem: size must be power of 2\n");
539 exit(1);
542 return value;
545 static void ivshmem_setup_msi(IVShmemState * s) {
547 int i;
549 /* allocate the MSI-X vectors */
551 memory_region_init(&s->msix_bar, "ivshmem-msix", 4096);
552 if (!msix_init(&s->dev, s->vectors, &s->msix_bar, 1, 0)) {
553 pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY,
554 &s->msix_bar);
555 IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s->vectors);
556 } else {
557 IVSHMEM_DPRINTF("msix initialization failed\n");
558 exit(1);
561 /* 'activate' the vectors */
562 for (i = 0; i < s->vectors; i++) {
563 msix_vector_use(&s->dev, i);
566 /* allocate Qemu char devices for receiving interrupts */
567 s->eventfd_table = qemu_mallocz(s->vectors * sizeof(EventfdEntry));
570 static void ivshmem_save(QEMUFile* f, void *opaque)
572 IVShmemState *proxy = opaque;
574 IVSHMEM_DPRINTF("ivshmem_save\n");
575 pci_device_save(&proxy->dev, f);
577 if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
578 msix_save(&proxy->dev, f);
579 } else {
580 qemu_put_be32(f, proxy->intrstatus);
581 qemu_put_be32(f, proxy->intrmask);
586 static int ivshmem_load(QEMUFile* f, void *opaque, int version_id)
588 IVSHMEM_DPRINTF("ivshmem_load\n");
590 IVShmemState *proxy = opaque;
591 int ret, i;
593 if (version_id > 0) {
594 return -EINVAL;
597 if (proxy->role_val == IVSHMEM_PEER) {
598 fprintf(stderr, "ivshmem: 'peer' devices are not migratable\n");
599 return -EINVAL;
602 ret = pci_device_load(&proxy->dev, f);
603 if (ret) {
604 return ret;
607 if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) {
608 msix_load(&proxy->dev, f);
609 for (i = 0; i < proxy->vectors; i++) {
610 msix_vector_use(&proxy->dev, i);
612 } else {
613 proxy->intrstatus = qemu_get_be32(f);
614 proxy->intrmask = qemu_get_be32(f);
617 return 0;
620 static int pci_ivshmem_init(PCIDevice *dev)
622 IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
623 uint8_t *pci_conf;
625 if (s->sizearg == NULL)
626 s->ivshmem_size = 4 << 20; /* 4 MB default */
627 else {
628 s->ivshmem_size = ivshmem_get_size(s);
631 register_savevm(&s->dev.qdev, "ivshmem", 0, 0, ivshmem_save, ivshmem_load,
632 dev);
634 /* IRQFD requires MSI */
635 if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) &&
636 !ivshmem_has_feature(s, IVSHMEM_MSI)) {
637 fprintf(stderr, "ivshmem: ioeventfd/irqfd requires MSI\n");
638 exit(1);
641 /* check that role is reasonable */
642 if (s->role) {
643 if (strncmp(s->role, "peer", 5) == 0) {
644 s->role_val = IVSHMEM_PEER;
645 } else if (strncmp(s->role, "master", 7) == 0) {
646 s->role_val = IVSHMEM_MASTER;
647 } else {
648 fprintf(stderr, "ivshmem: 'role' must be 'peer' or 'master'\n");
649 exit(1);
651 } else {
652 s->role_val = IVSHMEM_MASTER; /* default */
655 if (s->role_val == IVSHMEM_PEER) {
656 register_device_unmigratable(&s->dev.qdev, "ivshmem", s);
659 pci_conf = s->dev.config;
660 pci_conf[PCI_COMMAND] = PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
662 pci_config_set_interrupt_pin(pci_conf, 1);
664 s->shm_fd = 0;
666 memory_region_init_io(&s->ivshmem_mmio, &ivshmem_mmio_ops, s,
667 "ivshmem-mmio", IVSHMEM_REG_BAR_SIZE);
669 if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) {
670 setup_ioeventfds(s);
673 /* region for registers*/
674 pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY,
675 &s->ivshmem_mmio);
677 memory_region_init(&s->bar, "ivshmem-bar2-container", s->ivshmem_size);
679 if ((s->server_chr != NULL) &&
680 (strncmp(s->server_chr->filename, "unix:", 5) == 0)) {
681 /* if we get a UNIX socket as the parameter we will talk
682 * to the ivshmem server to receive the memory region */
684 if (s->shmobj != NULL) {
685 fprintf(stderr, "WARNING: do not specify both 'chardev' "
686 "and 'shm' with ivshmem\n");
689 IVSHMEM_DPRINTF("using shared memory server (socket = %s)\n",
690 s->server_chr->filename);
692 if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
693 ivshmem_setup_msi(s);
696 /* we allocate enough space for 16 guests and grow as needed */
697 s->nb_peers = 16;
698 s->vm_id = -1;
700 /* allocate/initialize space for interrupt handling */
701 s->peers = qemu_mallocz(s->nb_peers * sizeof(Peer));
703 pci_register_bar(&s->dev, 2,
704 PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ivshmem);
706 s->eventfd_chr = qemu_mallocz(s->vectors * sizeof(CharDriverState *));
708 qemu_chr_fe_open(s->server_chr);
709 qemu_chr_fe_set_handlers(s->server_chr, ivshmem_read, NULL,
710 ivshmem_event, s);
711 } else {
712 /* just map the file immediately, we're not using a server */
713 int fd;
715 if (s->shmobj == NULL) {
716 fprintf(stderr, "Must specify 'chardev' or 'shm' to ivshmem\n");
719 IVSHMEM_DPRINTF("using shm_open (shm object = %s)\n", s->shmobj);
721 /* try opening with O_EXCL and if it succeeds zero the memory
722 * by truncating to 0 */
723 if ((fd = shm_open(s->shmobj, O_CREAT|O_RDWR|O_EXCL,
724 S_IRWXU|S_IRWXG|S_IRWXO)) > 0) {
725 /* truncate file to length PCI device's memory */
726 if (ftruncate(fd, s->ivshmem_size) != 0) {
727 fprintf(stderr, "ivshmem: could not truncate shared file\n");
730 } else if ((fd = shm_open(s->shmobj, O_CREAT|O_RDWR,
731 S_IRWXU|S_IRWXG|S_IRWXO)) < 0) {
732 fprintf(stderr, "ivshmem: could not open shared file\n");
733 exit(-1);
737 if (check_shm_size(s, fd) == -1) {
738 exit(-1);
741 create_shared_memory_BAR(s, fd);
745 return 0;
748 static int pci_ivshmem_uninit(PCIDevice *dev)
750 IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
752 memory_region_destroy(&s->ivshmem_mmio);
753 memory_region_del_subregion(&s->bar, &s->ivshmem);
754 memory_region_destroy(&s->ivshmem);
755 memory_region_destroy(&s->bar);
756 unregister_savevm(&dev->qdev, "ivshmem", s);
758 return 0;
761 static PCIDeviceInfo ivshmem_info = {
762 .qdev.name = "ivshmem",
763 .qdev.size = sizeof(IVShmemState),
764 .qdev.reset = ivshmem_reset,
765 .init = pci_ivshmem_init,
766 .exit = pci_ivshmem_uninit,
767 .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
768 .device_id = 0x1110,
769 .class_id = PCI_CLASS_MEMORY_RAM,
770 .qdev.props = (Property[]) {
771 DEFINE_PROP_CHR("chardev", IVShmemState, server_chr),
772 DEFINE_PROP_STRING("size", IVShmemState, sizearg),
773 DEFINE_PROP_UINT32("vectors", IVShmemState, vectors, 1),
774 DEFINE_PROP_BIT("ioeventfd", IVShmemState, features, IVSHMEM_IOEVENTFD, false),
775 DEFINE_PROP_BIT("msi", IVShmemState, features, IVSHMEM_MSI, true),
776 DEFINE_PROP_STRING("shm", IVShmemState, shmobj),
777 DEFINE_PROP_STRING("role", IVShmemState, role),
778 DEFINE_PROP_END_OF_LIST(),
782 static void ivshmem_register_devices(void)
784 pci_qdev_register(&ivshmem_info);
787 device_init(ivshmem_register_devices)