2 * Inter-VM Shared Memory PCI device.
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)
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 "sysemu/char.h"
30 #include <sys/types.h>
32 #define PCI_VENDOR_ID_IVSHMEM PCI_VENDOR_ID_REDHAT_QUMRANET
33 #define PCI_DEVICE_ID_IVSHMEM 0x1110
35 #define IVSHMEM_IOEVENTFD 0
38 #define IVSHMEM_PEER 0
39 #define IVSHMEM_MASTER 1
41 #define IVSHMEM_REG_BAR_SIZE 0x100
43 //#define DEBUG_IVSHMEM
45 #define IVSHMEM_DPRINTF(fmt, ...) \
46 do {printf("IVSHMEM: " fmt, ## __VA_ARGS__); } while (0)
48 #define IVSHMEM_DPRINTF(fmt, ...)
53 EventNotifier
*eventfds
;
56 typedef struct EventfdEntry
{
61 typedef struct IVShmemState
{
67 CharDriverState
**eventfd_chr
;
68 CharDriverState
*server_chr
;
69 MemoryRegion ivshmem_mmio
;
71 /* We might need to register the BAR before we actually have the memory.
72 * So prepare a container MemoryRegion for the BAR immediately and
73 * add a subregion when we have the memory.
77 uint64_t ivshmem_size
; /* size of shared memory region */
78 uint32_t ivshmem_attr
;
79 uint32_t ivshmem_64bit
;
80 int shm_fd
; /* shared memory file descriptor */
83 int nb_peers
; /* how many guests we have space for */
84 int max_peer
; /* maximum numbered peer */
89 EventfdEntry
*eventfd_table
;
91 Error
*migration_blocker
;
96 int role_val
; /* scalar to avoid multiple string comparisons */
99 /* registers for the Inter-VM shared memory device */
100 enum ivshmem_registers
{
107 static inline uint32_t ivshmem_has_feature(IVShmemState
*ivs
,
108 unsigned int feature
) {
109 return (ivs
->features
& (1 << feature
));
112 static inline bool is_power_of_two(uint64_t x
) {
113 return (x
& (x
- 1)) == 0;
116 /* accessing registers - based on rtl8139 */
117 static void ivshmem_update_irq(IVShmemState
*s
, int val
)
120 isr
= (s
->intrstatus
& s
->intrmask
) & 0xffffffff;
122 /* don't print ISR resets */
124 IVSHMEM_DPRINTF("Set IRQ to %d (%04x %04x)\n",
125 isr
? 1 : 0, s
->intrstatus
, s
->intrmask
);
128 qemu_set_irq(s
->dev
.irq
[0], (isr
!= 0));
131 static void ivshmem_IntrMask_write(IVShmemState
*s
, uint32_t val
)
133 IVSHMEM_DPRINTF("IntrMask write(w) val = 0x%04x\n", val
);
137 ivshmem_update_irq(s
, val
);
140 static uint32_t ivshmem_IntrMask_read(IVShmemState
*s
)
142 uint32_t ret
= s
->intrmask
;
144 IVSHMEM_DPRINTF("intrmask read(w) val = 0x%04x\n", ret
);
149 static void ivshmem_IntrStatus_write(IVShmemState
*s
, uint32_t val
)
151 IVSHMEM_DPRINTF("IntrStatus write(w) val = 0x%04x\n", val
);
155 ivshmem_update_irq(s
, val
);
158 static uint32_t ivshmem_IntrStatus_read(IVShmemState
*s
)
160 uint32_t ret
= s
->intrstatus
;
162 /* reading ISR clears all interrupts */
165 ivshmem_update_irq(s
, 0);
170 static void ivshmem_io_write(void *opaque
, hwaddr addr
,
171 uint64_t val
, unsigned size
)
173 IVShmemState
*s
= opaque
;
175 uint16_t dest
= val
>> 16;
176 uint16_t vector
= val
& 0xff;
180 IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx
"\n", addr
);
184 ivshmem_IntrMask_write(s
, val
);
188 ivshmem_IntrStatus_write(s
, val
);
192 /* check that dest VM ID is reasonable */
193 if (dest
> s
->max_peer
) {
194 IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest
);
198 /* check doorbell range */
199 if (vector
< s
->peers
[dest
].nb_eventfds
) {
200 IVSHMEM_DPRINTF("Notifying VM %d on vector %d\n", dest
, vector
);
201 event_notifier_set(&s
->peers
[dest
].eventfds
[vector
]);
205 IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest
);
209 static uint64_t ivshmem_io_read(void *opaque
, hwaddr addr
,
213 IVShmemState
*s
= opaque
;
219 ret
= ivshmem_IntrMask_read(s
);
223 ret
= ivshmem_IntrStatus_read(s
);
227 /* return my VM ID if the memory is mapped */
236 IVSHMEM_DPRINTF("why are we reading " TARGET_FMT_plx
"\n", addr
);
243 static const MemoryRegionOps ivshmem_mmio_ops
= {
244 .read
= ivshmem_io_read
,
245 .write
= ivshmem_io_write
,
246 .endianness
= DEVICE_NATIVE_ENDIAN
,
248 .min_access_size
= 4,
249 .max_access_size
= 4,
253 static void ivshmem_receive(void *opaque
, const uint8_t *buf
, int size
)
255 IVShmemState
*s
= opaque
;
257 ivshmem_IntrStatus_write(s
, *buf
);
259 IVSHMEM_DPRINTF("ivshmem_receive 0x%02x\n", *buf
);
262 static int ivshmem_can_receive(void * opaque
)
267 static void ivshmem_event(void *opaque
, int event
)
269 IVSHMEM_DPRINTF("ivshmem_event %d\n", event
);
272 static void fake_irqfd(void *opaque
, const uint8_t *buf
, int size
) {
274 EventfdEntry
*entry
= opaque
;
275 PCIDevice
*pdev
= entry
->pdev
;
277 IVSHMEM_DPRINTF("interrupt on vector %p %d\n", pdev
, entry
->vector
);
278 msix_notify(pdev
, entry
->vector
);
281 static CharDriverState
* create_eventfd_chr_device(void * opaque
, EventNotifier
*n
,
284 /* create a event character device based on the passed eventfd */
285 IVShmemState
*s
= opaque
;
286 CharDriverState
* chr
;
287 int eventfd
= event_notifier_get_fd(n
);
289 chr
= qemu_chr_open_eventfd(eventfd
);
292 fprintf(stderr
, "creating eventfd for eventfd %d failed\n", eventfd
);
295 qemu_chr_fe_claim_no_fail(chr
);
297 /* if MSI is supported we need multiple interrupts */
298 if (ivshmem_has_feature(s
, IVSHMEM_MSI
)) {
299 s
->eventfd_table
[vector
].pdev
= &s
->dev
;
300 s
->eventfd_table
[vector
].vector
= vector
;
302 qemu_chr_add_handlers(chr
, ivshmem_can_receive
, fake_irqfd
,
303 ivshmem_event
, &s
->eventfd_table
[vector
]);
305 qemu_chr_add_handlers(chr
, ivshmem_can_receive
, ivshmem_receive
,
313 static int check_shm_size(IVShmemState
*s
, int fd
) {
314 /* check that the guest isn't going to try and map more memory than the
315 * the object has allocated return -1 to indicate error */
321 if (s
->ivshmem_size
> buf
.st_size
) {
323 "IVSHMEM ERROR: Requested memory size greater"
324 " than shared object size (%" PRIu64
" > %" PRIu64
")\n",
325 s
->ivshmem_size
, (uint64_t)buf
.st_size
);
332 /* create the shared memory BAR when we are not using the server, so we can
333 * create the BAR and map the memory immediately */
334 static void create_shared_memory_BAR(IVShmemState
*s
, int fd
) {
340 ptr
= mmap(0, s
->ivshmem_size
, PROT_READ
|PROT_WRITE
, MAP_SHARED
, fd
, 0);
342 memory_region_init_ram_ptr(&s
->ivshmem
, "ivshmem.bar2",
343 s
->ivshmem_size
, ptr
);
344 vmstate_register_ram(&s
->ivshmem
, &s
->dev
.qdev
);
345 memory_region_add_subregion(&s
->bar
, 0, &s
->ivshmem
);
347 /* region for shared memory */
348 pci_register_bar(&s
->dev
, 2, s
->ivshmem_attr
, &s
->bar
);
351 static void ivshmem_add_eventfd(IVShmemState
*s
, int posn
, int i
)
353 memory_region_add_eventfd(&s
->ivshmem_mmio
,
358 &s
->peers
[posn
].eventfds
[i
]);
361 static void ivshmem_del_eventfd(IVShmemState
*s
, int posn
, int i
)
363 memory_region_del_eventfd(&s
->ivshmem_mmio
,
368 &s
->peers
[posn
].eventfds
[i
]);
371 static void close_guest_eventfds(IVShmemState
*s
, int posn
)
373 int i
, guest_curr_max
;
375 if (!ivshmem_has_feature(s
, IVSHMEM_IOEVENTFD
)) {
379 guest_curr_max
= s
->peers
[posn
].nb_eventfds
;
381 memory_region_transaction_begin();
382 for (i
= 0; i
< guest_curr_max
; i
++) {
383 ivshmem_del_eventfd(s
, posn
, i
);
385 memory_region_transaction_commit();
386 for (i
= 0; i
< guest_curr_max
; i
++) {
387 event_notifier_cleanup(&s
->peers
[posn
].eventfds
[i
]);
390 g_free(s
->peers
[posn
].eventfds
);
391 s
->peers
[posn
].nb_eventfds
= 0;
394 /* this function increase the dynamic storage need to store data about other
396 static void increase_dynamic_storage(IVShmemState
*s
, int new_min_size
) {
400 old_nb_alloc
= s
->nb_peers
;
402 while (new_min_size
>= s
->nb_peers
)
403 s
->nb_peers
= s
->nb_peers
* 2;
405 IVSHMEM_DPRINTF("bumping storage to %d guests\n", s
->nb_peers
);
406 s
->peers
= g_realloc(s
->peers
, s
->nb_peers
* sizeof(Peer
));
408 /* zero out new pointers */
409 for (j
= old_nb_alloc
; j
< s
->nb_peers
; j
++) {
410 s
->peers
[j
].eventfds
= NULL
;
411 s
->peers
[j
].nb_eventfds
= 0;
415 static void ivshmem_read(void *opaque
, const uint8_t * buf
, int flags
)
417 IVShmemState
*s
= opaque
;
418 int incoming_fd
, tmp_fd
;
419 int guest_max_eventfd
;
422 memcpy(&incoming_posn
, buf
, sizeof(long));
423 /* pick off s->server_chr->msgfd and store it, posn should accompany msg */
424 tmp_fd
= qemu_chr_fe_get_msgfd(s
->server_chr
);
425 IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn
, tmp_fd
);
427 /* make sure we have enough space for this guest */
428 if (incoming_posn
>= s
->nb_peers
) {
429 increase_dynamic_storage(s
, incoming_posn
);
433 /* if posn is positive and unseen before then this is our posn*/
434 if ((incoming_posn
>= 0) &&
435 (s
->peers
[incoming_posn
].eventfds
== NULL
)) {
436 /* receive our posn */
437 s
->vm_id
= incoming_posn
;
440 /* otherwise an fd == -1 means an existing guest has gone away */
441 IVSHMEM_DPRINTF("posn %ld has gone away\n", incoming_posn
);
442 close_guest_eventfds(s
, incoming_posn
);
447 /* because of the implementation of get_msgfd, we need a dup */
448 incoming_fd
= dup(tmp_fd
);
450 if (incoming_fd
== -1) {
451 fprintf(stderr
, "could not allocate file descriptor %s\n",
456 /* if the position is -1, then it's shared memory region fd */
457 if (incoming_posn
== -1) {
463 if (check_shm_size(s
, incoming_fd
) == -1) {
467 /* mmap the region and map into the BAR2 */
468 map_ptr
= mmap(0, s
->ivshmem_size
, PROT_READ
|PROT_WRITE
, MAP_SHARED
,
470 memory_region_init_ram_ptr(&s
->ivshmem
,
471 "ivshmem.bar2", s
->ivshmem_size
, map_ptr
);
472 vmstate_register_ram(&s
->ivshmem
, &s
->dev
.qdev
);
474 IVSHMEM_DPRINTF("guest h/w addr = %" PRIu64
", size = %" PRIu64
"\n",
475 s
->ivshmem_offset
, s
->ivshmem_size
);
477 memory_region_add_subregion(&s
->bar
, 0, &s
->ivshmem
);
479 /* only store the fd if it is successfully mapped */
480 s
->shm_fd
= incoming_fd
;
485 /* each guest has an array of eventfds, and we keep track of how many
486 * guests for each VM */
487 guest_max_eventfd
= s
->peers
[incoming_posn
].nb_eventfds
;
489 if (guest_max_eventfd
== 0) {
490 /* one eventfd per MSI vector */
491 s
->peers
[incoming_posn
].eventfds
= g_new(EventNotifier
, s
->vectors
);
494 /* this is an eventfd for a particular guest VM */
495 IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn
,
496 guest_max_eventfd
, incoming_fd
);
497 event_notifier_init_fd(&s
->peers
[incoming_posn
].eventfds
[guest_max_eventfd
],
500 /* increment count for particular guest */
501 s
->peers
[incoming_posn
].nb_eventfds
++;
503 /* keep track of the maximum VM ID */
504 if (incoming_posn
> s
->max_peer
) {
505 s
->max_peer
= incoming_posn
;
508 if (incoming_posn
== s
->vm_id
) {
509 s
->eventfd_chr
[guest_max_eventfd
] = create_eventfd_chr_device(s
,
510 &s
->peers
[s
->vm_id
].eventfds
[guest_max_eventfd
],
514 if (ivshmem_has_feature(s
, IVSHMEM_IOEVENTFD
)) {
515 ivshmem_add_eventfd(s
, incoming_posn
, guest_max_eventfd
);
519 /* Select the MSI-X vectors used by device.
520 * ivshmem maps events to vectors statically, so
521 * we just enable all vectors on init and after reset. */
522 static void ivshmem_use_msix(IVShmemState
* s
)
526 if (!msix_present(&s
->dev
)) {
530 for (i
= 0; i
< s
->vectors
; i
++) {
531 msix_vector_use(&s
->dev
, i
);
535 static void ivshmem_reset(DeviceState
*d
)
537 IVShmemState
*s
= DO_UPCAST(IVShmemState
, dev
.qdev
, d
);
543 static uint64_t ivshmem_get_size(IVShmemState
* s
) {
548 value
= strtoull(s
->sizearg
, &ptr
, 10);
550 case 0: case 'M': case 'm':
557 fprintf(stderr
, "qemu: invalid ram size: %s\n", s
->sizearg
);
561 /* BARs must be a power of 2 */
562 if (!is_power_of_two(value
)) {
563 fprintf(stderr
, "ivshmem: size must be power of 2\n");
570 static void ivshmem_setup_msi(IVShmemState
* s
)
572 if (msix_init_exclusive_bar(&s
->dev
, s
->vectors
, 1)) {
573 IVSHMEM_DPRINTF("msix initialization failed\n");
577 IVSHMEM_DPRINTF("msix initialized (%d vectors)\n", s
->vectors
);
579 /* allocate QEMU char devices for receiving interrupts */
580 s
->eventfd_table
= g_malloc0(s
->vectors
* sizeof(EventfdEntry
));
585 static void ivshmem_save(QEMUFile
* f
, void *opaque
)
587 IVShmemState
*proxy
= opaque
;
589 IVSHMEM_DPRINTF("ivshmem_save\n");
590 pci_device_save(&proxy
->dev
, f
);
592 if (ivshmem_has_feature(proxy
, IVSHMEM_MSI
)) {
593 msix_save(&proxy
->dev
, f
);
595 qemu_put_be32(f
, proxy
->intrstatus
);
596 qemu_put_be32(f
, proxy
->intrmask
);
601 static int ivshmem_load(QEMUFile
* f
, void *opaque
, int version_id
)
603 IVSHMEM_DPRINTF("ivshmem_load\n");
605 IVShmemState
*proxy
= opaque
;
608 if (version_id
> 0) {
612 if (proxy
->role_val
== IVSHMEM_PEER
) {
613 fprintf(stderr
, "ivshmem: 'peer' devices are not migratable\n");
617 ret
= pci_device_load(&proxy
->dev
, f
);
622 if (ivshmem_has_feature(proxy
, IVSHMEM_MSI
)) {
623 msix_load(&proxy
->dev
, f
);
624 ivshmem_use_msix(proxy
);
626 proxy
->intrstatus
= qemu_get_be32(f
);
627 proxy
->intrmask
= qemu_get_be32(f
);
633 static void ivshmem_write_config(PCIDevice
*pci_dev
, uint32_t address
,
634 uint32_t val
, int len
)
636 pci_default_write_config(pci_dev
, address
, val
, len
);
637 msix_write_config(pci_dev
, address
, val
, len
);
640 static int pci_ivshmem_init(PCIDevice
*dev
)
642 IVShmemState
*s
= DO_UPCAST(IVShmemState
, dev
, dev
);
645 if (s
->sizearg
== NULL
)
646 s
->ivshmem_size
= 4 << 20; /* 4 MB default */
648 s
->ivshmem_size
= ivshmem_get_size(s
);
651 register_savevm(&s
->dev
.qdev
, "ivshmem", 0, 0, ivshmem_save
, ivshmem_load
,
654 /* IRQFD requires MSI */
655 if (ivshmem_has_feature(s
, IVSHMEM_IOEVENTFD
) &&
656 !ivshmem_has_feature(s
, IVSHMEM_MSI
)) {
657 fprintf(stderr
, "ivshmem: ioeventfd/irqfd requires MSI\n");
661 /* check that role is reasonable */
663 if (strncmp(s
->role
, "peer", 5) == 0) {
664 s
->role_val
= IVSHMEM_PEER
;
665 } else if (strncmp(s
->role
, "master", 7) == 0) {
666 s
->role_val
= IVSHMEM_MASTER
;
668 fprintf(stderr
, "ivshmem: 'role' must be 'peer' or 'master'\n");
672 s
->role_val
= IVSHMEM_MASTER
; /* default */
675 if (s
->role_val
== IVSHMEM_PEER
) {
676 error_set(&s
->migration_blocker
, QERR_DEVICE_FEATURE_BLOCKS_MIGRATION
,
677 "peer mode", "ivshmem");
678 migrate_add_blocker(s
->migration_blocker
);
681 pci_conf
= s
->dev
.config
;
682 pci_conf
[PCI_COMMAND
] = PCI_COMMAND_IO
| PCI_COMMAND_MEMORY
;
684 pci_config_set_interrupt_pin(pci_conf
, 1);
688 memory_region_init_io(&s
->ivshmem_mmio
, &ivshmem_mmio_ops
, s
,
689 "ivshmem-mmio", IVSHMEM_REG_BAR_SIZE
);
691 /* region for registers*/
692 pci_register_bar(&s
->dev
, 0, PCI_BASE_ADDRESS_SPACE_MEMORY
,
695 memory_region_init(&s
->bar
, "ivshmem-bar2-container", s
->ivshmem_size
);
696 s
->ivshmem_attr
= PCI_BASE_ADDRESS_SPACE_MEMORY
|
697 PCI_BASE_ADDRESS_MEM_PREFETCH
;
698 if (s
->ivshmem_64bit
) {
699 s
->ivshmem_attr
|= PCI_BASE_ADDRESS_MEM_TYPE_64
;
702 if ((s
->server_chr
!= NULL
) &&
703 (strncmp(s
->server_chr
->filename
, "unix:", 5) == 0)) {
704 /* if we get a UNIX socket as the parameter we will talk
705 * to the ivshmem server to receive the memory region */
707 if (s
->shmobj
!= NULL
) {
708 fprintf(stderr
, "WARNING: do not specify both 'chardev' "
709 "and 'shm' with ivshmem\n");
712 IVSHMEM_DPRINTF("using shared memory server (socket = %s)\n",
713 s
->server_chr
->filename
);
715 if (ivshmem_has_feature(s
, IVSHMEM_MSI
)) {
716 ivshmem_setup_msi(s
);
719 /* we allocate enough space for 16 guests and grow as needed */
723 /* allocate/initialize space for interrupt handling */
724 s
->peers
= g_malloc0(s
->nb_peers
* sizeof(Peer
));
726 pci_register_bar(&s
->dev
, 2, s
->ivshmem_attr
, &s
->bar
);
728 s
->eventfd_chr
= g_malloc0(s
->vectors
* sizeof(CharDriverState
*));
730 qemu_chr_add_handlers(s
->server_chr
, ivshmem_can_receive
, ivshmem_read
,
733 /* just map the file immediately, we're not using a server */
736 if (s
->shmobj
== NULL
) {
737 fprintf(stderr
, "Must specify 'chardev' or 'shm' to ivshmem\n");
740 IVSHMEM_DPRINTF("using shm_open (shm object = %s)\n", s
->shmobj
);
742 /* try opening with O_EXCL and if it succeeds zero the memory
743 * by truncating to 0 */
744 if ((fd
= shm_open(s
->shmobj
, O_CREAT
|O_RDWR
|O_EXCL
,
745 S_IRWXU
|S_IRWXG
|S_IRWXO
)) > 0) {
746 /* truncate file to length PCI device's memory */
747 if (ftruncate(fd
, s
->ivshmem_size
) != 0) {
748 fprintf(stderr
, "ivshmem: could not truncate shared file\n");
751 } else if ((fd
= shm_open(s
->shmobj
, O_CREAT
|O_RDWR
,
752 S_IRWXU
|S_IRWXG
|S_IRWXO
)) < 0) {
753 fprintf(stderr
, "ivshmem: could not open shared file\n");
758 if (check_shm_size(s
, fd
) == -1) {
762 create_shared_memory_BAR(s
, fd
);
766 s
->dev
.config_write
= ivshmem_write_config
;
771 static void pci_ivshmem_uninit(PCIDevice
*dev
)
773 IVShmemState
*s
= DO_UPCAST(IVShmemState
, dev
, dev
);
775 if (s
->migration_blocker
) {
776 migrate_del_blocker(s
->migration_blocker
);
777 error_free(s
->migration_blocker
);
780 memory_region_destroy(&s
->ivshmem_mmio
);
781 memory_region_del_subregion(&s
->bar
, &s
->ivshmem
);
782 vmstate_unregister_ram(&s
->ivshmem
, &s
->dev
.qdev
);
783 memory_region_destroy(&s
->ivshmem
);
784 memory_region_destroy(&s
->bar
);
785 unregister_savevm(&dev
->qdev
, "ivshmem", s
);
788 static Property ivshmem_properties
[] = {
789 DEFINE_PROP_CHR("chardev", IVShmemState
, server_chr
),
790 DEFINE_PROP_STRING("size", IVShmemState
, sizearg
),
791 DEFINE_PROP_UINT32("vectors", IVShmemState
, vectors
, 1),
792 DEFINE_PROP_BIT("ioeventfd", IVShmemState
, features
, IVSHMEM_IOEVENTFD
, false),
793 DEFINE_PROP_BIT("msi", IVShmemState
, features
, IVSHMEM_MSI
, true),
794 DEFINE_PROP_STRING("shm", IVShmemState
, shmobj
),
795 DEFINE_PROP_STRING("role", IVShmemState
, role
),
796 DEFINE_PROP_UINT32("use64", IVShmemState
, ivshmem_64bit
, 1),
797 DEFINE_PROP_END_OF_LIST(),
800 static void ivshmem_class_init(ObjectClass
*klass
, void *data
)
802 DeviceClass
*dc
= DEVICE_CLASS(klass
);
803 PCIDeviceClass
*k
= PCI_DEVICE_CLASS(klass
);
805 k
->init
= pci_ivshmem_init
;
806 k
->exit
= pci_ivshmem_uninit
;
807 k
->vendor_id
= PCI_VENDOR_ID_IVSHMEM
;
808 k
->device_id
= PCI_DEVICE_ID_IVSHMEM
;
809 k
->class_id
= PCI_CLASS_MEMORY_RAM
;
810 dc
->reset
= ivshmem_reset
;
811 dc
->props
= ivshmem_properties
;
814 static const TypeInfo ivshmem_info
= {
816 .parent
= TYPE_PCI_DEVICE
,
817 .instance_size
= sizeof(IVShmemState
),
818 .class_init
= ivshmem_class_init
,
821 static void ivshmem_register_types(void)
823 type_register_static(&ivshmem_info
);
826 type_init(ivshmem_register_types
)