Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


updates to virtio device framework
[palacios.git] / palacios / src / devices / sym_swap.c
1 /* 
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.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
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.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #include <palacios/vmm.h>
21 #include <palacios/vmm_dev_mgr.h>
22
23
24
25
26 struct swap_state {
27     
28     struct vm_device * blk_dev;
29
30 };
31
32
33
34
35 static int swap_free(struct vm_device * dev) {
36     return -1;
37 }
38
39
40
41 static struct v3_device_ops dev_ops = {
42     .free = swap_free,
43     .reset = NULL,
44     .start = NULL,
45     .stop = NULL,
46 };
47
48
49
50
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);
54
55     if (!virtio_blk) {
56         PrintError("could not find Virtio backend\n");
57         return -1;
58     }
59
60     PrintDebug("Creating Swap Device\n");
61
62     if (virtio_blk == NULL) {
63         PrintError("Swap device requires a virtio block device\n");
64         return -1;
65     }
66
67     swap = (struct swap_state *)V3_Malloc(sizeof(struct swap_state));
68
69     swap->blk_dev = virtio_blk;
70
71     struct vm_device * dev = v3_allocate_device("SYM_SWAP", &dev_ops, swap);
72
73     if (v3_attach_device(vm, dev) == -1) {
74         PrintError("Could not attach device %s\n", "SYM_SWAP");
75         return -1;
76     }
77
78     return 0;
79 }
80
81
82
83 device_register("SYM_SWAP", swap_init)