diff -r c6fe9aa77e5b libvirt.spec.in --- a/libvirt.spec.in Thu Jun 21 21:21:11 2007 -0400 +++ b/libvirt.spec.in Thu Jun 21 21:21:14 2007 -0400 @@ -124,10 +124,7 @@ fi %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/ %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/autostart %{_sysconfdir}/rc.d/init.d/libvirtd -%dir %{_sysconfdir}/libvirt -%dir %{_sysconfdir}/libvirt/qemu -%dir %{_sysconfdir}/libvirt/qemu/networks -%dir %{_sysconfdir}/libvirt/qemu/networks/autostart +%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd %dir %{_datadir}/libvirt/ %dir %{_datadir}/libvirt/networks/ %{_datadir}/libvirt/networks/default.xml diff -r c6fe9aa77e5b qemud/Makefile.am --- a/qemud/Makefile.am Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/Makefile.am Thu Jun 21 21:21:14 2007 -0400 @@ -7,17 +7,9 @@ sbin_PROGRAMS = libvirtd libvirtd_SOURCES = \ qemud.c internal.h \ - driver.c driver.h \ - dispatch.c dispatch.h \ - conf.c conf.h \ - bridge.c bridge.h \ - iptables.c iptables.h \ - uuid.c uuid.h \ - ../src/buf.c \ protocol.h protocol.c \ remote_protocol.h remote_protocol.c \ remote.c \ - ../src/virterror.c \ event.c event.h #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L libvirtd_CFLAGS = \ @@ -52,14 +44,19 @@ uninstall-local: uninstall-init # Distribute the generated files so that rpcgen isn't required on the # target machine (although almost any Unix machine will have it). -EXTRA_DIST = libvirtd.init.in default-network.xml \ +EXTRA_DIST = libvirtd.init.in libvirtd.sysconfig default-network.xml \ protocol.x remote_protocol.x \ protocol.c protocol.h \ remote_protocol.c remote_protocol.h \ remote_generate_stubs.pl rpcgen_fix.pl \ remote_dispatch_prototypes.h \ remote_dispatch_localvars.h \ - remote_dispatch_proc_switch.h + remote_dispatch_proc_switch.h \ + driver.c driver.h \ + conf.c conf.h \ + iptables.c iptables.h \ + bridge.c bridge.h \ + uuid.c uuid.h .x.c: rm -f $@ @@ -91,6 +88,8 @@ install-init: libvirtd.init install-init: libvirtd.init mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d $(INSTALL_SCRIPT) $(srcdir)/libvirtd.init $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd + mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig + $(INSTALL_SCRIPT) $(srcdir)/libvirtd.sysconfig $(DESTDIR)$(sysconfdir)/sysconfig/libvirtd uninstall-init: rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd diff -r c6fe9aa77e5b qemud/conf.c --- a/qemud/conf.c Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/conf.c Thu Jun 21 21:21:14 2007 -0400 @@ -42,7 +42,6 @@ #include -#include "internal.h" #include "conf.h" #include "uuid.h" #include "../src/buf.h" @@ -61,7 +60,6 @@ void qemudReportError(virConnectPtr conn } else { errorMessage[0] = '\0'; } - __virRaiseError(conn, dom, net, VIR_FROM_QEMU, code, VIR_ERR_ERROR, NULL, NULL, NULL, -1, -1, errorMessage); } diff -r c6fe9aa77e5b qemud/conf.h --- a/qemud/conf.h Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/conf.h Thu Jun 21 21:21:14 2007 -0400 @@ -25,6 +25,11 @@ #define __QEMUD_CONF_H #include "../src/internal.h" +#include "bridge.h" +#include "iptables.h" +#include + +#define qemudDebug(fmt, ...) do {} while(0) /* Different types of QEMU acceleration possible */ enum qemud_vm_virt_type { @@ -32,7 +37,6 @@ enum qemud_vm_virt_type { QEMUD_VIRT_KQEMU, QEMUD_VIRT_KVM, }; - /* Two types of disk backends */ enum qemud_vm_disk_type { @@ -73,6 +77,11 @@ enum qemud_vm_net_type { QEMUD_NET_NETWORK, QEMUD_NET_BRIDGE, }; + +#define QEMUD_UUID_RAW_LEN 16 +#define QEMUD_MAX_NAME_LEN 50 +#define QEMUD_MAX_XML_LEN 4096 +#define QEMUD_MAX_ERROR_LEN 1024 /* Stores the virtual network interface configuration */ struct qemud_vm_net_def { diff -r c6fe9aa77e5b qemud/driver.c --- a/qemud/driver.c Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/driver.c Thu Jun 21 21:21:14 2007 -0400 @@ -79,10 +79,6 @@ static int qemudSetNonBlock(int fd) { __virLogMessage(VIR_LOG_ERROR, "Failed to set non-blocking file descriptor flag"); return -1; } - - -#define virEventAddHandle(fd, events, cb, opaque) virEventAddHandleImpl(fd, events, cb, opaque) -#define virEventRemoveHandle(fd) virEventRemoveHandleImpl(fd) static void qemudDispatchVMEvent(int fd, int events, void *opaque); @@ -1708,7 +1704,7 @@ static int qemudGetProcessInfo(unsigned } -virDomainPtr qemudDomainLookupByID(virConnectPtr conn ATTRIBUTE_UNUSED, +virDomainPtr qemudDomainLookupByID(virConnectPtr conn, int id) { struct qemud_driver *driver = (struct qemud_driver *)conn->privateData; struct qemud_vm *vm = qemudFindVMByID(driver, id); @@ -1719,19 +1715,16 @@ virDomainPtr qemudDomainLookupByID(virCo return NULL; } - dom = calloc(1, sizeof(struct _virDomain)); + dom = virGetDomain(conn, vm->def->name, vm->def->uuid); if (!dom) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr"); return NULL; } - dom->conn = conn; dom->id = vm->id; - dom->name = vm->def->name; - memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid)); return dom; } -virDomainPtr qemudDomainLookupByUUID(virConnectPtr conn ATTRIBUTE_UNUSED, +virDomainPtr qemudDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) { struct qemud_driver *driver = (struct qemud_driver *)conn->privateData; struct qemud_vm *vm = qemudFindVMByUUID(driver, uuid); @@ -1742,19 +1735,16 @@ virDomainPtr qemudDomainLookupByUUID(vir return NULL; } - dom = calloc(1, sizeof(struct _virDomain)); + dom = virGetDomain(conn, vm->def->name, vm->def->uuid); if (!dom) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr"); return NULL; } - dom->conn = conn; dom->id = vm->id; - dom->name = vm->def->name; - memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid)); return dom; } -virDomainPtr qemudDomainLookupByName(virConnectPtr conn ATTRIBUTE_UNUSED, +virDomainPtr qemudDomainLookupByName(virConnectPtr conn, const char *name) { struct qemud_driver *driver = (struct qemud_driver *)conn->privateData; struct qemud_vm *vm = qemudFindVMByName(driver, name); @@ -1765,16 +1755,13 @@ virDomainPtr qemudDomainLookupByName(vir return NULL; } - dom = calloc(1, sizeof(struct _virDomain)); + dom = virGetDomain(conn, vm->def->name, vm->def->uuid); if (!dom) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr"); return NULL; } - dom->conn = conn; dom->id = vm->id; - dom->name = vm->def->name; - memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid)); return dom; } @@ -1824,17 +1811,13 @@ virDomainPtr qemudDomainCreate(virConnec return NULL; } - dom = calloc(1, sizeof(struct _virDomain)); + dom = virGetDomain(conn, vm->def->name, vm->def->uuid); if (!dom) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr"); return NULL; } - dom->conn = conn; dom->id = vm->id; - dom->name = vm->def->name; - memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid)); - return dom; } @@ -2053,16 +2036,13 @@ virDomainPtr qemudDomainDefine(virConnec return NULL; } - dom = calloc(1, sizeof(struct _virDomain)); + dom = virGetDomain(conn, vm->def->name, vm->def->uuid); if (!dom) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr"); return NULL; } - dom->conn = conn; dom->id = vm->id; - dom->name = vm->def->name; - memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid)); return dom; } @@ -2166,15 +2146,11 @@ virNetworkPtr qemudNetworkLookupByUUID(v return NULL; } - net = calloc(1, sizeof(struct _virNetwork)); + net = virGetNetwork(conn, network->def->name, network->def->uuid); if (!net) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr"); return NULL; } - - net->conn = conn; - net->name = network->def->name; - memcpy(net->uuid, network->def->uuid, sizeof(net->uuid)); return net; } virNetworkPtr qemudNetworkLookupByName(virConnectPtr conn ATTRIBUTE_UNUSED, @@ -2188,15 +2164,11 @@ virNetworkPtr qemudNetworkLookupByName(v return NULL; } - net = calloc(1, sizeof(struct _virNetwork)); + net = virGetNetwork(conn, network->def->name, network->def->uuid); if (!net) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr"); return NULL; } - - net->conn = conn; - net->name = network->def->name; - memcpy(net->uuid, network->def->uuid, sizeof(net->uuid)); return net; } @@ -2288,16 +2260,11 @@ virNetworkPtr qemudNetworkCreate(virConn return NULL; } - net = calloc(1, sizeof(struct _virNetwork)); + net = virGetNetwork(conn, network->def->name, network->def->uuid); if (!net) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr"); return NULL; } - - net->conn = conn; - net->name = network->def->name; - memcpy(net->uuid, network->def->uuid, sizeof(net->uuid)); - return net; } @@ -2320,16 +2287,11 @@ virNetworkPtr qemudNetworkDefine(virConn return NULL; } - net = calloc(1, sizeof(struct _virNetwork)); + net = virGetNetwork(conn, network->def->name, network->def->uuid); if (!net) { qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr"); return NULL; } - - net->conn = conn; - net->name = network->def->name; - memcpy(net->uuid, network->def->uuid, sizeof(net->uuid)); - return net; } @@ -2549,6 +2511,13 @@ static virStateDriver qemuStateDriver = qemudActive, }; +int qemudRegister(void) { + virRegisterDriver(&qemuDriver); + virRegisterNetworkDriver(&qemuNetworkDriver); + virRegisterStateDriver(&qemuStateDriver); + return 0; +} + /* * Local variables: * indent-tabs-mode: nil diff -r c6fe9aa77e5b qemud/driver.h --- a/qemud/driver.h Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/driver.h Thu Jun 21 21:21:14 2007 -0400 @@ -25,14 +25,13 @@ #ifndef QEMUD_DRIVER_H #define QEMUD_DRIVER_H -#include "internal.h" #include "../src/internal.h" int qemudStartup(void); int qemudReload(void); int qemudShutdown(void); int qemudActive(void); - +int qemudRegister(void); virDrvOpenStatus qemudOpen(virConnectPtr conn, const char *name, diff -r c6fe9aa77e5b qemud/internal.h --- a/qemud/internal.h Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/internal.h Thu Jun 21 21:21:14 2007 -0400 @@ -25,8 +25,6 @@ #ifndef QEMUD_INTERNAL_H__ #define QEMUD_INTERNAL_H__ -#include -#include #include #include diff -r c6fe9aa77e5b qemud/libvirtd.init.in --- a/qemud/libvirtd.init.in Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/libvirtd.init.in Thu Jun 21 21:21:14 2007 -0400 @@ -20,12 +20,22 @@ SERVICE=libvirtd SERVICE=libvirtd PROCESS=libvirtd +LIBVIRTD_CONFIG= +LIBVIRTD_ARGS= + +test -f @sysconfdir@/sysconfig/libvirtd && . @sysconfdir@/sysconfig/libvirtd + +LIBVIRTD_CONFIG_ARGS= +if [ -n "$LIBVIRTD_CONFIG" ] +then + LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG" +fi RETVAL=0 start() { echo -n $"Starting $SERVICE daemon: " - daemon --check $SERVICE $PROCESS --system --daemon + daemon --check $SERVICE $PROCESS --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$SERVICE diff -r c6fe9aa77e5b qemud/libvirtd.sysconf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qemud/libvirtd.sysconf Thu Jun 21 21:21:14 2007 -0400 @@ -0,0 +1,6 @@ +# Override the default config file +#LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf + +# Listen for TCP/IP connections +# NB. must setup TLS/SSL keys prior to using this +#LIBVIRTD_ARGS="--listen" diff -r c6fe9aa77e5b qemud/protocol.c --- a/qemud/protocol.c Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/protocol.c Thu Jun 21 21:21:14 2007 -0400 @@ -4,958 +4,6 @@ */ #include "protocol.h" - -bool_t -xdr_qemud_domain_runstate (XDR *xdrs, qemud_domain_runstate *objp) -{ - - if (!xdr_enum (xdrs, (enum_t *) objp)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_client_data_type (XDR *xdrs, qemud_packet_client_data_type *objp) -{ - - if (!xdr_enum (xdrs, (enum_t *) objp)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_server_data_type (XDR *xdrs, qemud_packet_server_data_type *objp) -{ - - if (!xdr_enum (xdrs, (enum_t *) objp)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_failure_reply (XDR *xdrs, qemud_packet_failure_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->code)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->message, QEMUD_MAX_ERROR_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_get_version_reply (XDR *xdrs, qemud_packet_get_version_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->versionNum)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_get_node_info_reply (XDR *xdrs, qemud_packet_get_node_info_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->model, 32, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->memory)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->cpus)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->mhz)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->nodes)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->sockets)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->cores)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->threads)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_get_capabilities_reply (XDR *xdrs, qemud_packet_get_capabilities_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->xml, QEMUD_MAX_XML_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_list_domains_reply (XDR *xdrs, qemud_packet_list_domains_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->numDomains)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->domains, QEMUD_MAX_NUM_DOMAINS, - sizeof (int32_t), (xdrproc_t) xdr_int32_t)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_num_domains_reply (XDR *xdrs, qemud_packet_num_domains_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->numDomains)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_create_request (XDR *xdrs, qemud_packet_domain_create_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->xml, QEMUD_MAX_XML_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_create_reply (XDR *xdrs, qemud_packet_domain_create_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_lookup_by_id_request (XDR *xdrs, qemud_packet_domain_lookup_by_id_request *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_lookup_by_id_reply (XDR *xdrs, qemud_packet_domain_lookup_by_id_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_lookup_by_name_request (XDR *xdrs, qemud_packet_domain_lookup_by_name_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_lookup_by_name_reply (XDR *xdrs, qemud_packet_domain_lookup_by_name_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_lookup_by_uuid_request (XDR *xdrs, qemud_packet_domain_lookup_by_uuid_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_lookup_by_uuid_reply (XDR *xdrs, qemud_packet_domain_lookup_by_uuid_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_suspend_request (XDR *xdrs, qemud_packet_domain_suspend_request *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_resume_request (XDR *xdrs, qemud_packet_domain_resume_request *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_destroy_request (XDR *xdrs, qemud_packet_domain_destroy_request *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_get_info_request (XDR *xdrs, qemud_packet_domain_get_info_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_get_info_reply (XDR *xdrs, qemud_packet_domain_get_info_reply *objp) -{ - - if (!xdr_uint64_t (xdrs, &objp->cpuTime)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->runstate)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->memory)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->maxmem)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->nrVirtCpu)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_save_request (XDR *xdrs, qemud_packet_domain_save_request *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->file, PATH_MAX, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_restore_request (XDR *xdrs, qemud_packet_domain_restore_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->file, PATH_MAX, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_restore_reply (XDR *xdrs, qemud_packet_domain_restore_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_dump_xml_request (XDR *xdrs, qemud_packet_domain_dump_xml_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_dump_xml_reply (XDR *xdrs, qemud_packet_domain_dump_xml_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->xml, QEMUD_MAX_XML_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_list_defined_domains_reply (XDR *xdrs, qemud_packet_list_defined_domains_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->numDomains)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->domains, QEMUD_MAX_DOMAINS_NAME_BUF, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_num_defined_domains_reply (XDR *xdrs, qemud_packet_num_defined_domains_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->numDomains)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_start_request (XDR *xdrs, qemud_packet_domain_start_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_start_reply (XDR *xdrs, qemud_packet_domain_start_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_define_request (XDR *xdrs, qemud_packet_domain_define_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->xml, QEMUD_MAX_XML_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_define_reply (XDR *xdrs, qemud_packet_domain_define_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_undefine_request (XDR *xdrs, qemud_packet_domain_undefine_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_num_networks_reply (XDR *xdrs, qemud_packet_num_networks_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->numNetworks)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_list_networks_reply (XDR *xdrs, qemud_packet_list_networks_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->numNetworks)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->networks, QEMUD_MAX_NETWORKS_NAME_BUF, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_num_defined_networks_reply (XDR *xdrs, qemud_packet_num_defined_networks_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->numNetworks)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_list_defined_networks_reply (XDR *xdrs, qemud_packet_list_defined_networks_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->numNetworks)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->networks, QEMUD_MAX_NETWORKS_NAME_BUF, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_lookup_by_name_request (XDR *xdrs, qemud_packet_network_lookup_by_name_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_lookup_by_name_reply (XDR *xdrs, qemud_packet_network_lookup_by_name_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_lookup_by_uuid_request (XDR *xdrs, qemud_packet_network_lookup_by_uuid_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_lookup_by_uuid_reply (XDR *xdrs, qemud_packet_network_lookup_by_uuid_reply *objp) -{ - - if (!xdr_int32_t (xdrs, &objp->id)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_create_request (XDR *xdrs, qemud_packet_network_create_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->xml, QEMUD_MAX_XML_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_create_reply (XDR *xdrs, qemud_packet_network_create_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_define_request (XDR *xdrs, qemud_packet_network_define_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->xml, QEMUD_MAX_XML_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_define_reply (XDR *xdrs, qemud_packet_network_define_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - if (!xdr_vector (xdrs, (char *)objp->name, QEMUD_MAX_NAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_undefine_request (XDR *xdrs, qemud_packet_network_undefine_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_start_request (XDR *xdrs, qemud_packet_network_start_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_destroy_request (XDR *xdrs, qemud_packet_network_destroy_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_dump_xml_request (XDR *xdrs, qemud_packet_network_dump_xml_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_dump_xml_reply (XDR *xdrs, qemud_packet_network_dump_xml_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->xml, QEMUD_MAX_XML_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_get_bridge_name_request (XDR *xdrs, qemud_packet_network_get_bridge_name_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_get_bridge_name_reply (XDR *xdrs, qemud_packet_network_get_bridge_name_reply *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->ifname, QEMUD_MAX_IFNAME_LEN, - sizeof (char), (xdrproc_t) xdr_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_get_autostart_request (XDR *xdrs, qemud_packet_domain_get_autostart_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_get_autostart_reply (XDR *xdrs, qemud_packet_domain_get_autostart_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->autostart)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_domain_set_autostart_request (XDR *xdrs, qemud_packet_domain_set_autostart_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->autostart)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_get_autostart_request (XDR *xdrs, qemud_packet_network_get_autostart_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_get_autostart_reply (XDR *xdrs, qemud_packet_network_get_autostart_reply *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->autostart)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_network_set_autostart_request (XDR *xdrs, qemud_packet_network_set_autostart_request *objp) -{ - - if (!xdr_vector (xdrs, (char *)objp->uuid, QEMUD_UUID_RAW_LEN, - sizeof (u_char), (xdrproc_t) xdr_u_char)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->autostart)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_client_data (XDR *xdrs, qemud_packet_client_data *objp) -{ - - if (!xdr_qemud_packet_client_data_type (xdrs, &objp->type)) - return FALSE; - switch (objp->type) { - case QEMUD_CLIENT_PKT_GET_VERSION: - break; - case QEMUD_CLIENT_PKT_GET_NODEINFO: - break; - case QEMUD_CLIENT_PKT_LIST_DOMAINS: - break; - case QEMUD_CLIENT_PKT_NUM_DOMAINS: - break; - case QEMUD_CLIENT_PKT_DOMAIN_CREATE: - if (!xdr_qemud_packet_domain_create_request (xdrs, &objp->qemud_packet_client_data_u.domainCreateRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_ID: - if (!xdr_qemud_packet_domain_lookup_by_id_request (xdrs, &objp->qemud_packet_client_data_u.domainLookupByIDRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_UUID: - if (!xdr_qemud_packet_domain_lookup_by_uuid_request (xdrs, &objp->qemud_packet_client_data_u.domainLookupByUUIDRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_NAME: - if (!xdr_qemud_packet_domain_lookup_by_name_request (xdrs, &objp->qemud_packet_client_data_u.domainLookupByNameRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_SUSPEND: - if (!xdr_qemud_packet_domain_suspend_request (xdrs, &objp->qemud_packet_client_data_u.domainSuspendRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_RESUME: - if (!xdr_qemud_packet_domain_resume_request (xdrs, &objp->qemud_packet_client_data_u.domainResumeRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_DESTROY: - if (!xdr_qemud_packet_domain_destroy_request (xdrs, &objp->qemud_packet_client_data_u.domainDestroyRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_GET_INFO: - if (!xdr_qemud_packet_domain_get_info_request (xdrs, &objp->qemud_packet_client_data_u.domainGetInfoRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_SAVE: - if (!xdr_qemud_packet_domain_save_request (xdrs, &objp->qemud_packet_client_data_u.domainSaveRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_RESTORE: - if (!xdr_qemud_packet_domain_restore_request (xdrs, &objp->qemud_packet_client_data_u.domainRestoreRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DUMP_XML: - if (!xdr_qemud_packet_domain_dump_xml_request (xdrs, &objp->qemud_packet_client_data_u.domainDumpXMLRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_LIST_DEFINED_DOMAINS: - break; - case QEMUD_CLIENT_PKT_NUM_DEFINED_DOMAINS: - break; - case QEMUD_CLIENT_PKT_DOMAIN_START: - if (!xdr_qemud_packet_domain_start_request (xdrs, &objp->qemud_packet_client_data_u.domainStartRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_DEFINE: - if (!xdr_qemud_packet_domain_define_request (xdrs, &objp->qemud_packet_client_data_u.domainDefineRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_UNDEFINE: - if (!xdr_qemud_packet_domain_undefine_request (xdrs, &objp->qemud_packet_client_data_u.domainUndefineRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NUM_NETWORKS: - break; - case QEMUD_CLIENT_PKT_LIST_NETWORKS: - break; - case QEMUD_CLIENT_PKT_NUM_DEFINED_NETWORKS: - break; - case QEMUD_CLIENT_PKT_LIST_DEFINED_NETWORKS: - break; - case QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_UUID: - if (!xdr_qemud_packet_network_lookup_by_uuid_request (xdrs, &objp->qemud_packet_client_data_u.networkLookupByUUIDRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_NAME: - if (!xdr_qemud_packet_network_lookup_by_name_request (xdrs, &objp->qemud_packet_client_data_u.networkLookupByNameRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_CREATE: - if (!xdr_qemud_packet_network_create_request (xdrs, &objp->qemud_packet_client_data_u.networkCreateRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_DEFINE: - if (!xdr_qemud_packet_network_define_request (xdrs, &objp->qemud_packet_client_data_u.networkDefineRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_UNDEFINE: - if (!xdr_qemud_packet_network_undefine_request (xdrs, &objp->qemud_packet_client_data_u.networkUndefineRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_START: - if (!xdr_qemud_packet_network_start_request (xdrs, &objp->qemud_packet_client_data_u.networkStartRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_DESTROY: - if (!xdr_qemud_packet_network_destroy_request (xdrs, &objp->qemud_packet_client_data_u.networkDestroyRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_DUMP_XML: - if (!xdr_qemud_packet_network_dump_xml_request (xdrs, &objp->qemud_packet_client_data_u.networkDumpXMLRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_GET_BRIDGE_NAME: - if (!xdr_qemud_packet_network_get_bridge_name_request (xdrs, &objp->qemud_packet_client_data_u.networkGetBridgeNameRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_GET_AUTOSTART: - if (!xdr_qemud_packet_domain_get_autostart_request (xdrs, &objp->qemud_packet_client_data_u.domainGetAutostartRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_DOMAIN_SET_AUTOSTART: - if (!xdr_qemud_packet_domain_set_autostart_request (xdrs, &objp->qemud_packet_client_data_u.domainSetAutostartRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_GET_AUTOSTART: - if (!xdr_qemud_packet_network_get_autostart_request (xdrs, &objp->qemud_packet_client_data_u.networkGetAutostartRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_NETWORK_SET_AUTOSTART: - if (!xdr_qemud_packet_network_set_autostart_request (xdrs, &objp->qemud_packet_client_data_u.networkSetAutostartRequest)) - return FALSE; - break; - case QEMUD_CLIENT_PKT_GET_CAPABILITIES: - break; - default: - return FALSE; - } - return TRUE; -} - -bool_t -xdr_qemud_packet_server_data (XDR *xdrs, qemud_packet_server_data *objp) -{ - - if (!xdr_qemud_packet_server_data_type (xdrs, &objp->type)) - return FALSE; - switch (objp->type) { - case QEMUD_SERVER_PKT_FAILURE: - if (!xdr_qemud_packet_failure_reply (xdrs, &objp->qemud_packet_server_data_u.failureReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_GET_VERSION: - if (!xdr_qemud_packet_get_version_reply (xdrs, &objp->qemud_packet_server_data_u.getVersionReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_GET_NODEINFO: - if (!xdr_qemud_packet_get_node_info_reply (xdrs, &objp->qemud_packet_server_data_u.getNodeInfoReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_LIST_DOMAINS: - if (!xdr_qemud_packet_list_domains_reply (xdrs, &objp->qemud_packet_server_data_u.listDomainsReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NUM_DOMAINS: - if (!xdr_qemud_packet_num_domains_reply (xdrs, &objp->qemud_packet_server_data_u.numDomainsReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_CREATE: - if (!xdr_qemud_packet_domain_create_reply (xdrs, &objp->qemud_packet_server_data_u.domainCreateReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_ID: - if (!xdr_qemud_packet_domain_lookup_by_id_reply (xdrs, &objp->qemud_packet_server_data_u.domainLookupByIDReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_UUID: - if (!xdr_qemud_packet_domain_lookup_by_uuid_reply (xdrs, &objp->qemud_packet_server_data_u.domainLookupByUUIDReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_NAME: - if (!xdr_qemud_packet_domain_lookup_by_name_reply (xdrs, &objp->qemud_packet_server_data_u.domainLookupByNameReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_SUSPEND: - break; - case QEMUD_SERVER_PKT_DOMAIN_RESUME: - break; - case QEMUD_SERVER_PKT_DOMAIN_DESTROY: - break; - case QEMUD_SERVER_PKT_DOMAIN_GET_INFO: - if (!xdr_qemud_packet_domain_get_info_reply (xdrs, &objp->qemud_packet_server_data_u.domainGetInfoReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_SAVE: - break; - case QEMUD_SERVER_PKT_DOMAIN_RESTORE: - if (!xdr_qemud_packet_domain_restore_reply (xdrs, &objp->qemud_packet_server_data_u.domainRestoreReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DUMP_XML: - if (!xdr_qemud_packet_domain_dump_xml_reply (xdrs, &objp->qemud_packet_server_data_u.domainDumpXMLReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_LIST_DEFINED_DOMAINS: - if (!xdr_qemud_packet_list_defined_domains_reply (xdrs, &objp->qemud_packet_server_data_u.listDefinedDomainsReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NUM_DEFINED_DOMAINS: - if (!xdr_qemud_packet_num_defined_domains_reply (xdrs, &objp->qemud_packet_server_data_u.numDefinedDomainsReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_START: - if (!xdr_qemud_packet_domain_start_reply (xdrs, &objp->qemud_packet_server_data_u.domainStartReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_DEFINE: - if (!xdr_qemud_packet_domain_define_reply (xdrs, &objp->qemud_packet_server_data_u.domainDefineReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_UNDEFINE: - break; - case QEMUD_SERVER_PKT_NUM_NETWORKS: - if (!xdr_qemud_packet_num_networks_reply (xdrs, &objp->qemud_packet_server_data_u.numNetworksReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_LIST_NETWORKS: - if (!xdr_qemud_packet_list_networks_reply (xdrs, &objp->qemud_packet_server_data_u.listNetworksReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NUM_DEFINED_NETWORKS: - if (!xdr_qemud_packet_num_defined_networks_reply (xdrs, &objp->qemud_packet_server_data_u.numDefinedNetworksReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_LIST_DEFINED_NETWORKS: - if (!xdr_qemud_packet_list_defined_networks_reply (xdrs, &objp->qemud_packet_server_data_u.listDefinedNetworksReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_UUID: - if (!xdr_qemud_packet_network_lookup_by_uuid_reply (xdrs, &objp->qemud_packet_server_data_u.networkLookupByUUIDReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_NAME: - if (!xdr_qemud_packet_network_lookup_by_name_reply (xdrs, &objp->qemud_packet_server_data_u.networkLookupByNameReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NETWORK_CREATE: - if (!xdr_qemud_packet_network_create_reply (xdrs, &objp->qemud_packet_server_data_u.networkCreateReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NETWORK_DEFINE: - if (!xdr_qemud_packet_network_define_reply (xdrs, &objp->qemud_packet_server_data_u.networkDefineReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NETWORK_UNDEFINE: - break; - case QEMUD_SERVER_PKT_NETWORK_START: - break; - case QEMUD_SERVER_PKT_NETWORK_DESTROY: - break; - case QEMUD_SERVER_PKT_NETWORK_DUMP_XML: - if (!xdr_qemud_packet_network_dump_xml_reply (xdrs, &objp->qemud_packet_server_data_u.networkDumpXMLReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NETWORK_GET_BRIDGE_NAME: - if (!xdr_qemud_packet_network_get_bridge_name_reply (xdrs, &objp->qemud_packet_server_data_u.networkGetBridgeNameReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_GET_AUTOSTART: - if (!xdr_qemud_packet_domain_get_autostart_reply (xdrs, &objp->qemud_packet_server_data_u.domainGetAutostartReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_DOMAIN_SET_AUTOSTART: - break; - case QEMUD_SERVER_PKT_NETWORK_GET_AUTOSTART: - if (!xdr_qemud_packet_network_get_autostart_reply (xdrs, &objp->qemud_packet_server_data_u.networkGetAutostartReply)) - return FALSE; - break; - case QEMUD_SERVER_PKT_NETWORK_SET_AUTOSTART: - break; - case QEMUD_SERVER_PKT_GET_CAPABILITIES: - if (!xdr_qemud_packet_get_capabilities_reply (xdrs, &objp->qemud_packet_server_data_u.getCapabilitiesReply)) - return FALSE; - break; - default: - return FALSE; - } - return TRUE; -} - -bool_t -xdr_qemud_packet_client (XDR *xdrs, qemud_packet_client *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->serial)) - return FALSE; - if (!xdr_qemud_packet_client_data (xdrs, &objp->data)) - return FALSE; - return TRUE; -} - -bool_t -xdr_qemud_packet_server (XDR *xdrs, qemud_packet_server *objp) -{ - - if (!xdr_uint32_t (xdrs, &objp->serial)) - return FALSE; - if (!xdr_uint32_t (xdrs, &objp->inReplyTo)) - return FALSE; - if (!xdr_qemud_packet_server_data (xdrs, &objp->data)) - return FALSE; - return TRUE; -} bool_t xdr_qemud_packet_header (XDR *xdrs, qemud_packet_header *objp) diff -r c6fe9aa77e5b qemud/protocol.h --- a/qemud/protocol.h Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/protocol.h Thu Jun 21 21:21:14 2007 -0400 @@ -13,501 +13,6 @@ extern "C" { extern "C" { #endif -#define QEMUD_UUID_RAW_LEN 16 -#define QEMUD_MAX_NAME_LEN 50 -#define QEMUD_MAX_XML_LEN 4096 -#define QEMUD_MAX_IFNAME_LEN 50 -#define QEMUD_MAX_NUM_DOMAINS 100 -#define QEMUD_MAX_NUM_NETWORKS 100 -#define QEMUD_MAX_DOMAINS_NAME_BUF 5000 -#define QEMUD_MAX_NETWORKS_NAME_BUF 5000 -#define QEMUD_MAX_ERROR_LEN 1024 - -enum qemud_domain_runstate { - QEMUD_STATE_RUNNING = 1, - QEMUD_STATE_PAUSED = 1 + 1, - QEMUD_STATE_STOPPED = 1 + 2, -}; -typedef enum qemud_domain_runstate qemud_domain_runstate; - -enum qemud_packet_client_data_type { - QEMUD_CLIENT_PKT_GET_VERSION = 0, - QEMUD_CLIENT_PKT_GET_NODEINFO = 1, - QEMUD_CLIENT_PKT_LIST_DOMAINS = 2, - QEMUD_CLIENT_PKT_NUM_DOMAINS = 3, - QEMUD_CLIENT_PKT_DOMAIN_CREATE = 4, - QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_ID = 5, - QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_UUID = 6, - QEMUD_CLIENT_PKT_DOMAIN_LOOKUP_BY_NAME = 7, - QEMUD_CLIENT_PKT_DOMAIN_SUSPEND = 8, - QEMUD_CLIENT_PKT_DOMAIN_RESUME = 9, - QEMUD_CLIENT_PKT_DOMAIN_DESTROY = 10, - QEMUD_CLIENT_PKT_DOMAIN_GET_INFO = 11, - QEMUD_CLIENT_PKT_DOMAIN_SAVE = 12, - QEMUD_CLIENT_PKT_DOMAIN_RESTORE = 13, - QEMUD_CLIENT_PKT_DUMP_XML = 14, - QEMUD_CLIENT_PKT_LIST_DEFINED_DOMAINS = 15, - QEMUD_CLIENT_PKT_NUM_DEFINED_DOMAINS = 16, - QEMUD_CLIENT_PKT_DOMAIN_START = 17, - QEMUD_CLIENT_PKT_DOMAIN_DEFINE = 18, - QEMUD_CLIENT_PKT_DOMAIN_UNDEFINE = 19, - QEMUD_CLIENT_PKT_NUM_NETWORKS = 20, - QEMUD_CLIENT_PKT_LIST_NETWORKS = 21, - QEMUD_CLIENT_PKT_NUM_DEFINED_NETWORKS = 22, - QEMUD_CLIENT_PKT_LIST_DEFINED_NETWORKS = 23, - QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_UUID = 24, - QEMUD_CLIENT_PKT_NETWORK_LOOKUP_BY_NAME = 25, - QEMUD_CLIENT_PKT_NETWORK_CREATE = 26, - QEMUD_CLIENT_PKT_NETWORK_DEFINE = 27, - QEMUD_CLIENT_PKT_NETWORK_UNDEFINE = 28, - QEMUD_CLIENT_PKT_NETWORK_START = 29, - QEMUD_CLIENT_PKT_NETWORK_DESTROY = 30, - QEMUD_CLIENT_PKT_NETWORK_DUMP_XML = 31, - QEMUD_CLIENT_PKT_NETWORK_GET_BRIDGE_NAME = 32, - QEMUD_CLIENT_PKT_DOMAIN_GET_AUTOSTART = 33, - QEMUD_CLIENT_PKT_DOMAIN_SET_AUTOSTART = 34, - QEMUD_CLIENT_PKT_NETWORK_GET_AUTOSTART = 35, - QEMUD_CLIENT_PKT_NETWORK_SET_AUTOSTART = 36, - QEMUD_CLIENT_PKT_GET_CAPABILITIES = 37, - QEMUD_CLIENT_PKT_MAX = 38, -}; -typedef enum qemud_packet_client_data_type qemud_packet_client_data_type; - -enum qemud_packet_server_data_type { - QEMUD_SERVER_PKT_FAILURE = 0, - QEMUD_SERVER_PKT_GET_VERSION = 0 + 1, - QEMUD_SERVER_PKT_GET_NODEINFO = 0 + 2, - QEMUD_SERVER_PKT_LIST_DOMAINS = 0 + 3, - QEMUD_SERVER_PKT_NUM_DOMAINS = 0 + 4, - QEMUD_SERVER_PKT_DOMAIN_CREATE = 0 + 5, - QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_ID = 0 + 6, - QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_UUID = 0 + 7, - QEMUD_SERVER_PKT_DOMAIN_LOOKUP_BY_NAME = 0 + 8, - QEMUD_SERVER_PKT_DOMAIN_SUSPEND = 0 + 9, - QEMUD_SERVER_PKT_DOMAIN_RESUME = 0 + 10, - QEMUD_SERVER_PKT_DOMAIN_DESTROY = 0 + 11, - QEMUD_SERVER_PKT_DOMAIN_GET_INFO = 0 + 12, - QEMUD_SERVER_PKT_DOMAIN_SAVE = 0 + 13, - QEMUD_SERVER_PKT_DOMAIN_RESTORE = 0 + 14, - QEMUD_SERVER_PKT_DUMP_XML = 0 + 15, - QEMUD_SERVER_PKT_LIST_DEFINED_DOMAINS = 0 + 16, - QEMUD_SERVER_PKT_NUM_DEFINED_DOMAINS = 0 + 17, - QEMUD_SERVER_PKT_DOMAIN_START = 0 + 18, - QEMUD_SERVER_PKT_DOMAIN_DEFINE = 0 + 19, - QEMUD_SERVER_PKT_DOMAIN_UNDEFINE = 0 + 20, - QEMUD_SERVER_PKT_NUM_NETWORKS = 0 + 21, - QEMUD_SERVER_PKT_LIST_NETWORKS = 0 + 22, - QEMUD_SERVER_PKT_NUM_DEFINED_NETWORKS = 0 + 23, - QEMUD_SERVER_PKT_LIST_DEFINED_NETWORKS = 0 + 24, - QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_UUID = 0 + 25, - QEMUD_SERVER_PKT_NETWORK_LOOKUP_BY_NAME = 0 + 26, - QEMUD_SERVER_PKT_NETWORK_CREATE = 0 + 27, - QEMUD_SERVER_PKT_NETWORK_DEFINE = 0 + 28, - QEMUD_SERVER_PKT_NETWORK_UNDEFINE = 0 + 29, - QEMUD_SERVER_PKT_NETWORK_START = 0 + 30, - QEMUD_SERVER_PKT_NETWORK_DESTROY = 0 + 31, - QEMUD_SERVER_PKT_NETWORK_DUMP_XML = 0 + 32, - QEMUD_SERVER_PKT_NETWORK_GET_BRIDGE_NAME = 0 + 33, - QEMUD_SERVER_PKT_DOMAIN_GET_AUTOSTART = 0 + 34, - QEMUD_SERVER_PKT_DOMAIN_SET_AUTOSTART = 0 + 35, - QEMUD_SERVER_PKT_NETWORK_GET_AUTOSTART = 0 + 36, - QEMUD_SERVER_PKT_NETWORK_SET_AUTOSTART = 0 + 37, - QEMUD_SERVER_PKT_GET_CAPABILITIES = 0 + 38, - QEMUD_SERVER_PKT_MAX = 0 + 39, -}; -typedef enum qemud_packet_server_data_type qemud_packet_server_data_type; - -struct qemud_packet_failure_reply { - uint32_t code; - char message[QEMUD_MAX_ERROR_LEN]; -}; -typedef struct qemud_packet_failure_reply qemud_packet_failure_reply; - -struct qemud_packet_get_version_reply { - uint32_t versionNum; -}; -typedef struct qemud_packet_get_version_reply qemud_packet_get_version_reply; - -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; -}; -typedef struct qemud_packet_get_node_info_reply qemud_packet_get_node_info_reply; - -struct qemud_packet_get_capabilities_reply { - char xml[QEMUD_MAX_XML_LEN]; -}; -typedef struct qemud_packet_get_capabilities_reply qemud_packet_get_capabilities_reply; - -struct qemud_packet_list_domains_reply { - int32_t numDomains; - int32_t domains[QEMUD_MAX_NUM_DOMAINS]; -}; -typedef struct qemud_packet_list_domains_reply qemud_packet_list_domains_reply; - -struct qemud_packet_num_domains_reply { - int32_t numDomains; -}; -typedef struct qemud_packet_num_domains_reply qemud_packet_num_domains_reply; - -struct qemud_packet_domain_create_request { - char xml[QEMUD_MAX_XML_LEN]; -}; -typedef struct qemud_packet_domain_create_request qemud_packet_domain_create_request; - -struct qemud_packet_domain_create_reply { - int32_t id; - u_char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_domain_create_reply qemud_packet_domain_create_reply; - -struct qemud_packet_domain_lookup_by_id_request { - int32_t id; -}; -typedef struct qemud_packet_domain_lookup_by_id_request qemud_packet_domain_lookup_by_id_request; - -struct qemud_packet_domain_lookup_by_id_reply { - u_char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_domain_lookup_by_id_reply qemud_packet_domain_lookup_by_id_reply; - -struct qemud_packet_domain_lookup_by_name_request { - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_domain_lookup_by_name_request qemud_packet_domain_lookup_by_name_request; - -struct qemud_packet_domain_lookup_by_name_reply { - int32_t id; - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_domain_lookup_by_name_reply qemud_packet_domain_lookup_by_name_reply; - -struct qemud_packet_domain_lookup_by_uuid_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_domain_lookup_by_uuid_request qemud_packet_domain_lookup_by_uuid_request; - -struct qemud_packet_domain_lookup_by_uuid_reply { - int32_t id; - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_domain_lookup_by_uuid_reply qemud_packet_domain_lookup_by_uuid_reply; - -struct qemud_packet_domain_suspend_request { - int32_t id; -}; -typedef struct qemud_packet_domain_suspend_request qemud_packet_domain_suspend_request; - -struct qemud_packet_domain_resume_request { - int32_t id; -}; -typedef struct qemud_packet_domain_resume_request qemud_packet_domain_resume_request; - -struct qemud_packet_domain_destroy_request { - int32_t id; -}; -typedef struct qemud_packet_domain_destroy_request qemud_packet_domain_destroy_request; - -struct qemud_packet_domain_get_info_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_domain_get_info_request qemud_packet_domain_get_info_request; - -struct qemud_packet_domain_get_info_reply { - uint64_t cpuTime; - uint32_t runstate; - uint32_t memory; - uint32_t maxmem; - uint32_t nrVirtCpu; -}; -typedef struct qemud_packet_domain_get_info_reply qemud_packet_domain_get_info_reply; - -struct qemud_packet_domain_save_request { - int32_t id; - char file[PATH_MAX]; -}; -typedef struct qemud_packet_domain_save_request qemud_packet_domain_save_request; - -struct qemud_packet_domain_restore_request { - char file[PATH_MAX]; -}; -typedef struct qemud_packet_domain_restore_request qemud_packet_domain_restore_request; - -struct qemud_packet_domain_restore_reply { - int32_t id; -}; -typedef struct qemud_packet_domain_restore_reply qemud_packet_domain_restore_reply; - -struct qemud_packet_domain_dump_xml_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_domain_dump_xml_request qemud_packet_domain_dump_xml_request; - -struct qemud_packet_domain_dump_xml_reply { - char xml[QEMUD_MAX_XML_LEN]; -}; -typedef struct qemud_packet_domain_dump_xml_reply qemud_packet_domain_dump_xml_reply; - -struct qemud_packet_list_defined_domains_reply { - uint32_t numDomains; - char domains[QEMUD_MAX_DOMAINS_NAME_BUF]; -}; -typedef struct qemud_packet_list_defined_domains_reply qemud_packet_list_defined_domains_reply; - -struct qemud_packet_num_defined_domains_reply { - uint32_t numDomains; -}; -typedef struct qemud_packet_num_defined_domains_reply qemud_packet_num_defined_domains_reply; - -struct qemud_packet_domain_start_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_domain_start_request qemud_packet_domain_start_request; - -struct qemud_packet_domain_start_reply { - int32_t id; -}; -typedef struct qemud_packet_domain_start_reply qemud_packet_domain_start_reply; - -struct qemud_packet_domain_define_request { - char xml[QEMUD_MAX_XML_LEN]; -}; -typedef struct qemud_packet_domain_define_request qemud_packet_domain_define_request; - -struct qemud_packet_domain_define_reply { - u_char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_domain_define_reply qemud_packet_domain_define_reply; - -struct qemud_packet_domain_undefine_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_domain_undefine_request qemud_packet_domain_undefine_request; - -struct qemud_packet_num_networks_reply { - uint32_t numNetworks; -}; -typedef struct qemud_packet_num_networks_reply qemud_packet_num_networks_reply; - -struct qemud_packet_list_networks_reply { - uint32_t numNetworks; - char networks[QEMUD_MAX_NETWORKS_NAME_BUF]; -}; -typedef struct qemud_packet_list_networks_reply qemud_packet_list_networks_reply; - -struct qemud_packet_num_defined_networks_reply { - uint32_t numNetworks; -}; -typedef struct qemud_packet_num_defined_networks_reply qemud_packet_num_defined_networks_reply; - -struct qemud_packet_list_defined_networks_reply { - uint32_t numNetworks; - char networks[QEMUD_MAX_NETWORKS_NAME_BUF]; -}; -typedef struct qemud_packet_list_defined_networks_reply qemud_packet_list_defined_networks_reply; - -struct qemud_packet_network_lookup_by_name_request { - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_network_lookup_by_name_request qemud_packet_network_lookup_by_name_request; - -struct qemud_packet_network_lookup_by_name_reply { - int32_t id; - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_lookup_by_name_reply qemud_packet_network_lookup_by_name_reply; - -struct qemud_packet_network_lookup_by_uuid_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_lookup_by_uuid_request qemud_packet_network_lookup_by_uuid_request; - -struct qemud_packet_network_lookup_by_uuid_reply { - int32_t id; - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_network_lookup_by_uuid_reply qemud_packet_network_lookup_by_uuid_reply; - -struct qemud_packet_network_create_request { - char xml[QEMUD_MAX_XML_LEN]; -}; -typedef struct qemud_packet_network_create_request qemud_packet_network_create_request; - -struct qemud_packet_network_create_reply { - u_char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_network_create_reply qemud_packet_network_create_reply; - -struct qemud_packet_network_define_request { - char xml[QEMUD_MAX_XML_LEN]; -}; -typedef struct qemud_packet_network_define_request qemud_packet_network_define_request; - -struct qemud_packet_network_define_reply { - u_char uuid[QEMUD_UUID_RAW_LEN]; - char name[QEMUD_MAX_NAME_LEN]; -}; -typedef struct qemud_packet_network_define_reply qemud_packet_network_define_reply; - -struct qemud_packet_network_undefine_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_undefine_request qemud_packet_network_undefine_request; - -struct qemud_packet_network_start_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_start_request qemud_packet_network_start_request; - -struct qemud_packet_network_destroy_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_destroy_request qemud_packet_network_destroy_request; - -struct qemud_packet_network_dump_xml_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_dump_xml_request qemud_packet_network_dump_xml_request; - -struct qemud_packet_network_dump_xml_reply { - char xml[QEMUD_MAX_XML_LEN]; -}; -typedef struct qemud_packet_network_dump_xml_reply qemud_packet_network_dump_xml_reply; - -struct qemud_packet_network_get_bridge_name_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_get_bridge_name_request qemud_packet_network_get_bridge_name_request; - -struct qemud_packet_network_get_bridge_name_reply { - char ifname[QEMUD_MAX_IFNAME_LEN]; -}; -typedef struct qemud_packet_network_get_bridge_name_reply qemud_packet_network_get_bridge_name_reply; - -struct qemud_packet_domain_get_autostart_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_domain_get_autostart_request qemud_packet_domain_get_autostart_request; - -struct qemud_packet_domain_get_autostart_reply { - uint32_t autostart; -}; -typedef struct qemud_packet_domain_get_autostart_reply qemud_packet_domain_get_autostart_reply; - -struct qemud_packet_domain_set_autostart_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; - uint32_t autostart; -}; -typedef struct qemud_packet_domain_set_autostart_request qemud_packet_domain_set_autostart_request; - -struct qemud_packet_network_get_autostart_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; -}; -typedef struct qemud_packet_network_get_autostart_request qemud_packet_network_get_autostart_request; - -struct qemud_packet_network_get_autostart_reply { - uint32_t autostart; -}; -typedef struct qemud_packet_network_get_autostart_reply qemud_packet_network_get_autostart_reply; - -struct qemud_packet_network_set_autostart_request { - u_char uuid[QEMUD_UUID_RAW_LEN]; - uint32_t autostart; -}; -typedef struct qemud_packet_network_set_autostart_request qemud_packet_network_set_autostart_request; - -struct qemud_packet_client_data { - qemud_packet_client_data_type type; - union { - qemud_packet_domain_create_request domainCreateRequest; - qemud_packet_domain_lookup_by_id_request domainLookupByIDRequest; - qemud_packet_domain_lookup_by_uuid_request domainLookupByUUIDRequest; - qemud_packet_domain_lookup_by_name_request domainLookupByNameRequest; - qemud_packet_domain_suspend_request domainSuspendRequest; - qemud_packet_domain_resume_request domainResumeRequest; - qemud_packet_domain_destroy_request domainDestroyRequest; - qemud_packet_domain_get_info_request domainGetInfoRequest; - qemud_packet_domain_save_request domainSaveRequest; - qemud_packet_domain_restore_request domainRestoreRequest; - qemud_packet_domain_dump_xml_request domainDumpXMLRequest; - qemud_packet_domain_start_request domainStartRequest; - qemud_packet_domain_define_request domainDefineRequest; - qemud_packet_domain_undefine_request domainUndefineRequest; - qemud_packet_network_lookup_by_uuid_request networkLookupByUUIDRequest; - qemud_packet_network_lookup_by_name_request networkLookupByNameRequest; - qemud_packet_network_create_request networkCreateRequest; - qemud_packet_network_define_request networkDefineRequest; - qemud_packet_network_undefine_request networkUndefineRequest; - qemud_packet_network_start_request networkStartRequest; - qemud_packet_network_destroy_request networkDestroyRequest; - qemud_packet_network_dump_xml_request networkDumpXMLRequest; - qemud_packet_network_get_bridge_name_request networkGetBridgeNameRequest; - qemud_packet_domain_get_autostart_request domainGetAutostartRequest; - qemud_packet_domain_set_autostart_request domainSetAutostartRequest; - qemud_packet_network_get_autostart_request networkGetAutostartRequest; - qemud_packet_network_set_autostart_request networkSetAutostartRequest; - } qemud_packet_client_data_u; -}; -typedef struct qemud_packet_client_data qemud_packet_client_data; - -struct qemud_packet_server_data { - qemud_packet_server_data_type type; - union { - qemud_packet_failure_reply failureReply; - qemud_packet_get_version_reply getVersionReply; - qemud_packet_get_node_info_reply getNodeInfoReply; - qemud_packet_list_domains_reply listDomainsReply; - qemud_packet_num_domains_reply numDomainsReply; - qemud_packet_domain_create_reply domainCreateReply; - qemud_packet_domain_lookup_by_id_reply domainLookupByIDReply; - qemud_packet_domain_lookup_by_uuid_reply domainLookupByUUIDReply; - qemud_packet_domain_lookup_by_name_reply domainLookupByNameReply; - qemud_packet_domain_get_info_reply domainGetInfoReply; - qemud_packet_domain_restore_reply domainRestoreReply; - qemud_packet_domain_dump_xml_reply domainDumpXMLReply; - qemud_packet_list_defined_domains_reply listDefinedDomainsReply; - qemud_packet_num_defined_domains_reply numDefinedDomainsReply; - qemud_packet_domain_start_reply domainStartReply; - qemud_packet_domain_define_reply domainDefineReply; - qemud_packet_num_networks_reply numNetworksReply; - qemud_packet_list_networks_reply listNetworksReply; - qemud_packet_num_defined_networks_reply numDefinedNetworksReply; - qemud_packet_list_defined_networks_reply listDefinedNetworksReply; - qemud_packet_network_lookup_by_uuid_reply networkLookupByUUIDReply; - qemud_packet_network_lookup_by_name_reply networkLookupByNameReply; - qemud_packet_network_create_reply networkCreateReply; - qemud_packet_network_define_reply networkDefineReply; - qemud_packet_network_dump_xml_reply networkDumpXMLReply; - qemud_packet_network_get_bridge_name_reply networkGetBridgeNameReply; - qemud_packet_domain_get_autostart_reply domainGetAutostartReply; - qemud_packet_network_get_autostart_reply networkGetAutostartReply; - qemud_packet_get_capabilities_reply getCapabilitiesReply; - } qemud_packet_server_data_u; -}; -typedef struct qemud_packet_server_data qemud_packet_server_data; - -struct qemud_packet_client { - uint32_t serial; - struct qemud_packet_client_data data; -}; -typedef struct qemud_packet_client qemud_packet_client; - -struct qemud_packet_server { - uint32_t serial; - uint32_t inReplyTo; - struct qemud_packet_server_data data; -}; -typedef struct qemud_packet_server qemud_packet_server; #define QEMUD_PROGRAM 0x20001A64 #define QEMUD_PKT_HEADER_XDR_LEN 8 @@ -520,135 +25,9 @@ typedef struct qemud_packet_header qemud /* the xdr functions */ #if defined(__STDC__) || defined(__cplusplus) -extern bool_t xdr_qemud_domain_runstate (XDR *, qemud_domain_runstate*); -extern bool_t xdr_qemud_packet_client_data_type (XDR *, qemud_packet_client_data_type*); -extern bool_t xdr_qemud_packet_server_data_type (XDR *, qemud_packet_server_data_type*); -extern bool_t xdr_qemud_packet_failure_reply (XDR *, qemud_packet_failure_reply*); -extern bool_t xdr_qemud_packet_get_version_reply (XDR *, qemud_packet_get_version_reply*); -extern bool_t xdr_qemud_packet_get_node_info_reply (XDR *, qemud_packet_get_node_info_reply*); -extern bool_t xdr_qemud_packet_get_capabilities_reply (XDR *, qemud_packet_get_capabilities_reply*); -extern bool_t xdr_qemud_packet_list_domains_reply (XDR *, qemud_packet_list_domains_reply*); -extern bool_t xdr_qemud_packet_num_domains_reply (XDR *, qemud_packet_num_domains_reply*); -extern bool_t xdr_qemud_packet_domain_create_request (XDR *, qemud_packet_domain_create_request*); -extern bool_t xdr_qemud_packet_domain_create_reply (XDR *, qemud_packet_domain_create_reply*); -extern bool_t xdr_qemud_packet_domain_lookup_by_id_request (XDR *, qemud_packet_domain_lookup_by_id_request*); -extern bool_t xdr_qemud_packet_domain_lookup_by_id_reply (XDR *, qemud_packet_domain_lookup_by_id_reply*); -extern bool_t xdr_qemud_packet_domain_lookup_by_name_request (XDR *, qemud_packet_domain_lookup_by_name_request*); -extern bool_t xdr_qemud_packet_domain_lookup_by_name_reply (XDR *, qemud_packet_domain_lookup_by_name_reply*); -extern bool_t xdr_qemud_packet_domain_lookup_by_uuid_request (XDR *, qemud_packet_domain_lookup_by_uuid_request*); -extern bool_t xdr_qemud_packet_domain_lookup_by_uuid_reply (XDR *, qemud_packet_domain_lookup_by_uuid_reply*); -extern bool_t xdr_qemud_packet_domain_suspend_request (XDR *, qemud_packet_domain_suspend_request*); -extern bool_t xdr_qemud_packet_domain_resume_request (XDR *, qemud_packet_domain_resume_request*); -extern bool_t xdr_qemud_packet_domain_destroy_request (XDR *, qemud_packet_domain_destroy_request*); -extern bool_t xdr_qemud_packet_domain_get_info_request (XDR *, qemud_packet_domain_get_info_request*); -extern bool_t xdr_qemud_packet_domain_get_info_reply (XDR *, qemud_packet_domain_get_info_reply*); -extern bool_t xdr_qemud_packet_domain_save_request (XDR *, qemud_packet_domain_save_request*); -extern bool_t xdr_qemud_packet_domain_restore_request (XDR *, qemud_packet_domain_restore_request*); -extern bool_t xdr_qemud_packet_domain_restore_reply (XDR *, qemud_packet_domain_restore_reply*); -extern bool_t xdr_qemud_packet_domain_dump_xml_request (XDR *, qemud_packet_domain_dump_xml_request*); -extern bool_t xdr_qemud_packet_domain_dump_xml_reply (XDR *, qemud_packet_domain_dump_xml_reply*); -extern bool_t xdr_qemud_packet_list_defined_domains_reply (XDR *, qemud_packet_list_defined_domains_reply*); -extern bool_t xdr_qemud_packet_num_defined_domains_reply (XDR *, qemud_packet_num_defined_domains_reply*); -extern bool_t xdr_qemud_packet_domain_start_request (XDR *, qemud_packet_domain_start_request*); -extern bool_t xdr_qemud_packet_domain_start_reply (XDR *, qemud_packet_domain_start_reply*); -extern bool_t xdr_qemud_packet_domain_define_request (XDR *, qemud_packet_domain_define_request*); -extern bool_t xdr_qemud_packet_domain_define_reply (XDR *, qemud_packet_domain_define_reply*); -extern bool_t xdr_qemud_packet_domain_undefine_request (XDR *, qemud_packet_domain_undefine_request*); -extern bool_t xdr_qemud_packet_num_networks_reply (XDR *, qemud_packet_num_networks_reply*); -extern bool_t xdr_qemud_packet_list_networks_reply (XDR *, qemud_packet_list_networks_reply*); -extern bool_t xdr_qemud_packet_num_defined_networks_reply (XDR *, qemud_packet_num_defined_networks_reply*); -extern bool_t xdr_qemud_packet_list_defined_networks_reply (XDR *, qemud_packet_list_defined_networks_reply*); -extern bool_t xdr_qemud_packet_network_lookup_by_name_request (XDR *, qemud_packet_network_lookup_by_name_request*); -extern bool_t xdr_qemud_packet_network_lookup_by_name_reply (XDR *, qemud_packet_network_lookup_by_name_reply*); -extern bool_t xdr_qemud_packet_network_lookup_by_uuid_request (XDR *, qemud_packet_network_lookup_by_uuid_request*); -extern bool_t xdr_qemud_packet_network_lookup_by_uuid_reply (XDR *, qemud_packet_network_lookup_by_uuid_reply*); -extern bool_t xdr_qemud_packet_network_create_request (XDR *, qemud_packet_network_create_request*); -extern bool_t xdr_qemud_packet_network_create_reply (XDR *, qemud_packet_network_create_reply*); -extern bool_t xdr_qemud_packet_network_define_request (XDR *, qemud_packet_network_define_request*); -extern bool_t xdr_qemud_packet_network_define_reply (XDR *, qemud_packet_network_define_reply*); -extern bool_t xdr_qemud_packet_network_undefine_request (XDR *, qemud_packet_network_undefine_request*); -extern bool_t xdr_qemud_packet_network_start_request (XDR *, qemud_packet_network_start_request*); -extern bool_t xdr_qemud_packet_network_destroy_request (XDR *, qemud_packet_network_destroy_request*); -extern bool_t xdr_qemud_packet_network_dump_xml_request (XDR *, qemud_packet_network_dump_xml_request*); -extern bool_t xdr_qemud_packet_network_dump_xml_reply (XDR *, qemud_packet_network_dump_xml_reply*); -extern bool_t xdr_qemud_packet_network_get_bridge_name_request (XDR *, qemud_packet_network_get_bridge_name_request*); -extern bool_t xdr_qemud_packet_network_get_bridge_name_reply (XDR *, qemud_packet_network_get_bridge_name_reply*); -extern bool_t xdr_qemud_packet_domain_get_autostart_request (XDR *, qemud_packet_domain_get_autostart_request*); -extern bool_t xdr_qemud_packet_domain_get_autostart_reply (XDR *, qemud_packet_domain_get_autostart_reply*); -extern bool_t xdr_qemud_packet_domain_set_autostart_request (XDR *, qemud_packet_domain_set_autostart_request*); -extern bool_t xdr_qemud_packet_network_get_autostart_request (XDR *, qemud_packet_network_get_autostart_request*); -extern bool_t xdr_qemud_packet_network_get_autostart_reply (XDR *, qemud_packet_network_get_autostart_reply*); -extern bool_t xdr_qemud_packet_network_set_autostart_request (XDR *, qemud_packet_network_set_autostart_request*); -extern bool_t xdr_qemud_packet_client_data (XDR *, qemud_packet_client_data*); -extern bool_t xdr_qemud_packet_server_data (XDR *, qemud_packet_server_data*); -extern bool_t xdr_qemud_packet_client (XDR *, qemud_packet_client*); -extern bool_t xdr_qemud_packet_server (XDR *, qemud_packet_server*); extern bool_t xdr_qemud_packet_header (XDR *, qemud_packet_header*); #else /* K&R C */ -extern bool_t xdr_qemud_domain_runstate (); -extern bool_t xdr_qemud_packet_client_data_type (); -extern bool_t xdr_qemud_packet_server_data_type (); -extern bool_t xdr_qemud_packet_failure_reply (); -extern bool_t xdr_qemud_packet_get_version_reply (); -extern bool_t xdr_qemud_packet_get_node_info_reply (); -extern bool_t xdr_qemud_packet_get_capabilities_reply (); -extern bool_t xdr_qemud_packet_list_domains_reply (); -extern bool_t xdr_qemud_packet_num_domains_reply (); -extern bool_t xdr_qemud_packet_domain_create_request (); -extern bool_t xdr_qemud_packet_domain_create_reply (); -extern bool_t xdr_qemud_packet_domain_lookup_by_id_request (); -extern bool_t xdr_qemud_packet_domain_lookup_by_id_reply (); -extern bool_t xdr_qemud_packet_domain_lookup_by_name_request (); -extern bool_t xdr_qemud_packet_domain_lookup_by_name_reply (); -extern bool_t xdr_qemud_packet_domain_lookup_by_uuid_request (); -extern bool_t xdr_qemud_packet_domain_lookup_by_uuid_reply (); -extern bool_t xdr_qemud_packet_domain_suspend_request (); -extern bool_t xdr_qemud_packet_domain_resume_request (); -extern bool_t xdr_qemud_packet_domain_destroy_request (); -extern bool_t xdr_qemud_packet_domain_get_info_request (); -extern bool_t xdr_qemud_packet_domain_get_info_reply (); -extern bool_t xdr_qemud_packet_domain_save_request (); -extern bool_t xdr_qemud_packet_domain_restore_request (); -extern bool_t xdr_qemud_packet_domain_restore_reply (); -extern bool_t xdr_qemud_packet_domain_dump_xml_request (); -extern bool_t xdr_qemud_packet_domain_dump_xml_reply (); -extern bool_t xdr_qemud_packet_list_defined_domains_reply (); -extern bool_t xdr_qemud_packet_num_defined_domains_reply (); -extern bool_t xdr_qemud_packet_domain_start_request (); -extern bool_t xdr_qemud_packet_domain_start_reply (); -extern bool_t xdr_qemud_packet_domain_define_request (); -extern bool_t xdr_qemud_packet_domain_define_reply (); -extern bool_t xdr_qemud_packet_domain_undefine_request (); -extern bool_t xdr_qemud_packet_num_networks_reply (); -extern bool_t xdr_qemud_packet_list_networks_reply (); -extern bool_t xdr_qemud_packet_num_defined_networks_reply (); -extern bool_t xdr_qemud_packet_list_defined_networks_reply (); -extern bool_t xdr_qemud_packet_network_lookup_by_name_request (); -extern bool_t xdr_qemud_packet_network_lookup_by_name_reply (); -extern bool_t xdr_qemud_packet_network_lookup_by_uuid_request (); -extern bool_t xdr_qemud_packet_network_lookup_by_uuid_reply (); -extern bool_t xdr_qemud_packet_network_create_request (); -extern bool_t xdr_qemud_packet_network_create_reply (); -extern bool_t xdr_qemud_packet_network_define_request (); -extern bool_t xdr_qemud_packet_network_define_reply (); -extern bool_t xdr_qemud_packet_network_undefine_request (); -extern bool_t xdr_qemud_packet_network_start_request (); -extern bool_t xdr_qemud_packet_network_destroy_request (); -extern bool_t xdr_qemud_packet_network_dump_xml_request (); -extern bool_t xdr_qemud_packet_network_dump_xml_reply (); -extern bool_t xdr_qemud_packet_network_get_bridge_name_request (); -extern bool_t xdr_qemud_packet_network_get_bridge_name_reply (); -extern bool_t xdr_qemud_packet_domain_get_autostart_request (); -extern bool_t xdr_qemud_packet_domain_get_autostart_reply (); -extern bool_t xdr_qemud_packet_domain_set_autostart_request (); -extern bool_t xdr_qemud_packet_network_get_autostart_request (); -extern bool_t xdr_qemud_packet_network_get_autostart_reply (); -extern bool_t xdr_qemud_packet_network_set_autostart_request (); -extern bool_t xdr_qemud_packet_client_data (); -extern bool_t xdr_qemud_packet_server_data (); -extern bool_t xdr_qemud_packet_client (); -extern bool_t xdr_qemud_packet_server (); extern bool_t xdr_qemud_packet_header (); #endif /* K&R C */ diff -r c6fe9aa77e5b qemud/protocol.x --- a/qemud/protocol.x Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/protocol.x Thu Jun 21 21:21:14 2007 -0400 @@ -21,580 +21,6 @@ * Author: Daniel P. Berrange */ -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; -}; /* The first two words in the messages are length and program number * (previously called "magic"). This makes the protocol compatible diff -r c6fe9aa77e5b qemud/qemud.c --- a/qemud/qemud.c Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/qemud.c Thu Jun 21 21:21:14 2007 -0400 @@ -57,18 +57,15 @@ #include "../src/internal.h" #include "../src/remote_internal.h" #include "../src/conf.h" -#include "dispatch.h" -#include "driver.h" #include "event.h" static int godaemon = 0; /* -d: Be a daemon */ static int verbose = 0; /* -v: Verbose mode */ -static int remote = 0; /* -r: Remote mode */ -static int sys = 0; /* -s: (QEMUD only) system mode */ -static int timeout = -1; /* -t: (QEMUD only) timeout */ +static int timeout = -1; /* -t: Shutdown timeout */ static int sigwrite = -1; /* Signal handler pipe */ - -/* Defaults for configuration file elements (remote only). */ +static int ipsock = 0; /* -l Listen for TCP/IP */ + +/* Defaults for configuration file elements */ static int listen_tls = 1; static int listen_tcp = 0; static const char *tls_port = LIBVIRTD_TLS_PORT; @@ -209,21 +206,12 @@ static void qemudDispatchSignalEvent(int qemudLog(QEMUD_INFO, "Reloading configuration on SIGHUP"); if (virStateReload() < 0) qemudLog(QEMUD_WARN, "Error while reloading drivers"); - - if (!remote) { - qemudReload(); - } break; case SIGINT: case SIGQUIT: case SIGTERM: qemudLog(QEMUD_WARN, "Shutting down on signal %d", sigc); - - if (!remote) { - qemudShutdown(); - } - server->shutdown = 1; break; @@ -294,6 +282,17 @@ static void qemudLogHandler(void *data A !verbose) return; fprintf(stderr, "%s\n", msg); + } +} + +static void qemudLogError(void *data ATTRIBUTE_UNUSED, + virErrorPtr err) +{ + if (verbose) { + if (err->level == VIR_ERR_WARNING) + qemudLogHandler(data, VIR_LOG_WARN, err->message); + else + qemudLogHandler(data, VIR_LOG_ERROR, err->message); } } @@ -641,12 +640,10 @@ static int qemudInitPaths(struct qemud_s char *roSockname, int maxlen) { char *base = 0; - - if (remote) { /* Remote daemon */ - /* I'm not sure if it's meaningful to have a "session remote daemon" - * so currently this code ignores the --system flag. - RWMJ. - */ - + uid_t uid = geteuid(); + + + if (!uid) { if (snprintf (sockname, maxlen, "%s/run/libvirt/libvirt-sock", LOCAL_STATE_DIR) >= maxlen) goto snprintf_error; @@ -659,48 +656,26 @@ static int qemudInitPaths(struct qemud_s unlink(roSockname); - if (snprintf(server->logDir, PATH_MAX, "%s/log/libvirt/qemu", LOCAL_STATE_DIR) >= PATH_MAX) + if (snprintf(server->logDir, PATH_MAX, "%s/log/libvirt/", LOCAL_STATE_DIR) >= PATH_MAX) goto snprintf_error; } else { - uid_t uid = geteuid(); struct passwd *pw; - if (sys) { /* QEMUD, system */ - if (uid != 0) { - qemudLog (QEMUD_ERR, - "You must run the daemon as root to use system mode"); - return -1; - } - - if (snprintf(sockname, maxlen, "%s/run/libvirt/qemud-sock", LOCAL_STATE_DIR) >= maxlen) - goto snprintf_error; - - unlink(sockname); - - if (snprintf(roSockname, maxlen, "%s/run/libvirt/qemud-sock-ro", LOCAL_STATE_DIR) >= maxlen) - goto snprintf_error; - - unlink(roSockname); - - if ((base = strdup (SYSCONF_DIR "/libvirt/qemu")) == NULL) - goto out_of_memory; - } else { /* QEMUD, session */ - if (!(pw = getpwuid(uid))) { - qemudLog(QEMUD_ERR, "Failed to find user record for uid '%d': %s", - uid, strerror(errno)); - return -1; - } - - if (snprintf(sockname, maxlen, "@%s/.libvirt/qemud-sock", pw->pw_dir) >= maxlen) - goto snprintf_error; - - if (snprintf(server->logDir, PATH_MAX, "%s/.libvirt/qemu/log", pw->pw_dir) >= PATH_MAX) - goto snprintf_error; - - if (asprintf (&base, "%s/.libvirt/qemu", pw->pw_dir) == -1) { - qemudLog (QEMUD_ERR, "out of memory in asprintf"); - return -1; - } + if (!(pw = getpwuid(uid))) { + qemudLog(QEMUD_ERR, "Failed to find user record for uid '%d': %s", + uid, strerror(errno)); + return -1; + } + + if (snprintf(sockname, maxlen, "@%s/.libvirt/libvirt-sock", pw->pw_dir) >= maxlen) + goto snprintf_error; + + if (snprintf(server->logDir, PATH_MAX, "%s/.libvirt/log", pw->pw_dir) >= PATH_MAX) + goto snprintf_error; + + if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1) { + qemudLog (QEMUD_ERR, "out of memory in asprintf"); + return -1; } } /* !remote */ @@ -711,11 +686,6 @@ static int qemudInitPaths(struct qemud_s snprintf_error: qemudLog(QEMUD_ERR, "Resulting path to long for buffer in qemudInitPaths()"); - return -1; - - out_of_memory: - qemudLog (QEMUD_ERR, "qemudInitPaths: out of memory"); - if (base) free (base); return -1; } @@ -744,13 +714,14 @@ static struct qemud_server *qemudInitial goto cleanup; virSetLogFunc(NULL, qemudLogHandler); + virSetErrorFunc(NULL, qemudLogError); + __virEventRegisterImpl(virEventAddHandleImpl, + virEventRemoveHandleImpl, + virEventAddTimeoutImpl, + virEventRemoveTimeoutImpl); virStateInitialize(); - if (!remote) /* qemud only */ { - if (qemudStartup() < 0) { - goto cleanup; - } - } else /* remote only */ { + if (ipsock) { if (listen_tcp && remoteListenTCP (server, tcp_port, 0) < 0) goto cleanup; @@ -766,7 +737,6 @@ static struct qemud_server *qemudInitial return server; cleanup: - qemudShutdown(); if (server) { struct qemud_socket *sock = server->sockets; while (sock) { @@ -1106,70 +1076,6 @@ static void qemudDispatchClientFailure(s } -static void qemudDispatchClientRequest(struct qemud_server *server, - struct qemud_client *client, - qemud_packet_client *req) { - qemud_packet_server res; - qemud_packet_header h; - XDR x; - - assert (client->magic == QEMUD_CLIENT_MAGIC); - - if (req->serial != ++client->incomingSerial) { - qemudDebug("Invalid serial number. Got %d expect %d", - req->serial, client->incomingSerial); - qemudDispatchClientFailure(server, client); - return; - } - - if (qemudDispatch(server, - client, - &req->data, - &res.data) < 0) { - qemudDispatchClientFailure(server, client); - return; - } - - res.serial = ++client->outgoingSerial; - res.inReplyTo = req->serial; - - xdrmem_create(&x, client->buffer, sizeof client->buffer, - XDR_ENCODE); - - /* Encode a dummy header. We'll come back to encode the real header. */ - if (!xdr_qemud_packet_header (&x, &h)) { - qemudDebug ("failed to encode dummy header"); - qemudDispatchClientFailure (server, client); - return; - } - - /* Real payload. */ - if (!xdr_qemud_packet_server(&x, &res)) { - qemudDebug("Failed to XDR encode reply payload"); - qemudDispatchClientFailure(server, client); - return; - } - - /* Go back and encode the real header. */ - h.length = xdr_getpos (&x); - h.prog = QEMUD_PROGRAM; - - if (xdr_setpos (&x, 0) == 0) { - qemudDebug("xdr_setpos failed"); - qemudDispatchClientFailure(server, client); - return; - } - - if (!xdr_qemud_packet_header(&x, &h)) { - qemudDebug("Failed to XDR encode reply header"); - qemudDispatchClientFailure(server, client); - return; - } - - client->mode = QEMUD_MODE_TX_PACKET; - client->bufferLength = h.length; - client->bufferOffset = 0; -} static int qemudClientRead(struct qemud_server *server, struct qemud_client *client) { @@ -1234,11 +1140,7 @@ static void qemudDispatchClientRead(stru return; } - /* We're expecting either QEMUD_PROGRAM or REMOTE_PROGRAM, - * corresponding to qemud or remote calls respectively. - */ - if ((!remote && h.prog != QEMUD_PROGRAM) - || (remote && h.prog != REMOTE_PROGRAM)) { + if (h.prog != REMOTE_PROGRAM) { qemudDebug("Header magic %x mismatch", h.prog); qemudDispatchClientFailure(server, client); return; @@ -1287,26 +1189,13 @@ static void qemudDispatchClientRead(stru return; } - if (remote && h.prog == REMOTE_PROGRAM) { + if (h.prog == REMOTE_PROGRAM) { remoteDispatchClientRequest (server, client); - if (qemudRegisterClientEvent(server, client, 1) < 0) - qemudDispatchClientFailure(server, client); - } else if (!remote && h.prog == QEMUD_PROGRAM) { - qemud_packet_client p; - - if (!xdr_qemud_packet_client(&x, &p)) { - qemudDebug("Failed to decode client packet"); - qemudDispatchClientFailure(server, client); - return; - } - - qemudDispatchClientRequest(server, client, &p); - if (qemudRegisterClientEvent(server, client, 1) < 0) qemudDispatchClientFailure(server, client); } else { /* An internal error. */ - qemudDebug ("Not REMOTE_PROGRAM or QEMUD_PROGRAM"); + qemudDebug ("Not REMOTE_PROGRAM"); qemudDispatchClientFailure(server, client); } @@ -1575,7 +1464,6 @@ static void qemudCleanup(struct qemud_se } - qemudShutdown(); virStateCleanup(); free(server); @@ -1728,32 +1616,24 @@ Options:\n\ Options:\n\ -v | --verbose Verbose messages.\n\ -d | --daemon Run as a daemon & write PID file.\n\ - -r | --remote Act as remote server.\n\ - -s | --system Run as system daemon (QEMUD only).\n\ - -t | --timeout Exit after timeout period (QEMUD only).\n\ - -f | --config Configuration file (remote only).\n\ + -l | --listen Listen for TCP/IP connections.\n\ + -t | --timeout Exit after timeout period.\n\ + -c | --config Configuration file.\n\ -p | --pid-file Change name of PID file.\n\ \n\ -Remote and QEMU/network management:\n\ -\n\ -The '--remote' flag selects between running as a remote server\n\ -for remote libvirt requests, versus running as a QEMU\n\ -and network management daemon.\n\ -\n\ -Normally you need to have one daemon of each type.\n\ -\n\ -See also http://libvirt.org/remote.html\n\ -\n\ -For remote daemon:\n\ +libvirt management daemon:\n\ \n\ Default paths:\n\ \n\ - Configuration file (unless overridden by -f):\n\ + Configuration file (unless overridden by -c):\n\ " SYSCONF_DIR "/libvirt/libvirtd.conf\n\ \n\ - Sockets:\n\ + Sockets (as root):\n\ " LOCAL_STATE_DIR "/run/libvirt/libvirt-sock\n\ " LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro\n\ +\n\ + Sockets (as non-root):\n\ + $HOME/.libvirt/libvirt-sock (in UNIX abstract namespace)\n\ \n\ TLS:\n\ CA certificate: " LIBVIRT_CACERT "\n\ @@ -1762,44 +1642,10 @@ For remote daemon:\n\ \n\ PID file (unless overridden by --pid-file):\n\ %s\n\ -\n\ -For QEMU and network management daemon:\n\ -\n\ - For '--system' option you must be running this daemon as root.\n\ -\n\ - The '--timeout' applies only when the daemon is not servicing\n\ - clients.\n\ -\n\ - Default paths:\n\ -\n\ - Configuration files (in system mode):\n\ - " SYSCONF_DIR "/libvirt/qemu\n\ - " SYSCONF_DIR "/libvirt/qemu/autostart\n\ - " SYSCONF_DIR "/libvirt/qemu/networkd\n\ - " SYSCONF_DIR "/libvirt/qemu/networks/autostart\n\ -\n\ - Configuration files (not in system mode):\n\ - $HOME/.libvirt/qemu\n\ - $HOME/.libvirt/qemu/autostart\n\ - $HOME/.libvirt/qemu/networks\n\ - $HOME/.libvirt/qemu/networks/autostart\n\ -\n\ - Sockets (in system mode):\n\ - " LOCAL_STATE_DIR "/run/libvirt/qemud-sock\n\ - " LOCAL_STATE_DIR "/run/libvirt/qemud-sock-ro\n\ -\n\ - Sockets (not in system mode):\n\ - $HOME/.libvirt/qemud-sock (in Unix abstract namespace)\n\ -\n\ - PID file (unless overridden by --pid-file):\n\ - %s\n\ \n", argv0, REMOTE_PID_FILE[0] != '\0' ? REMOTE_PID_FILE - : "(disabled in ./configure)", - QEMUD_PID_FILE[0] != '\0' - ? QEMUD_PID_FILE : "(disabled in ./configure)"); } @@ -1815,9 +1661,8 @@ int main(int argc, char **argv) { struct option opts[] = { { "verbose", no_argument, &verbose, 1}, { "daemon", no_argument, &godaemon, 1}, - { "remote", no_argument, &remote, 1}, - { "config", required_argument, NULL, 'f'}, - { "system", no_argument, &sys, 1}, + { "listen", no_argument, &ipsock, 1}, + { "config", required_argument, NULL, 'c'}, { "timeout", required_argument, NULL, 't'}, { "pid-file", required_argument, NULL, 'p'}, { "help", no_argument, NULL, '?' }, @@ -1829,7 +1674,7 @@ int main(int argc, char **argv) { int c; char *tmp; - c = getopt_long(argc, argv, "dfp:s:t:v", opts, &optidx); + c = getopt_long(argc, argv, "ldfp:t:v", opts, &optidx); if (c == -1) { break; @@ -1845,11 +1690,8 @@ int main(int argc, char **argv) { case 'd': godaemon = 1; break; - case 'r': - remote = 1; - break; - case 's': - sys = 1; + case 'l': + ipsock = 1; break; case 't': @@ -1877,14 +1719,12 @@ int main(int argc, char **argv) { } } - /* In remote mode only, now read the config file (if it exists). */ - if (remote) { - if (remoteReadConfigFile (remote_config_file) < 0) - goto error1; - } + /* Read the config file (if it exists). */ + if (remoteReadConfigFile (remote_config_file) < 0) + goto error1; if (godaemon) - openlog("libvirt-qemud", 0, 0); + openlog("libvirtd", 0, 0); if (pipe(sigpipe) < 0 || qemudSetNonBlock(sigpipe[0]) < 0 || @@ -1921,13 +1761,8 @@ int main(int argc, char **argv) { /* Choose the name of the PID file. */ if (!pid_file) { - if (remote) { - if (REMOTE_PID_FILE[0] != '\0') - pid_file = REMOTE_PID_FILE; - } else { - if (QEMUD_PID_FILE[0] != '\0') - pid_file = QEMUD_PID_FILE; - } + if (REMOTE_PID_FILE[0] != '\0') + pid_file = REMOTE_PID_FILE; } if (pid_file && qemudWritePidFile (pid_file) < 0) diff -r c6fe9aa77e5b qemud/remote.c --- a/qemud/remote.c Thu Jun 21 21:21:11 2007 -0400 +++ b/qemud/remote.c Thu Jun 21 21:21:14 2007 -0400 @@ -49,10 +49,6 @@ #include "internal.h" #include "../src/internal.h" -#include "dispatch.h" -#include "driver.h" -#include "conf.h" -#include "iptables.h" #define DEBUG 0 diff -r c6fe9aa77e5b src/Makefile.am --- a/src/Makefile.am Thu Jun 21 21:21:11 2007 -0400 +++ b/src/Makefile.am Thu Jun 21 21:21:14 2007 -0400 @@ -16,7 +16,8 @@ LDADDS = @STATIC_BINARIES@ libvirt.la LDADDS = @STATIC_BINARIES@ libvirt.la VIRSH_LIBS = @VIRSH_LIBS@ -EXTRA_DIST = libvirt_sym.version +EXTRA_DIST = libvirt_sym.version \ + qemu_internal.c qemu_internal.h lib_LTLIBRARIES = libvirt.la libvirt_la_LIBADD = @LIBXML_LIBS@ @@ -42,8 +43,12 @@ CLIENT_SOURCES = \ proxy_internal.c proxy_internal.h \ conf.c conf.h \ xm_internal.c xm_internal.h \ - qemu_internal.c qemu_internal.h \ - remote_internal.c remote_internal.h + remote_internal.c remote_internal.h \ + ../qemud/bridge.c ../qemud/bridge.h \ + ../qemud/iptables.c ../qemud/iptables.h \ + ../qemud/uuid.c ../qemud/uuid.h \ + ../qemud/driver.c ../qemud/driver.h \ + ../qemud/qemu_conf.c ../qemud/conf.h SERVER_SOURCES = \ ../qemud/protocol.h ../qemud/protocol.c \ @@ -58,6 +63,9 @@ virsh_DEPENDENCIES = $(DEPS) virsh_DEPENDENCIES = $(DEPS) virsh_LDADD = $(LDADDS) $(VIRSH_LIBS) virsh_CFLAGS = $(COVERAGE_CFLAGS) + +../qemud/qemu_conf.c: + ln -s conf.c $@ # # target to ease building test programs diff -r c6fe9aa77e5b src/libvirt.c --- a/src/libvirt.c Thu Jun 21 21:21:11 2007 -0400 +++ b/src/libvirt.c Thu Jun 21 21:21:14 2007 -0400 @@ -27,8 +27,8 @@ #include "xml.h" #include "test.h" #include "xen_unified.h" -#include "qemu_internal.h" #include "remote_internal.h" +#include "../qemud/driver.h" /* * TODO: @@ -71,7 +71,7 @@ virInitialize(void) if (testRegister() == -1) return -1; #endif #ifdef WITH_QEMU - if (qemuRegister() == -1) return -1; + if (qemudRegister() == -1) return -1; #endif #ifdef WITH_XEN if (xenUnifiedRegister () == -1) return -1; @@ -272,6 +272,9 @@ virRegisterStateDriver(virStateDriverPtr int __virStateInitialize(void) { int i, ret = 0; + + if (virInitialize() < 0) + return -1; if (virInitialize() < 0) return -1; diff -r c6fe9aa77e5b src/remote_internal.c --- a/src/remote_internal.c Thu Jun 21 21:21:11 2007 -0400 +++ b/src/remote_internal.c Thu Jun 21 21:21:14 2007 -0400 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -126,8 +127,6 @@ remoteOpen (virConnectPtr conn, const ch return VIR_DRV_OPEN_DECLINED; /* Decline - not a URL. */ char *transport_str = get_transport_from_scheme (uri->scheme); - if (!uri->server && !transport_str) - return VIR_DRV_OPEN_DECLINED; /* Decline - not a remote URL. */ /* What transport? */ enum transport transport; @@ -147,6 +146,12 @@ remoteOpen (virConnectPtr conn, const ch "(should be tls|unix|ssh|ext|tcp)"); return VIR_DRV_OPEN_ERROR; } + + if (!strcmp(uri_str, "qemu:///system") || + !strcmp(uri_str, "qemu:///session")) + transport = trans_unix; + else if (!uri->server && !transport_str) + return VIR_DRV_OPEN_DECLINED; /* Decline - not a remote URL. */ /* Return code from this function, and the private data. */ int retcode = VIR_DRV_OPEN_ERROR; @@ -347,10 +352,27 @@ remoteOpen (virConnectPtr conn, const ch case trans_unix: { if (!sockname) { - if (flags & VIR_DRV_OPEN_RO) - sockname = strdup (LIBVIRTD_UNIX_SOCKET_RO); - else - sockname = strdup (LIBVIRTD_UNIX_SOCKET); + if (!strcmp(uri->scheme, "qemu") && + uri->path && + !strcmp(uri->path, "/session")) { + struct passwd *pw; + uid_t uid = getuid(); + + if (!(pw = getpwuid(uid))) { + error (NULL, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto failed; + } + + if (asprintf (&sockname, "@%s" LIBVIRTD_USER_UNIX_SOCKET, pw->pw_dir) < 0) { + error (NULL, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto failed; + } + } else { + if (flags & VIR_DRV_OPEN_RO) + sockname = strdup (LIBVIRTD_PRIV_UNIX_SOCKET_RO); + else + sockname = strdup (LIBVIRTD_PRIV_UNIX_SOCKET); + } } #ifndef UNIX_PATH_MAX @@ -360,6 +382,8 @@ remoteOpen (virConnectPtr conn, const ch memset (&addr, 0, sizeof addr); addr.sun_family = AF_UNIX; strncpy (addr.sun_path, sockname, UNIX_PATH_MAX (addr)); + if (addr.sun_path[0] == '@') + addr.sun_path[0] = '\0'; priv.sock = socket (AF_UNIX, SOCK_STREAM, 0); if (priv.sock == -1) { @@ -393,7 +417,7 @@ remoteOpen (virConnectPtr conn, const ch cmd_argv[j++] = strdup (server); cmd_argv[j++] = strdup (netcat ? netcat : "nc"); cmd_argv[j++] = strdup ("-U"); - cmd_argv[j++] = strdup (sockname ? sockname : LIBVIRTD_UNIX_SOCKET); + cmd_argv[j++] = strdup (sockname ? sockname : LIBVIRTD_PRIV_UNIX_SOCKET); cmd_argv[j++] = 0; assert (j == nr_args); } diff -r c6fe9aa77e5b src/remote_internal.h --- a/src/remote_internal.h Thu Jun 21 21:21:11 2007 -0400 +++ b/src/remote_internal.h Thu Jun 21 21:21:14 2007 -0400 @@ -34,8 +34,9 @@ int remoteRegister (void); #define LIBVIRTD_TLS_PORT "16514" #define LIBVIRTD_TCP_PORT "16509" -#define LIBVIRTD_UNIX_SOCKET LOCAL_STATE_DIR "/run/libvirt/libvirt-sock" -#define LIBVIRTD_UNIX_SOCKET_RO LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro" +#define LIBVIRTD_PRIV_UNIX_SOCKET LOCAL_STATE_DIR "/run/libvirt/libvirt-sock" +#define LIBVIRTD_PRIV_UNIX_SOCKET_RO LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro" +#define LIBVIRTD_USER_UNIX_SOCKET "/.libvirt/libvirt-sock" #define LIBVIRTD_CONFIGURATION_FILE SYSCONF_DIR "/libvirtd.conf" /* Defaults for PKI directory. */