xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xensource.com, Ian.Campbell@citrix.com,
	ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com,
	wei.liu2@citrix.com
Cc: Juergen Gross <jgross@suse.com>
Subject: [PATCH 2/5] libxc: do initrd processing of domain builder in own function
Date: Fri, 11 Sep 2015 14:32:19 +0200	[thread overview]
Message-ID: <1441974742-27352-3-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1441974742-27352-1-git-send-email-jgross@suse.com>

Factor out the initrd processing in xc_dom_build_image() into an own
function to prepare starting a domain with unmapped initrd.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/libxc/xc_dom_core.c | 77 ++++++++++++++++++++++++++---------------------
 1 file changed, 43 insertions(+), 34 deletions(-)

diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c
index b432762..b510bbd 100644
--- a/tools/libxc/xc_dom_core.c
+++ b/tools/libxc/xc_dom_core.c
@@ -953,6 +953,48 @@ int xc_dom_update_guest_p2m(struct xc_dom_image *dom)
     return 0;
 }
 
+static int xc_dom_build_ramdisk(struct xc_dom_image *dom)
+{
+    size_t unziplen, ramdisklen;
+    void *ramdiskmap;
+
+    if ( !dom->ramdisk_seg.vstart )
+    {
+        unziplen = xc_dom_check_gzip(dom->xch,
+                                     dom->ramdisk_blob, dom->ramdisk_size);
+        if ( xc_dom_ramdisk_check_size(dom, unziplen) != 0 )
+            unziplen = 0;
+    }
+    else
+        unziplen = 0;
+
+    ramdisklen = unziplen ? unziplen : dom->ramdisk_size;
+
+    if ( xc_dom_alloc_segment(dom, &dom->ramdisk_seg, "ramdisk",
+                              dom->ramdisk_seg.vstart, ramdisklen) != 0 )
+        goto err;
+    ramdiskmap = xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg);
+    if ( ramdiskmap == NULL )
+    {
+        DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg) => NULL",
+                  __FUNCTION__);
+        goto err;
+    }
+    if ( unziplen )
+    {
+        if ( xc_dom_do_gunzip(dom->xch, dom->ramdisk_blob, dom->ramdisk_size,
+                              ramdiskmap, ramdisklen) == -1 )
+            goto err;
+    }
+    else
+        memcpy(ramdiskmap, dom->ramdisk_blob, dom->ramdisk_size);
+
+    return 0;
+
+ err:
+    return -1;
+}
+
 int xc_dom_build_image(struct xc_dom_image *dom)
 {
     unsigned int page_size;
@@ -980,41 +1022,8 @@ int xc_dom_build_image(struct xc_dom_image *dom)
     /* load ramdisk */
     if ( dom->ramdisk_blob )
     {
-        size_t unziplen, ramdisklen;
-        void *ramdiskmap;
-
-        if ( !dom->ramdisk_seg.vstart )
-        {
-            unziplen = xc_dom_check_gzip(dom->xch,
-                                         dom->ramdisk_blob, dom->ramdisk_size);
-            if ( xc_dom_ramdisk_check_size(dom, unziplen) != 0 )
-                unziplen = 0;
-        }
-        else
-            unziplen = 0;
-
-        ramdisklen = unziplen ? unziplen : dom->ramdisk_size;
-
-        if ( xc_dom_alloc_segment(dom, &dom->ramdisk_seg, "ramdisk",
-                                  dom->ramdisk_seg.vstart,
-                                  ramdisklen) != 0 )
+        if ( xc_dom_build_ramdisk(dom) != 0 )
             goto err;
-        ramdiskmap = xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg);
-        if ( ramdiskmap == NULL )
-        {
-            DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg) => NULL",
-                      __FUNCTION__);
-            goto err;
-        }
-        if ( unziplen )
-        {
-            if ( xc_dom_do_gunzip(dom->xch,
-                                  dom->ramdisk_blob, dom->ramdisk_size,
-                                  ramdiskmap, ramdisklen) == -1 )
-                goto err;
-        }
-        else
-            memcpy(ramdiskmap, dom->ramdisk_blob, dom->ramdisk_size);
     }
 
     /* load devicetree */
-- 
2.1.4

  parent reply	other threads:[~2015-09-11 12:32 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 12:32 [PATCH 0/5] libxc: support building large pv-domains Juergen Gross
2015-09-11 12:32 ` [PATCH 1/5] libxc: remove allocate member from struct xc_dom_image Juergen Gross
2015-09-11 12:44   ` Ian Jackson
2015-09-25 15:39     ` Ian Campbell
2015-09-28  3:55       ` Juergen Gross
2015-09-28  9:33         ` Ian Campbell
2015-09-11 12:32 ` Juergen Gross [this message]
2015-09-11 12:45   ` [PATCH 2/5] libxc: do initrd processing of domain builder in own function Ian Jackson
2015-09-25 15:39     ` Ian Campbell
2015-09-11 12:32 ` [PATCH 3/5] libxc: create unmapped initrd in domain builder if supported Juergen Gross
2015-09-11 12:54   ` Ian Jackson
2015-09-11 13:15     ` Julien Grall
2015-09-11 13:39       ` Juergen Gross
2015-09-25 15:22         ` Ian Campbell
2015-09-11 13:32     ` Juergen Gross
2015-09-11 15:51       ` Ian Jackson
2015-09-11 12:32 ` [PATCH 4/5] libxc: split p2m allocation in domain builder from other magic pages Juergen Gross
2015-10-01 12:47   ` Ian Campbell
2015-10-02  3:55     ` Juergen Gross
2015-10-02  9:04       ` Ian Campbell
2015-10-02  9:14         ` Juergen Gross
2015-10-02  9:28           ` Ian Campbell
2015-09-11 12:32 ` [PATCH 5/5] libxc: create p2m list outside of kernel mapping if supported Juergen Gross
2015-09-11 13:28 ` [PATCH 0/5] libxc: support building large pv-domains Ian Campbell
2015-09-11 13:42   ` Juergen Gross
2015-09-11 13:53     ` Ian Campbell
2015-09-11 14:01       ` Juergen Gross
2015-09-25 15:40         ` Ian Campbell
2015-09-22 12:12 ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441974742-27352-3-git-send-email-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).