First off we have the XDR definition file. This is basically a translation of the original qemud/protocol.h into the XDR format. The important changes are that - Instead of a single enum of message types there are now two enums - enum qemud_packet_client_data_type lists valid packets (ie method calls) that a client can make - enum qemud_packet_server_data_type lists valie packets (ie method replies) that a server can make There are two reasons for this split - This lets us add in more server packets which are not neccessaril method replies. ie async notifications ('domain foo start') - We use the enum to discriminate two unions later and there is actually already one type that's used by the server only QEMU_SERVER_PACKET_FAILURE to indicate a method which failed. - The big union qemud_packet_data is now split up - The inline per-message type structs are now all represented at the top level as fully named structs. - There is a qemud_packet_client_data union which is the union of all structs relevant to method calls - There is a qemud_packet_server_data union which is the union of all structs relevant to method replies - Introduce the idea of serial numbers. A serial number allows a client to track the incoming packet from the server which corresponds to a message it just sent. This is because in the future a server may be sending async notifications mixed inbetween method replies. So we have - A qemud_packet_client struct which contains a serial number & a qemud_packet_client_data struct. - A qemud_packet_server struct which contains a serial number, a replyto serial number & a qemud_packet_server_data struct. - Finally there is a qemud_packet_header which contains a magic 4 byte sequence and a length field. This is basically to make pulling the variable length XDR payloads off the wire easier to deal with. The header is always followed by a qemud_packet_client or qemud_packet_server XDR payload. The header length field gives the size of the payload. The magic byte sequence is just a sanity check, which is also useful in debugging. $ diffstat libvirt-qemu-xdr-protocol.patch Makefile.am | 15 + protocol.h | 329 -------------------------------- protocol.x | 608 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 620 insertions(+), 332 deletions(-) Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
Index: qemud/Makefile.am =================================================================== RCS file: /data/cvs/libvirt/qemud/Makefile.am,v retrieving revision 1.16 diff -u -p -u -p -r1.16 Makefile.am --- qemud/Makefile.am 15 Mar 2007 17:24:57 -0000 1.16 +++ qemud/Makefile.am 22 Mar 2007 19:47:09 -0000 @@ -12,9 +12,10 @@ libvirt_qemud_SOURCES = qemud.c internal bridge.c bridge.h \ iptables.c iptables.h \ uuid.c uuid.h \ - buf.c buf.h + buf.c buf.h \ + protocol.h protocol.c #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L -libvirt_qemud_CFLAGS = \ +libvirt_qemud_CFLAGS = -g \ -I$(top_srcdir)/include -I$(top_builddir)/include $(LIBXML_CFLAGS) \ $(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \ -DSYSCONF_DIR="\"$(sysconfdir)\"" @@ -38,7 +39,15 @@ uninstall-local: rmdir $(DESTDIR)$(localstatedir)/run/libvirt || : rmdir $(DESTDIR)$(localstatedir)/lib/libvirt || : -EXTRA_DIST = libvirtd.in default-network.xml +EXTRA_DIST = libvirtd.in default-network.xml protocol.x + +protocol.c: protocol.x + rm -f $@ + rpcgen -c -o $@ $< + +protocol.h: protocol.x + rm -f $@ + rpcgen -h -o $@ $< if LIBVIRT_INIT_SCRIPTS_RED_HAT initdir = $(sysconfdir)/rc.d/init.d Index: qemud/protocol.h =================================================================== RCS file: qemud/protocol.h diff -N qemud/protocol.h --- qemud/protocol.h 19 Mar 2007 14:18:05 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,329 +0,0 @@ -/* - * protocol.h: wire protocol message format & data structures - * - * Copyright (C) 2006, 2007 Red Hat, Inc. - * Copyright (C) 2006 Daniel P. Berrange - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Daniel P. Berrange <berrange@xxxxxxxxxx> - */ - - -#ifndef QEMUD_PROTOCOL_H__ -#define QEMUD_PROTOCOL_H__ - -#include <stdint.h> -#include <net/if.h> /* for IF_NAMESIZE */ - -/* List of different packet types which can be sent */ -enum qemud_packet_type { - QEMUD_PKT_FAILURE = 0, - QEMUD_PKT_GET_VERSION, - QEMUD_PKT_GET_NODEINFO, - QEMUD_PKT_LIST_DOMAINS, - QEMUD_PKT_NUM_DOMAINS, - QEMUD_PKT_DOMAIN_CREATE, - QEMUD_PKT_DOMAIN_LOOKUP_BY_ID, - QEMUD_PKT_DOMAIN_LOOKUP_BY_UUID, - QEMUD_PKT_DOMAIN_LOOKUP_BY_NAME, - QEMUD_PKT_DOMAIN_SUSPEND, - QEMUD_PKT_DOMAIN_RESUME, - QEMUD_PKT_DOMAIN_DESTROY, - QEMUD_PKT_DOMAIN_GET_INFO, - QEMUD_PKT_DOMAIN_SAVE, - QEMUD_PKT_DOMAIN_RESTORE, - QEMUD_PKT_DUMP_XML, - QEMUD_PKT_LIST_DEFINED_DOMAINS, - QEMUD_PKT_NUM_DEFINED_DOMAINS, - QEMUD_PKT_DOMAIN_START, - QEMUD_PKT_DOMAIN_DEFINE, - QEMUD_PKT_DOMAIN_UNDEFINE, - QEMUD_PKT_NUM_NETWORKS, - QEMUD_PKT_LIST_NETWORKS, - QEMUD_PKT_NUM_DEFINED_NETWORKS, - QEMUD_PKT_LIST_DEFINED_NETWORKS, - QEMUD_PKT_NETWORK_LOOKUP_BY_UUID, - QEMUD_PKT_NETWORK_LOOKUP_BY_NAME, - QEMUD_PKT_NETWORK_CREATE, - QEMUD_PKT_NETWORK_DEFINE, - QEMUD_PKT_NETWORK_UNDEFINE, - QEMUD_PKT_NETWORK_START, - QEMUD_PKT_NETWORK_DESTROY, - QEMUD_PKT_NETWORK_DUMP_XML, - QEMUD_PKT_NETWORK_GET_BRIDGE_NAME, - QEMUD_PKT_DOMAIN_GET_AUTOSTART, - QEMUD_PKT_DOMAIN_SET_AUTOSTART, - QEMUD_PKT_NETWORK_GET_AUTOSTART, - QEMUD_PKT_NETWORK_SET_AUTOSTART, - QEMUD_PKT_GET_CAPABILITIES, - - QEMUD_PKT_MAX, -}; - - -#define QEMUD_PROTOCOL_VERSION_MAJOR 1 -#define QEMUD_PROTOCOL_VERSION_MINOR 0 - -#define QEMUD_UUID_RAW_LEN 16 -#define QEMUD_MAX_NAME_LEN 50 -#define QEMUD_MAX_XML_LEN 4096 -#define QEMUD_MAX_IFNAME_LEN IF_NAMESIZE -#define QEMUD_MAX_NUM_DOMAINS 100 -#define QEMUD_MAX_NUM_NETWORKS 100 -#define QEMUD_MAX_ERROR_LEN 1024 - -/* Possible guest VM states */ -enum qemud_domain_runstate { - QEMUD_STATE_RUNNING = 1, - QEMUD_STATE_PAUSED, - QEMUD_STATE_STOPPED, -}; - -/* Each packets has at least a fixed size header. - * - * All data required to be network byte order - * to 32-bit boundaries */ -struct qemud_packet_header { - uint32_t type; - /* Stores the size of the data struct matching - the type arg. - Must be <= sizeof(union qemudPacketData) */ - uint32_t dataSize; -}; - -/* Most packets also have some message specific data - * All data required to be network byte order, padded - * to 32-bit boundaries */ -union qemud_packet_data { - struct { - int32_t code; - char message[QEMUD_MAX_ERROR_LEN]; - } failureReply; - struct { - int32_t version; - } getVersionReply; - struct { - char model[32]; - uint32_t memory; - uint32_t cpus; - uint32_t mhz; - uint32_t nodes; - uint32_t sockets; - uint32_t cores; - uint32_t threads; - } getNodeInfoReply; - struct { - char xml[QEMUD_MAX_XML_LEN]; - } getCapabilitiesReply; - struct { - int32_t numDomains; - int32_t domains[QEMUD_MAX_NUM_DOMAINS]; - } listDomainsReply; - struct { - int32_t numDomains; - } numDomainsReply; - struct { - char xml[QEMUD_MAX_XML_LEN]; - } domainCreateRequest; - struct { - int32_t id; - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; - } domainCreateReply; - struct { - int32_t id; - } domainLookupByIDRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; - } domainLookupByIDReply; - struct { - char name[QEMUD_MAX_NAME_LEN]; - } domainLookupByNameRequest; - struct { - int32_t id; - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } domainLookupByNameReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } domainLookupByUUIDRequest; - struct { - int32_t id; - char name[QEMUD_MAX_NAME_LEN]; - } domainLookupByUUIDReply; - struct { - int32_t id; - } domainSuspendRequest; - struct { - int32_t id; - } domainResumeRequest; - struct { - } domainResumeReply; - struct { - int32_t id; - } domainDestroyRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } domainGetInfoRequest; - struct { - uint64_t cpuTime; - int32_t runstate; - uint32_t memory; - uint32_t maxmem; - uint32_t nrVirtCpu; - } domainGetInfoReply; - struct { - int32_t id; - char file[PATH_MAX]; - } domainSaveRequest; - struct { - char file[PATH_MAX]; - } domainRestoreRequest; - struct { - int32_t id; - } domainRestoreReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } domainDumpXMLRequest; - struct { - char xml[QEMUD_MAX_XML_LEN]; - } domainDumpXMLReply; - struct { - int32_t numDomains; - char domains[QEMUD_MAX_NUM_DOMAINS][QEMUD_MAX_NAME_LEN]; - } listDefinedDomainsReply; - struct { - int32_t numDomains; - } numDefinedDomainsReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } domainStartRequest; - struct { - int32_t id; - } domainStartReply; - struct { - char xml[QEMUD_MAX_XML_LEN]; - } domainDefineRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; - } domainDefineReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } domainUndefineRequest; - struct { - int32_t numNetworks; - } numNetworksReply; - struct { - int32_t numNetworks; - char networks[QEMUD_MAX_NUM_NETWORKS][QEMUD_MAX_NAME_LEN]; - } listNetworksReply; - struct { - int32_t numNetworks; - } numDefinedNetworksReply; - struct { - int32_t numNetworks; - char networks[QEMUD_MAX_NUM_NETWORKS][QEMUD_MAX_NAME_LEN]; - } listDefinedNetworksReply; - struct { - char name[QEMUD_MAX_NAME_LEN]; - } networkLookupByNameRequest; - struct { - int32_t id; - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkLookupByNameReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkLookupByUUIDRequest; - struct { - int32_t id; - char name[QEMUD_MAX_NAME_LEN]; - } networkLookupByUUIDReply; - struct { - char xml[QEMUD_MAX_XML_LEN]; - } networkCreateRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; - } networkCreateReply; - struct { - char xml[QEMUD_MAX_XML_LEN]; - } networkDefineRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; - } networkDefineReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkUndefineRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkStartRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkDestroyRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkDumpXMLRequest; - struct { - char xml[QEMUD_MAX_XML_LEN]; - } networkDumpXMLReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkGetBridgeNameRequest; - struct { - char ifname[QEMUD_MAX_IFNAME_LEN]; - } networkGetBridgeNameReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } domainGetAutostartRequest; - struct { - int autostart; - } domainGetAutostartReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - unsigned int autostart : 1; - } domainSetAutostartRequest; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - } networkGetAutostartRequest; - struct { - unsigned int autostart : 1; - } networkGetAutostartReply; - struct { - unsigned char uuid[QEMUD_UUID_RAW_LEN]; - unsigned int autostart : 1; - } networkSetAutostartRequest; -}; - -/* Each packet has header & data */ -struct qemud_packet { - struct qemud_packet_header header; - union qemud_packet_data data; -}; - - -#endif - - -/* - * Local variables: - * indent-tabs-mode: nil - * c-indent-level: 4 - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ Index: qemud/protocol.x =================================================================== RCS file: qemud/protocol.x diff -N qemud/protocol.x --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ qemud/protocol.x 22 Mar 2007 19:47:12 -0000 @@ -0,0 +1,608 @@ +/* -*- c-mode -*- + * protocol_xdr.x: wire protocol message format & data structures + * + * Copyright (C) 2006, 2007 Red Hat, Inc. + * Copyright (C) 2006 Daniel P. Berrange + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Daniel P. Berrange <berrange@xxxxxxxxxx> + */ + +const QEMUD_UUID_RAW_LEN = 16; +const QEMUD_MAX_NAME_LEN = 50; +const QEMUD_MAX_XML_LEN = 4096; +/*#define QEMUD_MAX_IFNAME_LEN IF_NAMESIZE */ +const QEMUD_MAX_IFNAME_LEN = 50; + +const QEMUD_MAX_NUM_DOMAINS = 100; +const QEMUD_MAX_NUM_NETWORKS = 100; + +/* + * Damn, we can't do multiplcation when declaring + * constants with XDR ! + * These two should be QEMUD_MAX_NUM_DOMAIN * QEMUD_MAX_NAME_LEN + */ +const QEMUD_MAX_DOMAINS_NAME_BUF = 5000; +const QEMUD_MAX_NETWORKS_NAME_BUF = 5000; + +const QEMUD_MAX_ERROR_LEN = 1024; + +/* Possible guest VM states */ +enum qemud_domain_runstate { + QEMUD_STATE_RUNNING = 1, + QEMUD_STATE_PAUSED, + QEMUD_STATE_STOPPED +}; + +/* Message sent by a client */ +enum qemud_packet_client_data_type { + QEMUD_CLIENT_PKT_GET_VERSION, + QEMUD_CLIENT_PKT_GET_NODEINFO, + QEMUD_CLIENT_PKT_LIST_DOMAINS, + QEMUD_CLIENT_PKT_NUM_DOMAINS, + QEMUD_CLIENT_PKT_DOMAIN_CREATE, + QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_ID, + QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_UUID, + QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_NAME, + QEMUD_CLIENT_PKT_DOMAIN_SUSPEND, + QEMUD_CLIENT_PKT_DOMAIN_RESUME, + QEMUD_CLIENT_PKT_DOMAIN_DESTROY, + QEMUD_CLIENT_PKT_DOMAIN_GET_INFO, + QEMUD_CLIENT_PKT_DOMAIN_SAVE, + QEMUD_CLIENT_PKT_DOMAIN_RESTORE, + QEMUD_CLIENT_PKT_DUMP_XML, + QEMUD_CLIENT_PKT_LIST_DEFINED_DOMAINS, + QEMUD_CLIENT_PKT_NUM_DEFINED_DOMAINS, + QEMUD_CLIENT_PKT_DOMAIN_START, + QEMUD_CLIENT_PKT_DOMAIN_DEFINE, + QEMUD_CLIENT_PKT_DOMAIN_UNDEFINE, + QEMUD_CLIENT_PKT_NUM_NETWORKS, + QEMUD_CLIENT_PKT_LIST_NETWORKS, + QEMUD_CLIENT_PKT_NUM_DEFINED_NETWORKS, + QEMUD_CLIENT_PKT_LIST_DEFINED_NETWORKS, + QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_UUID, + QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_NAME, + QEMUD_CLIENT_PKT_NETWORK_CREATE, + QEMUD_CLIENT_PKT_NETWORK_DEFINE, + QEMUD_CLIENT_PKT_NETWORK_UNDEFINE, + QEMUD_CLIENT_PKT_NETWORK_START, + QEMUD_CLIENT_PKT_NETWORK_DESTROY, + QEMUD_CLIENT_PKT_NETWORK_DUMP_XML, + QEMUD_CLIENT_PKT_NETWORK_GET_BRIDGE_NAME, + QEMUD_CLIENT_PKT_DOMAIN_GET_AUTOSTART, + QEMUD_CLIENT_PKT_DOMAIN_SET_AUTOSTART, + QEMUD_CLIENT_PKT_NETWORK_GET_AUTOSTART, + QEMUD_CLIENT_PKT_NETWORK_SET_AUTOSTART, + QEMUD_CLIENT_PKT_GET_CAPABILITIES, + + QEMUD_CLIENT_PKT_MAX +}; + +/* Messages sent by a server */ +enum qemud_packet_server_data_type { + QEMUD_SERVER_PKT_FAILURE = 0, + QEMUD_SERVER_PKT_GET_VERSION, + QEMUD_SERVER_PKT_GET_NODEINFO, + QEMUD_SERVER_PKT_LIST_DOMAINS, + QEMUD_SERVER_PKT_NUM_DOMAINS, + QEMUD_SERVER_PKT_DOMAIN_CREATE, + QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_ID, + QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_UUID, + QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_NAME, + QEMUD_SERVER_PKT_DOMAIN_SUSPEND, + QEMUD_SERVER_PKT_DOMAIN_RESUME, + QEMUD_SERVER_PKT_DOMAIN_DESTROY, + QEMUD_SERVER_PKT_DOMAIN_GET_INFO, + QEMUD_SERVER_PKT_DOMAIN_SAVE, + QEMUD_SERVER_PKT_DOMAIN_RESTORE, + QEMUD_SERVER_PKT_DUMP_XML, + QEMUD_SERVER_PKT_LIST_DEFINED_DOMAINS, + QEMUD_SERVER_PKT_NUM_DEFINED_DOMAINS, + QEMUD_SERVER_PKT_DOMAIN_START, + QEMUD_SERVER_PKT_DOMAIN_DEFINE, + QEMUD_SERVER_PKT_DOMAIN_UNDEFINE, + QEMUD_SERVER_PKT_NUM_NETWORKS, + QEMUD_SERVER_PKT_LIST_NETWORKS, + QEMUD_SERVER_PKT_NUM_DEFINED_NETWORKS, + QEMUD_SERVER_PKT_LIST_DEFINED_NETWORKS, + QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_UUID, + QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_NAME, + QEMUD_SERVER_PKT_NETWORK_CREATE, + QEMUD_SERVER_PKT_NETWORK_DEFINE, + QEMUD_SERVER_PKT_NETWORK_UNDEFINE, + QEMUD_SERVER_PKT_NETWORK_START, + QEMUD_SERVER_PKT_NETWORK_DESTROY, + QEMUD_SERVER_PKT_NETWORK_DUMP_XML, + QEMUD_SERVER_PKT_NETWORK_GET_BRIDGE_NAME, + QEMUD_SERVER_PKT_DOMAIN_GET_AUTOSTART, + QEMUD_SERVER_PKT_DOMAIN_SET_AUTOSTART, + QEMUD_SERVER_PKT_NETWORK_GET_AUTOSTART, + QEMUD_SERVER_PKT_NETWORK_SET_AUTOSTART, + QEMUD_SERVER_PKT_GET_CAPABILITIES, + + QEMUD_SERVER_PKT_MAX +}; + + + +struct qemud_packet_failure_reply { + uint32_t code; + char message[QEMUD_MAX_ERROR_LEN]; +}; + +struct qemud_packet_get_version_reply { + uint32_t versionNum; +}; + +struct qemud_packet_get_node_info_reply { + char model[32]; + uint32_t memory; + uint32_t cpus; + uint32_t mhz; + uint32_t nodes; + uint32_t sockets; + uint32_t cores; + uint32_t threads; +}; + +struct qemud_packet_get_capabilities_reply { + char xml[QEMUD_MAX_XML_LEN]; +}; + +struct qemud_packet_list_domains_reply { + int32_t numDomains; + int32_t domains[QEMUD_MAX_NUM_DOMAINS]; +}; + +struct qemud_packet_num_domains_reply{ + int32_t numDomains; +}; + +struct qemud_packet_domain_create_request { + char xml[QEMUD_MAX_XML_LEN]; +}; +struct qemud_packet_domain_create_reply { + int32_t id; + unsigned char uuid[QEMUD_UUID_RAW_LEN]; + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_domain_lookup_by_id_request { + int32_t id; +}; + +struct qemud_packet_domain_lookup_by_id_reply { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; + char name[QEMUD_MAX_NAME_LEN]; +}; + +struct qemud_packet_domain_lookup_by_name_request { + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_domain_lookup_by_name_reply { + int32_t id; + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_domain_lookup_by_uuid_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; + +struct qemud_packet_domain_lookup_by_uuid_reply { + int32_t id; + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_domain_suspend_request { + int32_t id; +}; +struct qemud_packet_domain_resume_request { + int32_t id; +}; +struct qemud_packet_domain_destroy_request { + int32_t id; +}; +struct qemud_packet_domain_get_info_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_domain_get_info_reply { + uint64_t cpuTime; + uint32_t runstate; + uint32_t memory; + uint32_t maxmem; + uint32_t nrVirtCpu; +}; +struct qemud_packet_domain_save_request { + int32_t id; + char file[PATH_MAX]; +}; +struct qemud_packet_domain_restore_request { + char file[PATH_MAX]; +}; +struct qemud_packet_domain_restore_reply { + int32_t id; +}; +struct qemud_packet_domain_dump_xml_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_domain_dump_xml_reply { + char xml[QEMUD_MAX_XML_LEN]; +}; +struct qemud_packet_list_defined_domains_reply{ + uint32_t numDomains; + char domains[QEMUD_MAX_DOMAINS_NAME_BUF]; +}; +struct qemud_packet_num_defined_domains_reply{ + uint32_t numDomains; +}; +struct qemud_packet_domain_start_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_domain_start_reply { + int32_t id; +}; +struct qemud_packet_domain_define_request { + char xml[QEMUD_MAX_XML_LEN]; +}; +struct qemud_packet_domain_define_reply { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_domain_undefine_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_num_networks_reply { + uint32_t numNetworks; +}; + +struct qemud_packet_list_networks_reply { + uint32_t numNetworks; + char networks[QEMUD_MAX_NETWORKS_NAME_BUF]; +}; + +struct qemud_packet_num_defined_networks_reply { + uint32_t numNetworks; +}; + +struct qemud_packet_list_defined_networks_reply { + uint32_t numNetworks; + char networks[QEMUD_MAX_NETWORKS_NAME_BUF]; +}; +struct qemud_packet_network_lookup_by_name_request { + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_network_lookup_by_name_reply { + int32_t id; + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_lookup_by_uuid_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_lookup_by_uuid_reply { + int32_t id; + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_network_create_request { + char xml[QEMUD_MAX_XML_LEN]; +}; +struct qemud_packet_network_create_reply { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_network_define_request { + char xml[QEMUD_MAX_XML_LEN]; +}; +struct qemud_packet_network_define_reply { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; + char name[QEMUD_MAX_NAME_LEN]; +}; +struct qemud_packet_network_undefine_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_start_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_destroy_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_dump_xml_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_dump_xml_reply { + char xml[QEMUD_MAX_XML_LEN]; +}; +struct qemud_packet_network_get_bridge_name_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_get_bridge_name_reply { + char ifname[QEMUD_MAX_IFNAME_LEN]; +}; +struct qemud_packet_domain_get_autostart_request{ + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_domain_get_autostart_reply { + uint32_t autostart; +}; +struct qemud_packet_domain_set_autostart_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; + uint32_t autostart; +}; + +struct qemud_packet_network_get_autostart_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; +}; +struct qemud_packet_network_get_autostart_reply { + uint32_t autostart; +}; +struct qemud_packet_network_set_autostart_request { + unsigned char uuid[QEMUD_UUID_RAW_LEN]; + uint32_t autostart; +}; + +union qemud_packet_client_data switch (qemud_packet_client_data_type type) { + case QEMUD_CLIENT_PKT_GET_VERSION: + void; + + case QEMUD_CLIENT_PKT_GET_NODEINFO: + void; + + case QEMUD_CLIENT_PKT_LIST_DOMAINS: + void; + + case QEMUD_CLIENT_PKT_NUM_DOMAINS: + void; + + case QEMUD_CLIENT_PKT_DOMAIN_CREATE: + qemud_packet_domain_create_request domainCreateRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_ID: + qemud_packet_domain_lookup_by_id_request domainLookupByIDRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_UUID: + qemud_packet_domain_lookup_by_uuid_request domainLookupByUUIDRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_NAME: + qemud_packet_domain_lookup_by_name_request domainLookupByNameRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_SUSPEND: + qemud_packet_domain_suspend_request domainSuspendRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_RESUME: + qemud_packet_domain_resume_request domainResumeRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_DESTROY: + qemud_packet_domain_destroy_request domainDestroyRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_GET_INFO: + qemud_packet_domain_get_info_request domainGetInfoRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_SAVE: + qemud_packet_domain_save_request domainSaveRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_RESTORE: + qemud_packet_domain_restore_request domainRestoreRequest; + + case QEMUD_CLIENT_PKT_DUMP_XML: + qemud_packet_domain_dump_xml_request domainDumpXMLRequest; + + case QEMUD_CLIENT_PKT_LIST_DEFINED_DOMAINS: + void; + + case QEMUD_CLIENT_PKT_NUM_DEFINED_DOMAINS: + void; + + case QEMUD_CLIENT_PKT_DOMAIN_START: + qemud_packet_domain_start_request domainStartRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_DEFINE: + qemud_packet_domain_define_request domainDefineRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_UNDEFINE: + qemud_packet_domain_undefine_request domainUndefineRequest; + + case QEMUD_CLIENT_PKT_NUM_NETWORKS: + void; + + case QEMUD_CLIENT_PKT_LIST_NETWORKS: + void; + + case QEMUD_CLIENT_PKT_NUM_DEFINED_NETWORKS: + void; + + case QEMUD_CLIENT_PKT_LIST_DEFINED_NETWORKS: + void; + + case QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_UUID: + qemud_packet_network_lookup_by_uuid_request networkLookupByUUIDRequest; + + case QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_NAME: + qemud_packet_network_lookup_by_name_request networkLookupByNameRequest; + + case QEMUD_CLIENT_PKT_NETWORK_CREATE: + qemud_packet_network_create_request networkCreateRequest; + + case QEMUD_CLIENT_PKT_NETWORK_DEFINE: + qemud_packet_network_define_request networkDefineRequest; + + case QEMUD_CLIENT_PKT_NETWORK_UNDEFINE: + qemud_packet_network_undefine_request networkUndefineRequest; + + case QEMUD_CLIENT_PKT_NETWORK_START: + qemud_packet_network_start_request networkStartRequest; + + case QEMUD_CLIENT_PKT_NETWORK_DESTROY: + qemud_packet_network_destroy_request networkDestroyRequest; + + case QEMUD_CLIENT_PKT_NETWORK_DUMP_XML: + qemud_packet_network_dump_xml_request networkDumpXMLRequest; + + case QEMUD_CLIENT_PKT_NETWORK_GET_BRIDGE_NAME: + qemud_packet_network_get_bridge_name_request networkGetBridgeNameRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_GET_AUTOSTART: + qemud_packet_domain_get_autostart_request domainGetAutostartRequest; + + case QEMUD_CLIENT_PKT_DOMAIN_SET_AUTOSTART: + qemud_packet_domain_set_autostart_request domainSetAutostartRequest; + + case QEMUD_CLIENT_PKT_NETWORK_GET_AUTOSTART: + qemud_packet_network_get_autostart_request networkGetAutostartRequest; + + case QEMUD_CLIENT_PKT_NETWORK_SET_AUTOSTART: + qemud_packet_network_set_autostart_request networkSetAutostartRequest; + + case QEMUD_CLIENT_PKT_GET_CAPABILITIES: + void; + +}; + +union qemud_packet_server_data switch (qemud_packet_server_data_type type) { + case QEMUD_SERVER_PKT_FAILURE: + qemud_packet_failure_reply failureReply; + + case QEMUD_SERVER_PKT_GET_VERSION: + qemud_packet_get_version_reply getVersionReply; + + case QEMUD_SERVER_PKT_GET_NODEINFO: + qemud_packet_get_node_info_reply getNodeInfoReply; + + case QEMUD_SERVER_PKT_LIST_DOMAINS: + qemud_packet_list_domains_reply listDomainsReply; + + case QEMUD_SERVER_PKT_NUM_DOMAINS: + qemud_packet_num_domains_reply numDomainsReply; + + case QEMUD_SERVER_PKT_DOMAIN_CREATE: + qemud_packet_domain_create_reply domainCreateReply; + + case QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_ID: + qemud_packet_domain_lookup_by_id_reply domainLookupByIDReply; + + case QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_UUID: + qemud_packet_domain_lookup_by_uuid_reply domainLookupByUUIDReply; + + case QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_NAME: + qemud_packet_domain_lookup_by_name_reply domainLookupByNameReply; + + case QEMUD_SERVER_PKT_DOMAIN_SUSPEND: + void; + + case QEMUD_SERVER_PKT_DOMAIN_RESUME: + void; + + case QEMUD_SERVER_PKT_DOMAIN_DESTROY: + void; + + case QEMUD_SERVER_PKT_DOMAIN_GET_INFO: + qemud_packet_domain_get_info_reply domainGetInfoReply; + + case QEMUD_SERVER_PKT_DOMAIN_SAVE: + void; + + case QEMUD_SERVER_PKT_DOMAIN_RESTORE: + qemud_packet_domain_restore_reply domainRestoreReply; + + case QEMUD_SERVER_PKT_DUMP_XML: + qemud_packet_domain_dump_xml_reply domainDumpXMLReply; + + case QEMUD_SERVER_PKT_LIST_DEFINED_DOMAINS: + qemud_packet_list_defined_domains_reply listDefinedDomainsReply; + + case QEMUD_SERVER_PKT_NUM_DEFINED_DOMAINS: + qemud_packet_num_defined_domains_reply numDefinedDomainsReply; + + case QEMUD_SERVER_PKT_DOMAIN_START: + qemud_packet_domain_start_reply domainStartReply; + + case QEMUD_SERVER_PKT_DOMAIN_DEFINE: + qemud_packet_domain_define_reply domainDefineReply; + + case QEMUD_SERVER_PKT_DOMAIN_UNDEFINE: + void; + + case QEMUD_SERVER_PKT_NUM_NETWORKS: + qemud_packet_num_networks_reply numNetworksReply; + + case QEMUD_SERVER_PKT_LIST_NETWORKS: + qemud_packet_list_networks_reply listNetworksReply; + + case QEMUD_SERVER_PKT_NUM_DEFINED_NETWORKS: + qemud_packet_num_defined_networks_reply numDefinedNetworksReply; + + case QEMUD_SERVER_PKT_LIST_DEFINED_NETWORKS: + qemud_packet_list_defined_networks_reply listDefinedNetworksReply; + + case QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_UUID: + qemud_packet_network_lookup_by_uuid_reply networkLookupByUUIDReply; + + case QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_NAME: + qemud_packet_network_lookup_by_name_reply networkLookupByNameReply; + + case QEMUD_SERVER_PKT_NETWORK_CREATE: + qemud_packet_network_create_reply networkCreateReply; + + case QEMUD_SERVER_PKT_NETWORK_DEFINE: + qemud_packet_network_define_reply networkDefineReply; + + case QEMUD_SERVER_PKT_NETWORK_UNDEFINE: + void; + + case QEMUD_SERVER_PKT_NETWORK_START: + void; + + case QEMUD_SERVER_PKT_NETWORK_DESTROY: + void; + + case QEMUD_SERVER_PKT_NETWORK_DUMP_XML: + qemud_packet_network_dump_xml_reply networkDumpXMLReply; + + case QEMUD_SERVER_PKT_NETWORK_GET_BRIDGE_NAME: + qemud_packet_network_get_bridge_name_reply networkGetBridgeNameReply; + + case QEMUD_SERVER_PKT_DOMAIN_GET_AUTOSTART: + qemud_packet_domain_get_autostart_reply domainGetAutostartReply; + + case QEMUD_SERVER_PKT_DOMAIN_SET_AUTOSTART: + void; + + case QEMUD_SERVER_PKT_NETWORK_GET_AUTOSTART: + qemud_packet_network_get_autostart_reply networkGetAutostartReply; + + case QEMUD_SERVER_PKT_NETWORK_SET_AUTOSTART: + void; + + case QEMUD_SERVER_PKT_GET_CAPABILITIES: + qemud_packet_get_capabilities_reply getCapabilitiesReply; +}; + +struct qemud_packet_client { + uint32_t serial; + struct qemud_packet_client_data data; +}; + +struct qemud_packet_server { + uint32_t serial; + uint32_t inReplyTo; + struct qemud_packet_server_data data; +}; + +const QEMUD_PKT_HEADER_MAGIC = 0xdeadbeaf; +const QEMUD_PKT_HEADER_XDR_LEN = 8; +const QEMUD_PKT_PAYLOAD_XDR_LEN = 30000; +const QEMUD_PKT_PACKET_XDR_LEN = 30008; + +struct qemud_packet_header { + uint32_t magic; + uint32_t length; +}; +