]> xenbits.xensource.com Git - libvirt.git/commitdiff
* src/driver.h src/libvirt.c src/proxy_internal.c src/test.c
authorDaniel Veillard <veillard@redhat.com>
Tue, 8 Aug 2006 22:22:55 +0000 (22:22 +0000)
committerDaniel Veillard <veillard@redhat.com>
Tue, 8 Aug 2006 22:22:55 +0000 (22:22 +0000)
  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

ChangeLog
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

index daddac3db094d0fd7372ffd8625799a349c8fcb4..9029ef5e952a21bce7bdec71a2c7e72e2bf156fd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * src/xend_internal.c: Added details of serial console TTY to XML 
index 838827df2897ddea15ec23c5c7708326cb1bfc3d..8b7ad66b70a9d0511d54ef3697b1b344c0df7382 100644 (file)
@@ -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;
 };
 
 
index 14294894cda198e67d18399dbeb4763f3219c8ed..66580e89d98b3df55a1f6b4c39487aa12e54ad8f 100644 (file)
@@ -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);
 }
index 5f1037afea072f9967d83535f3b126a0a4c0364f..ad9d123c4f6f1aa78a3617adf4fb9f858ba7dbff 100644 (file)
@@ -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);
            }
index bed514cd38719176be1cf35fc666ea77692ea83e..7045269096fca2a2159d6349a6045f704509bab9 100644 (file)
@@ -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));
index 8887abbe945e5cc2c810006461a56e12ddd38af6..68c3eabd8dc42a4609c559b335a3fd2029877574 100644 (file)
@@ -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 */
 
index ed9f2f3e5baaa38a653fa0a9b0e6075ecb15de61..0e07054c923ec8b955fae1b2abb0632e7d2141be 100644 (file)
@@ -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;
         }
index 336913bca5177102d530ca7a026b0756a2bd0ec9..2103ded214f7d898bdf39576658d2b99f87f96b8 100644 (file)
@@ -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,
index e1b4e8ad40bb22ffc214d0feea5378b939718396..f01ec77409fed4d6f18c5424e0336c38b057a9d6 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -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);
index f53812a71d1f48c795703110e8ff6c23208fc263..b0c3d67b378b15b6949979e7497d8e40bdf9af0d 100644 (file)
@@ -64,7 +64,10 @@ static virDriver xenStoreDriver = {
     xenStoreDomainSetMemory, /* domainSetMemory */
     xenStoreGetDomainInfo, /* domainGetInfo */
     NULL, /* domainSave */
-    NULL /* domainRestore */
+    NULL, /* domainRestore */
+    NULL, /* domainSetVcpus */
+    NULL, /* domainPinVcpu */
+    NULL /* domainGetVcpus */
 };
 
 /**