提交 0342994a 编写于 作者: D Daniel Veillard

* 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
上级 3c432123
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
......
......@@ -105,6 +105,21 @@ typedef int
(*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;
......@@ -146,6 +161,9 @@ struct _virDriver {
virDrvDomainGetInfo domainGetInfo;
virDrvDomainSave domainSave;
virDrvDomainRestore domainRestore;
virDrvDomainSetVcpus domainSetVcpus;
virDrvDomainPinVcpu domainPinVcpu;
virDrvDomainGetVcpus domainGetVcpus;
};
......
......@@ -1665,6 +1665,9 @@ virDomainCreate(virDomainPtr domain) {
int
virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{
int i;
virConnectPtr conn;
if (domain == NULL) {
TODO
return (-1);
......@@ -1679,13 +1682,31 @@ virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
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);
}
/**
......@@ -1710,6 +1731,9 @@ int
virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
unsigned char *cpumap, int maplen)
{
int i;
virConnectPtr conn;
if (domain == NULL) {
TODO
return (-1);
......@@ -1720,14 +1744,25 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
}
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);
}
/**
......@@ -1756,6 +1791,8 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen)
{
int ret;
int i;
virConnectPtr conn;
if (domain == NULL) {
TODO
......@@ -1773,8 +1810,20 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
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);
}
......@@ -71,7 +71,10 @@ static virDriver xenProxyDriver = {
NULL, /* domainSetMemory */
xenProxyDomainGetInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL /* domainRestore */
NULL, /* domainRestore */
NULL, /* domainSetVcpus */
NULL, /* domainPinVcpu */
NULL /* domainGetVcpus */
};
/**
......@@ -404,7 +407,7 @@ retry:
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);
}
......@@ -412,7 +415,7 @@ retry:
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);
}
......@@ -425,7 +428,7 @@ retry:
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);
}
......@@ -445,7 +448,7 @@ retry:
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);
}
......
......@@ -47,7 +47,10 @@ static virDriver testDriver = {
NULL, /* domainSetMemory */
testGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL /* domainRestore */
NULL, /* domainRestore */
NULL, /* domainSetVcpus */
NULL, /* domainPinVcpu */
NULL /* domainGetVcpus */
};
/* Amount of time it takes to shutdown */
......@@ -211,14 +214,14 @@ int testClose(virConnectPtr conn)
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));
......
......@@ -89,7 +89,10 @@ static virDriver xenHypervisorDriver = {
NULL, /* domainSetMemory */
xenHypervisorGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL /* domainRestore */
NULL, /* domainRestore */
xenHypervisorSetVcpus, /* domainSetVcpus */
xenHypervisorPinVcpu, /* domainPinVcpu */
xenHypervisorGetVcpus /* domainGetVcpus */
};
#endif /* !PROXY */
......
......@@ -83,7 +83,10 @@ static virDriver xenDaemonDriver = {
xenDaemonDomainSetMemory, /* domainMaxMemory */
xenDaemonDomainGetInfo, /* domainGetInfo */
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"
"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);
......@@ -2458,7 +2461,7 @@ xenDaemonLookupByID(virConnectPtr conn, int id) {
* Returns 0 for success; -1 (with errno) on error
*/
int
xenDaemonDomainSetVcpus(virDomainPtr domain, int vcpus)
xenDaemonDomainSetVcpus(virDomainPtr domain, unsigned int vcpus)
{
char buf[16];
......@@ -2564,7 +2567,7 @@ xenDaemonDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
!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;
}
......
......@@ -632,7 +632,7 @@ unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
char **xenDaemonListDomainsOld(virConnectPtr xend);
int xenDaemonDomainSetVcpus (virDomainPtr domain,
int vcpus);
unsigned int vcpus);
int xenDaemonDomainPinVcpu (virDomainPtr domain,
unsigned int vcpu,
unsigned char *cpumap,
......
......@@ -582,7 +582,6 @@ virDomainParseXMLOSDescHVM(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr
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;
......@@ -1020,8 +1019,8 @@ virDomainParseXMLDesc(const char *xmldesc, char **name)
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);
......
......@@ -64,7 +64,10 @@ static virDriver xenStoreDriver = {
xenStoreDomainSetMemory, /* domainSetMemory */
xenStoreGetDomainInfo, /* domainGetInfo */
NULL, /* domainSave */
NULL /* domainRestore */
NULL, /* domainRestore */
NULL, /* domainSetVcpus */
NULL, /* domainPinVcpu */
NULL /* domainGetVcpus */
};
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册