+Thu Jun 29 23:57:35 EDT 2006 Daniel Veillard <veillard@redhat.com>
+
+ * proxy/libvirt_proxy.c src/proxy_internal.c src/xen_internal.c
+ src/xen_internal.h src/xend_internal.c src/xend_internal.h:
+ implemented id based lookup and other cleanups, virsh starts to
+ work, but still some TODOs
+
Thu Jun 29 22:19:51 EDT 2006 Daniel Veillard <veillard@redhat.com>
* src/proxy_internal.c src/proxy_internal.h src/driver.h src/libvirt.c
req->data.larg = xenHypervisorGetDomMaxMemory(conn, req->data.arg);
break;
case VIR_PROXY_DOMAIN_INFO:
+ if (req->len != sizeof(virProxyPacket))
+ goto comm_error;
+ memset(&request.extra.dinfo, 0, sizeof(virDomainInfo));
+ ret = xenHypervisorGetDomInfo(conn, req->data.arg,
+ &request.extra.dinfo);
+ if (ret < 0) {
+ req->data.arg = -1;
+ } else {
+ req->len += sizeof(virDomainInfo);
+ }
+ break;
+ case VIR_PROXY_LOOKUP_ID: {
+ char **names;
+ char **tmp;
+ int ident, len;
+ char *name = NULL;
+ unsigned char uuid[16];
+
+ if (req->len != sizeof(virProxyPacket))
+ goto comm_error;
+
+ /*
+ * Xend API forces to collect the full domain list by names, and
+ * then query each of them until the id is found
+ */
+ names = xenDaemonListDomainsOld(conn);
+ tmp = names;
+
+ if (names != NULL) {
+ while (*tmp != NULL) {
+ ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
+ if (ident == req->data.arg) {
+ name = *tmp;
+ break;
+ }
+ tmp++;
+ }
+ }
+ if (name == NULL) {
+ req->data.arg = -1;
+ } else {
+ len = strlen(name);
+ if (len > 1000) {
+ len = 1000;
+ name[1000] = 0;
+ }
+ req->len += 16 + len + 1;
+ memcpy(&request.extra.str[0], uuid, 16);
+ strcpy(&request.extra.str[16], name);
+ }
+ free(names);
+ break;
+ }
case VIR_PROXY_NODE_INFO:
- case VIR_PROXY_LOOKUP_ID:
case VIR_PROXY_LOOKUP_UUID:
case VIR_PROXY_LOOKUP_NAME:
TODO;
+ req->data.arg = -1;
break;
default:
goto comm_error;
static virDomainPtr
xenProxyLookupByID(virConnectPtr conn, int id)
{
- TODO
- return(NULL);
+ virProxyPacket req;
+ virProxyFullPacket ans;
+ unsigned char uuid[16];
+ const char *name;
+ int ret;
+ virDomainPtr res;
+
+ if (!VIR_IS_CONNECT(conn)) {
+ virProxyError(conn, VIR_ERR_INVALID_CONN, __FUNCTION__);
+ return (NULL);
+ }
+ memset(&req, 0, sizeof(req));
+ req.command = VIR_PROXY_LOOKUP_ID;
+ req.data.arg = id;
+ req.len = sizeof(req);
+ ret = xenProxyCommand(conn, &req, &ans);
+ if (ret < 0) {
+ xenProxyClose(conn);
+ return(NULL);
+ }
+ if (req.data.arg == -1) {
+ return(NULL);
+ }
+ memcpy(uuid, &ans.extra.str[0], 16);
+ name = &ans.extra.str[16];
+ res = virGetDomain(conn, name, uuid);
+
+ if (res == NULL)
+ virProxyError(conn, VIR_ERR_NO_MEMORY, "Allocating domain");
+ else
+ res->handle = id;
+
+ return(res);
}
/**
}
/**
- * xenHypervisorGetDomainInfo:
- * @domain: pointer to the domain block
+ * xenHypervisorGetDomInfo:
+ * @conn: connection data
+ * @id: the domain ID
* @info: the place where informations should be stored
*
* Do an hypervisor call to get the related set of domain informations.
* Returns 0 in case of success, -1 in case of error.
*/
int
-xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
+xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
{
dom0_op_t op;
dom0_getdomaininfo_t dominfo;
int ret;
- if ((domain == NULL) || (domain->conn == NULL) ||
- (domain->conn->handle < 0) || (info == NULL))
+ if ((conn == NULL) || (conn->handle < 0) || (info == NULL))
return (-1);
memset(info, 0, sizeof(virDomainInfo));
}
op.cmd = DOM0_GETDOMAININFOLIST;
- op.u.getdomaininfolist.first_domain = (domid_t) domain->handle;
+ op.u.getdomaininfolist.first_domain = (domid_t) id;
op.u.getdomaininfolist.max_domains = 1;
op.u.getdomaininfolist.buffer = &dominfo;
op.u.getdomaininfolist.num_domains = 1;
- dominfo.domain = domain->handle;
+ dominfo.domain = id;
- ret = xenHypervisorDoOp(domain->conn->handle, &op);
+ ret = xenHypervisorDoOp(conn->handle, &op);
if (munlock(&dominfo, sizeof(dom0_getdomaininfo_t)) < 0) {
virXenError(VIR_ERR_XEN_CALL, " release",
return (0);
}
+/**
+ * xenHypervisorGetDomainInfo:
+ * @domain: pointer to the domain block
+ * @info: the place where informations should be stored
+ *
+ * Do an hypervisor call to get the related set of domain informations.
+ *
+ * Returns 0 in case of success, -1 in case of error.
+ */
+int
+xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
+{
+ dom0_op_t op;
+ dom0_getdomaininfo_t dominfo;
+ int ret;
+
+ if ((domain == NULL) || (domain->conn == NULL) ||
+ (domain->conn->handle < 0) || (info == NULL) ||
+ (domain->handle < 0))
+ return (-1);
+ return(xenHypervisorGetDomInfo(domain->conn, domain->handle, info));
+
+}
+
/**
* xenHypervisorPauseDomain:
* @domain: pointer to the domain block
int xenHypervisorPauseDomain (virDomainPtr domain);
int xenHypervisorGetDomainInfo (virDomainPtr domain,
virDomainInfoPtr info);
+int xenHypervisorGetDomInfo (virConnectPtr conn,
+ int id,
+ virDomainInfoPtr info);
int xenHypervisorSetMaxMemory (virDomainPtr domain,
unsigned long memory);
int xenHypervisorCheckID (virConnectPtr conn,
*
* Returns a list of names or NULL in case of error.
*/
-static char **
+char **
xenDaemonListDomainsOld(virConnectPtr xend)
{
size_t extra = 0;
char *xenDaemonDomainDumpXML(virDomainPtr domain);
virDomainPtr xenDaemonDomainLookupByName(virConnectPtr conn, const char *domname);
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
+char **xenDaemonListDomainsOld(virConnectPtr xend);
#ifdef __cplusplus
}