]> xenbits.xensource.com Git - xenclient/toolstack.git/commitdiff
start on xenvm protocol autogeneration
authorPrashanth Mundkur <prashanth.mundkur@citrix.com>
Fri, 15 May 2009 21:04:16 +0000 (14:04 -0700)
committerPrashanth Mundkur <prashanth.mundkur@citrix.com>
Fri, 15 May 2009 21:08:27 +0000 (14:08 -0700)
xenvm/proto/Makefile [new file with mode: 0644]
xenvm/proto/xenvm_control.json [new file with mode: 0644]
xenvm/proto/xenvm_notify.json [new file with mode: 0644]
xenvm/proto/xenvm_proto.ml [new file with mode: 0644]

diff --git a/xenvm/proto/Makefile b/xenvm/proto/Makefile
new file mode 100644 (file)
index 0000000..9633eb8
--- /dev/null
@@ -0,0 +1,58 @@
+TOPLEVEL=../..
+
+OCAMLC = ocamlc
+OCAMLOPT = ocamlopt
+OCAMLDEP = ocamldep
+
+GEN_JSON_CONV = $(TOPLEVEL)/gen/json_conv/gen_json_conv
+GEN_RPC = $(TOPLEVEL)/gen/rpc/gen_rpc
+
+INCLUDES = -I $(TOPLEVEL)/libs/json -I $(TOPLEVEL)/libs/jsonrpc
+OFLAGS = -g -dtypes $(INCLUDES)
+
+GENERATED = xenvm_proto_json xenvm_notify_client xenvm_notify_server xenvm_control_client xenvm_control_server
+GENERATED_SRC = $(addsuffix .ml, $(GENERATED))
+
+FILES = xenvm_proto $(GENERATED)
+SRC = $(addsuffix .ml, $(FILES))
+OBJ = $(addsuffix .o, $(FILES))
+
+all: $(OBJ)
+
+xenvm_proto_json.ml: xenvm_proto.ml
+       $(GEN_JSON_CONV) -i $< -o $@
+
+xenvm_notify_client.ml xenvm_notify_server.ml: xenvm_notify.json
+       $(GEN_RPC) -i $< -c xenvm_notify_client.ml -s xenvm_notify_server.ml
+
+xenvm_control_client.ml xenvm_control_server.ml: xenvm_control.json
+       $(GEN_RPC) -i $< -c xenvm_control_client.ml -s xenvm_control_server.ml
+
+.SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly .tex .dvi .ps .html
+
+.mli.cmi:
+       $(OCAMLC) -c $(OFLAGS) $<
+
+.ml.cmo:
+       $(OCAMLC) -c $(OFLAGS) $<
+
+.ml.o:
+       $(OCAMLOPT) -c $(OFLAGS) $<
+
+.ml.cmx:
+       $(OCAMLOPT) -c $(OFLAGS) $<
+
+
+.PHONY: clean realclean depend
+
+clean:
+       rm -f *.cmi *.cmo *.annot *.o *.cmxa *.cmx
+
+realclean: clean
+       rm -f $(GENERATED_SRC)
+
+.depend depend: $(GENERATED_SRC)
+       rm -f .depend
+       $(OCAMLDEP) $(INCLUDES) *.ml *.mli > .depend
+
+include .depend
diff --git a/xenvm/proto/xenvm_control.json b/xenvm/proto/xenvm_control.json
new file mode 100644 (file)
index 0000000..e2b7892
--- /dev/null
@@ -0,0 +1,433 @@
+{ "use_modules": ["xenvm_proto", "xenvm_proto_json"]}
+
+{ "server_name": "xenvm_control",
+  "server_doc": "This module describes the messages in the protocol from XenVM to XenMgr.",
+  "server_error_handler": "xenvm_error_handler"
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "Cmd_Quit",
+                   "request_doc": "Commands XenVM to exit.",
+                   "request_handler": "quit_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "cmd_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "Cmd_ReadConfig",
+                   "request_doc": "Commands XenVM to (re) load the specified config.",
+                   "request_handler": "read_config_handler",
+                   "request_params": [ { "param_name": "location",
+                                         "param_doc": "",
+                                         "param_type": "string" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "cmd_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Start",
+                   "request_doc": "",
+                   "request_handler": "vm_start_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Pause",
+                   "request_doc": "",
+                   "request_handler": "vm_pause_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Unpause",
+                   "request_doc": "",
+                   "request_handler": "vm_unpause_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Reboot",
+                   "request_doc": "",
+                   "request_handler": "vm_reboot_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Restart",
+                   "request_doc": "",
+                   "request_handler": "vm_restart_handler",
+                   "request_params": [ { "param_name": "force",
+                                        "param_doc": "",
+                                        "param_type": "bool" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Halt",
+                   "request_doc": "",
+                   "request_handler": "vm_halt_handler",
+                   "request_params": [ { "param_name": "force",
+                                        "param_doc": "",
+                                        "param_type": "bool" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Suspend",
+                   "request_doc": "",
+                   "request_handler": "vm_suspend_handler",
+                   "request_params": [ { "param_name": "flags",
+                                        "param_doc": "",
+                                        "param_type": "suspend_flags" },
+                                      { "param_name": "location",
+                                        "param_doc": "",
+                                        "param_type": "file_location" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Restore",
+                   "request_doc": "",
+                   "request_handler": "vm_restore_handler",
+                   "request_params": [ { "param_name": "flags",
+                                        "param_doc": "",
+                                        "param_type": "restore_flags" },
+                                      { "param_name": "location",
+                                        "param_doc": "",
+                                        "param_type": "file_location" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Checkpoint",
+                   "request_doc": "",
+                   "request_handler": "vm_checkpoint_handler",
+                   "request_params": [ { "param_name": "location",
+                                        "param_doc": "",
+                                        "param_type": "file_location" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_GetStatus",
+                   "request_doc": "",
+                   "request_handler": "vm_getstatus_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vm_getstatus_handler",
+                    "response_value": { "param_name": "status",
+                                        "param_doc": "Current VM state",
+                                        "param_type": "vmstate"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_GetVNC",
+                   "request_doc": "",
+                   "request_handler": "vm_getvnc_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vm_getvnc_handler",
+                    "response_value": { "param_name": "status",
+                                        "param_doc": "Current VM state",
+                                        "param_type": "vmstate"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_GetDomId",
+                   "request_doc": "",
+                   "request_handler": "vm_getdomid_handler",
+                   "request_params": [ ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vm_getdomid_handler",
+                    "response_value": { "param_name": "domid",
+                                        "param_doc": "",
+                                        "param_type": "int"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "Device_Plug",
+                   "request_doc": "",
+                   "request_handler": "device_plug_handler",
+                   "request_params": [ { "param_name": "device",
+                                         "param_doc": "",
+                                         "param_type": "device" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "devop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "Device_Unplug",
+                   "request_doc": "",
+                   "request_handler": "device_unplug_handler",
+                   "request_params": [ { "param_name": "device",
+                                         "param_doc": "",
+                                         "param_type": "device" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "devop_response_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "Device_List",
+                   "request_doc": "",
+                   "request_handler": "device_list_handler",
+                   "request_params": [ { "param_name": "devtype",
+                                         "param_doc": "",
+                                         "param_type": "device_type" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "device_list_response_handler",
+                    "response_value": { "param_name": "device_list",
+                                        "param_doc": "",
+                                        "param_type": "device_list"
+                                      }
+                  }
+}
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_State_Get",
+                   "request_doc": "",
+                   "request_handler": "vmstate_get_handler",
+                   "request_params": [ { "param_name": "field",
+                                         "param_doc": "",
+                                         "param_type": "string" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmstate_get_handler",
+                    "response_value": { "param_name": "value",
+                                        "param_doc": "",
+                                        "param_type": "string"
+                                      }
+                  }
+}
+
+
+{ "rpc_type": "rpc",
+  "rpc_server": "xenvm_control",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_State_Set",
+                   "request_doc": "",
+                   "request_handler": "vmstate_set_handler",
+                   "request_params": [ { "param_name": "field",
+                                         "param_doc": "",
+                                         "param_type": "string" },
+                                      { "param_name": "value",
+                                         "param_doc": "",
+                                         "param_type": "string" }
+                                    ]
+                 },
+
+  "rpc_response": { "response_doc": "",
+                    "response_handler": "vmstate_set_handler",
+                    "response_value": { "param_name": "resp",
+                                        "param_doc": "",
+                                        "param_type": "rpc_result"
+                                      }
+                  }
+}
+
diff --git a/xenvm/proto/xenvm_notify.json b/xenvm/proto/xenvm_notify.json
new file mode 100644 (file)
index 0000000..5128572
--- /dev/null
@@ -0,0 +1,50 @@
+{ "use_modules": ["xenvm_proto", "xenvm_proto_json"]}
+
+{ "server_name": "xenvm_monitor",
+  "server_doc": "This module describes the notification messages emitted by XenVM.",
+  "server_error_handler": "xenvm_error_handler"
+}
+
+{ "rpc_type": "notification",
+  "rpc_server": "xenvm_monitor",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "Proto_Hup",
+                   "request_doc": "This is the last message sent on the connection before a clean exit.",
+                   "request_handler": "hup_handler",
+                   "request_params": []
+                 }
+}
+
+{ "rpc_type": "notification",
+  "rpc_server": "xenvm_monitor",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Status",
+                   "request_doc": "This is usually sent when the VM changes its state, but is also sent on startup.",
+                   "request_handler": "vm_status_handler",
+                   "request_params": [ { "param_name": "current_state",
+                                         "param_doc": "The current state of the monitored VM.",
+                                         "param_type": "vmstate"
+                                       }
+                                     ]
+                 }
+}
+
+{ "rpc_type": "notification",
+  "rpc_server": "xenvm_monitor",
+  "rpc_doc": "",
+  "rpc_version": "0.1",
+
+  "rpc_request": { "request_name": "VM_Error",
+                   "request_doc": "This is sent whenever XenVM experiences any error.",
+                   "request_handler": "vm_error_handler",
+                   "request_params": [ { "param_name": "error",
+                                         "param_doc": "",
+                                         "param_type": "error"
+                                       }
+                                     ]
+                 }
+}
diff --git a/xenvm/proto/xenvm_proto.ml b/xenvm/proto/xenvm_proto.ml
new file mode 100644 (file)
index 0000000..420a2d0
--- /dev/null
@@ -0,0 +1,60 @@
+(* VM state *)
+type vmstate =
+       | VmCreated     | VmShutdown    | VmShuttingDown
+       | VmPaused      | VmSuspending  | VmSuspended
+       | VmRestoring   | VmRunning
+
+(* errors *)
+type severity = Warning | Critical | Fatal
+type error = severity * string
+
+(* failure codes *)
+(* TODO: this should be a variant *)
+type code = int
+
+
+(* common rpc responses *)
+type rpc_result =
+       | Ok
+       | Error of code * string
+
+type op_result =
+       | Op_started
+       | Op_in_progress of float
+       | Op_done
+       | Op_failed of code * string
+
+(* rpc specific types *)
+type suspend_flag =
+       | Suspend_flag_live
+       | Suspend_flag_debug
+
+type suspend_flags = suspend_flag list
+
+type file_location =
+       | File_local of string
+       | File_nfs of string
+
+type restore_flag =
+       | Restore_flag_delete
+
+type restore_flags = restore_flag list
+
+type vnc = VNC of (* address *) string * (* port *) int
+
+type device_type =
+       | Devtype_PCI | Devtype_PBD | Devtype_PIF
+       | Devtype_VIF | Devtype_VBD | Devtype_RTC
+
+(* TODO: fix device types *)
+type device =
+       | Dev_PCI of string
+       | Dev_PBD of string
+       | Dev_PIF of string
+       | Dev_VIF of string
+       | Dev_VBD of string
+       | Dev_RTC of string
+
+type device_list = device list
+
+type path = string