* 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.
Daniel
This commit is contained in:
Daniel Veillard 2006-08-08 22:22:55 +00:00
parent 3c43212307
commit 0342994a8d
10 changed files with 122 additions and 33 deletions

View File

@ -1,3 +1,11 @@
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> 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 * src/xend_internal.c: Added details of serial console TTY to XML

View File

@ -105,6 +105,21 @@ typedef int
(*virDrvDomainRestore) (virConnectPtr conn, (*virDrvDomainRestore) (virConnectPtr conn,
const char *from); 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 struct _virDriver virDriver;
typedef virDriver *virDriverPtr; typedef virDriver *virDriverPtr;
@ -146,6 +161,9 @@ struct _virDriver {
virDrvDomainGetInfo domainGetInfo; virDrvDomainGetInfo domainGetInfo;
virDrvDomainSave domainSave; virDrvDomainSave domainSave;
virDrvDomainRestore domainRestore; virDrvDomainRestore domainRestore;
virDrvDomainSetVcpus domainSetVcpus;
virDrvDomainPinVcpu domainPinVcpu;
virDrvDomainGetVcpus domainGetVcpus;
}; };

View File

@ -1665,6 +1665,9 @@ virDomainCreate(virDomainPtr domain) {
int int
virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus) virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{ {
int i;
virConnectPtr conn;
if (domain == NULL) { if (domain == NULL) {
TODO TODO
return (-1); return (-1);
@ -1679,13 +1682,31 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__); virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1); return (-1);
} }
/* TODO: access though the driver API not directly */ conn = domain->conn;
#if 0 /*
if (xenHypervisorSetVcpus(domain, nvcpus) == 0) * Go though the driver registered entry points but use the
return 0; * XEN_HYPERVISOR directly only as a last mechanism
#endif */
return xenDaemonDomainSetVcpus(domain, nvcpus); 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);
} }
/** /**
@ -1710,6 +1731,9 @@ int
virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu, virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
unsigned char *cpumap, int maplen) unsigned char *cpumap, int maplen)
{ {
int i;
virConnectPtr conn;
if (domain == NULL) { if (domain == NULL) {
TODO TODO
return (-1); return (-1);
@ -1720,14 +1744,25 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
} }
if (domain->conn->flags & VIR_CONNECT_RO) if (domain->conn->flags & VIR_CONNECT_RO)
return (-1); return (-1);
if ((vcpu < 0) || (cpumap == NULL) || (maplen < 1)) { if ((vcpu > 32000) || (cpumap == NULL) || (maplen < 1)) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__); virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1); return (-1);
} }
/* TODO: access though the driver API not directly */ conn = domain->conn;
if (xenHypervisorPinVcpu(domain, vcpu, cpumap, maplen) == 0)
return 0; /*
return (-1); //xenDaemonDomainPinVcpu(domain, vcpu, cpumap, maplen); * 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);
} }
/** /**
@ -1756,6 +1791,8 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen) unsigned char *cpumaps, int maplen)
{ {
int ret; int ret;
int i;
virConnectPtr conn;
if (domain == NULL) { if (domain == NULL) {
TODO TODO
@ -1773,8 +1810,20 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__); virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1); return (-1);
} }
/* TODO: access though the driver API not directly */ conn = domain->conn;
ret = xenHypervisorGetVcpus(domain, info, maxinfo, cpumaps, maplen);
if (ret != -1) return ret; /*
return xenDaemonDomainGetVcpus(domain, info, maxinfo, cpumaps, maplen); * 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);
} }

View File

@ -71,7 +71,10 @@ static virDriver xenProxyDriver = {
NULL, /* domainSetMemory */ NULL, /* domainSetMemory */
xenProxyDomainGetInfo, /* domainGetInfo */ xenProxyDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */ NULL, /* domainSave */
NULL /* domainRestore */ NULL, /* domainRestore */
NULL, /* domainSetVcpus */
NULL, /* domainPinVcpu */
NULL /* domainGetVcpus */
}; };
/** /**
@ -404,7 +407,7 @@ retry:
if (ret != sizeof(virProxyPacket)) { if (ret != sizeof(virProxyPacket)) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n", "Communication error with proxy: got %d bytes of %d\n",
ret, sizeof(virProxyPacket)); ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
} }
@ -412,7 +415,7 @@ retry:
if (res->len != sizeof(virProxyPacket)) { if (res->len != sizeof(virProxyPacket)) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: expected %d bytes got %d\n", "Communication error with proxy: expected %d bytes got %d\n",
sizeof(virProxyPacket), res->len); (int) sizeof(virProxyPacket), res->len);
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
} }
@ -425,7 +428,7 @@ retry:
if (ret != sizeof(virProxyPacket)) { if (ret != sizeof(virProxyPacket)) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n", "Communication error with proxy: got %d bytes of %d\n",
ret, sizeof(virProxyPacket)); ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
} }
@ -445,7 +448,7 @@ retry:
if (ret != (int) (res->len - sizeof(virProxyPacket))) { if (ret != (int) (res->len - sizeof(virProxyPacket))) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n", "Communication error with proxy: got %d bytes of %d\n",
ret, sizeof(virProxyPacket)); ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
} }

View File

@ -47,7 +47,10 @@ static virDriver testDriver = {
NULL, /* domainSetMemory */ NULL, /* domainSetMemory */
testGetDomainInfo, /* domainGetInfo */ testGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */ NULL, /* domainSave */
NULL /* domainRestore */ NULL, /* domainRestore */
NULL, /* domainSetVcpus */
NULL, /* domainPinVcpu */
NULL /* domainGetVcpus */
}; };
/* Amount of time it takes to shutdown */ /* Amount of time it takes to shutdown */
@ -211,14 +214,14 @@ int testClose(virConnectPtr conn)
return 0; return 0;
} }
int testGetVersion(virConnectPtr conn, int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED,
unsigned long *hvVer) unsigned long *hvVer)
{ {
*hvVer = 1; *hvVer = 1;
return 0; return 0;
} }
int testNodeGetInfo(virConnectPtr conn, int testNodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED,
virNodeInfoPtr info) virNodeInfoPtr info)
{ {
memcpy(info, &nodeInfo, sizeof(nodeInfo)); memcpy(info, &nodeInfo, sizeof(nodeInfo));

View File

@ -89,7 +89,10 @@ static virDriver xenHypervisorDriver = {
NULL, /* domainSetMemory */ NULL, /* domainSetMemory */
xenHypervisorGetDomainInfo, /* domainGetInfo */ xenHypervisorGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */ NULL, /* domainSave */
NULL /* domainRestore */ NULL, /* domainRestore */
xenHypervisorSetVcpus, /* domainSetVcpus */
xenHypervisorPinVcpu, /* domainPinVcpu */
xenHypervisorGetVcpus /* domainGetVcpus */
}; };
#endif /* !PROXY */ #endif /* !PROXY */

View File

@ -83,7 +83,10 @@ static virDriver xenDaemonDriver = {
xenDaemonDomainSetMemory, /* domainMaxMemory */ xenDaemonDomainSetMemory, /* domainMaxMemory */
xenDaemonDomainGetInfo, /* domainGetInfo */ xenDaemonDomainGetInfo, /* domainGetInfo */
xenDaemonDomainSave, /* domainSave */ xenDaemonDomainSave, /* domainSave */
xenDaemonDomainRestore /* domainRestore */ xenDaemonDomainRestore, /* domainRestore */
xenDaemonDomainSetVcpus, /* domainSetVcpus */
xenDaemonDomainPinVcpu, /* domainPinVcpu */
xenDaemonDomainGetVcpus /* domainGetVcpus */
}; };
/** /**
@ -475,7 +478,7 @@ xend_post(virConnectPtr xend, const char *path, const char *ops,
"Accept-Encoding: identity\r\n" "Accept-Encoding: identity\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n" "Content-Type: application/x-www-form-urlencoded\r\n"
"Content-Length: "); "Content-Length: ");
snprintf(buffer, sizeof(buffer), "%d", strlen(ops)); snprintf(buffer, sizeof(buffer), "%d", (int) strlen(ops));
swrites(s, buffer); swrites(s, buffer);
swrites(s, "\r\n\r\n"); swrites(s, "\r\n\r\n");
swrites(s, ops); swrites(s, ops);
@ -2458,7 +2461,7 @@ xenDaemonLookupByID(virConnectPtr conn, int id) {
* Returns 0 for success; -1 (with errno) on error * Returns 0 for success; -1 (with errno) on error
*/ */
int int
xenDaemonDomainSetVcpus(virDomainPtr domain, int vcpus) xenDaemonDomainSetVcpus(virDomainPtr domain, unsigned int vcpus)
{ {
char buf[16]; char buf[16];
@ -2564,7 +2567,7 @@ xenDaemonDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
!strcmp(s->car->car->value, "vcpu")) { !strcmp(s->car->car->value, "vcpu")) {
t = s->car; t = s->car;
vcpu = ipt->number = sexpr_int(t, "vcpu/number"); 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/running")) ipt->state = VIR_VCPU_RUNNING;
if (sexpr_int(t, "vcpu/blocked")) ipt->state = VIR_VCPU_BLOCKED; if (sexpr_int(t, "vcpu/blocked")) ipt->state = VIR_VCPU_BLOCKED;
} }

View File

@ -632,7 +632,7 @@ unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
char **xenDaemonListDomainsOld(virConnectPtr xend); char **xenDaemonListDomainsOld(virConnectPtr xend);
int xenDaemonDomainSetVcpus (virDomainPtr domain, int xenDaemonDomainSetVcpus (virDomainPtr domain,
int vcpus); unsigned int vcpus);
int xenDaemonDomainPinVcpu (virDomainPtr domain, int xenDaemonDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu, unsigned int vcpu,
unsigned char *cpumap, unsigned char *cpumap,

View File

@ -582,7 +582,6 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
xmlNodePtr cur, txt; xmlNodePtr cur, txt;
const xmlChar *type = NULL; const xmlChar *type = NULL;
const xmlChar *loader = NULL; const xmlChar *loader = NULL;
const xmlChar *dev_model = NULL;
const xmlChar *boot_dev = NULL; const xmlChar *boot_dev = NULL;
xmlChar *graphics_type = NULL; xmlChar *graphics_type = NULL;
@ -1020,8 +1019,8 @@ virDomainParseXMLDesc(const char *xmldesc, char **name)
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt); obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt);
if ((obj == NULL) || (obj->type == XPATH_STRING) && if ((obj == NULL) || ((obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) { (obj->stringval != NULL) && (obj->stringval[0] != 0))) {
virBufferVSprintf(&buf, "(uuid '%s')", obj->stringval); virBufferVSprintf(&buf, "(uuid '%s')", obj->stringval);
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);

View File

@ -64,7 +64,10 @@ static virDriver xenStoreDriver = {
xenStoreDomainSetMemory, /* domainSetMemory */ xenStoreDomainSetMemory, /* domainSetMemory */
xenStoreGetDomainInfo, /* domainGetInfo */ xenStoreGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */ NULL, /* domainSave */
NULL /* domainRestore */ NULL, /* domainRestore */
NULL, /* domainSetVcpus */
NULL, /* domainPinVcpu */
NULL /* domainGetVcpus */
}; };
/** /**