[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] libxc: remove most of tools/libxc/xc_dom_compat_linux.c



commit 512d4d960507def70329acb9bfa0da325d9b4e03
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Fri Oct 23 15:05:00 2015 +0200
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Mon Nov 16 11:21:13 2015 +0000

    libxc: remove most of tools/libxc/xc_dom_compat_linux.c
    
    In tools/libxc/xc_dom_compat_linux.c xc_linux_build() is the only
    domain building function used by an in-tree component (qemu-xen) which
    is really necessary.
    
    Remove the other domain building functions and the unused python
    wrapper xc.linux_build() referencing one of the to be removed
    functions.
    
    Suggested-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/libxc/include/xc_dom.h      |    5 ++
 tools/libxc/include/xenguest.h    |   48 -------------
 tools/libxc/xc_dom_compat_linux.c |  141 ++++++++-----------------------------
 tools/libxl/libxl_internal.h      |    1 +
 tools/python/xen/lowlevel/xc/xc.c |   98 -------------------------
 5 files changed, 36 insertions(+), 257 deletions(-)

diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index ccc5926..6c15589 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -13,6 +13,9 @@
  * License along with this library; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#ifndef _XC_DOM_H
+#define _XC_DOM_H
+
 #include <xen/libelf/libelf.h>
 #include <xenguest.h>
 
@@ -406,6 +409,8 @@ static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image 
*dom, xen_pfn_t pfn)
     return dom->p2m_host[pfn - dom->rambase_pfn];
 }
 
+#endif /* _XC_DOM_H */
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h
index ec67fbd..a9fa32c 100644
--- a/tools/libxc/include/xenguest.h
+++ b/tools/libxc/include/xenguest.h
@@ -151,54 +151,6 @@ int xc_linux_build(xc_interface *xch,
                    unsigned int console_evtchn,
                    unsigned long *console_mfn);
 
-/** The same interface, but the dom structure is managed by the caller */
-struct xc_dom_image;
-int xc_dom_linux_build(xc_interface *xch,
-                      struct xc_dom_image *dom,
-                      uint32_t domid,
-                      unsigned int mem_mb,
-                      const char *image_name,
-                      const char *ramdisk_name,
-                      unsigned long flags,
-                      unsigned int store_evtchn,
-                      unsigned long *store_mfn,
-                      unsigned int console_evtchn,
-                      unsigned long *console_mfn);
-
-/**
- * This function will create a domain for a paravirtualized Linux
- * using buffers for kernel and initrd
- *
- * @parm xch a handle to an open hypervisor interface
- * @parm domid the id of the domain
- * @parm mem_mb memory size in megabytes
- * @parm image_buffer buffer containing kernel image
- * @parm image_size size of the kernel image buffer
- * @parm initrd_buffer name of the ramdisk image file
- * @parm initrd_size size of the ramdisk buffer
- * @parm cmdline command line string
- * @parm flags domain creation flags
- * @parm store_evtchn the store event channel for this domain to use
- * @parm store_mfn returned with the mfn of the store page
- * @parm console_evtchn the console event channel for this domain to use
- * @parm conole_mfn returned with the mfn of the console page
- * @return 0 on success, -1 on failure
- */
-int xc_linux_build_mem(xc_interface *xch,
-                       uint32_t domid,
-                       unsigned int mem_mb,
-                       const char *image_buffer,
-                       unsigned long image_size,
-                       const char *initrd_buffer,
-                       unsigned long initrd_size,
-                       const char *cmdline,
-                       const char *features,
-                       unsigned long flags,
-                       unsigned int store_evtchn,
-                       unsigned long *store_mfn,
-                       unsigned int console_evtchn,
-                       unsigned long *console_mfn);
-
 struct xc_hvm_firmware_module {
     uint8_t  *data;
     uint32_t  length;
diff --git a/tools/libxc/xc_dom_compat_linux.c 
b/tools/libxc/xc_dom_compat_linux.c
index 5c1f043..20521cf 100644
--- a/tools/libxc/xc_dom_compat_linux.c
+++ b/tools/libxc/xc_dom_compat_linux.c
@@ -34,74 +34,26 @@
 
 /* ------------------------------------------------------------------------ */
 
-static int xc_linux_build_internal(struct xc_dom_image *dom,
-                                   xc_interface *xch, uint32_t domid,
-                                   unsigned int mem_mb,
-                                   unsigned long flags,
-                                   unsigned int store_evtchn,
-                                   unsigned long *store_mfn,
-                                   unsigned int console_evtchn,
-                                   unsigned long *console_mfn)
-{
-    int rc;
-
-    dom->flags = flags;
-    dom->console_evtchn = console_evtchn;
-    dom->xenstore_evtchn = store_evtchn;
-
-    if ( (rc = xc_dom_boot_xen_init(dom, xch, domid)) != 0 )
-        goto out;
-    if ( (rc = xc_dom_parse_image(dom)) != 0 )
-        goto out;
-    if ( (rc = xc_dom_mem_init(dom, mem_mb)) != 0 )
-        goto out;
-    if ( (rc = xc_dom_boot_mem_init(dom)) != 0 )
-        goto out;
-    if ( (rc = xc_dom_build_image(dom)) != 0 )
-        goto out;
-    if ( (rc = xc_dom_boot_image(dom)) != 0 )
-        goto out;
-    if ( (rc = xc_dom_gnttab_init(dom)) != 0)
-        goto out;
-
-    *console_mfn = xc_dom_p2m(dom, dom->console_pfn);
-    *store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
-
- out:
-    return rc;
-}
-
-int xc_linux_build_mem(xc_interface *xch, uint32_t domid,
-                       unsigned int mem_mb,
-                       const char *image_buffer,
-                       unsigned long image_size,
-                       const char *initrd,
-                       unsigned long initrd_len,
-                       const char *cmdline,
-                       const char *features,
-                       unsigned long flags,
-                       unsigned int store_evtchn,
-                       unsigned long *store_mfn,
-                       unsigned int console_evtchn,
-                       unsigned long *console_mfn)
+int xc_get_bit_size(xc_interface *xch,
+                    const char *image_name, const char *cmdline,
+                    const char *features, int *bit_size)
 {
     struct xc_dom_image *dom;
     int rc;
-
-    xc_dom_loginit(xch);
+    *bit_size = 0;
     dom = xc_dom_allocate(xch, cmdline, features);
     if (dom == NULL)
         return -1;
-    if ( (rc = xc_dom_kernel_mem(dom, image_buffer, image_size)) != 0 )
+    if ( (rc = xc_dom_kernel_file(dom, image_name)) != 0 )
         goto out;
-    if ( initrd && ((rc = xc_dom_ramdisk_mem(dom, initrd, initrd_len)) != 0) )
+    if ( (rc = xc_dom_parse_image(dom)) != 0 )
         goto out;
-
-    rc = xc_linux_build_internal(dom, xch, domid,
-                                 mem_mb, flags,
-                                 store_evtchn, store_mfn,
-                                 console_evtchn, console_mfn);
-
+    if( dom->guest_type != NULL){
+        if(strstr(dom->guest_type, "x86_64") != NULL)
+            *bit_size = X86_64_B_SIZE; //64bit Guest
+        if(strstr(dom->guest_type, "x86_32") != NULL)
+            *bit_size = X86_32_B_SIZE; //32bit Guest
+    }
  out:
     xc_dom_release(dom);
     return rc;
@@ -132,66 +84,33 @@ int xc_linux_build(xc_interface *xch, uint32_t domid,
          ((rc = xc_dom_ramdisk_file(dom, initrd_name)) != 0) )
         goto out;
 
-    rc = xc_linux_build_internal(dom, xch, domid,
-                                 mem_mb, flags,
-                                 store_evtchn, store_mfn,
-                                 console_evtchn, console_mfn);
+    dom->flags = flags;
+    dom->console_evtchn = console_evtchn;
+    dom->xenstore_evtchn = store_evtchn;
 
- out:
-    xc_dom_release(dom);
-    return rc;
-}
-int xc_get_bit_size(xc_interface *xch,
-                    const char *image_name, const char *cmdline, 
-                    const char *features, int *bit_size)
-{
-    struct xc_dom_image *dom;
-    int rc;
-    *bit_size = 0;
-    dom = xc_dom_allocate(xch, cmdline, features);
-    if (dom == NULL)
-        return -1;
-    if ( (rc = xc_dom_kernel_file(dom, image_name)) != 0 )
+    if ( (rc = xc_dom_boot_xen_init(dom, xch, domid)) != 0 )
         goto out;
     if ( (rc = xc_dom_parse_image(dom)) != 0 )
         goto out;
-    if( dom->guest_type != NULL){
-        if(strstr(dom->guest_type, "x86_64") != NULL)
-            *bit_size = X86_64_B_SIZE; //64bit Guest 
-        if(strstr(dom->guest_type, "x86_32") != NULL)
-            *bit_size = X86_32_B_SIZE; //32bit Guest
-    }
+    if ( (rc = xc_dom_mem_init(dom, mem_mb)) != 0 )
+        goto out;
+    if ( (rc = xc_dom_boot_mem_init(dom)) != 0 )
+        goto out;
+    if ( (rc = xc_dom_build_image(dom)) != 0 )
+        goto out;
+    if ( (rc = xc_dom_boot_image(dom)) != 0 )
+        goto out;
+    if ( (rc = xc_dom_gnttab_init(dom)) != 0)
+        goto out;
+
+    *console_mfn = xc_dom_p2m(dom, dom->console_pfn);
+    *store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
 
-out:
+ out:
     xc_dom_release(dom);
     return rc;
 }
 
-int xc_dom_linux_build(xc_interface *xch,
-                       struct xc_dom_image *dom,
-                       uint32_t domid,
-                       unsigned int mem_mb,
-                       const char *image_name,
-                       const char *initrd_name,
-                       unsigned long flags,
-                       unsigned int store_evtchn,
-                       unsigned long *store_mfn,
-                       unsigned int console_evtchn, unsigned long *console_mfn)
-{
-    int rc;
-
-    if ( (rc = xc_dom_kernel_file(dom, image_name)) != 0 )
-        return rc;
-    if ( initrd_name && strlen(initrd_name) &&
-         ((rc = xc_dom_ramdisk_file(dom, initrd_name)) != 0) )
-        return rc;
-
-    return xc_linux_build_internal(dom, xch, domid,
-                                   mem_mb, flags,
-                                   store_evtchn, store_mfn,
-                                   console_evtchn, console_mfn);
-}
-
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 952b668..590870a 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -51,6 +51,7 @@
 #include <xenstore.h>
 #include <xenctrl.h>
 #include <xenguest.h>
+#include <xc_dom.h>
 
 #include "xentoollog.h"
 
diff --git a/tools/python/xen/lowlevel/xc/xc.c 
b/tools/python/xen/lowlevel/xc/xc.c
index 26290a3..94f0a13 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -7,7 +7,6 @@
 #include <Python.h>
 #include <xenctrl.h>
 #include <xenguest.h>
-#include <zlib.h>
 #include <fcntl.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
@@ -17,8 +16,6 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 
-#include "xenctrl.h"
-#include <xen/elfnote.h>
 #include <xen/tmem.h>
 #include "xc_dom.h"
 #include <xen/hvm/hvm_info_table.h>
@@ -454,90 +451,6 @@ static PyObject *pyxc_getBitSize(XcObject *self,
     return info_type;
 }
 
-static PyObject *pyxc_linux_build(XcObject *self,
-                                  PyObject *args,
-                                  PyObject *kwds)
-{
-    uint32_t domid;
-    struct xc_dom_image *dom;
-    char *image, *ramdisk = NULL, *cmdline = "", *features = NULL;
-    int flags = 0;
-    int store_evtchn, console_evtchn;
-    unsigned int mem_mb;
-    unsigned long store_mfn = 0;
-    unsigned long console_mfn = 0;
-    PyObject* elfnote_dict;
-    PyObject* elfnote = NULL;
-    PyObject* ret;
-    int i;
-
-    static char *kwd_list[] = { "domid", "store_evtchn", "memsize",
-                                "console_evtchn", "image",
-                                /* optional */
-                                "ramdisk", "cmdline", "flags",
-                                "features", NULL };
-
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list,
-                                      &domid, &store_evtchn, &mem_mb,
-                                      &console_evtchn, &image,
-                                      /* optional */
-                                      &ramdisk, &cmdline, &flags, &features) )
-        return NULL;
-
-    xc_dom_loginit(self->xc_handle);
-    if (!(dom = xc_dom_allocate(self->xc_handle, cmdline, features)))
-        return pyxc_error_to_exception(self->xc_handle);
-
-    if ( xc_dom_linux_build(self->xc_handle, dom, domid, mem_mb, image,
-                            ramdisk, flags, store_evtchn, &store_mfn,
-                            console_evtchn, &console_mfn) != 0 ) {
-        goto out;
-    }
-
-    if ( !(elfnote_dict = PyDict_New()) )
-        goto out;
-    
-    for ( i = 0; i < ARRAY_SIZE(dom->parms.elf_notes); i++ )
-    {
-        switch ( dom->parms.elf_notes[i].type )
-        {
-        case XEN_ENT_NONE:
-            continue;
-        case XEN_ENT_LONG:
-            elfnote = Py_BuildValue("k", dom->parms.elf_notes[i].data.num);
-            break;
-        case XEN_ENT_STR:
-            elfnote = Py_BuildValue("s", dom->parms.elf_notes[i].data.str);
-            break;
-        }
-        PyDict_SetItemString(elfnote_dict,
-                             dom->parms.elf_notes[i].name,
-                             elfnote);
-        Py_DECREF(elfnote);
-    }
-
-    ret = Py_BuildValue("{s:i,s:i,s:N}",
-                        "store_mfn", store_mfn,
-                        "console_mfn", console_mfn,
-                        "notes", elfnote_dict);
-
-    if ( dom->arch_hooks->native_protocol )
-    {
-        PyObject *native_protocol =
-            Py_BuildValue("s", dom->arch_hooks->native_protocol);
-        PyDict_SetItemString(ret, "native_protocol", native_protocol);
-        Py_DECREF(native_protocol);
-    }
-
-    xc_dom_release(dom);
-
-    return ret;
-
-  out:
-    xc_dom_release(dom);
-    return pyxc_error_to_exception(self->xc_handle);
-}
-
 static PyObject *pyxc_hvm_param_get(XcObject *self,
                                     PyObject *args,
                                     PyObject *kwds)
@@ -2269,17 +2182,6 @@ static PyMethodDef pyxc_methods[] = {
       " cpumap   [int]:  Bitmap of CPUs this VCPU can run on\n"
       " cpu      [int]:  CPU that this VCPU is currently bound to\n" },
 
-    { "linux_build", 
-      (PyCFunction)pyxc_linux_build, 
-      METH_VARARGS | METH_KEYWORDS, "\n"
-      "Build a new Linux guest OS.\n"
-      " dom     [int]:      Identifier of domain to build into.\n"
-      " image   [str]:      Name of kernel image file. May be gzipped.\n"
-      " ramdisk [str, n/a]: Name of ramdisk file, if any.\n"
-      " cmdline [str, n/a]: Kernel parameters, if any.\n\n"
-      " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
-      "Returns: [int] 0 on success; -1 on error.\n" },
-
     {"getBitSize",
       (PyCFunction)pyxc_getBitSize,
       METH_VARARGS | METH_KEYWORDS, "\n"
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.