+Tue Aug 8 23:24:51 CEST 2006 Daniel Veillard <veillard@redhat.com>
+
+ * src/driver.h src/libvirt.c src/proxy_internal.c src/test.c
+ src/xen_internal.c src/xend_internal.c src/xend_internal.h
+ src/xml.c src/xs_internal.c: cleanups, force the new vCPU
+ and affinity entry point to go though the driver framework,
+ and fix a few warning showing up in my pedantic environment.
+
Mon Aug 7 18:33:45 EDT 2006 Daniel Berrange <berrange@redhat.com>
* src/xend_internal.c: Added details of serial console TTY to XML
(*virDrvDomainRestore) (virConnectPtr conn,
const char *from);
+typedef int
+ (*virDrvDomainSetVcpus) (virDomainPtr domain,
+ unsigned int nvcpus);
+typedef int
+ (*virDrvDomainPinVcpu) (virDomainPtr domain,
+ unsigned int vcpu,
+ unsigned char *cpumap,
+ int maplen);
+typedef int
+ (*virDrvDomainGetVcpus) (virDomainPtr domain,
+ virVcpuInfoPtr info,
+ int maxinfo,
+ unsigned char *cpumaps,
+ int maplen);
+
typedef struct _virDriver virDriver;
typedef virDriver *virDriverPtr;
virDrvDomainGetInfo domainGetInfo;
virDrvDomainSave domainSave;
virDrvDomainRestore domainRestore;
+ virDrvDomainSetVcpus domainSetVcpus;
+ virDrvDomainPinVcpu domainPinVcpu;
+ virDrvDomainGetVcpus domainGetVcpus;
};
int
virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{
+ int i;
+ virConnectPtr conn;
+
if (domain == NULL) {
TODO
return (-1);
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1);
}
- /* TODO: access though the driver API not directly */
+ conn = domain->conn;
-#if 0
- if (xenHypervisorSetVcpus(domain, nvcpus) == 0)
- return 0;
-#endif
- return xenDaemonDomainSetVcpus(domain, nvcpus);
+ /*
+ * Go though the driver registered entry points but use the
+ * XEN_HYPERVISOR directly only as a last mechanism
+ */
+ for (i = 0;i < conn->nb_drivers;i++) {
+ if ((conn->drivers[i] != NULL) &&
+ (conn->drivers[i]->no != VIR_DRV_XEN_HYPERVISOR) &&
+ (conn->drivers[i]->domainSetVcpus != NULL)) {
+ if (conn->drivers[i]->domainSetVcpus(domain, nvcpus) == 0)
+ return(0);
+ }
+ }
+ for (i = 0;i < conn->nb_drivers;i++) {
+ if ((conn->drivers[i] != NULL) &&
+ (conn->drivers[i]->no == VIR_DRV_XEN_HYPERVISOR) &&
+ (conn->drivers[i]->domainSetVcpus != NULL)) {
+ if (conn->drivers[i]->domainSetVcpus(domain, nvcpus) == 0)
+ return(0);
+ }
+ }
+
+ virLibConnError(conn, VIR_ERR_CALL_FAILED, __FUNCTION__);
+ return (-1);
}
/**
virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
unsigned char *cpumap, int maplen)
{
+ int i;
+ virConnectPtr conn;
+
if (domain == NULL) {
TODO
return (-1);
}
if (domain->conn->flags & VIR_CONNECT_RO)
return (-1);
- if ((vcpu < 0) || (cpumap == NULL) || (maplen < 1)) {
+ if ((vcpu > 32000) || (cpumap == NULL) || (maplen < 1)) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1);
}
- /* TODO: access though the driver API not directly */
- if (xenHypervisorPinVcpu(domain, vcpu, cpumap, maplen) == 0)
- return 0;
- return (-1); //xenDaemonDomainPinVcpu(domain, vcpu, cpumap, maplen);
+ conn = domain->conn;
+
+ /*
+ * Go though the driver registered entry points
+ */
+ for (i = 0;i < conn->nb_drivers;i++) {
+ if ((conn->drivers[i] != NULL) &&
+ (conn->drivers[i]->domainPinVcpu != NULL)) {
+ if (conn->drivers[i]->domainPinVcpu(domain, vcpu,
+ cpumap, maplen) == 0)
+ return(0);
+ }
+ }
+ virLibConnError(conn, VIR_ERR_CALL_FAILED, __FUNCTION__);
+ return (-1);
}
/**
unsigned char *cpumaps, int maplen)
{
int ret;
+ int i;
+ virConnectPtr conn;
if (domain == NULL) {
TODO
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1);
}
- /* TODO: access though the driver API not directly */
- ret = xenHypervisorGetVcpus(domain, info, maxinfo, cpumaps, maplen);
- if (ret != -1) return ret;
- return xenDaemonDomainGetVcpus(domain, info, maxinfo, cpumaps, maplen);
+ conn = domain->conn;
+
+ /*
+ * Go though the driver registered entry points
+ */
+ for (i = 0;i < conn->nb_drivers;i++) {
+ if ((conn->drivers[i] != NULL) &&
+ (conn->drivers[i]->domainGetVcpus != NULL)) {
+ ret = conn->drivers[i]->domainGetVcpus(domain, info, maxinfo,
+ cpumaps, maplen);
+ if (ret >= 0)
+ return(ret);
+ }
+ }
+ virLibConnError(conn, VIR_ERR_CALL_FAILED, __FUNCTION__);
+ return (-1);
}
NULL, /* domainSetMemory */
xenProxyDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
- NULL /* domainRestore */
+ NULL, /* domainRestore */
+ NULL, /* domainSetVcpus */
+ NULL, /* domainPinVcpu */
+ NULL /* domainGetVcpus */
};
/**
if (ret != sizeof(virProxyPacket)) {
fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n",
- ret, sizeof(virProxyPacket));
+ ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
if (res->len != sizeof(virProxyPacket)) {
fprintf(stderr,
"Communication error with proxy: expected %d bytes got %d\n",
- sizeof(virProxyPacket), res->len);
+ (int) sizeof(virProxyPacket), res->len);
xenProxyClose(conn);
return(-1);
}
if (ret != sizeof(virProxyPacket)) {
fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n",
- ret, sizeof(virProxyPacket));
+ ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
if (ret != (int) (res->len - sizeof(virProxyPacket))) {
fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n",
- ret, sizeof(virProxyPacket));
+ ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn);
return(-1);
}
NULL, /* domainSetMemory */
testGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */
- NULL /* domainRestore */
+ NULL, /* domainRestore */
+ NULL, /* domainSetVcpus */
+ NULL, /* domainPinVcpu */
+ NULL /* domainGetVcpus */
};
/* Amount of time it takes to shutdown */
return 0;
}
-int testGetVersion(virConnectPtr conn,
+int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned long *hvVer)
{
*hvVer = 1;
return 0;
}
-int testNodeGetInfo(virConnectPtr conn,
+int testNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr info)
{
memcpy(info, &nodeInfo, sizeof(nodeInfo));
NULL, /* domainSetMemory */
xenHypervisorGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */
- NULL /* domainRestore */
+ NULL, /* domainRestore */
+ xenHypervisorSetVcpus, /* domainSetVcpus */
+ xenHypervisorPinVcpu, /* domainPinVcpu */
+ xenHypervisorGetVcpus /* domainGetVcpus */
};
#endif /* !PROXY */
xenDaemonDomainSetMemory, /* domainMaxMemory */
xenDaemonDomainGetInfo, /* domainGetInfo */
xenDaemonDomainSave, /* domainSave */
- xenDaemonDomainRestore /* domainRestore */
+ xenDaemonDomainRestore, /* domainRestore */
+ xenDaemonDomainSetVcpus, /* domainSetVcpus */
+ xenDaemonDomainPinVcpu, /* domainPinVcpu */
+ xenDaemonDomainGetVcpus /* domainGetVcpus */
};
/**
"Accept-Encoding: identity\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: ");
- snprintf(buffer, sizeof(buffer), "%d", strlen(ops));
+ snprintf(buffer, sizeof(buffer), "%d", (int) strlen(ops));
swrites(s, buffer);
swrites(s, "\r\n\r\n");
swrites(s, ops);
* Returns 0 for success; -1 (with errno) on error
*/
int
-xenDaemonDomainSetVcpus(virDomainPtr domain, int vcpus)
+xenDaemonDomainSetVcpus(virDomainPtr domain, unsigned int vcpus)
{
char buf[16];
!strcmp(s->car->car->value, "vcpu")) {
t = s->car;
vcpu = ipt->number = sexpr_int(t, "vcpu/number");
- if (oln = sexpr_int(t, "vcpu/online")) {
+ if ((oln = sexpr_int(t, "vcpu/online")) != 0) {
if (sexpr_int(t, "vcpu/running")) ipt->state = VIR_VCPU_RUNNING;
if (sexpr_int(t, "vcpu/blocked")) ipt->state = VIR_VCPU_BLOCKED;
}
char **xenDaemonListDomainsOld(virConnectPtr xend);
int xenDaemonDomainSetVcpus (virDomainPtr domain,
- int vcpus);
+ unsigned int vcpus);
int xenDaemonDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
xmlNodePtr cur, txt;
const xmlChar *type = NULL;
const xmlChar *loader = NULL;
- const xmlChar *dev_model = NULL;
const xmlChar *boot_dev = NULL;
xmlChar *graphics_type = NULL;
xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt);
- if ((obj == NULL) || (obj->type == XPATH_STRING) &&
- (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
+ if ((obj == NULL) || ((obj->type == XPATH_STRING) &&
+ (obj->stringval != NULL) && (obj->stringval[0] != 0))) {
virBufferVSprintf(&buf, "(uuid '%s')", obj->stringval);
}
xmlXPathFreeObject(obj);
xenStoreDomainSetMemory, /* domainSetMemory */
xenStoreGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */
- NULL /* domainRestore */
+ NULL, /* domainRestore */
+ NULL, /* domainSetVcpus */
+ NULL, /* domainPinVcpu */
+ NULL /* domainGetVcpus */
};
/**