DBG ( "COMBOOT: fetching initrd '%s'\n", initrd_file );
/* Fetch initrd */
- if ( ( rc = imgdownload_string ( initrd_file, &initrd ) ) != 0){
+ if ( ( rc = imgdownload_string ( initrd_file, 0,
+ &initrd ) ) != 0 ) {
DBG ( "COMBOOT: could not fetch initrd: %s\n",
strerror ( rc ) );
return rc;
DBG ( "COMBOOT: fetching kernel '%s'\n", kernel_file );
/* Fetch kernel */
- if ( ( rc = imgdownload_string ( kernel_file, &kernel ) ) != 0 ) {
+ if ( ( rc = imgdownload_string ( kernel_file, 0, &kernel ) ) != 0 ) {
DBG ( "COMBOOT: could not fetch kernel: %s\n",
strerror ( rc ) );
return rc;
if ( opts.picture ) {
/* Acquire image */
- if ( ( rc = imgacquire ( opts.picture, &image ) ) != 0 )
+ if ( ( rc = imgacquire ( opts.picture, 0, &image ) ) != 0 )
goto err_acquire;
/* Convert to pixel buffer */
for ( i = optind ; i < argc ; i++ ) {
/* Acquire image */
- if ( ( rc = imgacquire ( argv[i], &image ) ) != 0 )
+ if ( ( rc = imgacquire ( argv[i], 0, &image ) ) != 0 )
continue;
offset = 0;
len = image->len;
struct imgsingle_options {
/** Image name */
char *name;
+ /** Download timeout */
+ unsigned long timeout;
/** Replace image */
int replace;
/** Free image after execution */
/** "img{single}" option list */
static union {
/* "imgexec" takes all three options */
- struct option_descriptor imgexec[3];
- /* Other "img{single}" commands take only --name and --autofree */
- struct option_descriptor imgsingle[2];
+ struct option_descriptor imgexec[4];
+ /* Other "img{single}" commands take only --name, --timeout,
+ * and --autofree
+ */
+ struct option_descriptor imgsingle[3];
} opts = {
.imgexec = {
OPTION_DESC ( "name", 'n', required_argument,
struct imgsingle_options, name, parse_string ),
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct imgsingle_options, timeout, parse_timeout),
OPTION_DESC ( "autofree", 'a', no_argument,
struct imgsingle_options, autofree, parse_flag ),
OPTION_DESC ( "replace", 'r', no_argument,
/** Command descriptor */
struct command_descriptor *cmd;
/** Function to use to acquire the image */
- int ( * acquire ) ( const char *name, struct image **image );
+ int ( * acquire ) ( const char *name, unsigned long timeout,
+ struct image **image );
/** Pre-action to take upon image, or NULL */
void ( * preaction ) ( struct image *image );
/** Action to take upon image, or NULL */
/* Acquire the image */
if ( name_uri ) {
- if ( ( rc = desc->acquire ( name_uri, &image ) ) != 0 )
+ if ( ( rc = desc->acquire ( name_uri, opts.timeout,
+ &image ) ) != 0 )
goto err_acquire;
} else {
image = image_find_selected();
char *signer;
/** Keep signature after verification */
int keep;
+ /** Download timeout */
+ unsigned long timeout;
};
/** "imgverify" option list */
struct imgverify_options, signer, parse_string ),
OPTION_DESC ( "keep", 'k', no_argument,
struct imgverify_options, keep, parse_flag ),
+ OPTION_DESC ( "timeout", 't', required_argument,
+ struct imgverify_options, timeout, parse_timeout),
};
/** "imgverify" command descriptor */
signature_name_uri = argv[ optind + 1 ];
/* Acquire the image */
- if ( ( rc = imgacquire ( image_name_uri, &image ) ) != 0 )
+ if ( ( rc = imgacquire ( image_name_uri, opts.timeout, &image ) ) != 0 )
goto err_acquire_image;
/* Acquire the signature image */
- if ( ( rc = imgacquire ( signature_name_uri, &signature ) ) != 0 )
+ if ( ( rc = imgacquire ( signature_name_uri, opts.timeout,
+ &signature ) ) != 0 )
goto err_acquire_signature;
/* Verify image */
#include <ipxe/image.h>
-extern int imgdownload ( struct uri *uri, struct image **image );
-extern int imgdownload_string ( const char *uri_string, struct image **image );
-extern int imgacquire ( const char *name, struct image **image );
+extern int imgdownload ( struct uri *uri, unsigned long timeout,
+ struct image **image );
+extern int imgdownload_string ( const char *uri_string, unsigned long timeout,
+ struct image **image );
+extern int imgacquire ( const char *name, unsigned long timeout,
+ struct image **image );
extern void imgstat ( struct image *image );
#endif /* _USR_IMGMGMT_H */
/* Attempt filename boot if applicable */
if ( filename ) {
- if ( ( rc = imgdownload ( filename, &image ) ) != 0 )
+ if ( ( rc = imgdownload ( filename, 0, &image ) ) != 0 )
goto err_download;
image->flags |= IMAGE_AUTO_UNREGISTER;
if ( ( rc = image_exec ( image ) ) != 0 ) {
* Download a new image
*
* @v uri URI
+ * @v timeout Download timeout
* @v image Image to fill in
* @ret rc Return status code
*/
-int imgdownload ( struct uri *uri, struct image **image ) {
+int imgdownload ( struct uri *uri, unsigned long timeout,
+ struct image **image ) {
const char *password;
char *uri_string_redacted;
int rc;
}
/* Wait for download to complete */
- if ( ( rc = monojob_wait ( uri_string_redacted, 0 ) ) != 0 )
+ if ( ( rc = monojob_wait ( uri_string_redacted, timeout ) ) != 0 )
goto err_monojob_wait;
/* Register image */
* Download a new image
*
* @v uri_string URI string
+ * @v timeout Download timeout
* @v image Image to fill in
* @ret rc Return status code
*/
-int imgdownload_string ( const char *uri_string, struct image **image ) {
+int imgdownload_string ( const char *uri_string, unsigned long timeout,
+ struct image **image ) {
struct uri *uri;
int rc;
if ( ! ( uri = parse_uri ( uri_string ) ) )
return -ENOMEM;
- rc = imgdownload ( uri, image );
+ rc = imgdownload ( uri, timeout, image );
uri_put ( uri );
return rc;
* Acquire an image
*
* @v name_uri Name or URI string
+ * @v timeout Download timeout
* @v image Image to fill in
* @ret rc Return status code
*/
-int imgacquire ( const char *name_uri, struct image **image ) {
+int imgacquire ( const char *name_uri, unsigned long timeout,
+ struct image **image ) {
/* If we already have an image with the specified name, use it */
*image = find_image ( name_uri );
return 0;
/* Otherwise, download a new image */
- return imgdownload_string ( name_uri, image );
+ return imgdownload_string ( name_uri, timeout, image );
}
/**