mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 09:01:24 +03:00
[image] Simplify image management commands and internal API
Remove the name, cmdline, and action parameters from imgdownload() and imgdownload_string(). These functions now simply download and return an image. Add the function imgacquire(), which will interpret a "name or URI string" parameter and return either an existing image or a newly downloaded image. Use imgacquire() to merge similar image-management commands that currently differ only by whether they take the name of an existing image or the URI of a new image to download. For example, "chain" and "imgexec" can now be merged. Extend imgstat and imgfree commands to take an optional list of images. Remove the arbitrary restriction on the length of image names. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -189,14 +189,18 @@ static int initrd_init ( void ) {
|
||||
initrd_phys, ( initrd_phys + initrd_len ) );
|
||||
|
||||
/* Allocate image */
|
||||
image = alloc_image();
|
||||
image = alloc_image ( NULL );
|
||||
if ( ! image ) {
|
||||
DBGC ( colour, "RUNTIME could not allocate image for "
|
||||
"initrd\n" );
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc_image;
|
||||
}
|
||||
image_set_name ( image, "<INITRD>" );
|
||||
if ( ( rc = image_set_name ( image, "<INITRD>" ) ) != 0 ) {
|
||||
DBGC ( colour, "RUNTIME could not set image name: %s\n",
|
||||
strerror ( rc ) );
|
||||
goto err_set_name;
|
||||
}
|
||||
|
||||
/* Allocate and copy initrd content */
|
||||
image->data = umalloc ( initrd_len );
|
||||
@@ -227,6 +231,7 @@ static int initrd_init ( void ) {
|
||||
|
||||
err_register_image:
|
||||
err_umalloc:
|
||||
err_set_name:
|
||||
image_put ( image );
|
||||
err_alloc_image:
|
||||
return rc;
|
||||
|
||||
@@ -166,6 +166,8 @@ void comboot_force_text_mode ( void ) {
|
||||
* Fetch kernel and optional initrd
|
||||
*/
|
||||
static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
|
||||
struct image *kernel;
|
||||
struct image *initrd;
|
||||
char *initrd_file;
|
||||
int rc;
|
||||
|
||||
@@ -184,8 +186,7 @@ static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
|
||||
DBG ( "COMBOOT: fetching initrd '%s'\n", initrd_file );
|
||||
|
||||
/* Fetch initrd */
|
||||
if ( ( rc = imgdownload_string ( initrd_file, NULL, NULL,
|
||||
NULL ) ) != 0 ) {
|
||||
if ( ( rc = imgdownload_string ( initrd_file, &initrd ) ) != 0){
|
||||
DBG ( "COMBOOT: could not fetch initrd: %s\n",
|
||||
strerror ( rc ) );
|
||||
return rc;
|
||||
@@ -198,14 +199,20 @@ static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
|
||||
|
||||
DBG ( "COMBOOT: fetching kernel '%s'\n", kernel_file );
|
||||
|
||||
/* Allocate and fetch kernel */
|
||||
if ( ( rc = imgdownload_string ( kernel_file, NULL, cmdline,
|
||||
image_replace ) ) != 0 ) {
|
||||
/* Fetch kernel */
|
||||
if ( ( rc = imgdownload_string ( kernel_file, &kernel ) ) != 0 ) {
|
||||
DBG ( "COMBOOT: could not fetch kernel: %s\n",
|
||||
strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Replace comboot image with kernel */
|
||||
if ( ( rc = image_replace ( kernel ) ) != 0 ) {
|
||||
DBG ( "COMBOOT: could not replace with kernel: %s\n",
|
||||
strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user