2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #include <palacios/vmm.h>
21 #include <palacios/vmm_dev_mgr.h>
22 #include <devices/lnx_virtio.h>
28 struct vm_device * blk_dev;
35 static int swap_free(struct vm_device * dev) {
41 static struct v3_device_ops dev_ops = {
51 static int swap_init(struct guest_info * vm, void * cfg_data) {
52 struct swap_state * swap = NULL;
53 struct vm_device * virtio_blk = v3_find_dev(vm, (char *)cfg_data);
56 PrintError("could not find Virtio backend\n");
60 PrintDebug("Creating Swap Device\n");
62 if (virtio_blk == NULL) {
63 PrintError("Swap device requires a virtio block device\n");
67 swap = (struct swap_state *)V3_Malloc(sizeof(struct swap_state));
69 swap->blk_dev = virtio_blk;
71 struct vm_device * dev = v3_allocate_device("SYM_SWAP", &dev_ops, swap);
73 if (v3_attach_device(vm, dev) == -1) {
74 PrintError("Could not attach device %s\n", "SYM_SWAP");
83 device_register("SYM_SWAP", swap_init)